Bug 1348273 - Convert the docshell and XPConnect-related annotations; r?bz draft
authorGabriele Svelto <gsvelto@mozilla.com>
Fri, 16 Mar 2018 21:29:16 +0100
changeset 776640 74696d272ff37dd5c6173ebcc201f664f4b95a49
parent 776639 33bc5c97726654f3a586e61a7384d365736d532d
child 776641 8531fdbdd02b9f26fa3bcc46b9fc468c2e84f959
push id104933
push usergsvelto@mozilla.com
push dateTue, 03 Apr 2018 14:35:30 +0000
reviewersbz
bugs1348273
milestone61.0a1
Bug 1348273 - Convert the docshell and XPConnect-related annotations; r?bz MozReview-Commit-ID: 7ACJI5xWOsa
docshell/base/nsDocShell.cpp
js/xpconnect/loader/mozJSComponentLoader.cpp
toolkit/crashreporter/CrashAnnotations.yaml
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -1811,18 +1811,18 @@ nsDocShell::GetUseRemoteTabs(bool* aUseR
   *aUseRemoteTabs = mUseRemoteTabs;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::SetRemoteTabs(bool aUseRemoteTabs)
 {
   if (aUseRemoteTabs) {
-    CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("DOMIPCEnabled"),
-                                       NS_LITERAL_CSTRING("1"));
+    CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::DOMIPCEnabled,
+                                       true);
   }
 
   mUseRemoteTabs = aUseRemoteTabs;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::SetAffectPrivateSessionLifetime(bool aAffectLifetime)
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -15,16 +15,17 @@
 #ifdef XP_WIN
 #include <windows.h>
 #endif
 
 #include "jsapi.h"
 #include "js/Printf.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
+#include "nsExceptionHandler.h"
 #include "nsIComponentManager.h"
 #include "mozilla/Module.h"
 #include "nsIFile.h"
 #include "mozJSComponentLoader.h"
 #include "mozJSLoaderUtils.h"
 #include "nsIXPConnect.h"
 #include "nsIObserverService.h"
 #include "nsIScriptSecurityManager.h"
@@ -51,20 +52,16 @@
 #include "mozilla/ResultExtensions.h"
 #include "mozilla/ScriptPreloader.h"
 #include "mozilla/dom/DOMPrefs.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/ResultExtensions.h"
 #include "mozilla/UniquePtrExtensions.h"
 #include "mozilla/Unused.h"
 
-#ifdef MOZ_CRASHREPORTER
-#include "mozilla/ipc/CrashReporterClient.h"
-#endif
-
 using namespace mozilla;
 using namespace mozilla::scache;
 using namespace mozilla::loader;
 using namespace xpc;
 using namespace JS;
 
 static const char kObserverServiceContractID[] = "@mozilla.org/observer-service;1";
 
@@ -358,51 +355,47 @@ ResolveModuleObjectProperty(JSContext* a
         }
         if (found) {
             return lexical;
         }
     }
     return aModObj;
 }
 
-#ifdef MOZ_CRASHREPORTER
 static mozilla::Result<nsCString, nsresult> ReadScript(ComponentLoaderInfo& aInfo);
 
 static nsresult
-AnnotateScriptContents(const nsACString& aName, const nsACString& aURI)
+AnnotateScriptContents(CrashReporter::Annotation aName, const nsACString& aURI)
 {
     ComponentLoaderInfo info(aURI);
 
     nsCString str;
     MOZ_TRY_VAR(str, ReadScript(info));
 
     // The crash reporter won't accept any strings with embedded nuls. We
     // shouldn't have any here, but if we do because of data corruption, we
     // still want the annotation. So replace any embedded nuls before
     // annotating.
     str.ReplaceSubstring(NS_LITERAL_CSTRING("\0"), NS_LITERAL_CSTRING("\\0"));
 
     CrashReporter::AnnotateCrashReport(aName, str);
 
     return NS_OK;
 }
-#endif // defined MOZ_CRASHREPORTER
 
 nsresult
 mozJSComponentLoader::AnnotateCrashReport()
 {
-#ifdef MOZ_CRASHREPORTER
     Unused << AnnotateScriptContents(
-        NS_LITERAL_CSTRING("nsAsyncShutdownComponent"),
+        CrashReporter::Annotation::nsAsyncShutdownComponent,
         NS_LITERAL_CSTRING("resource://gre/components/nsAsyncShutdown.js"));
 
     Unused << AnnotateScriptContents(
-        NS_LITERAL_CSTRING("AsyncShutdownModule"),
+        CrashReporter::Annotation::AsyncShutdownModule,
         NS_LITERAL_CSTRING("resource://gre/modules/AsyncShutdown.jsm"));
-#endif // defined MOZ_CRASHREPORTER
 
     return NS_OK;
 }
 
 const mozilla::Module*
 mozJSComponentLoader::LoadModule(FileLocation& aFile)
 {
     if (!NS_IsMainThread()) {
--- a/toolkit/crashreporter/CrashAnnotations.yaml
+++ b/toolkit/crashreporter/CrashAnnotations.yaml
@@ -23,16 +23,21 @@ AccessibilityClient:
   type: string
 
 AccessibilityInProcClient:
   description: >
     Hexadecimal mask of accessibility consumers, see
     accessible/windows/msaa/Compatibility.h for the mappings.
   type: string
 
+AsyncShutdownModule:
+  description: >
+    Holds the contents of the AsyncShutdown.js script
+  type: string
+
 AvailablePageFile:
   description: >
     Windows-only, maximum amount of memory that can be committed.  This
     annotation is populated with the contents of the MEMORYSTATUSEX's structure
     ullAvailPageFile field.
   type: string
   ping: true
 
@@ -81,16 +86,21 @@ ContainsMemoryReport:
   ping: true
 
 CrashTime:
   description: >
     Crash time in seconds since the Epoch.
   type: string
   ping: true
 
+DOMIPCEnabled:
+  description: >
+    Set to 1 when a tab is running in a content process
+  type: boolean
+
 EventLoopNestingLevel:
   description: >
     Present only if higher than 0, indicates that we're running in a nested
     event loop and indicates the nesting level.
   type: integer
   ping: true
 
 IAccessibleConfig:
@@ -118,16 +128,21 @@ MozCrashReason:
   type: string
   ping: true
 
 Notes:
   description: >
     Miscellaneous notes that can be appended to a crash.
   type: string
 
+nsAsyncShutdownComponent:
+  description: >
+    Holds the contents of the nsAsyncShutdown.js script
+  type: string
+
 OOMAllocationSize:
   description: >
     Size of the allocation that caused an out-of-memory condition.
   type: string
   ping: true
 
 PluginHang:
   description: >