Bug 1252650 - Add data parameter to NS_CreateServicesFromCategory; r=froydnj
authorJim Chen <nchen@mozilla.com>
Wed, 20 Apr 2016 15:06:13 -0400
changeset 332027 ea417c8620f751e3c81f57d25d0ff449730be933
parent 332026 dccbf2ad3fa2f62f581b18824acbc15a07037fe7
child 332028 d29c9c527c7a080d3cec0d5e37dc3caa9520ddba
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1252650
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1252650 - Add data parameter to NS_CreateServicesFromCategory; r=froydnj Add a data parameter to be passed into any observers implemented by created services.
xpcom/components/nsCategoryManager.cpp
xpcom/components/nsCategoryManagerUtils.h
--- a/xpcom/components/nsCategoryManager.cpp
+++ b/xpcom/components/nsCategoryManager.cpp
@@ -757,17 +757,18 @@ nsCategoryManager::SuppressNotifications
  * creates a service of every CID or ContractID registered under the category.
  * If observerTopic is non null and the service implements nsIObserver,
  * this will attempt to notify the observer with the origin, observerTopic string
  * as parameter.
  */
 void
 NS_CreateServicesFromCategory(const char* aCategory,
                               nsISupports* aOrigin,
-                              const char* aObserverTopic)
+                              const char* aObserverTopic,
+                              const char16_t* aObserverData)
 {
   nsresult rv;
 
   nsCOMPtr<nsICategoryManager> categoryManager =
     do_GetService("@mozilla.org/categorymanager;1");
   if (!categoryManager) {
     return;
   }
@@ -807,16 +808,17 @@ NS_CreateServicesFromCategory(const char
                  aCategory, entryString.get(), contractID.get());
       continue;
     }
 
     if (aObserverTopic) {
       // try an observer, if it implements it.
       nsCOMPtr<nsIObserver> observer = do_QueryInterface(instance);
       if (observer) {
-        observer->Observe(aOrigin, aObserverTopic, EmptyString().get());
+        observer->Observe(aOrigin, aObserverTopic,
+                          aObserverData ? aObserverData : EmptyString().get());
       } else {
         LogMessage("While creating services from category '%s', service for entry '%s', contract ID '%s' does not implement nsIObserver.",
                    aCategory, entryString.get(), contractID.get());
       }
     }
   }
 }
--- a/xpcom/components/nsCategoryManagerUtils.h
+++ b/xpcom/components/nsCategoryManagerUtils.h
@@ -7,11 +7,12 @@
 #ifndef nsCategoryManagerUtils_h__
 #define nsCategoryManagerUtils_h__
 
 #include "nsICategoryManager.h"
 
 void
 NS_CreateServicesFromCategory(const char* aCategory,
                               nsISupports* aOrigin,
-                              const char* aObserverTopic);
+                              const char* aObserverTopic,
+                              const char16_t* aObserverData = nullptr);
 
 #endif