Remove PCrashReporter. (bug 1338310, r=billm)
authorDavid Anderson <danderson@mozilla.com>
Tue, 21 Feb 2017 11:24:26 -0800
changeset 344152 9eec9caa5b5d82003ac8fae45bd1d475e885f136
parent 344151 851149e5e759b0395c047fe38af7a858d9ba7fde
child 344153 a79f71b7d7a3e3d0189b9bcd801ee76548ddcc70
push id31402
push usercbook@mozilla.com
push dateWed, 22 Feb 2017 13:33:50 +0000
treeherdermozilla-central@f5372cb6c3c7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1338310
milestone54.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
Remove PCrashReporter. (bug 1338310, r=billm)
dom/ipc/CrashReporterChild.cpp
dom/ipc/CrashReporterChild.h
dom/ipc/CrashReporterParent.cpp
dom/ipc/CrashReporterParent.h
dom/ipc/PCrashReporter.ipdl
dom/ipc/moz.build
dom/plugins/ipc/PluginModuleChild.cpp
toolkit/crashreporter/nsExceptionHandler.cpp
deleted file mode 100644
--- a/dom/ipc/CrashReporterChild.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "mozilla/plugins/PluginModuleChild.h"
-#include "ContentChild.h"
-#include "CrashReporterChild.h"
-#include "nsXULAppAPI.h"
-
-using mozilla::plugins::PluginModuleChild;
-
-namespace mozilla {
-namespace dom {
-
-/*static*/
-PCrashReporterChild*
-CrashReporterChild::GetCrashReporter()
-{
-  return nullptr;
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/ipc/CrashReporterChild.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_CrashReporterChild_h
-#define mozilla_dom_CrashReporterChild_h
-
-#include "mozilla/dom/PCrashReporterChild.h"
-
-namespace mozilla {
-namespace dom {
-
-class CrashReporterChild :
-  public PCrashReporterChild
-{
-public:
-  CrashReporterChild() {
-    MOZ_COUNT_CTOR(CrashReporterChild);
-  }
-  ~CrashReporterChild() {
-    MOZ_COUNT_DTOR(CrashReporterChild);
-  }
-
-  static PCrashReporterChild* GetCrashReporter();
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_CrashReporterChild_h
deleted file mode 100644
--- a/dom/ipc/CrashReporterParent.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "CrashReporterParent.h"
-#include "mozilla/Sprintf.h"
-#include "mozilla/dom/ContentParent.h"
-#include "mozilla/ipc/CrashReporterHost.h"
-#include "nsAutoPtr.h"
-#include "nsXULAppAPI.h"
-#include <time.h>
-
-#include "mozilla/Telemetry.h"
-
-#ifdef MOZ_CRASHREPORTER
-#include "nsExceptionHandler.h"
-#include "nsICrashService.h"
-#include "mozilla/SyncRunnable.h"
-#include "nsThreadUtils.h"
-#endif
-
-namespace mozilla {
-namespace dom {
-
-using namespace mozilla::ipc;
-
-void
-CrashReporterParent::AnnotateCrashReport(const nsCString& key,
-                                         const nsCString& data)
-{
-#ifdef MOZ_CRASHREPORTER
-  mNotes.Put(key, data);
-#endif
-}
-
-void
-CrashReporterParent::ActorDestroy(ActorDestroyReason aWhy)
-{
-  // Implement me! Bug 1005155
-}
-
-mozilla::ipc::IPCResult
-CrashReporterParent::RecvAppendAppNotes(const nsCString& data)
-{
-  mAppNotes.Append(data);
-  return IPC_OK();
-}
-
-CrashReporterParent::CrashReporterParent()
-  :
-#ifdef MOZ_CRASHREPORTER
-    mNotes(4),
-#endif
-    mStartTime(::time(nullptr))
-  , mInitialized(false)
-{
-  MOZ_COUNT_CTOR(CrashReporterParent);
-}
-
-CrashReporterParent::~CrashReporterParent()
-{
-  MOZ_COUNT_DTOR(CrashReporterParent);
-}
-
-void
-CrashReporterParent::SetChildData(const NativeThreadId& tid,
-                                  const uint32_t& processType)
-{
-  mInitialized = true;
-  mMainThread = tid;
-  mProcessType = GeckoProcessType(processType);
-}
-
-#ifdef MOZ_CRASHREPORTER
-bool
-CrashReporterParent::GenerateCrashReportForMinidump(nsIFile* minidump,
-                                                    const AnnotationTable* processNotes)
-{
-  if (!CrashReporter::GetIDFromMinidump(minidump, mChildDumpID)) {
-    return false;
-  }
-
-  bool result = GenerateChildData(processNotes);
-  FinalizeChildData();
-  return result;
-}
-
-bool
-CrashReporterParent::GenerateChildData(const AnnotationTable* processNotes)
-{
-  MOZ_ASSERT(mInitialized);
-
-  if (mChildDumpID.IsEmpty()) {
-    NS_WARNING("problem with GenerateChildData: no child dump id yet!");
-    return false;
-  }
-
-  nsAutoCString type;
-  switch (mProcessType) {
-    case GeckoProcessType_Content:
-      type = NS_LITERAL_CSTRING("content");
-      break;
-    case GeckoProcessType_Plugin:
-    case GeckoProcessType_GMPlugin:
-      type = NS_LITERAL_CSTRING("plugin");
-      break;
-    default:
-      NS_ERROR("unknown process type");
-      break;
-  }
-  mNotes.Put(NS_LITERAL_CSTRING("ProcessType"), type);
-
-  char startTime[32];
-  SprintfLiteral(startTime, "%lld", static_cast<long long>(mStartTime));
-  mNotes.Put(NS_LITERAL_CSTRING("StartupTime"), nsDependentCString(startTime));
-
-  if (!mAppNotes.IsEmpty()) {
-    mNotes.Put(NS_LITERAL_CSTRING("Notes"), mAppNotes);
-  }
-
-  // Append these notes to the end of the extra file based on the current
-  // dump id we obtained from CreatePairedMinidumps.
-  bool ret = CrashReporter::AppendExtraData(mChildDumpID, mNotes);
-  if (ret && processNotes) {
-    ret = CrashReporter::AppendExtraData(mChildDumpID, *processNotes);
-  }
-
-  if (!ret) {
-    NS_WARNING("problem appending child data to .extra");
-  }
-  return ret;
-}
-
-void
-CrashReporterParent::FinalizeChildData()
-{
-  MOZ_ASSERT(mInitialized);
-
-  CrashReporterHost::NotifyCrashService(mProcessType, mChildDumpID, &mNotes);
-  mNotes.Clear();
-}
-#endif
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/ipc/CrashReporterParent.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_CrashReporterParent_h
-#define mozilla_dom_CrashReporterParent_h
-
-#include "mozilla/dom/PCrashReporterParent.h"
-#include "mozilla/dom/TabMessageUtils.h"
-#include "nsIFile.h"
-#ifdef MOZ_CRASHREPORTER
-#include "nsExceptionHandler.h"
-#include "nsDataHashtable.h"
-#endif
-
-namespace mozilla {
-namespace dom {
-
-class CrashReporterParent : public PCrashReporterParent
-{
-#ifdef MOZ_CRASHREPORTER
-  typedef CrashReporter::AnnotationTable AnnotationTable;
-#endif
-public:
-  CrashReporterParent();
-  virtual ~CrashReporterParent();
-
-#ifdef MOZ_CRASHREPORTER
-
-  /*
-   * Attempt to create a bare-bones crash report, along with extra process-
-   * specific annotations present in the given AnnotationTable. Calls
-   * GenerateChildData and FinalizeChildData.
-   *
-   * @returns true if successful, false otherwise.
-   */
-  template<class Toplevel>
-  bool
-  GenerateCrashReport(Toplevel* t, const AnnotationTable* processNotes);
-
-  /**
-   * Apply child process annotations to an existing paired mindump generated
-   * with GeneratePairedMinidump.
-   *
-   * Be careful about calling generate apis immediately after this call,
-   * see FinalizeChildData.
-   *
-   * @param processNotes (optional) - Additional notes to append. Annotations
-   *   stored in mNotes will also be applied. processNotes can be null.
-   * @returns true if successful, false otherwise.
-   */
-  bool
-  GenerateChildData(const AnnotationTable* processNotes);
-
-  /**
-   * Handles main thread finalization tasks after a report has been
-   * generated. Does the following:
-   *  - register the finished report with the crash service manager
-   *  - records telemetry related data about crashes
-   *
-   * Be careful about calling generate apis immediately after this call,
-   * if this api is called on a non-main thread it will fire off a runnable
-   * to complete its work async.
-   */
-  void
-  FinalizeChildData();
-
-  /*
-   * Attempt to generate a full paired dump complete with any child
-   * annoations, and finalizes the report. Note this call is only valid
-   * on the main thread. Calling on a background thread will fail.
-   *
-   * @returns true if successful, false otherwise.
-   */
-  template<class Toplevel>
-  bool
-  GenerateCompleteMinidump(Toplevel* t);
-
-  /**
-   * Submits a raw minidump handed in, calls GenerateChildData and
-   * FinalizeChildData. Used by content plugins and gmp.
-   *
-   * @returns true if successful, false otherwise.
-   */
-  bool
-  GenerateCrashReportForMinidump(nsIFile* minidump,
-                                 const AnnotationTable* processNotes);
-#endif // MOZ_CRASHREPORTER
-
-  /*
-   * Initialize this reporter with data from the child process.
-   */
-  void
-  SetChildData(const NativeThreadId& id, const uint32_t& processType);
-
-  /*
-   * Returns the ID of the child minidump.
-   * GeneratePairedMinidump or GenerateCrashReport must be called first.
-   */
-  const nsString& ChildDumpID() const {
-    return mChildDumpID;
-  }
-
-  /*
-   * Add an annotation to our internally tracked list of annotations.
-   * Callers must apply these notes using GenerateChildData otherwise
-   * the notes will get dropped.
-   */
-  void
-  AnnotateCrashReport(const nsCString& aKey, const nsCString& aData);
-
- protected:
-  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
-
-  virtual mozilla::ipc::IPCResult RecvAnnotateCrashReport(const nsCString& aKey,
-                                                          const nsCString& aData) override
-  {
-    AnnotateCrashReport(aKey, aData);
-    return IPC_OK();
-  }
-
-  virtual mozilla::ipc::IPCResult RecvAppendAppNotes(const nsCString& aData) override;
-
-#ifdef MOZ_CRASHREPORTER
-  void
-  NotifyCrashService();
-#endif
-
-#ifdef MOZ_CRASHREPORTER
-  AnnotationTable mNotes;
-#endif
-  nsCString mAppNotes;
-  nsString mChildDumpID;
-  // stores the child main thread id
-  NativeThreadId mMainThread;
-  time_t mStartTime;
-  // stores the child process type
-  GeckoProcessType mProcessType;
-  bool mInitialized;
-};
-
-#ifdef MOZ_CRASHREPORTER
-template<class Toplevel>
-inline bool
-CrashReporterParent::GenerateCrashReport(Toplevel* t,
-                                         const AnnotationTable* processNotes)
-{
-  nsCOMPtr<nsIFile> crashDump;
-  if (t->TakeMinidump(getter_AddRefs(crashDump), nullptr) &&
-      CrashReporter::GetIDFromMinidump(crashDump, mChildDumpID)) {
-    bool result = GenerateChildData(processNotes);
-    FinalizeChildData();
-    return result;
-  }
-  return false;
-}
-
-template<class Toplevel>
-inline bool
-CrashReporterParent::GenerateCompleteMinidump(Toplevel* t)
-{
-  mozilla::ipc::ScopedProcessHandle child;
-  if (!NS_IsMainThread()) {
-    NS_WARNING("GenerateCompleteMinidump can't be called on non-main thread.");
-    return false;
-  }
-
-#ifdef XP_MACOSX
-  child = t->Process()->GetChildTask();
-#else
-  if (!base::OpenPrivilegedProcessHandle(t->OtherPid(), &child.rwget())) {
-    NS_WARNING("Failed to open child process handle.");
-    return false;
-  }
-#endif
-  nsCOMPtr<nsIFile> childDump;
-  if (CrashReporter::CreateMinidumpsAndPair(child,
-                                            mMainThread,
-                                            NS_LITERAL_CSTRING("browser"),
-                                            nullptr, // pair with a dump of this process and thread
-                                            getter_AddRefs(childDump)) &&
-      CrashReporter::GetIDFromMinidump(childDump, mChildDumpID)) {
-    bool result = GenerateChildData(nullptr);
-    FinalizeChildData();
-    return result;
-  }
-  return false;
-}
-
-#endif
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_CrashReporterParent_h
deleted file mode 100644
--- a/dom/ipc/PCrashReporter.ipdl
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set sw=4 ts=8 et tw=80 : 
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-include protocol PContent;
-include protocol PPluginModule;
-include protocol PGMP;
-
-namespace mozilla {
-namespace dom {
-
-struct Mapping {
-  nsCString library_name;
-  nsCString file_id;
-  uintptr_t start_address;
-  size_t mapping_length;
-  size_t file_offset;
-};
-
-async protocol PCrashReporter {
-parent:
-  async AnnotateCrashReport(nsCString key, nsCString data);
-  async AppendAppNotes(nsCString data);
-  async __delete__();
-};
-
-}
-}
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -19,18 +19,16 @@ EXPORTS.mozilla.dom += [
     'ContentBridgeChild.h',
     'ContentBridgeParent.h',
     'ContentChild.h',
     'ContentParent.h',
     'ContentPrefs.h',
     'ContentProcess.h',
     'ContentProcessManager.h',
     'CPOWManagerGetter.h',
-    'CrashReporterChild.h',
-    'CrashReporterParent.h',
     'FilePickerParent.h',
     'MemoryReportRequest.h',
     'nsIContentChild.h',
     'nsIContentParent.h',
     'PermissionMessageUtils.h',
     'TabChild.h',
     'TabContext.h',
     'TabMessageUtils.h',
@@ -49,17 +47,16 @@ EXPORTS.mozilla += [
 UNIFIED_SOURCES += [
     'ColorPickerParent.cpp',
     'ContentBridgeChild.cpp',
     'ContentBridgeParent.cpp',
     'ContentParent.cpp',
     'ContentPrefs.cpp',
     'ContentProcess.cpp',
     'ContentProcessManager.cpp',
-    'CrashReporterParent.cpp',
     'DatePickerParent.cpp',
     'FilePickerParent.cpp',
     'MemoryReportRequest.cpp',
     'nsIContentChild.cpp',
     'nsIContentParent.cpp',
     'PermissionMessageUtils.cpp',
     'PreallocatedProcessManager.cpp',
     'ProcessPriorityManager.cpp',
@@ -68,36 +65,32 @@ UNIFIED_SOURCES += [
     'TabChild.cpp',
     'TabContext.cpp',
     'TabMessageUtils.cpp',
     'TabParent.cpp',
     'URLClassifierChild.cpp',
     'URLClassifierParent.cpp',
 ]
 
-# CrashReporterChild.cpp cannot be compiled in unified mode because of name clashes
-# in OS X headers.
 # ContentChild.cpp cannot be compiled in unified mode on  linux due to Time conflict
 SOURCES += [
     'ContentChild.cpp',
-    'CrashReporterChild.cpp',
     'ProcessHangMonitor.cpp',
 ]
 
 IPDL_SOURCES += [
     'DOMTypes.ipdlh',
     'MemoryReportTypes.ipdlh',
     'PBrowser.ipdl',
     'PBrowserOrId.ipdlh',
     'PColorPicker.ipdl',
     'PContent.ipdl',
     'PContentBridge.ipdl',
     'PContentPermission.ipdlh',
     'PContentPermissionRequest.ipdl',
-    'PCrashReporter.ipdl',
     'PCycleCollectWithLogs.ipdl',
     'PDatePicker.ipdl',
     'PDocumentRenderer.ipdl',
     'PFilePicker.ipdl',
     'PPluginWidget.ipdl',
     'PProcessHangMonitor.ipdl',
     'PScreenManager.ipdl',
     'PTabContext.ipdlh',
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -27,17 +27,16 @@
 # include "nsX11ErrorHandler.h"
 # include "mozilla/X11Util.h"
 #endif
 #include "mozilla/ipc/ProcessChild.h"
 #include "mozilla/plugins/PluginInstanceChild.h"
 #include "mozilla/plugins/StreamNotifyChild.h"
 #include "mozilla/plugins/BrowserStreamChild.h"
 #include "mozilla/plugins/PluginStreamChild.h"
-#include "mozilla/dom/CrashReporterChild.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/Unused.h"
 
 #include "nsNPAPIPlugin.h"
 
 #ifdef XP_WIN
 #include "nsWindowsDllInterceptor.h"
 #include "mozilla/widget/AudioSession.h"
--- a/toolkit/crashreporter/nsExceptionHandler.cpp
+++ b/toolkit/crashreporter/nsExceptionHandler.cpp
@@ -6,25 +6,24 @@
 
 #include "nsExceptionHandler.h"
 
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryService.h"
 #include "nsDataHashtable.h"
 #include "mozilla/ArrayUtils.h"
-#include "mozilla/dom/CrashReporterChild.h"
-#include "mozilla/ipc/CrashReporterClient.h"
 #include "mozilla/Services.h"
 #include "nsIObserverService.h"
 #include "mozilla/Unused.h"
 #include "mozilla/Printf.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/SyncRunnable.h"
 #include "mozilla/TimeStamp.h"
+#include "mozilla/ipc/CrashReporterClient.h"
 
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 #include "jsfriendapi.h"
 
 #if defined(XP_WIN32)
 #ifdef WIN32_LEAN_AND_MEAN
 #undef WIN32_LEAN_AND_MEAN
@@ -106,18 +105,16 @@ using google_breakpad::ClientInfo;
 using google_breakpad::MinidumpDescriptor;
 #endif
 #if defined(MOZ_WIDGET_ANDROID)
 using google_breakpad::auto_wasteful_vector;
 using google_breakpad::FileID;
 using google_breakpad::PageAllocator;
 #endif
 using namespace mozilla;
-using mozilla::dom::CrashReporterChild;
-using mozilla::dom::PCrashReporterChild;
 using mozilla::ipc::CrashReporterClient;
 
 namespace CrashReporter {
 
 #ifdef XP_WIN32
 typedef wchar_t XP_CHAR;
 typedef std::wstring xpstring;
 #define XP_TEXT(x) L##x
@@ -2254,38 +2251,16 @@ static void
 EnqueueDelayedNote(DelayedNote* aNote)
 {
   if (!gDelayedAnnotations) {
     gDelayedAnnotations = new nsTArray<nsAutoPtr<DelayedNote> >();
   }
   gDelayedAnnotations->AppendElement(aNote);
 }
 
-class CrashReporterHelperRunnable : public Runnable {
-public:
-  explicit CrashReporterHelperRunnable(const nsACString& aKey,
-                                       const nsACString& aData)
-    : mKey(aKey)
-    , mData(aData)
-    , mAppendAppNotes(false)
-    {}
-  explicit CrashReporterHelperRunnable(const nsACString& aData)
-    : mKey()
-    , mData(aData)
-    , mAppendAppNotes(true)
-    {}
-
-  NS_IMETHOD Run() override;
-
-private:
-  nsCString mKey;
-  nsCString mData;
-  bool mAppendAppNotes;
-};
-
 nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data)
 {
   if (!GetEnabled())
     return NS_ERROR_NOT_INITIALIZED;
 
   nsCString escapedData;
   nsresult rv = EscapeAnnotation(key, data, escapedData);
   if (NS_FAILED(rv))
@@ -2293,33 +2268,20 @@ nsresult AnnotateCrashReport(const nsACS
 
   if (!XRE_IsParentProcess()) {
     // The newer CrashReporterClient can be used from any thread.
     if (RefPtr<CrashReporterClient> client = CrashReporterClient::GetSingleton()) {
       client->AnnotateCrashReport(nsCString(key), escapedData);
       return NS_OK;
     }
 
-    // Otherwise, we have to handle this on the main thread since we will go
-    // through IPDL.
-    if (!NS_IsMainThread()) {
-      // Child process needs to handle this in the main thread:
-      nsCOMPtr<nsIRunnable> r = new CrashReporterHelperRunnable(key, data);
-      NS_DispatchToMainThread(r);
-      return NS_OK;
-    }
-
-    MOZ_ASSERT(NS_IsMainThread());
-    PCrashReporterChild* reporter = CrashReporterChild::GetCrashReporter();
-    if (!reporter) {
-      EnqueueDelayedNote(new DelayedNote(key, data));
-      return NS_OK;
-    }
-    if (!reporter->SendAnnotateCrashReport(nsCString(key), escapedData))
-      return NS_ERROR_FAILURE;
+    // EnqueueDelayedNote() can only be called on the main thread.
+    MOZ_RELEASE_ASSERT(NS_IsMainThread());
+
+    EnqueueDelayedNote(new DelayedNote(key, data));
     return NS_OK;
   }
 
   MutexAutoLock lock(*crashReporterAPILock);
 
   crashReporterAPIData_Hash->Put(key, escapedData);
 
   // now rebuild the file contents
@@ -2378,59 +2340,29 @@ nsresult AppendAppNotesToCrashReport(con
     if (NS_FAILED(rv))
       return rv;
 
     if (RefPtr<CrashReporterClient> client = CrashReporterClient::GetSingleton()) {
       client->AppendAppNotes(escapedData);
       return NS_OK;
     }
 
-    if (!NS_IsMainThread()) {
-      // Child process needs to handle this in the main thread:
-      nsCOMPtr<nsIRunnable> r = new CrashReporterHelperRunnable(data);
-      NS_DispatchToMainThread(r);
-      return NS_OK;
-    }
-
-    MOZ_ASSERT(NS_IsMainThread());
-    PCrashReporterChild* reporter = CrashReporterChild::GetCrashReporter();
-    if (!reporter) {
-      EnqueueDelayedNote(new DelayedNote(data));
-      return NS_OK;
-    }
-
-    if (!reporter->SendAppendAppNotes(escapedData))
-      return NS_ERROR_FAILURE;
+    // EnqueueDelayedNote can only be called on the main thread.
+    MOZ_RELEASE_ASSERT(NS_IsMainThread());
+
+    EnqueueDelayedNote(new DelayedNote(data));
     return NS_OK;
   }
 
   MutexAutoLock lock(*notesFieldLock);
 
   notesField->Append(data);
   return AnnotateCrashReport(NS_LITERAL_CSTRING("Notes"), *notesField);
 }
 
-nsresult CrashReporterHelperRunnable::Run()
-{
-  // We expect this to be in the child process' main thread.  If it isn't,
-  // something is happening we didn't design for.
-  MOZ_ASSERT(!XRE_IsParentProcess());
-  MOZ_ASSERT(NS_IsMainThread());
-
-  // Don't just leave the assert, paranoid about infinite recursion
-  if (NS_IsMainThread()) {
-    if (mAppendAppNotes) {
-      return AppendAppNotesToCrashReport(mData);
-    } else {
-      return AnnotateCrashReport(mKey, mData);
-    }
-  }
-  return NS_ERROR_FAILURE;
-}
-
 // Returns true if found, false if not found.
 bool GetAnnotation(const nsACString& key, nsACString& data)
 {
   if (!gExceptionHandler)
     return false;
 
   nsAutoCString entry;
   if (!crashReporterAPIData_Hash->Get(key, &entry))