Bug 1183433 - Replace GMPParent's crash report annotations (using multiple keys) with centralized reporting. r=cpearce, a=lmandel
authorGerald Squelart <gsquelart@mozilla.com>
Wed, 15 Jul 2015 21:33:00 -0400
changeset 275466 dcabd9b629d66ba9a557647e65677013875343db
parent 275465 603c57935f3d5124faa9f88cc19d909a7925e69d
child 275467 e404ee7ef5e511dd1fe7336d43aed887c4584524
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1183433
milestone40.0
Bug 1183433 - Replace GMPParent's crash report annotations (using multiple keys) with centralized reporting. r=cpearce, a=lmandel
dom/media/gmp/GMPParent.cpp
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -196,22 +196,21 @@ GMPParent::LoadProcess()
 }
 
 // static
 void
 GMPParent::AbortWaitingForGMPAsyncShutdown(nsITimer* aTimer, void* aClosure)
 {
   NS_WARNING("Timed out waiting for GMP async shutdown!");
   GMPParent* parent = reinterpret_cast<GMPParent*>(aClosure);
+  MOZ_ASSERT(parent->mService);
 #if defined(MOZ_CRASHREPORTER)
-  CrashReporter::AnnotateCrashReport(
-    nsPrintfCString("AsyncPluginShutdown-%s@%p", parent->GetDisplayName().get(), parent),
+  parent->mService->SetAsyncShutdownPluginState(parent, 'G',
     NS_LITERAL_CSTRING("Timed out waiting for async shutdown"));
 #endif
-  MOZ_ASSERT(parent->mService);
   parent->mService->AsyncShutdownComplete(parent);
 }
 
 nsresult
 GMPParent::EnsureAsyncShutdownTimeoutSet()
 {
   MOZ_ASSERT(mAsyncShutdownRequired);
   if (mAsyncShutdownTimeout) {
@@ -245,27 +244,29 @@ GMPParent::EnsureAsyncShutdownTimeoutSet
 }
 
 bool
 GMPParent::RecvPGMPContentChildDestroyed()
 {
   --mGMPContentChildCount;
   if (!IsUsed()) {
 #if defined(MOZ_CRASHREPORTER)
-    CrashReporter::AnnotateCrashReport(
-      nsPrintfCString("AsyncPluginShutdown-%s@%p", GetDisplayName().get(), this),
-      NS_LITERAL_CSTRING("Content children destroyed"));
+    if (mService) {
+      mService->SetAsyncShutdownPluginState(this, 'E',
+        NS_LITERAL_CSTRING("Last content child destroyed"));
+    }
 #endif
     CloseIfUnused();
   }
 #if defined(MOZ_CRASHREPORTER)
   else {
-    CrashReporter::AnnotateCrashReport(
-      nsPrintfCString("AsyncPluginShutdown-%s@%p", GetDisplayName().get(), this),
-      nsPrintfCString("Content child destroyed, remaining: %u", mGMPContentChildCount));
+    if (mService) {
+      mService->SetAsyncShutdownPluginState(this, 'F',
+        nsPrintfCString("Content child destroyed, remaining: %u", mGMPContentChildCount));
+    }
   }
 #endif
   return true;
 }
 
 void
 GMPParent::CloseIfUnused()
 {
@@ -280,38 +281,47 @@ GMPParent::CloseIfUnused()
     for (uint32_t i = mTimers.Length(); i > 0; i--) {
       mTimers[i - 1]->Shutdown();
     }
 
     if (mAsyncShutdownRequired) {
       if (!mAsyncShutdownInProgress) {
         LOGD("%s: sending async shutdown notification", __FUNCTION__);
 #if defined(MOZ_CRASHREPORTER)
-      CrashReporter::AnnotateCrashReport(
-        nsPrintfCString("AsyncPluginShutdown-%s@%p", GetDisplayName().get(), this),
-        NS_LITERAL_CSTRING("Sent BeginAsyncShutdown"));
+        if (mService) {
+          mService->SetAsyncShutdownPluginState(this, 'H',
+            NS_LITERAL_CSTRING("Sent BeginAsyncShutdown"));
+        }
 #endif
         mAsyncShutdownInProgress = true;
         if (!SendBeginAsyncShutdown()) {
 #if defined(MOZ_CRASHREPORTER)
-          CrashReporter::AnnotateCrashReport(
-            nsPrintfCString("AsyncPluginShutdown-%s@%p", GetDisplayName().get(), this),
-            NS_LITERAL_CSTRING("Could not send BeginAsyncShutdown - Aborting async shutdown"));
+          if (mService) {
+            mService->SetAsyncShutdownPluginState(this, 'I',
+              NS_LITERAL_CSTRING("Could not send BeginAsyncShutdown - Aborting async shutdown"));
+          }
 #endif
           AbortAsyncShutdown();
         } else if (NS_FAILED(EnsureAsyncShutdownTimeoutSet())) {
 #if defined(MOZ_CRASHREPORTER)
-          CrashReporter::AnnotateCrashReport(
-            nsPrintfCString("AsyncPluginShutdown-%s@%p", GetDisplayName().get(), this),
-            NS_LITERAL_CSTRING("Could not start timer after sending BeginAsyncShutdown - Aborting async shutdown"));
+          if (mService) {
+            mService->SetAsyncShutdownPluginState(this, 'J',
+              NS_LITERAL_CSTRING("Could not start timer after sending BeginAsyncShutdown - Aborting async shutdown"));
+          }
 #endif
           AbortAsyncShutdown();
         }
       }
     } else {
+#if defined(MOZ_CRASHREPORTER)
+      if (mService) {
+        mService->SetAsyncShutdownPluginState(this, 'K',
+          NS_LITERAL_CSTRING("No (more) async-shutdown required"));
+      }
+#endif
       // No async-shutdown, kill async-shutdown timer started in CloseActive().
       AbortAsyncShutdown();
       // Any async shutdown must be complete. Shutdown GMPStorage.
       for (size_t i = mStorage.Length(); i > 0; i--) {
         mStorage[i - 1]->Shutdown();
       }
       Shutdown();
     }
@@ -349,49 +359,53 @@ GMPParent::CloseActive(bool aDieWhenUnlo
   if (aDieWhenUnloaded) {
     mDeleteProcessOnlyOnUnload = true; // don't allow this to go back...
   }
   if (mState == GMPStateLoaded) {
     mState = GMPStateUnloading;
   }
   if (mState != GMPStateNotLoaded && IsUsed()) {
 #if defined(MOZ_CRASHREPORTER)
-    CrashReporter::AnnotateCrashReport(
-      nsPrintfCString("AsyncPluginShutdown-%s@%p", GetDisplayName().get(), this),
-      nsPrintfCString("Sent CloseActive, content children to close: %u", mGMPContentChildCount));
+    if (mService) {
+      mService->SetAsyncShutdownPluginState(this, 'A',
+        nsPrintfCString("Sent CloseActive, content children to close: %u", mGMPContentChildCount));
+    }
 #endif
     if (!SendCloseActive()) {
 #if defined(MOZ_CRASHREPORTER)
-      CrashReporter::AnnotateCrashReport(
-        nsPrintfCString("AsyncPluginShutdown-%s@%p", GetDisplayName().get(), this),
-        NS_LITERAL_CSTRING("Could not send CloseActive - Aborting async shutdown"));
+      if (mService) {
+        mService->SetAsyncShutdownPluginState(this, 'B',
+          NS_LITERAL_CSTRING("Could not send CloseActive - Aborting async shutdown"));
+      }
 #endif
       AbortAsyncShutdown();
     } else if (IsUsed()) {
       // We're expecting RecvPGMPContentChildDestroyed's -> Start async-shutdown timer now if needed.
       if (mAsyncShutdownRequired && NS_FAILED(EnsureAsyncShutdownTimeoutSet())) {
 #if defined(MOZ_CRASHREPORTER)
-        CrashReporter::AnnotateCrashReport(
-          nsPrintfCString("AsyncPluginShutdown-%s@%p", GetDisplayName().get(), this),
-          NS_LITERAL_CSTRING("Could not start timer after sending CloseActive - Aborting async shutdown"));
+        if (mService) {
+          mService->SetAsyncShutdownPluginState(this, 'C',
+            NS_LITERAL_CSTRING("Could not start timer after sending CloseActive - Aborting async shutdown"));
+        }
 #endif
         AbortAsyncShutdown();
       }
     } else {
       // We're not expecting any RecvPGMPContentChildDestroyed
       // -> Call CloseIfUnused() now, to run async shutdown if necessary.
       // Note that CloseIfUnused() may have already been called from a prior
       // RecvPGMPContentChildDestroyed(), however depending on the state at
       // that time, it might not have proceeded with shutdown; And calling it
       // again after shutdown is fine because after the first one we'll be in
       // GMPStateNotLoaded.
 #if defined(MOZ_CRASHREPORTER)
-      CrashReporter::AnnotateCrashReport(
-        nsPrintfCString("AsyncPluginShutdown-%s@%p", GetDisplayName().get(), this),
-        NS_LITERAL_CSTRING("Content children already destroyed"));
+      if (mService) {
+        mService->SetAsyncShutdownPluginState(this, 'D',
+          NS_LITERAL_CSTRING("Content children already destroyed"));
+      }
 #endif
       CloseIfUnused();
     }
   }
 }
 
 void
 GMPParent::MarkForDeletion()
@@ -640,19 +654,20 @@ GMPParent::ActorDestroy(ActorDestroyReas
   mAbnormalShutdownInProgress = true;
   CloseActive(false);
 
   // Normal Shutdown() will delete the process on unwind.
   if (AbnormalShutdown == aWhy) {
     nsRefPtr<GMPParent> self(this);
     if (mAsyncShutdownRequired) {
 #if defined(MOZ_CRASHREPORTER)
-      CrashReporter::AnnotateCrashReport(
-        nsPrintfCString("AsyncPluginShutdown-%s@%p", GetDisplayName().get(), this),
-        NS_LITERAL_CSTRING("Actor destroyed"));
+      if (mService) {
+        mService->SetAsyncShutdownPluginState(this, 'M',
+          NS_LITERAL_CSTRING("Actor destroyed"));
+      }
 #endif
       mService->AsyncShutdownComplete(this);
       mAsyncShutdownRequired = false;
     }
     // Must not call Close() again in DeleteProcess(), as we'll recurse
     // infinitely if we do.
     MOZ_ASSERT(mState == GMPStateClosing);
     DeleteProcess();
@@ -947,19 +962,20 @@ GMPParent::RecvAsyncShutdownRequired()
 
 bool
 GMPParent::RecvAsyncShutdownComplete()
 {
   LOGD("%s", __FUNCTION__);
 
   MOZ_ASSERT(mAsyncShutdownRequired);
 #if defined(MOZ_CRASHREPORTER)
-  CrashReporter::AnnotateCrashReport(
-    nsPrintfCString("AsyncPluginShutdown-%s@%p", GetDisplayName().get(), this),
-    NS_LITERAL_CSTRING("Received AsyncShutdownComplete"));
+  if (mService) {
+    mService->SetAsyncShutdownPluginState(this, 'L',
+      NS_LITERAL_CSTRING("Received AsyncShutdownComplete"));
+  }
 #endif
   AbortAsyncShutdown();
   return true;
 }
 
 class RunCreateContentParentCallbacks : public nsRunnable
 {
 public: