Bug 1237404: Part 1. Exposing some functionality in gfxCrashReporterUtils. r?benwa draft
authorMilan Sreckovic <milan@mozilla.com>
Wed, 06 Jan 2016 16:29:25 -0500
changeset 319390 39a34448be4d0fe2d9b686e6c156841bad1bf437
parent 319338 1ec3a3ff68f2d1a54e6ed33e926c28fee286bdf1
child 319391 4dca83026e2cd28f8a7869fa9354f3b38b488dd5
push id9031
push usermsreckovic@mozilla.com
push dateWed, 06 Jan 2016 22:25:00 +0000
reviewersbenwa
bugs1237404
milestone46.0a1
Bug 1237404: Part 1. Exposing some functionality in gfxCrashReporterUtils. r?benwa
gfx/src/gfxCrashReporterUtils.cpp
gfx/src/gfxCrashReporterUtils.h
--- a/gfx/src/gfxCrashReporterUtils.cpp
+++ b/gfx/src/gfxCrashReporterUtils.cpp
@@ -81,28 +81,28 @@ public:
     RefPtr<ObserverToDestroyFeaturesAlreadyReported> observer = new ObserverToDestroyFeaturesAlreadyReported;
     observerService->AddObserver(observer, "xpcom-shutdown", false);
     return NS_OK;
   }
 };
 
 class AppendAppNotesRunnable : public nsCancelableRunnable {
 public:
-  explicit AppendAppNotesRunnable(nsAutoCString aFeatureStr)
+  explicit AppendAppNotesRunnable(const nsACString& aFeatureStr)
     : mFeatureString(aFeatureStr)
   {
   }
 
   NS_IMETHOD Run() override {
     CrashReporter::AppendAppNotesToCrashReport(mFeatureString);
     return NS_OK;
   }
 
 private:
-  nsCString mFeatureString;
+  nsAutoCString mFeatureString;
 };
 
 void
 ScopedGfxFeatureReporter::WriteAppNote(char statusChar)
 {
   StaticMutexAutoLock al(gFeaturesAlreadyReportedMutex);
 
   if (!gFeaturesAlreadyReported) {
@@ -113,22 +113,30 @@ ScopedGfxFeatureReporter::WriteAppNote(c
 
   nsAutoCString featureString;
   featureString.AppendPrintf("%s%c ",
                              mFeature,
                              statusChar);
 
   if (!gFeaturesAlreadyReported->Contains(featureString)) {
     gFeaturesAlreadyReported->AppendElement(featureString);
-    nsCOMPtr<nsIRunnable> r = new AppendAppNotesRunnable(featureString);
-    NS_DispatchToMainThread(r);
+    AppNote(featureString);
   }
 }
 
+void
+ScopedGfxFeatureReporter::AppNote(const nsACString& aMessage)
+{
+  nsCOMPtr<nsIRunnable> r = new AppendAppNotesRunnable(aMessage);
+  NS_DispatchToMainThread(r);
+}
+  
 } // end namespace mozilla
 
 #else
 
 namespace mozilla {
 void ScopedGfxFeatureReporter::WriteAppNote(char) {}
+void ScopedGfxFeatureReporter::AppNote(const nsCString&) {}
+  
 } // namespace mozilla
 
 #endif
--- a/gfx/src/gfxCrashReporterUtils.h
+++ b/gfx/src/gfxCrashReporterUtils.h
@@ -18,26 +18,28 @@ namespace mozilla {
   *
   * This ScopedGfxFeatureReporter class is designed to be fool-proof to use in functions that
   * have many exit points. We don't want to encourage having function with many exit points.
   * It just happens that our graphics features initialization functions are like that.
   */
 class ScopedGfxFeatureReporter
 {
 public:
-  explicit ScopedGfxFeatureReporter(const char *aFeature, bool force = false)
+  explicit ScopedGfxFeatureReporter(const char *aFeature, bool aForce = false)
     : mFeature(aFeature), mStatusChar('-')
   {
-    WriteAppNote(force ? '!' : '?');
+    WriteAppNote(aForce ? '!' : '?');
   }
   ~ScopedGfxFeatureReporter() {
     WriteAppNote(mStatusChar);
   }
   void SetSuccessful() { mStatusChar = '+'; }
 
+  static void AppNote(const nsACString& aMessage);
+
   class AppNoteWritingRunnable;
 
 protected:
   const char *mFeature;
   char mStatusChar;
 
 private:
   void WriteAppNote(char statusChar);