Bug 833560 - Part 2: Add timings to Plugin Hang UI telemetry. r=vdjeric
authorAaron Klotz <aklotz@mozilla.com>
Tue, 12 Feb 2013 15:05:39 -0500
changeset 121660 ca180542fbcdd2e93c635c928e7911fc05b7faff
parent 121659 d388b8073cce4ab68914382332de9700574e3802
child 121661 84cb7aa96a52652fdc933f0c647d4f2f60c68760
child 121663 6124f1fc8e3a24331409df433ccc13e832d2f400
push idunknown
push userunknown
push dateunknown
reviewersvdjeric
bugs833560
milestone21.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 833560 - Part 2: Add timings to Plugin Hang UI telemetry. r=vdjeric
dom/plugins/ipc/PluginHangUIParent.cpp
dom/plugins/ipc/PluginHangUIParent.h
dom/plugins/ipc/PluginModuleParent.cpp
toolkit/components/telemetry/Histograms.json
--- a/dom/plugins/ipc/PluginHangUIParent.cpp
+++ b/dom/plugins/ipc/PluginHangUIParent.cpp
@@ -26,45 +26,56 @@ using mozilla::widget::WidgetUtils;
 
 using std::string;
 using std::vector;
 
 namespace {
 class nsPluginHangUITelemetry : public nsRunnable
 {
 public:
-  nsPluginHangUITelemetry(int aResponseCode, int aDontAskCode)
+  nsPluginHangUITelemetry(int aResponseCode, int aDontAskCode,
+                          uint32_t aResponseTimeMs, uint32_t aTimeoutMs)
     : mResponseCode(aResponseCode),
-      mDontAskCode(aDontAskCode)
+      mDontAskCode(aDontAskCode),
+      mResponseTimeMs(aResponseTimeMs),
+      mTimeoutMs(aTimeoutMs)
   {
   }
 
   NS_IMETHOD
   Run()
   {
     mozilla::Telemetry::Accumulate(
               mozilla::Telemetry::PLUGIN_HANG_UI_USER_RESPONSE, mResponseCode);
-    mozilla::Telemetry::Accumulate(mozilla::Telemetry::PLUGIN_HANG_UI_DONT_ASK,
-                                   mDontAskCode);
+    mozilla::Telemetry::Accumulate(
+              mozilla::Telemetry::PLUGIN_HANG_UI_DONT_ASK, mDontAskCode);
+    mozilla::Telemetry::Accumulate(
+              mozilla::Telemetry::PLUGIN_HANG_UI_RESPONSE_TIME, mResponseTimeMs);
+    mozilla::Telemetry::Accumulate(
+              mozilla::Telemetry::PLUGIN_HANG_TIME, mTimeoutMs + mResponseTimeMs);
     return NS_OK;
   }
 
 private:
   int mResponseCode;
   int mDontAskCode;
+  uint32_t mResponseTimeMs;
+  uint32_t mTimeoutMs;
 };
 } // anonymous namespace
 
 namespace mozilla {
 namespace plugins {
 
 const DWORD PluginHangUIParent::kTimeout = 5000U;
 
-PluginHangUIParent::PluginHangUIParent(PluginModuleParent* aModule)
+PluginHangUIParent::PluginHangUIParent(PluginModuleParent* aModule,
+                                       const int32_t aHangUITimeoutPref)
   : mModule(aModule),
+    mTimeoutPrefMs(static_cast<uint32_t>(aHangUITimeoutPref) * 1000U),
     mMainThreadMessageLoop(MessageLoop::current()),
     mIsShowing(false),
     mLastUserResponse(0),
     mHangUIProcessHandle(NULL),
     mMainWindowHandle(NULL),
     mRegWait(NULL),
     mShowEvent(NULL),
     mShowTicks(0),
@@ -273,17 +284,19 @@ PluginHangUIParent::RecvUserResponse(con
     // User clicked Continue
     responseCode = 2;
   } else {
     // Dialog was cancelled
     responseCode = 3;
   }
   int dontAskCode = (aResponse & HANGUI_USER_RESPONSE_DONT_SHOW_AGAIN) ? 1 : 0;
   nsCOMPtr<nsIRunnable> workItem = new nsPluginHangUITelemetry(responseCode,
-                                                               dontAskCode);
+                                                               dontAskCode,
+                                                               LastShowDurationMs(),
+                                                               mTimeoutPrefMs);
   NS_DispatchToMainThread(workItem, NS_DISPATCH_NORMAL);
   return true;
 }
 
 nsresult
 PluginHangUIParent::GetHangUIOwnerWindowHandle(NativeWindowHandle& windowHandle)
 {
   windowHandle = NULL;
--- a/dom/plugins/ipc/PluginHangUIParent.h
+++ b/dom/plugins/ipc/PluginHangUIParent.h
@@ -29,17 +29,18 @@ class PluginModuleParent;
  *       is describing the fact that firefox is the parent process to the 
  *       plugin-hang-ui process, which is the PluginHangUIChild.
  *       PluginHangUIParent and PluginHangUIChild are a matched pair.
  * @see PluginHangUIChild
  */
 class PluginHangUIParent : public MiniShmObserver
 {
 public:
-  PluginHangUIParent(PluginModuleParent* aModule);
+  PluginHangUIParent(PluginModuleParent* aModule,
+                     const int32_t aHangUITimeoutPref);
   virtual ~PluginHangUIParent();
 
   /**
    * Spawn the plugin-hang-ui.exe child process and terminate the given 
    * plugin container process if the user elects to stop the hung plugin.
    *
    * @param aPluginName Human-readable name of the affected plugin.
    * @return true if the plugin hang ui process was successfully launched,
@@ -124,16 +125,17 @@ private:
   bool
   RecvUserResponse(const unsigned int& aResponse);
 
   static
   VOID CALLBACK SOnHangUIProcessExit(PVOID aContext, BOOLEAN aIsTimer);
 
 private:
   PluginModuleParent* mModule;
+  const uint32_t mTimeoutPrefMs;
   MessageLoop* mMainThreadMessageLoop;
   volatile bool mIsShowing;
   unsigned int mLastUserResponse;
   base::ProcessHandle mHangUIProcessHandle;
   NativeWindowHandle mMainWindowHandle;
   HANDLE mRegWait;
   HANDLE mShowEvent;
   DWORD mShowTicks;
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -558,17 +558,18 @@ PluginModuleParent::LaunchHangUI()
             return false;
         }
         if (mHangUIParent->DontShowAgain()) {
             return !mHangUIParent->WasLastHangStopped();
         }
         delete mHangUIParent;
         mHangUIParent = nullptr;
     }
-    mHangUIParent = new PluginHangUIParent(this);
+    mHangUIParent = new PluginHangUIParent(this, 
+            Preferences::GetInt(kHangUITimeoutPref, 0));
     nsAutoString pluginName;
     if (!GetPluginName(pluginName)) {
         return false;
     }
     bool retval = mHangUIParent->Init(pluginName);
     if (retval) {
         /* Once the UI is shown we switch the timeout over to use 
            kChildTimeoutPref, allowing us to terminate a hung plugin 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -1467,16 +1467,28 @@
     "kind": "enumerated",
     "n_values": 3,
     "description": "User response to Plugin Hang UI"
   },
   "PLUGIN_HANG_UI_DONT_ASK": {
     "kind": "boolean",
     "description": "Whether the user has requested not to see the Plugin Hang UI again"
   },
+  "PLUGIN_HANG_UI_RESPONSE_TIME": {
+    "kind": "exponential",
+    "high": "60000",
+    "n_buckets": 20,
+    "description": "Time spent in Plugin Hang UI (ms)"
+  },
+  "PLUGIN_HANG_TIME": {
+    "kind": "exponential",
+    "high": "60000",
+    "n_buckets": 20,
+    "description": "Value of dom.ipc.plugins.hangUITimeoutSecs plus time spent in Plugin Hang UI (ms)"
+  },
   "PLUGIN_SHUTDOWN_MS": {
     "kind": "exponential",
     "high": "5000",
     "n_buckets": 20,
     "description": "Time spent shutting down plugins (ms)"
   },
   "MOZ_SQLITE_OPEN_MS": {
     "kind": "exponential",