Bug 803471 - Part 1a - Enable Binder ThreadPool. r=mwu
authorSotaro Ikeda <sikeda@mozilla.com>
Fri, 08 Mar 2013 14:43:32 -0500
changeset 124259 d477e8934f1cf5154c2d7651cdedafd12fa283df
parent 124258 c5db46df8596558a3d6152843c7533601a522a21
child 124260 2422115b7400378bf635f41c94638a7150dba5c8
push id24412
push userryanvm@gmail.com
push dateSun, 10 Mar 2013 00:01:53 +0000
treeherdermozilla-central@9e6232e86000 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu
bugs803471
milestone22.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 803471 - Part 1a - Enable Binder ThreadPool. r=mwu
b2g/app/nsBrowserApp.cpp
ipc/app/MozillaRuntimeMain.cpp
--- a/b2g/app/nsBrowserApp.cpp
+++ b/b2g/app/nsBrowserApp.cpp
@@ -32,16 +32,20 @@
 #ifdef MOZ_WIDGET_GONK
 #include "BootAnimation.h"
 #endif
 
 #include "BinaryPath.h"
 
 #include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL
 
+#ifdef MOZ_WIDGET_GONK
+# include <binder/ProcessState.h>
+#endif
+
 #include "mozilla/Telemetry.h"
 
 static void Output(const char *fmt, ... )
 {
   va_list ap;
   va_start(ap, fmt);
 
 #if defined(XP_WIN) && !MOZ_WINCONSOLE
@@ -163,16 +167,24 @@ static int do_main(int argc, char* argv[
 
   return XRE_main(argc, argv, &sAppData, 0);
 }
 
 int main(int argc, char* argv[])
 {
   char exePath[MAXPATHLEN];
 
+#ifdef MOZ_WIDGET_GONK
+  // This creates a ThreadPool for binder ipc. A ThreadPool is necessary to
+  // receive binder calls, though not necessary to send binder calls.
+  // ProcessState::Self() also needs to be called once on the main thread to
+  // register the main thread with the binder driver.
+  android::ProcessState::self()->startThreadPool();
+#endif
+
   nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath);
   if (NS_FAILED(rv)) {
     Output("Couldn't calculate the application directory.\n");
     return 255;
   }
 
   char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]);
   if (!lastSlash || ((lastSlash - exePath) + sizeof(XPCOM_DLL) + 1 > MAXPATHLEN))
--- a/ipc/app/MozillaRuntimeMain.cpp
+++ b/ipc/app/MozillaRuntimeMain.cpp
@@ -17,19 +17,31 @@
 // we want a wmain entry point
 // but we don't want its DLL load protection, because we'll handle it here
 #define XRE_DONT_PROTECT_DLL_LOAD
 #include "nsWindowsWMain.cpp"
 
 #include "nsSetDllDirectory.h"
 #endif
 
+#ifdef MOZ_WIDGET_GONK
+# include <binder/ProcessState.h>
+#endif
+
 int
 main(int argc, char* argv[])
 {
+#ifdef MOZ_WIDGET_GONK
+    // This creates a ThreadPool for binder ipc. A ThreadPool is necessary to
+    // receive binder calls, though not necessary to send binder calls.
+    // ProcessState::Self() also needs to be called once on the main thread to
+    // register the main thread with the binder driver.
+    android::ProcessState::self()->startThreadPool();
+#endif
+
 #if defined(XP_WIN) && defined(DEBUG_bent)
     MessageBox(NULL, L"Hi", L"Hi", MB_OK);
 #endif
 
     // Check for the absolute minimum number of args we need to move
     // forward here. We expect the last arg to be the child process type.
     if (argc < 1)
       return 1;