Bug 1332523 - Make the Bootstrap API entry point the same for both dependent and standalone linkage. r=bsmedberg draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 13 Jan 2017 07:29:56 +0900
changeset 464389 1301d1088ef39022571fad25e2a3c3efc412c08c
parent 464388 ac2f8e30f09d5e3b8ac4cfda479b50f154932880
child 464390 da2c2ad5833de14f4c16c3c176c28549add89669
push id42348
push userbmo:mh+mozilla@glandium.org
push dateFri, 20 Jan 2017 22:46:42 +0000
reviewersbsmedberg
bugs1332523
milestone53.0a1
Bug 1332523 - Make the Bootstrap API entry point the same for both dependent and standalone linkage. r=bsmedberg
ipc/app/MozillaRuntimeMain.cpp
ipc/ipdl/test/cxx/app/TestIPDL.cpp
js/xpconnect/shell/xpcshell.cpp
toolkit/xre/Bootstrap.h
--- a/ipc/app/MozillaRuntimeMain.cpp
+++ b/ipc/app/MozillaRuntimeMain.cpp
@@ -13,15 +13,14 @@ using namespace mozilla;
 
 int
 main(int argc, char *argv[])
 {
 #ifdef HAS_DLL_BLOCKLIST
   DllBlocklist_Initialize();
 #endif
 
-  Bootstrap::UniquePtr bootstrap;
-  XRE_GetBootstrap(bootstrap);
+  Bootstrap::UniquePtr bootstrap = GetBootstrap();
   if (!bootstrap) {
     return 2;
   }
   return content_process_main(bootstrap.get(), argc, argv);
 }
--- a/ipc/ipdl/test/cxx/app/TestIPDL.cpp
+++ b/ipc/ipdl/test/cxx/app/TestIPDL.cpp
@@ -14,15 +14,14 @@ using namespace mozilla;
 
 int
 main(int argc, char** argv)
 {
     // the first argument specifies which IPDL test case/suite to load
     if (argc < 2)
         return 1;
 
-    Bootstrap::UniquePtr bootstrap;
-    XRE_GetBootstrap(bootstrap);
+    Bootstrap::UniquePtr bootstrap = GetBootstrap();
     if (!bootstrap) {
         return 2;
     }
     return bootstrap->XRE_RunIPDLTest(argc, argv);
 }
--- a/js/xpconnect/shell/xpcshell.cpp
+++ b/js/xpconnect/shell/xpcshell.cpp
@@ -55,18 +55,17 @@ main(int argc, char** argv, char** envp)
 #endif
 
     XREShellData shellData;
 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
     shellData.sandboxBrokerServices =
       mozilla::sandboxing::GetInitializedBrokerServices();
 #endif
 
-    mozilla::Bootstrap::UniquePtr bootstrap;
-    XRE_GetBootstrap(bootstrap);
+    mozilla::Bootstrap::UniquePtr bootstrap = mozilla::GetBootstrap();
     if (!bootstrap) {
         return 2;
     }
 
     int result = bootstrap->XRE_XPCShellMain(argc, argv, envp, &shellData);
 
 #ifdef XP_MACOSX
     FinishAutoreleasePool();
--- a/toolkit/xre/Bootstrap.h
+++ b/toolkit/xre/Bootstrap.h
@@ -122,15 +122,26 @@ public:
 
 /**
  * Creates and returns the singleton instnace of the bootstrap object.
  * @param `b` is an outparam. We use a parameter and not a return value
  *        because MSVC doesn't let us return a c++ class from a function with
  *        "C" linkage. On failure this will be null.
  * @note This function may only be called once and will crash if called again.
  */
+#ifdef XPCOM_GLUE
+typedef void (*GetBootstrapType)(Bootstrap::UniquePtr&);
+Bootstrap::UniquePtr GetBootstrap(const char* aXPCOMFile=nullptr);
+#else
 extern "C" NS_EXPORT void NS_FROZENCALL
 XRE_GetBootstrap(Bootstrap::UniquePtr& b);
-typedef void (*GetBootstrapType)(Bootstrap::UniquePtr&);
+
+inline Bootstrap::UniquePtr
+GetBootstrap(const char* aXPCOMFile=nullptr) {
+  Bootstrap::UniquePtr bootstrap;
+  XRE_GetBootstrap(bootstrap);
+  return bootstrap;
+}
+#endif
 
 } // namespace mozilla
 
 #endif // mozilla_Bootstrap_h