Bug 1070755: Fix invalid key for module init histogram; r=vladan
authorAaron Klotz <aklotz@mozilla.com>
Mon, 15 Dec 2014 17:02:02 -0700
changeset 219868 f2f0d61c8acc217b57cfac70ed47ad6eba0c74fb
parent 219867 fe70a6c9a374a5b9b6c38cbffad5726824155626
child 219869 adc247a722ef1f44b3f6d07eb86bfdc56d9210a7
push id10419
push usercbook@mozilla.com
push dateTue, 16 Dec 2014 12:45:27 +0000
treeherderfx-team@ec87657146eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladan
bugs1070755
milestone37.0a1
Bug 1070755: Fix invalid key for module init histogram; r=vladan
dom/plugins/ipc/PluginModuleParent.cpp
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -1399,24 +1399,16 @@ PluginModuleParent::NP_Initialize(NPNets
             return NS_ERROR_FAILURE;
         }
         else if (*error != NPERR_NO_ERROR) {
             Close();
             return NS_OK;
         }
         TimeStamp callNpInitEnd = TimeStamp::Now();
         mTimeBlocked += (callNpInitEnd - callNpInitStart);
-        /** mTimeBlocked measures the time that the main thread has been blocked
-         *  on plugin module initialization. As implemented, this is the sum of
-         *  plugin-container launch + NP_Initialize
-         */
-        Telemetry::Accumulate(Telemetry::BLOCKED_ON_PLUGIN_MODULE_INIT_MS,
-                              GetHistogramKey(),
-                              static_cast<uint32_t>(mTimeBlocked.ToMilliseconds()));
-        mTimeBlocked = TimeDuration();
     }
 
     SetPluginFuncs(pFuncs);
 
     return NS_OK;
 }
 #else
 nsresult
@@ -1467,27 +1459,16 @@ PluginModuleChromeParent::NP_Initialize(
                                                           iconPath)))
         unused << SendSetAudioSessionData(id, sessionName, iconPath);
 #endif
 
 #ifdef MOZ_CRASHREPORTER_INJECTOR
     InitializeInjector();
 #endif
 
-    /** This Accumulate must be placed below the call to InitializeInjector()
-     *  because mTimeBlocked is modified in that function.
-     *  mTimeBlocked measures the time that the main thread has been blocked
-     *  on plugin module initialization. As implemented, this is the sum of
-     *  plugin-container launch + toolhelp32 snapshot + NP_Initialize
-     */
-    Telemetry::Accumulate(Telemetry::BLOCKED_ON_PLUGIN_MODULE_INIT_MS,
-                          GetHistogramKey(),
-                          static_cast<uint32_t>(mTimeBlocked.ToMilliseconds()));
-    mTimeBlocked = TimeDuration();
-
     return NS_OK;
 }
 #endif
 
 nsresult
 PluginModuleParent::NP_Shutdown(NPError* error)
 {
     PLUGIN_LOG_DEBUG_METHOD;
@@ -1569,16 +1550,26 @@ PluginModuleParent::NPP_New(NPMIMEType p
 
     if (mShutdown) {
         *error = NPERR_GENERIC_ERROR;
         return NS_ERROR_FAILURE;
     }
 
     if (mPluginName.IsEmpty()) {
         GetPluginDetails(mPluginName, mPluginVersion);
+        /** mTimeBlocked measures the time that the main thread has been blocked
+         *  on plugin module initialization. As implemented, this is the sum of
+         *  plugin-container launch + toolhelp32 snapshot + NP_Initialize.
+         *  We don't accumulate its value until here because the plugin info
+         *  is not available until *after* NP_Initialize.
+         */
+        Telemetry::Accumulate(Telemetry::BLOCKED_ON_PLUGIN_MODULE_INIT_MS,
+                              GetHistogramKey(),
+                              static_cast<uint32_t>(mTimeBlocked.ToMilliseconds()));
+        mTimeBlocked = TimeDuration();
     }
 
     // create the instance on the other side
     InfallibleTArray<nsCString> names;
     InfallibleTArray<nsCString> values;
 
     for (int i = 0; i < argc; ++i) {
         names.AppendElement(NullableString(argn[i]));