Bug 1235576 - Fix the indentation in dom/ipc, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 05 Jan 2016 09:59:30 +0000
changeset 318969 8af6d41e7d3b38ed41a9e87d02949ce60ea00fef
parent 318968 3fbbaedcf49587e25e5e4a3c19fbb3093abb9bf3
child 318970 700d49664df69b3808597dfe0e13e6d40db1e1fd
push id8951
push userbenj@benj.me
push dateTue, 05 Jan 2016 13:08:54 +0000
reviewerssmaug
bugs1235576
milestone46.0a1
Bug 1235576 - Fix the indentation in dom/ipc, r=smaug
dom/ipc/CPOWManagerGetter.h
dom/ipc/ContentBridgeParent.h
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/ContentProcess.h
dom/ipc/ContentProcessManager.h
dom/ipc/CrashReporterChild.h
dom/ipc/CrashReporterParent.cpp
dom/ipc/CrashReporterParent.h
dom/ipc/FilePickerParent.h
dom/ipc/IdType.h
dom/ipc/NuwaChild.h
dom/ipc/NuwaParent.h
dom/ipc/PermissionMessageUtils.h
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/TabContext.h
dom/ipc/TabMessageUtils.h
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
dom/ipc/nsIContentChild.h
dom/ipc/nsIContentParent.h
--- a/dom/ipc/CPOWManagerGetter.h
+++ b/dom/ipc/CPOWManagerGetter.h
@@ -9,18 +9,19 @@
 
 namespace mozilla {
 
 namespace jsipc {
 class CPOWManager;
 } /* namespace jsipc */
 
 namespace dom {
+
 class CPOWManagerGetter
 {
 public:
   virtual mozilla::jsipc::CPOWManager* GetCPOWManager() = 0;
 };
+
 } /* namespace dom */
-
 } /* namespace mozilla */
 
 #endif /* mozilla_dom_CPOWManagerGetter_h */
--- a/dom/ipc/ContentBridgeParent.h
+++ b/dom/ipc/ContentBridgeParent.h
@@ -22,17 +22,17 @@ class ContentBridgeParent : public PCont
 public:
   explicit ContentBridgeParent(Transport* aTransport);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
   void DeferredDestroy();
-  virtual bool IsContentBridgeParent() override { return true; }
+  virtual bool IsContentBridgeParent() const override { return true; }
   void NotifyTabDestroyed();
 
   static ContentBridgeParent*
   Create(Transport* aTransport, ProcessId aOtherProcess);
 
   virtual PBlobParent*
   SendPBlobConstructor(PBlobParent* actor,
                        const BlobConstructorParams& params) override;
@@ -43,67 +43,73 @@ public:
                           const IPCTabContext& aContext,
                           const uint32_t& aChromeFlags,
                           const ContentParentId& aCpID,
                           const bool& aIsForApp,
                           const bool& aIsForBrowser) override;
 
   jsipc::CPOWManager* GetCPOWManager() override;
 
-  virtual ContentParentId ChildID() override
+  virtual ContentParentId ChildID() const override
   {
     return mChildID;
   }
-  virtual bool IsForApp() override
+  virtual bool IsForApp() const override
   {
     return mIsForApp;
   }
-  virtual bool IsForBrowser() override
+  virtual bool IsForBrowser() const override
   {
     return mIsForBrowser;
   }
 
 protected:
   virtual ~ContentBridgeParent();
 
   void SetChildID(ContentParentId aId)
   {
     mChildID = aId;
   }
+
   void SetIsForApp(bool aIsForApp)
   {
     mIsForApp = aIsForApp;
   }
+
   void SetIsForBrowser(bool aIsForBrowser)
   {
     mIsForBrowser = aIsForBrowser;
   }
 
 protected:
-  virtual bool RecvSyncMessage(const nsString& aMsg,
-                               const ClonedMessageData& aData,
-                               InfallibleTArray<jsipc::CpowEntry>&& aCpows,
-                               const IPC::Principal& aPrincipal,
-                               nsTArray<StructuredCloneData>* aRetvals) override;
+  virtual bool
+  RecvSyncMessage(const nsString& aMsg,
+                  const ClonedMessageData& aData,
+                  InfallibleTArray<jsipc::CpowEntry>&& aCpows,
+                  const IPC::Principal& aPrincipal,
+                  nsTArray<StructuredCloneData>* aRetvals) override;
+
   virtual bool RecvAsyncMessage(const nsString& aMsg,
                                 const ClonedMessageData& aData,
                                 InfallibleTArray<jsipc::CpowEntry>&& aCpows,
                                 const IPC::Principal& aPrincipal) override;
 
   virtual jsipc::PJavaScriptParent* AllocPJavaScriptParent() override;
+
   virtual bool
   DeallocPJavaScriptParent(jsipc::PJavaScriptParent*) override;
 
   virtual PBrowserParent*
   AllocPBrowserParent(const TabId& aTabId,
                       const IPCTabContext &aContext,
                       const uint32_t& aChromeFlags,
                       const ContentParentId& aCpID,
                       const bool& aIsForApp,
                       const bool& aIsForBrowser) override;
+
   virtual bool DeallocPBrowserParent(PBrowserParent*) override;
 
   virtual PBlobParent*
   AllocPBlobParent(const BlobConstructorParams& aParams) override;
 
   virtual bool DeallocPBlobParent(PBlobParent*) override;
 
   DISALLOW_EVIL_CONSTRUCTORS(ContentBridgeParent);
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -230,384 +230,381 @@ using namespace mozilla::widget;
 
 namespace mozilla {
 namespace dom {
 
 class MemoryReportRequestChild : public PMemoryReportRequestChild,
                                  public nsIRunnable
 {
 public:
-    NS_DECL_ISUPPORTS
-
-    MemoryReportRequestChild(bool aAnonymize,
-                             const MaybeFileDesc& aDMDFile);
-    NS_IMETHOD Run() override;
+  NS_DECL_ISUPPORTS
+
+  MemoryReportRequestChild(bool aAnonymize,
+                           const MaybeFileDesc& aDMDFile);
+  NS_IMETHOD Run() override;
+
 private:
-    virtual ~MemoryReportRequestChild();
-
-    bool     mAnonymize;
-    FileDescriptor mDMDFile;
+  virtual ~MemoryReportRequestChild();
+
+  bool     mAnonymize;
+  FileDescriptor mDMDFile;
 };
 
 NS_IMPL_ISUPPORTS(MemoryReportRequestChild, nsIRunnable)
 
 MemoryReportRequestChild::MemoryReportRequestChild(
-    bool aAnonymize, const MaybeFileDesc& aDMDFile)
-  : mAnonymize(aAnonymize)
+  bool aAnonymize, const MaybeFileDesc& aDMDFile)
+: mAnonymize(aAnonymize)
 {
-    MOZ_COUNT_CTOR(MemoryReportRequestChild);
-    if (aDMDFile.type() == MaybeFileDesc::TFileDescriptor) {
-        mDMDFile = aDMDFile.get_FileDescriptor();
-    }
+  MOZ_COUNT_CTOR(MemoryReportRequestChild);
+  if (aDMDFile.type() == MaybeFileDesc::TFileDescriptor) {
+    mDMDFile = aDMDFile.get_FileDescriptor();
+  }
 }
 
 MemoryReportRequestChild::~MemoryReportRequestChild()
 {
-    MOZ_COUNT_DTOR(MemoryReportRequestChild);
+  MOZ_COUNT_DTOR(MemoryReportRequestChild);
 }
 
 // IPC sender for remote GC/CC logging.
 class CycleCollectWithLogsChild final
-    : public PCycleCollectWithLogsChild
-    , public nsICycleCollectorLogSink
+  : public PCycleCollectWithLogsChild
+  , public nsICycleCollectorLogSink
 {
 public:
-    NS_DECL_ISUPPORTS
-
-    CycleCollectWithLogsChild(const FileDescriptor& aGCLog,
-                              const FileDescriptor& aCCLog)
-    {
-        mGCLog = FileDescriptorToFILE(aGCLog, "w");
-        mCCLog = FileDescriptorToFILE(aCCLog, "w");
-    }
-
-    NS_IMETHOD Open(FILE** aGCLog, FILE** aCCLog) override
-    {
-        if (NS_WARN_IF(!mGCLog) || NS_WARN_IF(!mCCLog)) {
-            return NS_ERROR_FAILURE;
-        }
-        *aGCLog = mGCLog;
-        *aCCLog = mCCLog;
-        return NS_OK;
-    }
-
-    NS_IMETHOD CloseGCLog() override
-    {
-        MOZ_ASSERT(mGCLog);
-        fclose(mGCLog);
-        mGCLog = nullptr;
-        SendCloseGCLog();
-        return NS_OK;
+  NS_DECL_ISUPPORTS
+
+  CycleCollectWithLogsChild(const FileDescriptor& aGCLog,
+                            const FileDescriptor& aCCLog)
+  {
+    mGCLog = FileDescriptorToFILE(aGCLog, "w");
+    mCCLog = FileDescriptorToFILE(aCCLog, "w");
+  }
+
+  NS_IMETHOD Open(FILE** aGCLog, FILE** aCCLog) override
+  {
+    if (NS_WARN_IF(!mGCLog) || NS_WARN_IF(!mCCLog)) {
+      return NS_ERROR_FAILURE;
     }
-
-    NS_IMETHOD CloseCCLog() override
-    {
-        MOZ_ASSERT(mCCLog);
-        fclose(mCCLog);
-        mCCLog = nullptr;
-        SendCloseCCLog();
-        return NS_OK;
-    }
-
-    NS_IMETHOD GetFilenameIdentifier(nsAString& aIdentifier) override
-    {
-        return UnimplementedProperty();
-    }
-
-    NS_IMETHOD SetFilenameIdentifier(const nsAString& aIdentifier) override
-    {
-        return UnimplementedProperty();
-    }
-
-    NS_IMETHOD GetProcessIdentifier(int32_t *aIdentifier) override
-    {
-        return UnimplementedProperty();
-    }
-
-    NS_IMETHOD SetProcessIdentifier(int32_t aIdentifier) override
-    {
-        return UnimplementedProperty();
-    }
-
-    NS_IMETHOD GetGcLog(nsIFile** aPath) override
-    {
-        return UnimplementedProperty();
-    }
-
-    NS_IMETHOD GetCcLog(nsIFile** aPath) override
-    {
-        return UnimplementedProperty();
-    }
+    *aGCLog = mGCLog;
+    *aCCLog = mCCLog;
+    return NS_OK;
+  }
+
+  NS_IMETHOD CloseGCLog() override
+  {
+    MOZ_ASSERT(mGCLog);
+    fclose(mGCLog);
+    mGCLog = nullptr;
+    SendCloseGCLog();
+    return NS_OK;
+  }
+
+  NS_IMETHOD CloseCCLog() override
+  {
+    MOZ_ASSERT(mCCLog);
+    fclose(mCCLog);
+    mCCLog = nullptr;
+    SendCloseCCLog();
+    return NS_OK;
+  }
+
+  NS_IMETHOD GetFilenameIdentifier(nsAString& aIdentifier) override
+  {
+    return UnimplementedProperty();
+  }
+
+  NS_IMETHOD SetFilenameIdentifier(const nsAString& aIdentifier) override
+  {
+    return UnimplementedProperty();
+  }
+
+  NS_IMETHOD GetProcessIdentifier(int32_t *aIdentifier) override
+  {
+    return UnimplementedProperty();
+  }
+
+  NS_IMETHOD SetProcessIdentifier(int32_t aIdentifier) override
+  {
+    return UnimplementedProperty();
+  }
+
+  NS_IMETHOD GetGcLog(nsIFile** aPath) override
+  {
+    return UnimplementedProperty();
+  }
+
+  NS_IMETHOD GetCcLog(nsIFile** aPath) override
+  {
+    return UnimplementedProperty();
+  }
 
 private:
-    ~CycleCollectWithLogsChild()
-    {
-        if (mGCLog) {
-            fclose(mGCLog);
-            mGCLog = nullptr;
-        }
-        if (mCCLog) {
-            fclose(mCCLog);
-            mCCLog = nullptr;
-        }
-        // The XPCOM refcount drives the IPC lifecycle; see also
-        // DeallocPCycleCollectWithLogsChild.
-        Unused << Send__delete__(this);
+  ~CycleCollectWithLogsChild()
+  {
+    if (mGCLog) {
+      fclose(mGCLog);
+      mGCLog = nullptr;
+    }
+    if (mCCLog) {
+      fclose(mCCLog);
+      mCCLog = nullptr;
     }
-
-    nsresult UnimplementedProperty()
-    {
-        MOZ_ASSERT(false, "This object is a remote GC/CC logger;"
-                   " this property isn't meaningful.");
-        return NS_ERROR_UNEXPECTED;
-    }
-
-    FILE* mGCLog;
-    FILE* mCCLog;
+    // The XPCOM refcount drives the IPC lifecycle; see also
+    // DeallocPCycleCollectWithLogsChild.
+    Unused << Send__delete__(this);
+  }
+
+  nsresult UnimplementedProperty()
+  {
+    MOZ_ASSERT(false, "This object is a remote GC/CC logger;"
+                      " this property isn't meaningful.");
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  FILE* mGCLog;
+  FILE* mCCLog;
 };
 
 NS_IMPL_ISUPPORTS(CycleCollectWithLogsChild, nsICycleCollectorLogSink);
 
 class AlertObserver
 {
 public:
 
-    AlertObserver(nsIObserver *aObserver, const nsString& aData)
-        : mObserver(aObserver)
-        , mData(aData)
-    {
-    }
-
-    ~AlertObserver() {}
-
-    bool ShouldRemoveFrom(nsIObserver* aObserver,
-                          const nsString& aData) const
-    {
-        return (mObserver == aObserver &&
-                mData == aData);
-    }
-
-    bool Observes(const nsString& aData) const
-    {
-        return mData.Equals(aData);
-    }
-
-    bool Notify(const nsCString& aType) const
-    {
-        mObserver->Observe(nullptr, aType.get(), mData.get());
-        return true;
-    }
+  AlertObserver(nsIObserver *aObserver, const nsString& aData)
+    : mObserver(aObserver)
+    , mData(aData)
+  {
+  }
+
+  ~AlertObserver() {}
+
+  bool ShouldRemoveFrom(nsIObserver* aObserver,
+                        const nsString& aData) const
+  {
+    return (mObserver == aObserver && mData == aData);
+  }
+
+  bool Observes(const nsString& aData) const
+  {
+    return mData.Equals(aData);
+  }
+
+  bool Notify(const nsCString& aType) const
+  {
+    mObserver->Observe(nullptr, aType.get(), mData.get());
+    return true;
+  }
 
 private:
-    nsCOMPtr<nsIObserver> mObserver;
-    nsString mData;
+  nsCOMPtr<nsIObserver> mObserver;
+  nsString mData;
 };
 
 class ConsoleListener final : public nsIConsoleListener
 {
 public:
-    explicit ConsoleListener(ContentChild* aChild)
-    : mChild(aChild) {}
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSICONSOLELISTENER
+  explicit ConsoleListener(ContentChild* aChild)
+  : mChild(aChild) {}
+
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSICONSOLELISTENER
 
 private:
-    ~ConsoleListener() {}
-
-    ContentChild* mChild;
-    friend class ContentChild;
+  ~ConsoleListener() {}
+
+  ContentChild* mChild;
+  friend class ContentChild;
 };
 
 NS_IMPL_ISUPPORTS(ConsoleListener, nsIConsoleListener)
 
 NS_IMETHODIMP
 ConsoleListener::Observe(nsIConsoleMessage* aMessage)
 {
-    if (!mChild)
-        return NS_OK;
-
-    nsCOMPtr<nsIScriptError> scriptError = do_QueryInterface(aMessage);
-    if (scriptError) {
-        nsString msg, sourceName, sourceLine;
-        nsXPIDLCString category;
-        uint32_t lineNum, colNum, flags;
-
-        nsresult rv = scriptError->GetErrorMessage(msg);
-        NS_ENSURE_SUCCESS(rv, rv);
-        rv = scriptError->GetSourceName(sourceName);
-        NS_ENSURE_SUCCESS(rv, rv);
-        rv = scriptError->GetSourceLine(sourceLine);
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        // Before we send the error to the parent process (which
-        // involves copying the memory), truncate any long lines.  CSS
-        // errors in particular share the memory for long lines with
-        // repeated errors, but the IPC communication we're about to do
-        // will break that sharing, so we better truncate now.
-        if (sourceName.Length() > 1000) {
-            sourceName.Truncate(1000);
-        }
-        if (sourceLine.Length() > 1000) {
-            sourceLine.Truncate(1000);
-        }
-
-        rv = scriptError->GetCategory(getter_Copies(category));
-        NS_ENSURE_SUCCESS(rv, rv);
-        rv = scriptError->GetLineNumber(&lineNum);
-        NS_ENSURE_SUCCESS(rv, rv);
-        rv = scriptError->GetColumnNumber(&colNum);
-        NS_ENSURE_SUCCESS(rv, rv);
-        rv = scriptError->GetFlags(&flags);
-        NS_ENSURE_SUCCESS(rv, rv);
-        mChild->SendScriptError(msg, sourceName, sourceLine,
-                               lineNum, colNum, flags, category);
-        return NS_OK;
+  if (!mChild) {
+    return NS_OK;
+  }
+
+  nsCOMPtr<nsIScriptError> scriptError = do_QueryInterface(aMessage);
+  if (scriptError) {
+    nsString msg, sourceName, sourceLine;
+    nsXPIDLCString category;
+    uint32_t lineNum, colNum, flags;
+
+    nsresult rv = scriptError->GetErrorMessage(msg);
+    NS_ENSURE_SUCCESS(rv, rv);
+    rv = scriptError->GetSourceName(sourceName);
+    NS_ENSURE_SUCCESS(rv, rv);
+    rv = scriptError->GetSourceLine(sourceLine);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    // Before we send the error to the parent process (which
+    // involves copying the memory), truncate any long lines.  CSS
+    // errors in particular share the memory for long lines with
+    // repeated errors, but the IPC communication we're about to do
+    // will break that sharing, so we better truncate now.
+    if (sourceName.Length() > 1000) {
+      sourceName.Truncate(1000);
     }
-
-    nsXPIDLString msg;
-    nsresult rv = aMessage->GetMessageMoz(getter_Copies(msg));
+    if (sourceLine.Length() > 1000) {
+      sourceLine.Truncate(1000);
+    }
+
+    rv = scriptError->GetCategory(getter_Copies(category));
+    NS_ENSURE_SUCCESS(rv, rv);
+    rv = scriptError->GetLineNumber(&lineNum);
+    NS_ENSURE_SUCCESS(rv, rv);
+    rv = scriptError->GetColumnNumber(&colNum);
     NS_ENSURE_SUCCESS(rv, rv);
-    mChild->SendConsoleMessage(msg);
+    rv = scriptError->GetFlags(&flags);
+    NS_ENSURE_SUCCESS(rv, rv);
+    mChild->SendScriptError(msg, sourceName, sourceLine,
+                            lineNum, colNum, flags, category);
     return NS_OK;
+  }
+
+  nsXPIDLString msg;
+  nsresult rv = aMessage->GetMessageMoz(getter_Copies(msg));
+  NS_ENSURE_SUCCESS(rv, rv);
+  mChild->SendConsoleMessage(msg);
+  return NS_OK;
 }
 
 class SystemMessageHandledObserver final : public nsIObserver
 {
-    ~SystemMessageHandledObserver() {}
+  ~SystemMessageHandledObserver() {}
 
 public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIOBSERVER
-
-    void Init();
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIOBSERVER
+
+  void Init();
 };
 
 void SystemMessageHandledObserver::Init()
 {
-    nsCOMPtr<nsIObserverService> os =
-        mozilla::services::GetObserverService();
-
-    if (os) {
-        os->AddObserver(this, "handle-system-messages-done",
-                        /* ownsWeak */ false);
-    }
+  nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
+
+  if (os) {
+    os->AddObserver(this, "handle-system-messages-done", /* ownsWeak */ false);
+  }
 }
 
 NS_IMETHODIMP
 SystemMessageHandledObserver::Observe(nsISupports* aSubject,
                                       const char* aTopic,
                                       const char16_t* aData)
 {
-    if (ContentChild::GetSingleton()) {
-        ContentChild::GetSingleton()->SendSystemMessageHandled();
-    }
-    return NS_OK;
+  if (ContentChild::GetSingleton()) {
+    ContentChild::GetSingleton()->SendSystemMessageHandled();
+  }
+  return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS(SystemMessageHandledObserver, nsIObserver)
 
 class BackgroundChildPrimer final :
   public nsIIPCBackgroundChildCreateCallback
 {
 public:
-    BackgroundChildPrimer()
-    { }
-
-    NS_DECL_ISUPPORTS
+  BackgroundChildPrimer()
+  { }
+
+  NS_DECL_ISUPPORTS
 
 private:
-    ~BackgroundChildPrimer()
-    { }
-
-    virtual void
-    ActorCreated(PBackgroundChild* aActor) override
-    {
-        MOZ_ASSERT(aActor, "Failed to create a PBackgroundChild actor!");
-    }
-
-    virtual void
-    ActorFailed() override
-    {
-        MOZ_CRASH("Failed to create a PBackgroundChild actor!");
-    }
+  ~BackgroundChildPrimer()
+  { }
+
+  virtual void
+  ActorCreated(PBackgroundChild* aActor) override
+  {
+    MOZ_ASSERT(aActor, "Failed to create a PBackgroundChild actor!");
+  }
+
+  virtual void
+  ActorFailed() override
+  {
+    MOZ_CRASH("Failed to create a PBackgroundChild actor!");
+  }
 };
 
 NS_IMPL_ISUPPORTS(BackgroundChildPrimer, nsIIPCBackgroundChildCreateCallback)
 
 ContentChild* ContentChild::sSingleton;
 
 // Performs initialization that is not fork-safe, i.e. that must be done after
 // forking from the Nuwa process.
 void
 InitOnContentProcessCreated()
 {
 #ifdef MOZ_NUWA_PROCESS
-    // Wait until we are forked from Nuwa
-    if (IsNuwaProcess()) {
-        return;
-    }
-
-    nsCOMPtr<nsIPermissionManager> permManager =
-        services::GetPermissionManager();
-    MOZ_ASSERT(permManager, "Unable to get permission manager");
-    nsresult rv = permManager->RefreshPermission();
-    if (NS_FAILED(rv)) {
-        MOZ_ASSERT(false, "Failed updating permission in child process");
-    }
+  // Wait until we are forked from Nuwa
+  if (IsNuwaProcess()) {
+    return;
+  }
+
+  nsCOMPtr<nsIPermissionManager> permManager = services::GetPermissionManager();
+  MOZ_ASSERT(permManager, "Unable to get permission manager");
+  nsresult rv = permManager->RefreshPermission();
+  if (NS_FAILED(rv)) {
+    MOZ_ASSERT(false, "Failed updating permission in child process");
+  }
 #endif
 
-    nsCOMPtr<nsISystemMessageCache> smc =
-        do_GetService("@mozilla.org/system-message-cache;1");
-    NS_WARN_IF(!smc);
-
-    // This will register cross-process observer.
-    mozilla::dom::time::InitializeDateCacheCleaner();
+  nsCOMPtr<nsISystemMessageCache> smc =
+    do_GetService("@mozilla.org/system-message-cache;1");
+  NS_WARN_IF(!smc);
+
+  // This will register cross-process observer.
+  mozilla::dom::time::InitializeDateCacheCleaner();
 }
 
 #ifdef MOZ_NUWA_PROCESS
 static void
 ResetTransports(void* aUnused)
 {
   ContentChild* child = ContentChild::GetSingleton();
   mozilla::ipc::Transport* transport = child->GetTransport();
   int fd = transport->GetFileDescriptor();
   transport->ResetFileDescriptor(fd);
 
   nsTArray<IToplevelProtocol*> actors;
   child->GetOpenedActors(actors);
   for (size_t i = 0; i < actors.Length(); i++) {
-      IToplevelProtocol* toplevel = actors[i];
-      transport = toplevel->GetTransport();
-      fd = transport->GetFileDescriptor();
-      transport->ResetFileDescriptor(fd);
+    IToplevelProtocol* toplevel = actors[i];
+    transport = toplevel->GetTransport();
+    fd = transport->GetFileDescriptor();
+    transport->ResetFileDescriptor(fd);
   }
 }
 #endif
 
 #if defined(MOZ_TASK_TRACER) && defined(MOZ_NUWA_PROCESS)
 static void
 ReinitTaskTracer(void* /*aUnused*/)
 {
-    mozilla::tasktracer::InitTaskTracer(
-        mozilla::tasktracer::FORKED_AFTER_NUWA);
+  mozilla::tasktracer::InitTaskTracer(mozilla::tasktracer::FORKED_AFTER_NUWA);
 }
 #endif
 
 ContentChild::ContentChild()
  : mID(uint64_t(-1))
 #ifdef ANDROID
-   ,mScreenSize(0, 0)
+ , mScreenSize(0, 0)
 #endif
-   , mCanOverrideProcessName(true)
-   , mIsAlive(true)
+ , mCanOverrideProcessName(true)
+ , mIsAlive(true)
 {
-    // This process is a content process, so it's clearly running in
-    // multiprocess mode!
-    nsDebugImpl::SetMultiprocessMode("Child");
+  // This process is a content process, so it's clearly running in
+  // multiprocess mode!
+  nsDebugImpl::SetMultiprocessMode("Child");
 }
 
 ContentChild::~ContentChild()
 {
 }
 
 NS_INTERFACE_MAP_BEGIN(ContentChild)
   NS_INTERFACE_MAP_ENTRY(nsIContentChild)
@@ -616,541 +613,545 @@ NS_INTERFACE_MAP_BEGIN(ContentChild)
 NS_INTERFACE_MAP_END
 
 bool
 ContentChild::Init(MessageLoop* aIOLoop,
                    base::ProcessId aParentPid,
                    IPC::Channel* aChannel)
 {
 #ifdef MOZ_WIDGET_GTK
-    gtk_init(nullptr, nullptr);
+  gtk_init(nullptr, nullptr);
 #endif
 
 #ifdef MOZ_WIDGET_QT
-    // sigh, seriously
-    nsQAppInstance::AddRef();
+  // sigh, seriously
+  nsQAppInstance::AddRef();
 #endif
 
 #ifdef MOZ_X11
-    // Do this after initializing GDK, or GDK will install its own handler.
-    XRE_InstallX11ErrorHandler();
+  // Do this after initializing GDK, or GDK will install its own handler.
+  XRE_InstallX11ErrorHandler();
 #endif
 
 #ifdef MOZ_NUWA_PROCESS
-    SetTransport(aChannel);
+  SetTransport(aChannel);
 #endif
 
-    NS_ASSERTION(!sSingleton, "only one ContentChild per child");
-
-    // Once we start sending IPC messages, we need the thread manager to be
-    // initialized so we can deal with the responses. Do that here before we
-    // try to construct the crash reporter.
-    nsresult rv = nsThreadManager::get()->Init();
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-        return false;
-    }
-
-    if (!Open(aChannel, aParentPid, aIOLoop)) {
-      return false;
-    }
-    sSingleton = this;
-
-    // Make sure there's an nsAutoScriptBlocker on the stack when dispatching
-    // urgent messages.
-    GetIPCChannel()->BlockScripts();
-
-    // If communications with the parent have broken down, take the process
-    // down so it's not hanging around.
-    bool abortOnError = true;
+  NS_ASSERTION(!sSingleton, "only one ContentChild per child");
+
+  // Once we start sending IPC messages, we need the thread manager to be
+  // initialized so we can deal with the responses. Do that here before we
+  // try to construct the crash reporter.
+  nsresult rv = nsThreadManager::get()->Init();
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return false;
+  }
+
+  if (!Open(aChannel, aParentPid, aIOLoop)) {
+    return false;
+  }
+  sSingleton = this;
+
+  // Make sure there's an nsAutoScriptBlocker on the stack when dispatching
+  // urgent messages.
+  GetIPCChannel()->BlockScripts();
+
+  // If communications with the parent have broken down, take the process
+  // down so it's not hanging around.
+  bool abortOnError = true;
 #ifdef MOZ_NUWA_PROCESS
-    abortOnError &= !IsNuwaProcess();
+  abortOnError &= !IsNuwaProcess();
 #endif
-    GetIPCChannel()->SetAbortOnError(abortOnError);
+  GetIPCChannel()->SetAbortOnError(abortOnError);
 
 #ifdef MOZ_X11
-    // Send the parent our X socket to act as a proxy reference for our X
-    // resources.
-    int xSocketFd = ConnectionNumber(DefaultXDisplay());
-    SendBackUpXResources(FileDescriptor(xSocketFd));
+  // Send the parent our X socket to act as a proxy reference for our X
+  // resources.
+  int xSocketFd = ConnectionNumber(DefaultXDisplay());
+  SendBackUpXResources(FileDescriptor(xSocketFd));
 #endif
 
 #ifdef MOZ_CRASHREPORTER
-    SendPCrashReporterConstructor(CrashReporter::CurrentThreadId(),
-                                  XRE_GetProcessType());
+  SendPCrashReporterConstructor(CrashReporter::CurrentThreadId(),
+                                XRE_GetProcessType());
 #endif
 
-    SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
-    InitProcessAttributes();
+  SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
+  InitProcessAttributes();
 
 #if defined(MOZ_TASK_TRACER) && defined (MOZ_NUWA_PROCESS)
-    if (IsNuwaProcess()) {
-        NuwaAddConstructor(ReinitTaskTracer, nullptr);
-    }
+  if (IsNuwaProcess()) {
+    NuwaAddConstructor(ReinitTaskTracer, nullptr);
+  }
 #endif
 
 #ifdef MOZ_NUWA_PROCESS
-    if (IsNuwaProcess()) {
-      NuwaAddConstructor(ResetTransports, nullptr);
-    }
+  if (IsNuwaProcess()) {
+    NuwaAddConstructor(ResetTransports, nullptr);
+  }
 #endif
 
-    return true;
+  return true;
 }
 
 void
 ContentChild::InitProcessAttributes()
 {
 #ifdef MOZ_WIDGET_GONK
 #ifdef MOZ_NUWA_PROCESS
-    if (IsNuwaProcess()) {
-        SetProcessName(NS_LITERAL_STRING("(Nuwa)"), false);
-        return;
-    }
+  if (IsNuwaProcess()) {
+    SetProcessName(NS_LITERAL_STRING("(Nuwa)"), false);
+    return;
+  }
 #endif
-    if (mIsForApp && !mIsForBrowser) {
-        SetProcessName(NS_LITERAL_STRING("(Preallocated app)"), false);
-    } else {
-        SetProcessName(NS_LITERAL_STRING("Browser"), false);
-    }
+  if (mIsForApp && !mIsForBrowser) {
+    SetProcessName(NS_LITERAL_STRING("(Preallocated app)"), false);
+  } else {
+    SetProcessName(NS_LITERAL_STRING("Browser"), false);
+  }
 #else
-    SetProcessName(NS_LITERAL_STRING("Web Content"), true);
+  SetProcessName(NS_LITERAL_STRING("Web Content"), true);
 #endif
 }
 
 void
 ContentChild::SetProcessName(const nsAString& aName, bool aDontOverride)
 {
-    if (!mCanOverrideProcessName) {
-        return;
-    }
-
-    char* name;
-    if ((name = PR_GetEnv("MOZ_DEBUG_APP_PROCESS")) &&
-        aName.EqualsASCII(name)) {
+  if (!mCanOverrideProcessName) {
+    return;
+  }
+
+  char* name;
+  if ((name = PR_GetEnv("MOZ_DEBUG_APP_PROCESS")) &&
+    aName.EqualsASCII(name)) {
 #ifdef OS_POSIX
-        printf_stderr("\n\nCHILDCHILDCHILDCHILD\n  [%s] debug me @%d\n\n", name, getpid());
-        sleep(30);
+    printf_stderr("\n\nCHILDCHILDCHILDCHILD\n  [%s] debug me @%d\n\n", name,
+                  getpid());
+    sleep(30);
 #elif defined(OS_WIN)
-        // Windows has a decent JIT debugging story, so NS_DebugBreak does the
-        // right thing.
-        NS_DebugBreak(NS_DEBUG_BREAK,
-                      "Invoking NS_DebugBreak() to debug child process",
-                      nullptr, __FILE__, __LINE__);
+    // Windows has a decent JIT debugging story, so NS_DebugBreak does the
+    // right thing.
+    NS_DebugBreak(NS_DEBUG_BREAK,
+                 "Invoking NS_DebugBreak() to debug child process",
+                 nullptr, __FILE__, __LINE__);
 #endif
-    }
-
-    mProcessName = aName;
-    mozilla::ipc::SetThisProcessName(NS_LossyConvertUTF16toASCII(aName).get());
-
-    if (aDontOverride) {
-        mCanOverrideProcessName = false;
-    }
+  }
+
+  mProcessName = aName;
+  mozilla::ipc::SetThisProcessName(NS_LossyConvertUTF16toASCII(aName).get());
+
+  if (aDontOverride) {
+    mCanOverrideProcessName = false;
+  }
 }
 
 NS_IMETHODIMP
 ContentChild::ProvideWindow(nsIDOMWindow* aParent,
                             uint32_t aChromeFlags,
                             bool aCalledFromJS,
                             bool aPositionSpecified,
                             bool aSizeSpecified,
                             nsIURI* aURI,
                             const nsAString& aName,
                             const nsACString& aFeatures,
                             bool* aWindowIsNew,
                             nsIDOMWindow** aReturn)
 {
-    return ProvideWindowCommon(nullptr, aParent, false, aChromeFlags,
-                               aCalledFromJS, aPositionSpecified,
-                               aSizeSpecified, aURI, aName, aFeatures,
-                               aWindowIsNew, aReturn);
+  return ProvideWindowCommon(nullptr, aParent, false, aChromeFlags,
+                             aCalledFromJS, aPositionSpecified,
+                             aSizeSpecified, aURI, aName, aFeatures,
+                             aWindowIsNew, aReturn);
 }
 
 nsresult
 ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
                                   nsIDOMWindow* aParent,
                                   bool aIframeMoz,
                                   uint32_t aChromeFlags,
                                   bool aCalledFromJS,
                                   bool aPositionSpecified,
                                   bool aSizeSpecified,
                                   nsIURI* aURI,
                                   const nsAString& aName,
                                   const nsACString& aFeatures,
                                   bool* aWindowIsNew,
                                   nsIDOMWindow** aReturn)
 {
-    *aReturn = nullptr;
-
-    nsAutoPtr<IPCTabContext> ipcContext;
-    TabId openerTabId = TabId(0);
-
+  *aReturn = nullptr;
+
+  nsAutoPtr<IPCTabContext> ipcContext;
+  TabId openerTabId = TabId(0);
+
+  if (aTabOpener) {
+    PopupIPCTabContext context;
+    openerTabId = aTabOpener->GetTabId();
+    context.opener() = openerTabId;
+    context.isBrowserElement() = aTabOpener->IsBrowserElement();
+    ipcContext = new IPCTabContext(context);
+  } else {
+    // It's possible to not have a TabChild opener in the case
+    // of ServiceWorker::OpenWindow.
+    UnsafeIPCTabContext unsafeTabContext;
+    ipcContext = new IPCTabContext(unsafeTabContext);
+  }
+
+  MOZ_ASSERT(ipcContext);
+  TabId tabId;
+  SendAllocateTabId(openerTabId,
+                    *ipcContext,
+                    GetID(),
+                    &tabId);
+
+  TabContext newTabContext = aTabOpener ? *aTabOpener : TabContext();
+  RefPtr<TabChild> newChild = new TabChild(this, tabId,
+                                           newTabContext, aChromeFlags);
+  if (NS_FAILED(newChild->Init())) {
+    return NS_ERROR_ABORT;
+  }
+
+  if (aTabOpener) {
+    MOZ_ASSERT(ipcContext->type() == IPCTabContext::TPopupIPCTabContext);
+    ipcContext->get_PopupIPCTabContext().opener() = aTabOpener;
+  }
+
+  Unused << SendPBrowserConstructor(
+    // We release this ref in DeallocPBrowserChild
+    RefPtr<TabChild>(newChild).forget().take(),
+    tabId, *ipcContext, aChromeFlags,
+    GetID(), IsForApp(), IsForBrowser());
+
+  nsAutoCString url;
+  if (aURI) {
+    aURI->GetSpec(url);
+  } else {
+    // We can't actually send a nullptr up as the URI, since IPDL doesn't let us
+    // send nullptr's for primitives. We indicate that the nsString for the URI
+    // should be converted to a nullptr by voiding the string.
+    url.SetIsVoid(true);
+  }
+
+  nsString name(aName);
+  nsAutoCString features(aFeatures);
+  nsTArray<FrameScriptInfo> frameScripts;
+  nsCString urlToLoad;
+
+  if (aIframeMoz) {
+    MOZ_ASSERT(aTabOpener);
+    newChild->SendBrowserFrameOpenWindow(aTabOpener, NS_ConvertUTF8toUTF16(url),
+                                         name, NS_ConvertUTF8toUTF16(features),
+                                         aWindowIsNew);
+  } else {
+    nsAutoCString baseURIString;
     if (aTabOpener) {
-        PopupIPCTabContext context;
-        openerTabId = aTabOpener->GetTabId();
-        context.opener() = openerTabId;
-        context.isBrowserElement() = aTabOpener->IsBrowserElement();
-        ipcContext = new IPCTabContext(context);
-    } else {
-        // It's possible to not have a TabChild opener in the case
-        // of ServiceWorker::OpenWindow.
-        UnsafeIPCTabContext unsafeTabContext;
-        ipcContext = new IPCTabContext(unsafeTabContext);
-    }
-
-    MOZ_ASSERT(ipcContext);
-    TabId tabId;
-    SendAllocateTabId(openerTabId,
-                      *ipcContext,
-                      GetID(),
-                      &tabId);
-
-    TabContext newTabContext = aTabOpener ? *aTabOpener : TabContext();
-    RefPtr<TabChild> newChild = new TabChild(this, tabId,
-                                             newTabContext, aChromeFlags);
-    if (NS_FAILED(newChild->Init())) {
-        return NS_ERROR_ABORT;
-    }
-
-    if (aTabOpener) {
-        MOZ_ASSERT(ipcContext->type() == IPCTabContext::TPopupIPCTabContext);
-        ipcContext->get_PopupIPCTabContext().opener() = aTabOpener;
-    }
-
-    Unused << SendPBrowserConstructor(
-        // We release this ref in DeallocPBrowserChild
-        RefPtr<TabChild>(newChild).forget().take(),
-        tabId, *ipcContext, aChromeFlags,
-        GetID(), IsForApp(), IsForBrowser());
-
-    nsAutoCString url;
-    if (aURI) {
-        aURI->GetSpec(url);
-    } else {
-        // We can't actually send a nullptr up as the URI, since IPDL doesn't let us
-        // send nullptr's for primitives. We indicate that the nsString for the URI
-        // should be converted to a nullptr by voiding the string.
-        url.SetIsVoid(true);
+      nsCOMPtr<nsPIDOMWindow> opener = do_QueryInterface(aParent);
+      nsCOMPtr<nsIDocument> doc = opener->GetDoc();
+      nsCOMPtr<nsIURI> baseURI = doc->GetDocBaseURI();
+      if (!baseURI) {
+        NS_ERROR("nsIDocument didn't return a base URI");
+        return NS_ERROR_FAILURE;
+      }
+
+      baseURI->GetSpec(baseURIString);
     }
 
-    nsString name(aName);
-    nsAutoCString features(aFeatures);
-    nsTArray<FrameScriptInfo> frameScripts;
-    nsCString urlToLoad;
-
-    if (aIframeMoz) {
-        MOZ_ASSERT(aTabOpener);
-        newChild->SendBrowserFrameOpenWindow(aTabOpener, NS_ConvertUTF8toUTF16(url), name,
-                                             NS_ConvertUTF8toUTF16(features),
-                                             aWindowIsNew);
-    } else {
-        nsAutoCString baseURIString;
-        if (aTabOpener) {
-            nsCOMPtr<nsPIDOMWindow> opener = do_QueryInterface(aParent);
-            nsCOMPtr<nsIDocument> doc = opener->GetDoc();
-            nsCOMPtr<nsIURI> baseURI = doc->GetDocBaseURI();
-            if (!baseURI) {
-                NS_ERROR("nsIDocument didn't return a base URI");
-                return NS_ERROR_FAILURE;
-            }
-
-            baseURI->GetSpec(baseURIString);
-        }
-
-        nsresult rv;
-        if (!SendCreateWindow(aTabOpener, newChild,
-                              aChromeFlags, aCalledFromJS, aPositionSpecified,
-                              aSizeSpecified, url,
-                              name, features,
-                              baseURIString,
-                              &rv,
-                              aWindowIsNew,
-                              &frameScripts,
-                              &urlToLoad)) {
-            return NS_ERROR_NOT_AVAILABLE;
-        }
-
-        if (NS_FAILED(rv)) {
-            return rv;
-        }
+    nsresult rv;
+    if (!SendCreateWindow(aTabOpener, newChild,
+                          aChromeFlags, aCalledFromJS, aPositionSpecified,
+                          aSizeSpecified, url,
+                          name, features,
+                          baseURIString,
+                          &rv,
+                          aWindowIsNew,
+                          &frameScripts,
+                          &urlToLoad)) {
+      return NS_ERROR_NOT_AVAILABLE;
+    }
+
+    if (NS_FAILED(rv)) {
+      return rv;
     }
-    if (!*aWindowIsNew) {
-        PBrowserChild::Send__delete__(newChild);
-        return NS_ERROR_ABORT;
-    }
-
-    TextureFactoryIdentifier textureFactoryIdentifier;
-    uint64_t layersId = 0;
-    PRenderFrameChild* renderFrame = newChild->SendPRenderFrameConstructor();
-    newChild->SendGetRenderFrameInfo(renderFrame,
-                                     &textureFactoryIdentifier,
-                                     &layersId);
-    if (layersId == 0) { // if renderFrame is invalid.
-        PRenderFrameChild::Send__delete__(renderFrame);
-        renderFrame = nullptr;
-    }
+  }
+  if (!*aWindowIsNew) {
+    PBrowserChild::Send__delete__(newChild);
+    return NS_ERROR_ABORT;
+  }
+
+  TextureFactoryIdentifier textureFactoryIdentifier;
+  uint64_t layersId = 0;
+  PRenderFrameChild* renderFrame = newChild->SendPRenderFrameConstructor();
+  newChild->SendGetRenderFrameInfo(renderFrame,
+                                   &textureFactoryIdentifier,
+                                   &layersId);
+  if (layersId == 0) { // if renderFrame is invalid.
+    PRenderFrameChild::Send__delete__(renderFrame);
+    renderFrame = nullptr;
+  }
 
   ShowInfo showInfo(EmptyString(), false, false, true, 0, 0);
   nsCOMPtr<nsPIDOMWindow> opener = do_QueryInterface(aParent);
   nsIDocShell* openerShell;
   if (opener && (openerShell = opener->GetDocShell())) {
     nsCOMPtr<nsILoadContext> context = do_QueryInterface(openerShell);
     showInfo = ShowInfo(EmptyString(), false,
                         context->UsePrivateBrowsing(), true,
                         aTabOpener->mDPI, aTabOpener->mDefaultScale);
   }
 
-    // Unfortunately we don't get a window unless we've shown the frame.  That's
-    // pretty bogus; see bug 763602.
-    newChild->DoFakeShow(textureFactoryIdentifier, layersId, renderFrame,
-                         showInfo);
-
-    for (size_t i = 0; i < frameScripts.Length(); i++) {
-        FrameScriptInfo& info = frameScripts[i];
-        if (!newChild->RecvLoadRemoteScript(info.url(), info.runInGlobalScope())) {
-            MOZ_CRASH();
-        }
+  // Unfortunately we don't get a window unless we've shown the frame.  That's
+  // pretty bogus; see bug 763602.
+  newChild->DoFakeShow(textureFactoryIdentifier, layersId, renderFrame,
+                       showInfo);
+
+  for (size_t i = 0; i < frameScripts.Length(); i++) {
+    FrameScriptInfo& info = frameScripts[i];
+    if (!newChild->RecvLoadRemoteScript(info.url(), info.runInGlobalScope())) {
+      MOZ_CRASH();
     }
-
-    if (!urlToLoad.IsEmpty()) {
-        newChild->RecvLoadURL(urlToLoad, BrowserConfiguration(), showInfo);
-    }
-
-    nsCOMPtr<nsIDOMWindow> win = do_GetInterface(newChild->WebNavigation());
-    win.forget(aReturn);
-    return NS_OK;
+  }
+
+  if (!urlToLoad.IsEmpty()) {
+    newChild->RecvLoadURL(urlToLoad, BrowserConfiguration(), showInfo);
+  }
+
+  nsCOMPtr<nsIDOMWindow> win = do_GetInterface(newChild->WebNavigation());
+  win.forget(aReturn);
+  return NS_OK;
 }
 
 void
-ContentChild::GetProcessName(nsAString& aName)
+ContentChild::GetProcessName(nsAString& aName) const
 {
-    aName.Assign(mProcessName);
+  aName.Assign(mProcessName);
 }
 
 bool
-ContentChild::IsAlive()
+ContentChild::IsAlive() const
 {
-    return mIsAlive;
+  return mIsAlive;
 }
 
 void
-ContentChild::GetProcessName(nsACString& aName)
+ContentChild::GetProcessName(nsACString& aName) const
 {
-    aName.Assign(NS_ConvertUTF16toUTF8(mProcessName));
+  aName.Assign(NS_ConvertUTF16toUTF8(mProcessName));
 }
 
 /* static */ void
 ContentChild::AppendProcessId(nsACString& aName)
 {
-    if (!aName.IsEmpty()) {
-        aName.Append(' ');
-    }
-    unsigned pid = getpid();
-    aName.Append(nsPrintfCString("(pid %u)", pid));
+  if (!aName.IsEmpty()) {
+    aName.Append(' ');
+  }
+  unsigned pid = getpid();
+  aName.Append(nsPrintfCString("(pid %u)", pid));
 }
 
 void
 ContentChild::InitGraphicsDeviceData()
 {
-    // Initialize the graphics platform. This may contact the parent process
-    // to read device preferences.
-    gfxPlatform::GetPlatform();
+  // Initialize the graphics platform. This may contact the parent process
+  // to read device preferences.
+  gfxPlatform::GetPlatform();
 }
 
 void
 ContentChild::InitXPCOM()
 {
-    // Do this as early as possible to get the parent process to initialize the
-    // background thread since we'll likely need database information very soon.
-    BackgroundChild::Startup();
-
-    nsCOMPtr<nsIIPCBackgroundChildCreateCallback> callback =
-        new BackgroundChildPrimer();
-    if (!BackgroundChild::GetOrCreateForCurrentThread(callback)) {
-        MOZ_CRASH("Failed to create PBackgroundChild!");
-    }
-
-    BlobChild::Startup(BlobChild::FriendKey());
-
-    nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
-    if (!svc) {
-        NS_WARNING("Couldn't acquire console service");
-        return;
+  // Do this as early as possible to get the parent process to initialize the
+  // background thread since we'll likely need database information very soon.
+  BackgroundChild::Startup();
+
+  nsCOMPtr<nsIIPCBackgroundChildCreateCallback> callback =
+    new BackgroundChildPrimer();
+  if (!BackgroundChild::GetOrCreateForCurrentThread(callback)) {
+    MOZ_CRASH("Failed to create PBackgroundChild!");
+  }
+
+  BlobChild::Startup(BlobChild::FriendKey());
+
+  nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
+  if (!svc) {
+    NS_WARNING("Couldn't acquire console service");
+    return;
+  }
+
+  mConsoleListener = new ConsoleListener(this);
+  if (NS_FAILED(svc->RegisterListener(mConsoleListener)))
+    NS_WARNING("Couldn't register console listener for child process");
+
+  bool isOffline, isLangRTL;
+  bool isConnected;
+  ClipboardCapabilities clipboardCaps;
+  DomainPolicyClone domainPolicy;
+  StructuredCloneData initialData;
+
+  SendGetXPCOMProcessAttributes(&isOffline, &isConnected,
+                                &isLangRTL, &mAvailableDictionaries,
+                                &clipboardCaps, &domainPolicy, &initialData);
+  RecvSetOffline(isOffline);
+  RecvSetConnectivity(isConnected);
+  RecvBidiKeyboardNotify(isLangRTL);
+
+  // Create the CPOW manager as soon as possible.
+  SendPJavaScriptConstructor();
+
+  if (domainPolicy.active()) {
+    nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
+    MOZ_ASSERT(ssm);
+    ssm->ActivateDomainPolicyInternal(getter_AddRefs(mPolicy));
+    if (!mPolicy) {
+      MOZ_CRASH("Failed to activate domain policy.");
     }
-
-    mConsoleListener = new ConsoleListener(this);
-    if (NS_FAILED(svc->RegisterListener(mConsoleListener)))
-        NS_WARNING("Couldn't register console listener for child process");
-
-    bool isOffline, isLangRTL;
-    bool isConnected;
-    ClipboardCapabilities clipboardCaps;
-    DomainPolicyClone domainPolicy;
-    StructuredCloneData initialData;
-
-    SendGetXPCOMProcessAttributes(&isOffline, &isConnected,
-                                  &isLangRTL, &mAvailableDictionaries,
-                                  &clipboardCaps, &domainPolicy, &initialData);
-    RecvSetOffline(isOffline);
-    RecvSetConnectivity(isConnected);
-    RecvBidiKeyboardNotify(isLangRTL);
-
-    // Create the CPOW manager as soon as possible.
-    SendPJavaScriptConstructor();
-
-    if (domainPolicy.active()) {
-        nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
-        MOZ_ASSERT(ssm);
-        ssm->ActivateDomainPolicyInternal(getter_AddRefs(mPolicy));
-        if (!mPolicy) {
-            MOZ_CRASH("Failed to activate domain policy.");
-        }
-        mPolicy->ApplyClone(&domainPolicy);
+    mPolicy->ApplyClone(&domainPolicy);
+  }
+
+  nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1"));
+  if (nsCOMPtr<nsIClipboardProxy> clipboardProxy = do_QueryInterface(clipboard)) {
+    clipboardProxy->SetCapabilities(clipboardCaps);
+  }
+
+  {
+    AutoJSAPI jsapi;
+    if (NS_WARN_IF(!jsapi.Init(xpc::PrivilegedJunkScope()))) {
+      MOZ_CRASH();
     }
-
-    nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1"));
-    if (nsCOMPtr<nsIClipboardProxy> clipboardProxy = do_QueryInterface(clipboard)) {
-        clipboardProxy->SetCapabilities(clipboardCaps);
+    ErrorResult rv;
+    JS::RootedValue data(jsapi.cx());
+    initialData.Read(jsapi.cx(), &data, rv);
+    if (NS_WARN_IF(rv.Failed())) {
+      MOZ_CRASH();
     }
-
-    {
-        AutoJSAPI jsapi;
-        if (NS_WARN_IF(!jsapi.Init(xpc::PrivilegedJunkScope()))) {
-            MOZ_CRASH();
-        }
-        ErrorResult rv;
-        JS::RootedValue data(jsapi.cx());
-        initialData.Read(jsapi.cx(), &data, rv);
-        if (NS_WARN_IF(rv.Failed())) {
-            MOZ_CRASH();
-        }
-        ProcessGlobal* global = ProcessGlobal::Get();
-        global->SetInitialProcessData(data);
-    }
-
-    // This object is held alive by the observer service.
-    RefPtr<SystemMessageHandledObserver> sysMsgObserver =
-        new SystemMessageHandledObserver();
-    sysMsgObserver->Init();
-
-    InitOnContentProcessCreated();
+    ProcessGlobal* global = ProcessGlobal::Get();
+    global->SetInitialProcessData(data);
+  }
+
+  // This object is held alive by the observer service.
+  RefPtr<SystemMessageHandledObserver> sysMsgObserver =
+    new SystemMessageHandledObserver();
+  sysMsgObserver->Init();
+
+  InitOnContentProcessCreated();
 }
 
 PMemoryReportRequestChild*
 ContentChild::AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
                                              const bool &aAnonymize,
                                              const bool &aMinimizeMemoryUsage,
                                              const MaybeFileDesc& aDMDFile)
 {
-    MemoryReportRequestChild *actor =
-        new MemoryReportRequestChild(aAnonymize, aDMDFile);
-    actor->AddRef();
-    return actor;
+  MemoryReportRequestChild *actor =
+    new MemoryReportRequestChild(aAnonymize, aDMDFile);
+  actor->AddRef();
+  return actor;
 }
 
 class MemoryReportCallback final : public nsIMemoryReporterCallback
 {
 public:
-    NS_DECL_ISUPPORTS
-
-    explicit MemoryReportCallback(MemoryReportRequestChild* aActor,
-                                  const nsACString& aProcess)
-    : mActor(aActor)
-    , mProcess(aProcess)
-    {
-    }
-
-    NS_IMETHOD Callback(const nsACString& aProcess, const nsACString &aPath,
-                        int32_t aKind, int32_t aUnits, int64_t aAmount,
-                        const nsACString& aDescription,
-                        nsISupports* aUnused) override
-    {
-        MemoryReport memreport(mProcess, nsCString(aPath), aKind, aUnits,
-                               aAmount, nsCString(aDescription));
-        mActor->SendReport(memreport);
-        return NS_OK;
-    }
+  NS_DECL_ISUPPORTS
+
+  explicit MemoryReportCallback(MemoryReportRequestChild* aActor,
+                                const nsACString& aProcess)
+  : mActor(aActor)
+  , mProcess(aProcess)
+  { }
+
+  NS_IMETHOD Callback(const nsACString& aProcess, const nsACString &aPath,
+                      int32_t aKind, int32_t aUnits, int64_t aAmount,
+                      const nsACString& aDescription,
+                      nsISupports* aUnused) override
+  {
+    MemoryReport memreport(mProcess, nsCString(aPath), aKind, aUnits,
+                           aAmount, nsCString(aDescription));
+    mActor->SendReport(memreport);
+    return NS_OK;
+  }
 private:
-    ~MemoryReportCallback() {}
-
-    RefPtr<MemoryReportRequestChild> mActor;
-    const nsCString mProcess;
+  ~MemoryReportCallback() {}
+
+  RefPtr<MemoryReportRequestChild> mActor;
+  const nsCString mProcess;
 };
+
 NS_IMPL_ISUPPORTS(
   MemoryReportCallback
 , nsIMemoryReporterCallback
 )
 
 class MemoryReportFinishedCallback final : public nsIFinishReportingCallback
 {
 public:
-    NS_DECL_ISUPPORTS
-
-    explicit MemoryReportFinishedCallback(MemoryReportRequestChild* aActor)
-    : mActor(aActor)
-    {
-    }
-
-    NS_IMETHOD Callback(nsISupports* aUnused) override
-    {
-        bool sent = PMemoryReportRequestChild::Send__delete__(mActor);
-        return sent ? NS_OK : NS_ERROR_FAILURE;
-    }
+  NS_DECL_ISUPPORTS
+
+  explicit MemoryReportFinishedCallback(MemoryReportRequestChild* aActor)
+  : mActor(aActor)
+  {
+  }
+
+  NS_IMETHOD Callback(nsISupports* aUnused) override
+  {
+    bool sent = PMemoryReportRequestChild::Send__delete__(mActor);
+    return sent ? NS_OK : NS_ERROR_FAILURE;
+  }
 
 private:
-    ~MemoryReportFinishedCallback() {}
-
-    RefPtr<MemoryReportRequestChild> mActor;
+  ~MemoryReportFinishedCallback() {}
+
+  RefPtr<MemoryReportRequestChild> mActor;
 };
+
 NS_IMPL_ISUPPORTS(
   MemoryReportFinishedCallback
 , nsIFinishReportingCallback
 )
 
 bool
 ContentChild::RecvPMemoryReportRequestConstructor(
-    PMemoryReportRequestChild* aChild,
-    const uint32_t& aGeneration,
-    const bool& aAnonymize,
-    const bool& aMinimizeMemoryUsage,
-    const MaybeFileDesc& aDMDFile)
+  PMemoryReportRequestChild* aChild,
+  const uint32_t& aGeneration,
+  const bool& aAnonymize,
+  const bool& aMinimizeMemoryUsage,
+  const MaybeFileDesc& aDMDFile)
 {
-    MemoryReportRequestChild *actor =
-        static_cast<MemoryReportRequestChild*>(aChild);
-    nsresult rv;
-
-    if (aMinimizeMemoryUsage) {
-        nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
-        rv = mgr->MinimizeMemoryUsage(actor);
-        // mgr will eventually call actor->Run()
-    } else {
-        rv = actor->Run();
-    }
-
-    return !NS_WARN_IF(NS_FAILED(rv));
+  MemoryReportRequestChild *actor =
+    static_cast<MemoryReportRequestChild*>(aChild);
+  nsresult rv;
+
+  if (aMinimizeMemoryUsage) {
+    nsCOMPtr<nsIMemoryReporterManager> mgr =
+      do_GetService("@mozilla.org/memory-reporter-manager;1");
+    rv = mgr->MinimizeMemoryUsage(actor);
+    // mgr will eventually call actor->Run()
+  } else {
+    rv = actor->Run();
+  }
+
+  return !NS_WARN_IF(NS_FAILED(rv));
 }
 
 NS_IMETHODIMP MemoryReportRequestChild::Run()
 {
-    ContentChild *child = static_cast<ContentChild*>(Manager());
-    nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
-
-    nsCString process;
-    child->GetProcessName(process);
-    child->AppendProcessId(process);
-
-    // Run the reporters.  The callback will turn each measurement into a
-    // MemoryReport.
-    RefPtr<MemoryReportCallback> cb =
-        new MemoryReportCallback(this, process);
-    RefPtr<MemoryReportFinishedCallback> finished =
-        new MemoryReportFinishedCallback(this);
-
-    return mgr->GetReportsForThisProcessExtended(cb, nullptr, mAnonymize,
-                                                 FileDescriptorToFILE(mDMDFile, "wb"),
-                                                 finished, nullptr);
+  ContentChild *child = static_cast<ContentChild*>(Manager());
+  nsCOMPtr<nsIMemoryReporterManager> mgr =
+    do_GetService("@mozilla.org/memory-reporter-manager;1");
+
+  nsCString process;
+  child->GetProcessName(process);
+  child->AppendProcessId(process);
+
+  // Run the reporters.  The callback will turn each measurement into a
+  // MemoryReport.
+  RefPtr<MemoryReportCallback> cb =
+    new MemoryReportCallback(this, process);
+  RefPtr<MemoryReportFinishedCallback> finished =
+    new MemoryReportFinishedCallback(this);
+
+  return mgr->GetReportsForThisProcessExtended(cb, nullptr, mAnonymize,
+                                               FileDescriptorToFILE(mDMDFile, "wb"),
+                                               finished, nullptr);
 }
 
 bool
 ContentChild::RecvDataStoreNotify(const uint32_t& aAppId,
                                   const nsString& aName,
                                   const nsString& aManifestURL)
 {
   RefPtr<DataStoreService> service = DataStoreService::GetOrCreate();
@@ -1164,127 +1165,127 @@ ContentChild::RecvDataStoreNotify(const 
   }
 
   return true;
 }
 
 bool
 ContentChild::DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor)
 {
-    static_cast<MemoryReportRequestChild*>(actor)->Release();
-    return true;
+  static_cast<MemoryReportRequestChild*>(actor)->Release();
+  return true;
 }
 
 PCycleCollectWithLogsChild*
 ContentChild::AllocPCycleCollectWithLogsChild(const bool& aDumpAllTraces,
                                               const FileDescriptor& aGCLog,
                                               const FileDescriptor& aCCLog)
 {
-    CycleCollectWithLogsChild* actor = new CycleCollectWithLogsChild(aGCLog, aCCLog);
-    // Return actor with refcount 0, which is safe because it has a non-XPCOM type.
-    return actor;
+  CycleCollectWithLogsChild* actor = new CycleCollectWithLogsChild(aGCLog, aCCLog);
+  // Return actor with refcount 0, which is safe because it has a non-XPCOM type.
+  return actor;
 }
 
 bool
 ContentChild::RecvPCycleCollectWithLogsConstructor(PCycleCollectWithLogsChild* aActor,
                                                    const bool& aDumpAllTraces,
                                                    const FileDescriptor& aGCLog,
                                                    const FileDescriptor& aCCLog)
 {
-    // Take a reference here, where the XPCOM type is regained.
-    RefPtr<CycleCollectWithLogsChild> sink = static_cast<CycleCollectWithLogsChild*>(aActor);
-    nsCOMPtr<nsIMemoryInfoDumper> dumper = do_GetService("@mozilla.org/memory-info-dumper;1");
-
-    dumper->DumpGCAndCCLogsToSink(aDumpAllTraces, sink);
-
-    // The actor's destructor is called when the last reference goes away...
-    return true;
+  // Take a reference here, where the XPCOM type is regained.
+  RefPtr<CycleCollectWithLogsChild> sink = static_cast<CycleCollectWithLogsChild*>(aActor);
+  nsCOMPtr<nsIMemoryInfoDumper> dumper = do_GetService("@mozilla.org/memory-info-dumper;1");
+
+  dumper->DumpGCAndCCLogsToSink(aDumpAllTraces, sink);
+
+  // The actor's destructor is called when the last reference goes away...
+  return true;
 }
 
 bool
 ContentChild::DeallocPCycleCollectWithLogsChild(PCycleCollectWithLogsChild* /* aActor */)
 {
-    // ...so when we get here, there's nothing for us to do.
-    //
-    // Also, we're already in ~CycleCollectWithLogsChild (q.v.) at
-    // this point, so we shouldn't touch the actor in any case.
-    return true;
+  // ...so when we get here, there's nothing for us to do.
+  //
+  // Also, we're already in ~CycleCollectWithLogsChild (q.v.) at
+  // this point, so we shouldn't touch the actor in any case.
+  return true;
 }
 
 mozilla::plugins::PPluginModuleParent*
 ContentChild::AllocPPluginModuleParent(mozilla::ipc::Transport* aTransport,
                                        base::ProcessId aOtherProcess)
 {
-    return plugins::PluginModuleContentParent::Initialize(aTransport, aOtherProcess);
+  return plugins::PluginModuleContentParent::Initialize(aTransport, aOtherProcess);
 }
 
 PContentBridgeChild*
 ContentChild::AllocPContentBridgeChild(mozilla::ipc::Transport* aTransport,
                                        base::ProcessId aOtherProcess)
 {
-    return ContentBridgeChild::Create(aTransport, aOtherProcess);
+  return ContentBridgeChild::Create(aTransport, aOtherProcess);
 }
 
 PContentBridgeParent*
 ContentChild::AllocPContentBridgeParent(mozilla::ipc::Transport* aTransport,
                                         base::ProcessId aOtherProcess)
 {
-    MOZ_ASSERT(!mLastBridge);
-    mLastBridge = static_cast<ContentBridgeParent*>(
-        ContentBridgeParent::Create(aTransport, aOtherProcess));
-    return mLastBridge;
+  MOZ_ASSERT(!mLastBridge);
+  mLastBridge = static_cast<ContentBridgeParent*>(
+    ContentBridgeParent::Create(aTransport, aOtherProcess));
+  return mLastBridge;
 }
 
 PGMPServiceChild*
 ContentChild::AllocPGMPServiceChild(mozilla::ipc::Transport* aTransport,
                                     base::ProcessId aOtherProcess)
 {
-    return GMPServiceChild::Create(aTransport, aOtherProcess);
+  return GMPServiceChild::Create(aTransport, aOtherProcess);
 }
 
 PCompositorChild*
 ContentChild::AllocPCompositorChild(mozilla::ipc::Transport* aTransport,
                                     base::ProcessId aOtherProcess)
 {
-    return CompositorChild::Create(aTransport, aOtherProcess);
+  return CompositorChild::Create(aTransport, aOtherProcess);
 }
 
 PSharedBufferManagerChild*
 ContentChild::AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
                                               base::ProcessId aOtherProcess)
 {
-    return SharedBufferManagerChild::StartUpInChildProcess(aTransport, aOtherProcess);
+  return SharedBufferManagerChild::StartUpInChildProcess(aTransport, aOtherProcess);
 }
 
 PImageBridgeChild*
 ContentChild::AllocPImageBridgeChild(mozilla::ipc::Transport* aTransport,
                                      base::ProcessId aOtherProcess)
 {
-    return ImageBridgeChild::StartUpInChildProcess(aTransport, aOtherProcess);
+  return ImageBridgeChild::StartUpInChildProcess(aTransport, aOtherProcess);
 }
 
 gfx::PVRManagerChild*
 ContentChild::AllocPVRManagerChild(Transport* aTransport,
                                    ProcessId aOtherProcess)
 {
   return gfx::VRManagerChild::StartUpInChildProcess(aTransport, aOtherProcess);
 }
 
 PBackgroundChild*
 ContentChild::AllocPBackgroundChild(Transport* aTransport,
                                     ProcessId aOtherProcess)
 {
-    return BackgroundChild::Alloc(aTransport, aOtherProcess);
+  return BackgroundChild::Alloc(aTransport, aOtherProcess);
 }
 
 PProcessHangMonitorChild*
 ContentChild::AllocPProcessHangMonitorChild(Transport* aTransport,
                                             ProcessId aOtherProcess)
 {
-    return CreateHangMonitorChild(aTransport, aOtherProcess);
+  return CreateHangMonitorChild(aTransport, aOtherProcess);
 }
 
 #if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX)
 
 #include <stdlib.h>
 
 static bool
 GetAppPaths(nsCString &aAppPath, nsCString &aAppBinaryPath, nsCString &aAppDir)
@@ -1378,264 +1379,264 @@ StartMacOSContentSandbox()
     MOZ_CRASH("sandbox_init() failed");
   }
 }
 #endif
 
 bool
 ContentChild::RecvSetProcessSandbox(const MaybeFileDesc& aBroker)
 {
-    // We may want to move the sandbox initialization somewhere else
-    // at some point; see bug 880808.
+  // We may want to move the sandbox initialization somewhere else
+  // at some point; see bug 880808.
 #if defined(MOZ_CONTENT_SANDBOX)
 #if defined(XP_LINUX)
 #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 19
-    // For B2G >= KitKat, sandboxing is mandatory; this has already
-    // been enforced by ContentParent::StartUp().
-    MOZ_ASSERT(SandboxInfo::Get().CanSandboxContent());
+  // For B2G >= KitKat, sandboxing is mandatory; this has already
+  // been enforced by ContentParent::StartUp().
+  MOZ_ASSERT(SandboxInfo::Get().CanSandboxContent());
 #else
-    // Otherwise, sandboxing is best-effort.
-    if (!SandboxInfo::Get().CanSandboxContent()) {
-        return true;
-    }
+  // Otherwise, sandboxing is best-effort.
+  if (!SandboxInfo::Get().CanSandboxContent()) {
+      return true;
+  }
 #endif
-    int brokerFd = -1;
-    if (aBroker.type() == MaybeFileDesc::TFileDescriptor) {
-        brokerFd = aBroker.get_FileDescriptor().PlatformHandle();
-        // brokerFd < 0 means to allow direct filesystem access, so
-        // make absolutely sure that doesn't happen if the parent
-        // didn't intend it.
-        MOZ_RELEASE_ASSERT(brokerFd >= 0);
-    }
-    SetContentProcessSandbox(brokerFd);
+  int brokerFd = -1;
+  if (aBroker.type() == MaybeFileDesc::TFileDescriptor) {
+      brokerFd = aBroker.get_FileDescriptor().PlatformHandle();
+      // brokerFd < 0 means to allow direct filesystem access, so
+      // make absolutely sure that doesn't happen if the parent
+      // didn't intend it.
+      MOZ_RELEASE_ASSERT(brokerFd >= 0);
+  }
+  SetContentProcessSandbox(brokerFd);
 #elif defined(XP_WIN)
-    mozilla::SandboxTarget::Instance()->StartSandbox();
+  mozilla::SandboxTarget::Instance()->StartSandbox();
 #elif defined(XP_MACOSX)
-    StartMacOSContentSandbox();
+  StartMacOSContentSandbox();
 #endif
 #endif
-    return true;
+  return true;
 }
 
 bool
 ContentChild::RecvSpeakerManagerNotify()
 {
 #ifdef MOZ_WIDGET_GONK
-    // Only notify the process which has the SpeakerManager instance.
-    RefPtr<SpeakerManagerService> service =
-        SpeakerManagerService::GetSpeakerManagerService();
-    if (service) {
-        service->Notify();
-    }
-    return true;
+  // Only notify the process which has the SpeakerManager instance.
+  RefPtr<SpeakerManagerService> service =
+    SpeakerManagerService::GetSpeakerManagerService();
+  if (service) {
+    service->Notify();
+  }
+  return true;
 #endif
-    return false;
+  return false;
 }
 
 bool
 ContentChild::RecvBidiKeyboardNotify(const bool& aIsLangRTL)
 {
-    // bidi is always of type PuppetBidiKeyboard* (because in the child, the only
-    // possible implementation of nsIBidiKeyboard is PuppetBidiKeyboard).
-    PuppetBidiKeyboard* bidi = static_cast<PuppetBidiKeyboard*>(nsContentUtils::GetBidiKeyboard());
-    if (bidi) {
-        bidi->SetIsLangRTL(aIsLangRTL);
-    }
-    return true;
+  // bidi is always of type PuppetBidiKeyboard* (because in the child, the only
+  // possible implementation of nsIBidiKeyboard is PuppetBidiKeyboard).
+  PuppetBidiKeyboard* bidi = static_cast<PuppetBidiKeyboard*>(nsContentUtils::GetBidiKeyboard());
+  if (bidi) {
+    bidi->SetIsLangRTL(aIsLangRTL);
+  }
+  return true;
 }
 
 static CancelableTask* sFirstIdleTask;
 
 static void FirstIdle(void)
 {
-    MOZ_ASSERT(sFirstIdleTask);
-    sFirstIdleTask = nullptr;
-    ContentChild::GetSingleton()->SendFirstIdle();
+  MOZ_ASSERT(sFirstIdleTask);
+  sFirstIdleTask = nullptr;
+  ContentChild::GetSingleton()->SendFirstIdle();
 }
 
 mozilla::jsipc::PJavaScriptChild *
 ContentChild::AllocPJavaScriptChild()
 {
-    MOZ_ASSERT(ManagedPJavaScriptChild().IsEmpty());
-
-    return nsIContentChild::AllocPJavaScriptChild();
+  MOZ_ASSERT(ManagedPJavaScriptChild().IsEmpty());
+
+  return nsIContentChild::AllocPJavaScriptChild();
 }
 
 bool
 ContentChild::DeallocPJavaScriptChild(PJavaScriptChild *aChild)
 {
-    return nsIContentChild::DeallocPJavaScriptChild(aChild);
+  return nsIContentChild::DeallocPJavaScriptChild(aChild);
 }
 
 PBrowserChild*
 ContentChild::AllocPBrowserChild(const TabId& aTabId,
                                  const IPCTabContext& aContext,
                                  const uint32_t& aChromeFlags,
                                  const ContentParentId& aCpID,
                                  const bool& aIsForApp,
                                  const bool& aIsForBrowser)
 {
-    return nsIContentChild::AllocPBrowserChild(aTabId,
-                                               aContext,
-                                               aChromeFlags,
-                                               aCpID,
-                                               aIsForApp,
-                                               aIsForBrowser);
+  return nsIContentChild::AllocPBrowserChild(aTabId,
+                                             aContext,
+                                             aChromeFlags,
+                                             aCpID,
+                                             aIsForApp,
+                                             aIsForBrowser);
 }
 
 bool
 ContentChild::SendPBrowserConstructor(PBrowserChild* aActor,
                                       const TabId& aTabId,
                                       const IPCTabContext& aContext,
                                       const uint32_t& aChromeFlags,
                                       const ContentParentId& aCpID,
                                       const bool& aIsForApp,
                                       const bool& aIsForBrowser)
 {
-    return PContentChild::SendPBrowserConstructor(aActor,
-                                                  aTabId,
-                                                  aContext,
-                                                  aChromeFlags,
-                                                  aCpID,
-                                                  aIsForApp,
-                                                  aIsForBrowser);
+  return PContentChild::SendPBrowserConstructor(aActor,
+                                                aTabId,
+                                                aContext,
+                                                aChromeFlags,
+                                                aCpID,
+                                                aIsForApp,
+                                                aIsForBrowser);
 }
 
 bool
 ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
                                       const TabId& aTabId,
                                       const IPCTabContext& aContext,
                                       const uint32_t& aChromeFlags,
                                       const ContentParentId& aCpID,
                                       const bool& aIsForApp,
                                       const bool& aIsForBrowser)
 {
-    // This runs after AllocPBrowserChild() returns and the IPC machinery for this
-    // PBrowserChild has been set up.
-
-    nsCOMPtr<nsIObserverService> os = services::GetObserverService();
-    if (os) {
-        nsITabChild* tc =
-            static_cast<nsITabChild*>(static_cast<TabChild*>(aActor));
-        os->NotifyObservers(tc, "tab-child-created", nullptr);
-    }
-
-    static bool hasRunOnce = false;
-    if (!hasRunOnce) {
-        hasRunOnce = true;
-
-        MOZ_ASSERT(!sFirstIdleTask);
-        sFirstIdleTask = NewRunnableFunction(FirstIdle);
-        MessageLoop::current()->PostIdleTask(FROM_HERE, sFirstIdleTask);
-
-        // Redo InitProcessAttributes() when the app or browser is really
-        // launching so the attributes will be correct.
-        mID = aCpID;
-        mIsForApp = aIsForApp;
-        mIsForBrowser = aIsForBrowser;
-        InitProcessAttributes();
-    }
-
-    return true;
+  // This runs after AllocPBrowserChild() returns and the IPC machinery for this
+  // PBrowserChild has been set up.
+
+  nsCOMPtr<nsIObserverService> os = services::GetObserverService();
+  if (os) {
+    nsITabChild* tc =
+      static_cast<nsITabChild*>(static_cast<TabChild*>(aActor));
+    os->NotifyObservers(tc, "tab-child-created", nullptr);
+  }
+
+  static bool hasRunOnce = false;
+  if (!hasRunOnce) {
+      hasRunOnce = true;
+
+    MOZ_ASSERT(!sFirstIdleTask);
+    sFirstIdleTask = NewRunnableFunction(FirstIdle);
+    MessageLoop::current()->PostIdleTask(FROM_HERE, sFirstIdleTask);
+
+    // Redo InitProcessAttributes() when the app or browser is really
+    // launching so the attributes will be correct.
+    mID = aCpID;
+    mIsForApp = aIsForApp;
+    mIsForBrowser = aIsForBrowser;
+    InitProcessAttributes();
+  }
+
+  return true;
 }
 
 void
 ContentChild::GetAvailableDictionaries(InfallibleTArray<nsString>& aDictionaries)
 {
-    aDictionaries = mAvailableDictionaries;
+  aDictionaries = mAvailableDictionaries;
 }
 
 PFileDescriptorSetChild*
 ContentChild::AllocPFileDescriptorSetChild(const FileDescriptor& aFD)
 {
-    return new FileDescriptorSetChild(aFD);
+  return new FileDescriptorSetChild(aFD);
 }
 
 bool
 ContentChild::DeallocPFileDescriptorSetChild(PFileDescriptorSetChild* aActor)
 {
-    delete static_cast<FileDescriptorSetChild*>(aActor);
-    return true;
+  delete static_cast<FileDescriptorSetChild*>(aActor);
+  return true;
 }
 
 bool
 ContentChild::DeallocPBrowserChild(PBrowserChild* aIframe)
 {
-    return nsIContentChild::DeallocPBrowserChild(aIframe);
+  return nsIContentChild::DeallocPBrowserChild(aIframe);
 }
 
 PBlobChild*
 ContentChild::AllocPBlobChild(const BlobConstructorParams& aParams)
 {
-    return nsIContentChild::AllocPBlobChild(aParams);
+  return nsIContentChild::AllocPBlobChild(aParams);
 }
 
 mozilla::PRemoteSpellcheckEngineChild *
 ContentChild::AllocPRemoteSpellcheckEngineChild()
 {
-    NS_NOTREACHED("Default Constructor for PRemoteSpellcheckEngineChild should never be called");
-    return nullptr;
+  NS_NOTREACHED("Default Constructor for PRemoteSpellcheckEngineChild should never be called");
+  return nullptr;
 }
 
 bool
 ContentChild::DeallocPRemoteSpellcheckEngineChild(PRemoteSpellcheckEngineChild *child)
 {
-    delete child;
-    return true;
+  delete child;
+  return true;
 }
 
 bool
 ContentChild::DeallocPBlobChild(PBlobChild* aActor)
 {
-    return nsIContentChild::DeallocPBlobChild(aActor);
+  return nsIContentChild::DeallocPBlobChild(aActor);
 }
 
 PBlobChild*
 ContentChild::SendPBlobConstructor(PBlobChild* aActor,
                                    const BlobConstructorParams& aParams)
 {
-    return PContentChild::SendPBlobConstructor(aActor, aParams);
+  return PContentChild::SendPBlobConstructor(aActor, aParams);
 }
 
 PPresentationChild*
 ContentChild::AllocPPresentationChild()
 {
-    NS_NOTREACHED("We should never be manually allocating PPresentationChild actors");
-    return nullptr;
+  NS_NOTREACHED("We should never be manually allocating PPresentationChild actors");
+  return nullptr;
 }
 
 bool
 ContentChild::DeallocPPresentationChild(PPresentationChild* aActor)
 {
-    delete aActor;
-    return true;
+  delete aActor;
+  return true;
 }
 
 bool
 ContentChild::RecvNotifyPresentationReceiverLaunched(PBrowserChild* aIframe,
                                                      const nsString& aSessionId)
 {
-    nsCOMPtr<nsIDocShell> docShell =
-        do_GetInterface(static_cast<TabChild*>(aIframe)->WebNavigation());
-    NS_WARN_IF(!docShell);
-
-    nsCOMPtr<nsIPresentationService> service =
-        do_GetService(PRESENTATION_SERVICE_CONTRACTID);
-    NS_WARN_IF(!service);
-
-    NS_WARN_IF(NS_FAILED(static_cast<PresentationIPCService*>(service.get())->MonitorResponderLoading(aSessionId, docShell)));
-
-    return true;
+  nsCOMPtr<nsIDocShell> docShell =
+    do_GetInterface(static_cast<TabChild*>(aIframe)->WebNavigation());
+  NS_WARN_IF(!docShell);
+
+  nsCOMPtr<nsIPresentationService> service =
+    do_GetService(PRESENTATION_SERVICE_CONTRACTID);
+  NS_WARN_IF(!service);
+
+  NS_WARN_IF(NS_FAILED(static_cast<PresentationIPCService*>(service.get())->MonitorResponderLoading(aSessionId, docShell)));
+
+  return true;
 }
 
 bool
 ContentChild::RecvNotifyPresentationReceiverCleanUp(const nsString& aSessionId)
 {
   nsCOMPtr<nsIPresentationService> service =
-      do_GetService(PRESENTATION_SERVICE_CONTRACTID);
+    do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   NS_WARN_IF(!service);
 
   NS_WARN_IF(NS_FAILED(service->UntrackSessionInfo(aSessionId)));
 
   return true;
 }
 
 bool
@@ -1654,346 +1655,346 @@ ContentChild::AllocPCrashReporterChild(c
 #else
     return nullptr;
 #endif
 }
 
 bool
 ContentChild::DeallocPCrashReporterChild(PCrashReporterChild* crashreporter)
 {
-    delete crashreporter;
-    return true;
+  delete crashreporter;
+  return true;
 }
 
 PHalChild*
 ContentChild::AllocPHalChild()
 {
-    return CreateHalChild();
+  return CreateHalChild();
 }
 
 bool
 ContentChild::DeallocPHalChild(PHalChild* aHal)
 {
-    delete aHal;
-    return true;
+  delete aHal;
+  return true;
 }
 
 devtools::PHeapSnapshotTempFileHelperChild*
 ContentChild::AllocPHeapSnapshotTempFileHelperChild()
 {
-    return devtools::HeapSnapshotTempFileHelperChild::Create();
+  return devtools::HeapSnapshotTempFileHelperChild::Create();
 }
 
 bool
 ContentChild::DeallocPHeapSnapshotTempFileHelperChild(
-    devtools::PHeapSnapshotTempFileHelperChild* aHeapSnapshotHelper)
+  devtools::PHeapSnapshotTempFileHelperChild* aHeapSnapshotHelper)
 {
-    delete aHeapSnapshotHelper;
-    return true;
+  delete aHeapSnapshotHelper;
+  return true;
 }
 
 PIccChild*
 ContentChild::SendPIccConstructor(PIccChild* aActor,
                                   const uint32_t& aServiceId)
 {
-    // Add an extra ref for IPDL. Will be released in
-    // ContentChild::DeallocPIccChild().
-    static_cast<IccChild*>(aActor)->AddRef();
-    return PContentChild::SendPIccConstructor(aActor, aServiceId);
+  // Add an extra ref for IPDL. Will be released in
+  // ContentChild::DeallocPIccChild().
+  static_cast<IccChild*>(aActor)->AddRef();
+  return PContentChild::SendPIccConstructor(aActor, aServiceId);
 }
 
 PIccChild*
 ContentChild::AllocPIccChild(const uint32_t& aServiceId)
 {
-    NS_NOTREACHED("No one should be allocating PIccChild actors");
-    return nullptr;
+  NS_NOTREACHED("No one should be allocating PIccChild actors");
+  return nullptr;
 }
 
 bool
 ContentChild::DeallocPIccChild(PIccChild* aActor)
 {
-    // IccChild is refcounted, must not be freed manually.
-    static_cast<IccChild*>(aActor)->Release();
-    return true;
+  // IccChild is refcounted, must not be freed manually.
+  static_cast<IccChild*>(aActor)->Release();
+  return true;
 }
 
 PTestShellChild*
 ContentChild::AllocPTestShellChild()
 {
-    return new TestShellChild();
+  return new TestShellChild();
 }
 
 bool
 ContentChild::DeallocPTestShellChild(PTestShellChild* shell)
 {
-    delete shell;
-    return true;
+  delete shell;
+  return true;
 }
 
 jsipc::CPOWManager*
 ContentChild::GetCPOWManager()
 {
-    if (PJavaScriptChild* c = LoneManagedOrNullAsserts(ManagedPJavaScriptChild())) {
-        return CPOWManagerFor(c);
-    }
-    return CPOWManagerFor(SendPJavaScriptConstructor());
+  if (PJavaScriptChild* c = LoneManagedOrNullAsserts(ManagedPJavaScriptChild())) {
+    return CPOWManagerFor(c);
+  }
+  return CPOWManagerFor(SendPJavaScriptConstructor());
 }
 
 bool
 ContentChild::RecvPTestShellConstructor(PTestShellChild* actor)
 {
-    return true;
+  return true;
 }
 
 PDeviceStorageRequestChild*
 ContentChild::AllocPDeviceStorageRequestChild(const DeviceStorageParams& aParams)
 {
-    return new DeviceStorageRequestChild();
+  return new DeviceStorageRequestChild();
 }
 
 bool
 ContentChild::DeallocPDeviceStorageRequestChild(PDeviceStorageRequestChild* aDeviceStorage)
 {
-    delete aDeviceStorage;
-    return true;
+  delete aDeviceStorage;
+  return true;
 }
 
 PFileSystemRequestChild*
 ContentChild::AllocPFileSystemRequestChild(const FileSystemParams& aParams)
 {
-    NS_NOTREACHED("Should never get here!");
-    return nullptr;
+  NS_NOTREACHED("Should never get here!");
+  return nullptr;
 }
 
 bool
 ContentChild::DeallocPFileSystemRequestChild(PFileSystemRequestChild* aFileSystem)
 {
-    mozilla::dom::FileSystemTaskBase* child =
-      static_cast<mozilla::dom::FileSystemTaskBase*>(aFileSystem);
-    // The reference is increased in FileSystemTaskBase::Start of
-    // FileSystemTaskBase.cpp. We should decrease it after IPC.
-    NS_RELEASE(child);
-    return true;
+  mozilla::dom::FileSystemTaskBase* child =
+    static_cast<mozilla::dom::FileSystemTaskBase*>(aFileSystem);
+  // The reference is increased in FileSystemTaskBase::Start of
+  // FileSystemTaskBase.cpp. We should decrease it after IPC.
+  NS_RELEASE(child);
+  return true;
 }
 
 PMobileConnectionChild*
 ContentChild::SendPMobileConnectionConstructor(PMobileConnectionChild* aActor,
                                                const uint32_t& aClientId)
 {
 #ifdef MOZ_B2G_RIL
-    // Add an extra ref for IPDL. Will be released in
-    // ContentChild::DeallocPMobileConnectionChild().
-    static_cast<MobileConnectionChild*>(aActor)->AddRef();
-    return PContentChild::SendPMobileConnectionConstructor(aActor, aClientId);
+  // Add an extra ref for IPDL. Will be released in
+  // ContentChild::DeallocPMobileConnectionChild().
+  static_cast<MobileConnectionChild*>(aActor)->AddRef();
+  return PContentChild::SendPMobileConnectionConstructor(aActor, aClientId);
 #else
-    MOZ_CRASH("No support for mobileconnection on this platform!");;
+  MOZ_CRASH("No support for mobileconnection on this platform!");;
 #endif
 }
 
 PMobileConnectionChild*
 ContentChild::AllocPMobileConnectionChild(const uint32_t& aClientId)
 {
 #ifdef MOZ_B2G_RIL
-    NS_NOTREACHED("No one should be allocating PMobileConnectionChild actors");
-    return nullptr;
+  NS_NOTREACHED("No one should be allocating PMobileConnectionChild actors");
+  return nullptr;
 #else
-    MOZ_CRASH("No support for mobileconnection on this platform!");;
+  MOZ_CRASH("No support for mobileconnection on this platform!");;
 #endif
 }
 
 bool
 ContentChild::DeallocPMobileConnectionChild(PMobileConnectionChild* aActor)
 {
 #ifdef MOZ_B2G_RIL
-    // MobileConnectionChild is refcounted, must not be freed manually.
-    static_cast<MobileConnectionChild*>(aActor)->Release();
-    return true;
+  // MobileConnectionChild is refcounted, must not be freed manually.
+  static_cast<MobileConnectionChild*>(aActor)->Release();
+  return true;
 #else
-    MOZ_CRASH("No support for mobileconnection on this platform!");
+  MOZ_CRASH("No support for mobileconnection on this platform!");
 #endif
 }
 
 PNeckoChild*
 ContentChild::AllocPNeckoChild()
 {
-    return new NeckoChild();
+  return new NeckoChild();
 }
 
 bool
 ContentChild::DeallocPNeckoChild(PNeckoChild* necko)
 {
-    delete necko;
-    return true;
+  delete necko;
+  return true;
 }
 
 PPrintingChild*
 ContentChild::AllocPPrintingChild()
 {
-    // The ContentParent should never attempt to allocate the nsPrintingProxy,
-    // which implements PPrintingChild. Instead, the nsPrintingProxy service is
-    // requested and instantiated via XPCOM, and the constructor of
-    // nsPrintingProxy sets up the IPC connection.
-    NS_NOTREACHED("Should never get here!");
-    return nullptr;
+  // The ContentParent should never attempt to allocate the nsPrintingProxy,
+  // which implements PPrintingChild. Instead, the nsPrintingProxy service is
+  // requested and instantiated via XPCOM, and the constructor of
+  // nsPrintingProxy sets up the IPC connection.
+  NS_NOTREACHED("Should never get here!");
+  return nullptr;
 }
 
 bool
 ContentChild::DeallocPPrintingChild(PPrintingChild* printing)
 {
-    return true;
+  return true;
 }
 
 PScreenManagerChild*
 ContentChild::AllocPScreenManagerChild(uint32_t* aNumberOfScreens,
                                        float* aSystemDefaultScale,
                                        bool* aSuccess)
 {
-    // The ContentParent should never attempt to allocate the
-    // nsScreenManagerProxy. Instead, the nsScreenManagerProxy
-    // service is requested and instantiated via XPCOM, and the
-    // constructor of nsScreenManagerProxy sets up the IPC connection.
-    NS_NOTREACHED("Should never get here!");
-    return nullptr;
+  // The ContentParent should never attempt to allocate the
+  // nsScreenManagerProxy. Instead, the nsScreenManagerProxy
+  // service is requested and instantiated via XPCOM, and the
+  // constructor of nsScreenManagerProxy sets up the IPC connection.
+  NS_NOTREACHED("Should never get here!");
+  return nullptr;
 }
 
 bool
 ContentChild::DeallocPScreenManagerChild(PScreenManagerChild* aService)
 {
-    // nsScreenManagerProxy is AddRef'd in its constructor.
-    nsScreenManagerProxy *child = static_cast<nsScreenManagerProxy*>(aService);
-    child->Release();
-    return true;
+  // nsScreenManagerProxy is AddRef'd in its constructor.
+  nsScreenManagerProxy *child = static_cast<nsScreenManagerProxy*>(aService);
+  child->Release();
+  return true;
 }
 
 PPSMContentDownloaderChild*
 ContentChild::AllocPPSMContentDownloaderChild(const uint32_t& aCertType)
 {
-    // NB: We don't need aCertType in the child actor.
-    RefPtr<PSMContentDownloaderChild> child = new PSMContentDownloaderChild();
-    return child.forget().take();
+  // NB: We don't need aCertType in the child actor.
+  RefPtr<PSMContentDownloaderChild> child = new PSMContentDownloaderChild();
+  return child.forget().take();
 }
 
 bool
 ContentChild::DeallocPPSMContentDownloaderChild(PPSMContentDownloaderChild* aListener)
 {
-    auto* listener = static_cast<PSMContentDownloaderChild*>(aListener);
-    RefPtr<PSMContentDownloaderChild> child = dont_AddRef(listener);
-    return true;
+  auto* listener = static_cast<PSMContentDownloaderChild*>(aListener);
+  RefPtr<PSMContentDownloaderChild> child = dont_AddRef(listener);
+  return true;
 }
 
 PExternalHelperAppChild*
 ContentChild::AllocPExternalHelperAppChild(const OptionalURIParams& uri,
                                            const nsCString& aMimeContentType,
                                            const nsCString& aContentDisposition,
                                            const uint32_t& aContentDispositionHint,
                                            const nsString& aContentDispositionFilename,
                                            const bool& aForceSave,
                                            const int64_t& aContentLength,
                                            const OptionalURIParams& aReferrer,
                                            PBrowserChild* aBrowser)
 {
-    ExternalHelperAppChild *child = new ExternalHelperAppChild();
-    child->AddRef();
-    return child;
+  ExternalHelperAppChild *child = new ExternalHelperAppChild();
+  child->AddRef();
+  return child;
 }
 
 bool
 ContentChild::DeallocPExternalHelperAppChild(PExternalHelperAppChild* aService)
 {
-    ExternalHelperAppChild *child = static_cast<ExternalHelperAppChild*>(aService);
-    child->Release();
-    return true;
+  ExternalHelperAppChild *child = static_cast<ExternalHelperAppChild*>(aService);
+  child->Release();
+  return true;
 }
 
 PHandlerServiceChild*
 ContentChild::AllocPHandlerServiceChild()
 {
-    HandlerServiceChild* actor = new HandlerServiceChild();
-    actor->AddRef();
-    return actor;
+  HandlerServiceChild* actor = new HandlerServiceChild();
+  actor->AddRef();
+  return actor;
 }
 
 bool ContentChild::DeallocPHandlerServiceChild(PHandlerServiceChild* aHandlerServiceChild)
 {
-    static_cast<HandlerServiceChild*>(aHandlerServiceChild)->Release();
-    return true;
+  static_cast<HandlerServiceChild*>(aHandlerServiceChild)->Release();
+  return true;
 }
 
 PCellBroadcastChild*
 ContentChild::AllocPCellBroadcastChild()
 {
-    MOZ_CRASH("No one should be allocating PCellBroadcastChild actors");
+  MOZ_CRASH("No one should be allocating PCellBroadcastChild actors");
 }
 
 PCellBroadcastChild*
 ContentChild::SendPCellBroadcastConstructor(PCellBroadcastChild* aActor)
 {
-    aActor = PContentChild::SendPCellBroadcastConstructor(aActor);
-    if (aActor) {
-        static_cast<CellBroadcastIPCService*>(aActor)->AddRef();
-    }
-
-    return aActor;
+  aActor = PContentChild::SendPCellBroadcastConstructor(aActor);
+  if (aActor) {
+    static_cast<CellBroadcastIPCService*>(aActor)->AddRef();
+  }
+
+  return aActor;
 }
 
 bool
 ContentChild::DeallocPCellBroadcastChild(PCellBroadcastChild* aActor)
 {
-    static_cast<CellBroadcastIPCService*>(aActor)->Release();
-    return true;
+  static_cast<CellBroadcastIPCService*>(aActor)->Release();
+  return true;
 }
 
 PSmsChild*
 ContentChild::AllocPSmsChild()
 {
-    return new SmsChild();
+  return new SmsChild();
 }
 
 bool
 ContentChild::DeallocPSmsChild(PSmsChild* aSms)
 {
-    delete aSms;
-    return true;
+  delete aSms;
+  return true;
 }
 
 PTelephonyChild*
 ContentChild::AllocPTelephonyChild()
 {
-    MOZ_CRASH("No one should be allocating PTelephonyChild actors");
+  MOZ_CRASH("No one should be allocating PTelephonyChild actors");
 }
 
 bool
 ContentChild::DeallocPTelephonyChild(PTelephonyChild* aActor)
 {
-    delete aActor;
-    return true;
+  delete aActor;
+  return true;
 }
 
 PVoicemailChild*
 ContentChild::AllocPVoicemailChild()
 {
-    MOZ_CRASH("No one should be allocating PVoicemailChild actors");
+  MOZ_CRASH("No one should be allocating PVoicemailChild actors");
 }
 
 PVoicemailChild*
 ContentChild::SendPVoicemailConstructor(PVoicemailChild* aActor)
 {
-    aActor = PContentChild::SendPVoicemailConstructor(aActor);
-    if (aActor) {
-        static_cast<VoicemailIPCService*>(aActor)->AddRef();
-    }
-
-    return aActor;
+  aActor = PContentChild::SendPVoicemailConstructor(aActor);
+  if (aActor) {
+    static_cast<VoicemailIPCService*>(aActor)->AddRef();
+  }
+
+  return aActor;
 }
 
 bool
 ContentChild::DeallocPVoicemailChild(PVoicemailChild* aActor)
 {
-    static_cast<VoicemailIPCService*>(aActor)->Release();
-    return true;
+  static_cast<VoicemailIPCService*>(aActor)->Release();
+  return true;
 }
 
 media::PMediaChild*
 ContentChild::AllocPMediaChild()
 {
   return media::AllocPMediaChild();
 }
 
@@ -2001,1046 +2002,1053 @@ bool
 ContentChild::DeallocPMediaChild(media::PMediaChild *aActor)
 {
   return media::DeallocPMediaChild(aActor);
 }
 
 PStorageChild*
 ContentChild::AllocPStorageChild()
 {
-    NS_NOTREACHED("We should never be manually allocating PStorageChild actors");
-    return nullptr;
+  NS_NOTREACHED("We should never be manually allocating PStorageChild actors");
+  return nullptr;
 }
 
 bool
 ContentChild::DeallocPStorageChild(PStorageChild* aActor)
 {
-    DOMStorageDBChild* child = static_cast<DOMStorageDBChild*>(aActor);
-    child->ReleaseIPDLReference();
-    return true;
+  DOMStorageDBChild* child = static_cast<DOMStorageDBChild*>(aActor);
+  child->ReleaseIPDLReference();
+  return true;
 }
 
 PBluetoothChild*
 ContentChild::AllocPBluetoothChild()
 {
 #ifdef MOZ_B2G_BT
-    MOZ_CRASH("No one should be allocating PBluetoothChild actors");
+  MOZ_CRASH("No one should be allocating PBluetoothChild actors");
 #else
-    MOZ_CRASH("No support for bluetooth on this platform!");
+  MOZ_CRASH("No support for bluetooth on this platform!");
 #endif
 }
 
 bool
 ContentChild::DeallocPBluetoothChild(PBluetoothChild* aActor)
 {
 #ifdef MOZ_B2G_BT
-    delete aActor;
-    return true;
+  delete aActor;
+  return true;
 #else
-    MOZ_CRASH("No support for bluetooth on this platform!");
+  MOZ_CRASH("No support for bluetooth on this platform!");
 #endif
 }
 
 PFMRadioChild*
 ContentChild::AllocPFMRadioChild()
 {
 #ifdef MOZ_B2G_FM
-    NS_RUNTIMEABORT("No one should be allocating PFMRadioChild actors");
-    return nullptr;
+  NS_RUNTIMEABORT("No one should be allocating PFMRadioChild actors");
+  return nullptr;
 #else
-    NS_RUNTIMEABORT("No support for FMRadio on this platform!");
-    return nullptr;
+  NS_RUNTIMEABORT("No support for FMRadio on this platform!");
+  return nullptr;
 #endif
 }
 
 bool
 ContentChild::DeallocPFMRadioChild(PFMRadioChild* aActor)
 {
 #ifdef MOZ_B2G_FM
-    delete aActor;
-    return true;
+  delete aActor;
+  return true;
 #else
-    NS_RUNTIMEABORT("No support for FMRadio on this platform!");
-    return false;
+  NS_RUNTIMEABORT("No support for FMRadio on this platform!");
+  return false;
 #endif
 }
 
 PSpeechSynthesisChild*
 ContentChild::AllocPSpeechSynthesisChild()
 {
 #ifdef MOZ_WEBSPEECH
-    MOZ_CRASH("No one should be allocating PSpeechSynthesisChild actors");
+  MOZ_CRASH("No one should be allocating PSpeechSynthesisChild actors");
 #else
-    return nullptr;
+  return nullptr;
 #endif
 }
 
 bool
 ContentChild::DeallocPSpeechSynthesisChild(PSpeechSynthesisChild* aActor)
 {
 #ifdef MOZ_WEBSPEECH
-    delete aActor;
-    return true;
+  delete aActor;
+  return true;
 #else
-    return false;
+  return false;
 #endif
 }
 
 PWebrtcGlobalChild *
 ContentChild::AllocPWebrtcGlobalChild()
 {
 #ifdef MOZ_WEBRTC
-    WebrtcGlobalChild *child = new WebrtcGlobalChild();
-    return child;
+  WebrtcGlobalChild *child = new WebrtcGlobalChild();
+  return child;
 #else
-    return nullptr;
+  return nullptr;
 #endif
 }
 
 bool
 ContentChild::DeallocPWebrtcGlobalChild(PWebrtcGlobalChild *aActor)
 {
 #ifdef MOZ_WEBRTC
-    delete static_cast<WebrtcGlobalChild*>(aActor);
-    return true;
+  delete static_cast<WebrtcGlobalChild*>(aActor);
+  return true;
 #else
-    return false;
+  return false;
 #endif
 }
 
 
 bool
 ContentChild::RecvRegisterChrome(InfallibleTArray<ChromePackage>&& packages,
                                  InfallibleTArray<SubstitutionMapping>&& resources,
                                  InfallibleTArray<OverrideMapping>&& overrides,
                                  const nsCString& locale,
                                  const bool& reset)
 {
-    nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
-    nsChromeRegistryContent* chromeRegistry =
-        static_cast<nsChromeRegistryContent*>(registrySvc.get());
-    chromeRegistry->RegisterRemoteChrome(packages, resources, overrides,
-                                         locale, reset);
-    return true;
+  nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
+  nsChromeRegistryContent* chromeRegistry =
+    static_cast<nsChromeRegistryContent*>(registrySvc.get());
+  chromeRegistry->RegisterRemoteChrome(packages, resources, overrides,
+                                       locale, reset);
+  return true;
 }
 
 bool
 ContentChild::RecvRegisterChromeItem(const ChromeRegistryItem& item)
 {
-    nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
-    nsChromeRegistryContent* chromeRegistry =
-        static_cast<nsChromeRegistryContent*>(registrySvc.get());
-    switch (item.type()) {
-        case ChromeRegistryItem::TChromePackage:
-            chromeRegistry->RegisterPackage(item.get_ChromePackage());
-            break;
-
-        case ChromeRegistryItem::TOverrideMapping:
-            chromeRegistry->RegisterOverride(item.get_OverrideMapping());
-            break;
-
-        case ChromeRegistryItem::TSubstitutionMapping:
-            chromeRegistry->RegisterSubstitution(item.get_SubstitutionMapping());
-            break;
-
-        default:
-            MOZ_ASSERT(false, "bad chrome item");
-            return false;
-    }
-
-    return true;
+  nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
+  nsChromeRegistryContent* chromeRegistry =
+    static_cast<nsChromeRegistryContent*>(registrySvc.get());
+  switch (item.type()) {
+    case ChromeRegistryItem::TChromePackage:
+      chromeRegistry->RegisterPackage(item.get_ChromePackage());
+      break;
+
+    case ChromeRegistryItem::TOverrideMapping:
+      chromeRegistry->RegisterOverride(item.get_OverrideMapping());
+      break;
+
+    case ChromeRegistryItem::TSubstitutionMapping:
+      chromeRegistry->RegisterSubstitution(item.get_SubstitutionMapping());
+      break;
+
+    default:
+      MOZ_ASSERT(false, "bad chrome item");
+      return false;
+  }
+
+  return true;
 }
 
 bool
 ContentChild::RecvSetOffline(const bool& offline)
 {
-    nsCOMPtr<nsIIOService> io (do_GetIOService());
-    NS_ASSERTION(io, "IO Service can not be null");
-
-    io->SetOffline(offline);
-
-    return true;
+  nsCOMPtr<nsIIOService> io (do_GetIOService());
+  NS_ASSERTION(io, "IO Service can not be null");
+
+  io->SetOffline(offline);
+
+  return true;
 }
 
 bool
 ContentChild::RecvSetConnectivity(const bool& connectivity)
 {
-    nsCOMPtr<nsIIOService> io(do_GetIOService());
-    nsCOMPtr<nsIIOServiceInternal> ioInternal(do_QueryInterface(io));
-    NS_ASSERTION(ioInternal, "IO Service can not be null");
-
-    ioInternal->SetConnectivity(connectivity);
-
-    return true;
+  nsCOMPtr<nsIIOService> io(do_GetIOService());
+  nsCOMPtr<nsIIOServiceInternal> ioInternal(do_QueryInterface(io));
+  NS_ASSERTION(ioInternal, "IO Service can not be null");
+
+  ioInternal->SetConnectivity(connectivity);
+
+  return true;
 }
 
 void
 ContentChild::ActorDestroy(ActorDestroyReason why)
 {
-    if (AbnormalShutdown == why) {
-        NS_WARNING("shutting down early because of crash!");
-        QuickExit();
-    }
+  if (AbnormalShutdown == why) {
+    NS_WARNING("shutting down early because of crash!");
+    QuickExit();
+  }
 
 #ifndef NS_FREE_PERMANENT_DATA
-    // In release builds, there's no point in the content process
-    // going through the full XPCOM shutdown path, because it doesn't
-    // keep persistent state.
-    QuickExit();
+  // In release builds, there's no point in the content process
+  // going through the full XPCOM shutdown path, because it doesn't
+  // keep persistent state.
+  QuickExit();
 #else
-    if (sFirstIdleTask) {
-        sFirstIdleTask->Cancel();
-    }
-
-    mAlertObservers.Clear();
-
-    mIdleObservers.Clear();
-
-    nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
-    if (svc) {
-        svc->UnregisterListener(mConsoleListener);
-        mConsoleListener->mChild = nullptr;
-    }
-    mIsAlive = false;
+  if (sFirstIdleTask) {
+    sFirstIdleTask->Cancel();
+  }
+
+  mAlertObservers.Clear();
+
+  mIdleObservers.Clear();
+
+  nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
+  if (svc) {
+    svc->UnregisterListener(mConsoleListener);
+    mConsoleListener->mChild = nullptr;
+  }
+  mIsAlive = false;
 
 #ifdef MOZ_NUWA_PROCESS
-    if (IsNuwaProcess()) {
-        // The Nuwa cannot go through the full XPCOM shutdown path or deadlock
-        // will result.
-        QuickExit();
-    }
+  if (IsNuwaProcess()) {
+    // The Nuwa cannot go through the full XPCOM shutdown path or deadlock
+    // will result.
+    QuickExit();
+  }
 #endif
 
-    XRE_ShutdownChildProcess();
+  XRE_ShutdownChildProcess();
 #endif // NS_FREE_PERMANENT_DATA
 }
 
 void
 ContentChild::ProcessingError(Result aCode, const char* aReason)
 {
-    switch (aCode) {
-        case MsgDropped:
-            NS_WARNING("MsgDropped in ContentChild");
-            return;
-
-        case MsgNotKnown:
-        case MsgNotAllowed:
-        case MsgPayloadError:
-        case MsgProcessingError:
-        case MsgRouteError:
-        case MsgValueError:
-            break;
-
-        default:
-            NS_RUNTIMEABORT("not reached");
-    }
+  switch (aCode) {
+    case MsgDropped:
+      NS_WARNING("MsgDropped in ContentChild");
+      return;
+
+    case MsgNotKnown:
+    case MsgNotAllowed:
+    case MsgPayloadError:
+    case MsgProcessingError:
+    case MsgRouteError:
+    case MsgValueError:
+      break;
+
+    default:
+      NS_RUNTIMEABORT("not reached");
+  }
 
 #if defined(MOZ_CRASHREPORTER) && !defined(MOZ_B2G)
-    if (PCrashReporterChild* c = LoneManagedOrNullAsserts(ManagedPCrashReporterChild())) {
-        CrashReporterChild* crashReporter =
-            static_cast<CrashReporterChild*>(c);
-        nsDependentCString reason(aReason);
-        crashReporter->SendAnnotateCrashReport(
-                NS_LITERAL_CSTRING("ipc_channel_error"),
-                reason);
-    }
+  if (PCrashReporterChild* c = LoneManagedOrNullAsserts(ManagedPCrashReporterChild())) {
+    CrashReporterChild* crashReporter =
+      static_cast<CrashReporterChild*>(c);
+    nsDependentCString reason(aReason);
+    crashReporter->SendAnnotateCrashReport(
+        NS_LITERAL_CSTRING("ipc_channel_error"),
+        reason);
+  }
 #endif
-    NS_RUNTIMEABORT("Content child abort due to IPC error");
+  NS_RUNTIMEABORT("Content child abort due to IPC error");
 }
 
 void
 ContentChild::QuickExit()
 {
-    NS_WARNING("content process _exit()ing");
-    _exit(0);
+  NS_WARNING("content process _exit()ing");
+  _exit(0);
 }
 
 nsresult
 ContentChild::AddRemoteAlertObserver(const nsString& aData,
                                      nsIObserver* aObserver)
 {
-    NS_ASSERTION(aObserver, "Adding a null observer?");
-    mAlertObservers.AppendElement(new AlertObserver(aObserver, aData));
-    return NS_OK;
+  NS_ASSERTION(aObserver, "Adding a null observer?");
+  mAlertObservers.AppendElement(new AlertObserver(aObserver, aData));
+  return NS_OK;
 }
 
 
 bool
 ContentChild::RecvSystemMemoryAvailable(const uint64_t& aGetterId,
                                         const uint32_t& aMemoryAvailable)
 {
-    RefPtr<Promise> p = dont_AddRef(reinterpret_cast<Promise*>(aGetterId));
-
-    if (!aMemoryAvailable) {
-        p->MaybeReject(NS_ERROR_NOT_AVAILABLE);
-        return true;
-    }
-
-    p->MaybeResolve((int)aMemoryAvailable);
+  RefPtr<Promise> p = dont_AddRef(reinterpret_cast<Promise*>(aGetterId));
+
+  if (!aMemoryAvailable) {
+    p->MaybeReject(NS_ERROR_NOT_AVAILABLE);
     return true;
+  }
+
+  p->MaybeResolve((int)aMemoryAvailable);
+  return true;
 }
 
 bool
 ContentChild::RecvPreferenceUpdate(const PrefSetting& aPref)
 {
-    Preferences::SetPreference(aPref);
-    return true;
+  Preferences::SetPreference(aPref);
+  return true;
 }
 
 bool
 ContentChild::RecvDataStoragePut(const nsString& aFilename,
                                  const DataStorageItem& aItem)
 {
-    RefPtr<DataStorage> storage = DataStorage::GetIfExists(aFilename);
-    if (storage) {
-        storage->Put(aItem.key(), aItem.value(), aItem.type());
-    }
-    return true;
+  RefPtr<DataStorage> storage = DataStorage::GetIfExists(aFilename);
+  if (storage) {
+    storage->Put(aItem.key(), aItem.value(), aItem.type());
+  }
+  return true;
 }
 
 bool
 ContentChild::RecvDataStorageRemove(const nsString& aFilename,
                                     const nsCString& aKey,
                                     const DataStorageType& aType)
 {
-    RefPtr<DataStorage> storage = DataStorage::GetIfExists(aFilename);
-    if (storage) {
-        storage->Remove(aKey, aType);
-    }
-    return true;
+  RefPtr<DataStorage> storage = DataStorage::GetIfExists(aFilename);
+  if (storage) {
+    storage->Remove(aKey, aType);
+  }
+  return true;
 }
 
 bool
 ContentChild::RecvDataStorageClear(const nsString& aFilename)
 {
-    RefPtr<DataStorage> storage = DataStorage::GetIfExists(aFilename);
-    if (storage) {
-        storage->Clear();
-    }
-    return true;
+  RefPtr<DataStorage> storage = DataStorage::GetIfExists(aFilename);
+  if (storage) {
+    storage->Clear();
+  }
+  return true;
 }
 
 bool
 ContentChild::RecvNotifyAlertsObserver(const nsCString& aType, const nsString& aData)
 {
-    for (uint32_t i = 0; i < mAlertObservers.Length();
-         /*we mutate the array during the loop; ++i iff no mutation*/) {
-        AlertObserver* observer = mAlertObservers[i];
-        if (observer->Observes(aData) && observer->Notify(aType)) {
-            // if aType == alertfinished, this alert is done.  we can
-            // remove the observer.
-            if (aType.Equals(nsDependentCString("alertfinished"))) {
-                mAlertObservers.RemoveElementAt(i);
-                continue;
-            }
-        }
-        ++i;
+  for (uint32_t i = 0; i < mAlertObservers.Length();
+     /*we mutate the array during the loop; ++i iff no mutation*/) {
+    AlertObserver* observer = mAlertObservers[i];
+    if (observer->Observes(aData) && observer->Notify(aType)) {
+      // if aType == alertfinished, this alert is done.  we can
+      // remove the observer.
+      if (aType.Equals(nsDependentCString("alertfinished"))) {
+        mAlertObservers.RemoveElementAt(i);
+        continue;
+      }
     }
-    return true;
+    ++i;
+  }
+  return true;
 }
 
 bool
 ContentChild::RecvNotifyVisited(const URIParams& aURI)
 {
-    nsCOMPtr<nsIURI> newURI = DeserializeURI(aURI);
-    if (!newURI) {
-        return false;
-    }
-    nsCOMPtr<IHistory> history = services::GetHistoryService();
-    if (history) {
-        history->NotifyVisited(newURI);
-    }
-    return true;
+  nsCOMPtr<nsIURI> newURI = DeserializeURI(aURI);
+  if (!newURI) {
+    return false;
+  }
+  nsCOMPtr<IHistory> history = services::GetHistoryService();
+  if (history) {
+    history->NotifyVisited(newURI);
+  }
+  return true;
 }
 
 bool
 ContentChild::RecvLoadProcessScript(const nsString& aURL)
 {
-    ProcessGlobal* global = ProcessGlobal::Get();
-    global->LoadScript(aURL);
-    return true;
+  ProcessGlobal* global = ProcessGlobal::Get();
+  global->LoadScript(aURL);
+  return true;
 }
 
 bool
 ContentChild::RecvAsyncMessage(const nsString& aMsg,
                                const ClonedMessageData& aData,
                                InfallibleTArray<CpowEntry>&& aCpows,
                                const IPC::Principal& aPrincipal)
 {
-    RefPtr<nsFrameMessageManager> cpm = nsFrameMessageManager::GetChildProcessManager();
-    if (cpm) {
-        StructuredCloneData data;
-        ipc::UnpackClonedMessageDataForChild(aData, data);
-        CrossProcessCpowHolder cpows(this, aCpows);
-        cpm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(cpm.get()), nullptr,
-                            aMsg, false, &data, &cpows, aPrincipal, nullptr);
-    }
-    return true;
+  RefPtr<nsFrameMessageManager> cpm =
+    nsFrameMessageManager::GetChildProcessManager();
+  if (cpm) {
+    StructuredCloneData data;
+    ipc::UnpackClonedMessageDataForChild(aData, data);
+    CrossProcessCpowHolder cpows(this, aCpows);
+    cpm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(cpm.get()),
+                        nullptr, aMsg, false, &data, &cpows, aPrincipal,
+                        nullptr);
+  }
+  return true;
 }
 
 bool
 ContentChild::RecvGeolocationUpdate(const GeoPosition& somewhere)
 {
-    nsCOMPtr<nsIGeolocationUpdate> gs = do_GetService("@mozilla.org/geolocation/service;1");
-    if (!gs) {
-        return true;
-    }
-    nsCOMPtr<nsIDOMGeoPosition> position = somewhere;
-    gs->Update(position);
+  nsCOMPtr<nsIGeolocationUpdate> gs =
+    do_GetService("@mozilla.org/geolocation/service;1");
+  if (!gs) {
     return true;
+  }
+  nsCOMPtr<nsIDOMGeoPosition> position = somewhere;
+  gs->Update(position);
+  return true;
 }
 
 bool
 ContentChild::RecvGeolocationError(const uint16_t& errorCode)
 {
-    nsCOMPtr<nsIGeolocationUpdate> gs = do_GetService("@mozilla.org/geolocation/service;1");
-    if (!gs) {
-        return true;
-    }
-    gs->NotifyError(errorCode);
+  nsCOMPtr<nsIGeolocationUpdate> gs =
+    do_GetService("@mozilla.org/geolocation/service;1");
+  if (!gs) {
     return true;
+  }
+  gs->NotifyError(errorCode);
+  return true;
 }
 
 bool
 ContentChild::RecvUpdateDictionaryList(InfallibleTArray<nsString>&& aDictionaries)
 {
-    mAvailableDictionaries = aDictionaries;
-    mozInlineSpellChecker::UpdateCanEnableInlineSpellChecking();
-    return true;
+  mAvailableDictionaries = aDictionaries;
+  mozInlineSpellChecker::UpdateCanEnableInlineSpellChecking();
+  return true;
 }
 
 bool
 ContentChild::RecvAddPermission(const IPC::Permission& permission)
 {
 #if MOZ_PERMISSIONS
-    nsCOMPtr<nsIPermissionManager> permissionManagerIface =
-        services::GetPermissionManager();
-    nsPermissionManager* permissionManager =
-        static_cast<nsPermissionManager*>(permissionManagerIface.get());
-    MOZ_ASSERT(permissionManager,
-               "We have no permissionManager in the Content process !");
-
-    nsAutoCString originNoSuffix;
-    PrincipalOriginAttributes attrs;
-    attrs.PopulateFromOrigin(permission.origin, originNoSuffix);
-
-    nsCOMPtr<nsIURI> uri;
-    nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
-    NS_ENSURE_SUCCESS(rv, true);
-
-    nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(uri, attrs);
-
-    // child processes don't care about modification time.
-    int64_t modificationTime = 0;
-
-    permissionManager->AddInternal(principal,
-                                   nsCString(permission.type),
-                                   permission.capability,
-                                   0,
-                                   permission.expireType,
-                                   permission.expireTime,
-                                   modificationTime,
-                                   nsPermissionManager::eNotify,
-                                   nsPermissionManager::eNoDBOperation);
+  nsCOMPtr<nsIPermissionManager> permissionManagerIface =
+    services::GetPermissionManager();
+  nsPermissionManager* permissionManager =
+    static_cast<nsPermissionManager*>(permissionManagerIface.get());
+  MOZ_ASSERT(permissionManager,
+         "We have no permissionManager in the Content process !");
+
+  nsAutoCString originNoSuffix;
+  PrincipalOriginAttributes attrs;
+  attrs.PopulateFromOrigin(permission.origin, originNoSuffix);
+
+  nsCOMPtr<nsIURI> uri;
+  nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
+  NS_ENSURE_SUCCESS(rv, true);
+
+  nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(uri, attrs);
+
+  // child processes don't care about modification time.
+  int64_t modificationTime = 0;
+
+  permissionManager->AddInternal(principal,
+                                 nsCString(permission.type),
+                                 permission.capability,
+                                 0,
+                                 permission.expireType,
+                                 permission.expireTime,
+                                 modificationTime,
+                                 nsPermissionManager::eNotify,
+                                 nsPermissionManager::eNoDBOperation);
 #endif
 
-    return true;
+  return true;
 }
 
 bool
 ContentChild::RecvScreenSizeChanged(const gfx::IntSize& size)
 {
 #ifdef ANDROID
-    mScreenSize = size;
+  mScreenSize = size;
 #else
-    NS_RUNTIMEABORT("Message currently only expected on android");
+  NS_RUNTIMEABORT("Message currently only expected on android");
 #endif
-    return true;
+  return true;
 }
 
 bool
 ContentChild::RecvFlushMemory(const nsString& reason)
 {
 #ifdef MOZ_NUWA_PROCESS
-    MOZ_ASSERT(!IsNuwaProcess() || !IsNuwaReady());
+  MOZ_ASSERT(!IsNuwaProcess() || !IsNuwaReady());
 #endif
-    nsCOMPtr<nsIObserverService> os =
-        mozilla::services::GetObserverService();
-    if (os)
-        os->NotifyObservers(nullptr, "memory-pressure", reason.get());
-    return true;
+  nsCOMPtr<nsIObserverService> os =
+    mozilla::services::GetObserverService();
+  if (os) {
+    os->NotifyObservers(nullptr, "memory-pressure", reason.get());
+  }
+  return true;
 }
 
 bool
 ContentChild::RecvActivateA11y()
 {
 #ifdef ACCESSIBILITY
-    // Start accessibility in content process if it's running in chrome
-    // process.
-	nsCOMPtr<nsIAccessibilityService> accService =
-        services::GetAccessibilityService();
+  // Start accessibility in content process if it's running in chrome
+  // process.
+  nsCOMPtr<nsIAccessibilityService> accService =
+    services::GetAccessibilityService();
 #endif
-    return true;
+  return true;
 }
 
 bool
 ContentChild::RecvGarbageCollect()
 {
-    // Rebroadcast the "child-gc-request" so that workers will GC.
-    nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-    if (obs) {
-        obs->NotifyObservers(nullptr, "child-gc-request", nullptr);
-    }
-    nsJSContext::GarbageCollectNow(JS::gcreason::DOM_IPC);
-    return true;
+  // Rebroadcast the "child-gc-request" so that workers will GC.
+  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
+  if (obs) {
+    obs->NotifyObservers(nullptr, "child-gc-request", nullptr);
+  }
+  nsJSContext::GarbageCollectNow(JS::gcreason::DOM_IPC);
+  return true;
 }
 
 bool
 ContentChild::RecvCycleCollect()
 {
-    // Rebroadcast the "child-cc-request" so that workers will CC.
-    nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-    if (obs) {
-        obs->NotifyObservers(nullptr, "child-cc-request", nullptr);
-    }
-    nsJSContext::CycleCollectNow();
-    return true;
+  // Rebroadcast the "child-cc-request" so that workers will CC.
+  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
+  if (obs) {
+    obs->NotifyObservers(nullptr, "child-cc-request", nullptr);
+  }
+  nsJSContext::CycleCollectNow();
+  return true;
 }
 
 #ifdef MOZ_NUWA_PROCESS
 static void
 OnFinishNuwaPreparation()
 {
-    // We want to ensure that the PBackground actor gets cloned in the Nuwa
-    // process before we freeze. Also, we have to do this to avoid deadlock.
-    // Protocols that are "opened" (e.g. PBackground, PCompositor) block the
-    // main thread to wait for the IPC thread during the open operation.
-    // NuwaSpawnWait() blocks the IPC thread to wait for the main thread when
-    // the Nuwa process is forked. Unless we ensure that the two cannot happen
-    // at the same time then we risk deadlock. Spinning the event loop here
-    // guarantees the ordering is safe for PBackground.
-    while (!BackgroundChild::GetForCurrentThread()) {
-        if (NS_WARN_IF(!NS_ProcessNextEvent())) {
-            return;
-        }
+  // We want to ensure that the PBackground actor gets cloned in the Nuwa
+  // process before we freeze. Also, we have to do this to avoid deadlock.
+  // Protocols that are "opened" (e.g. PBackground, PCompositor) block the
+  // main thread to wait for the IPC thread during the open operation.
+  // NuwaSpawnWait() blocks the IPC thread to wait for the main thread when
+  // the Nuwa process is forked. Unless we ensure that the two cannot happen
+  // at the same time then we risk deadlock. Spinning the event loop here
+  // guarantees the ordering is safe for PBackground.
+  while (!BackgroundChild::GetForCurrentThread()) {
+    if (NS_WARN_IF(!NS_ProcessNextEvent())) {
+      return;
     }
-
-    // This will create the actor.
-    Unused << mozilla::dom::NuwaChild::GetSingleton();
-
-    MakeNuwaProcess();
+  }
+
+  // This will create the actor.
+  Unused << mozilla::dom::NuwaChild::GetSingleton();
+
+  MakeNuwaProcess();
 }
 #endif
 
 static void
 PreloadSlowThings()
 {
-    // This fetches and creates all the built-in stylesheets.
-    nsLayoutStylesheetCache::UserContentSheet();
-
-    TabChild::PreloadSlowThings();
+  // This fetches and creates all the built-in stylesheets.
+  nsLayoutStylesheetCache::UserContentSheet();
+
+  TabChild::PreloadSlowThings();
 
 }
 
 bool
 ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID,
                           const nsCString& name, const nsCString& UAName,
                           const nsCString& ID, const nsCString& vendor)
 {
-    mAppInfo.version.Assign(version);
-    mAppInfo.buildID.Assign(buildID);
-    mAppInfo.name.Assign(name);
-    mAppInfo.UAName.Assign(UAName);
-    mAppInfo.ID.Assign(ID);
-    mAppInfo.vendor.Assign(vendor);
-
-    return true;
+  mAppInfo.version.Assign(version);
+  mAppInfo.buildID.Assign(buildID);
+  mAppInfo.name.Assign(name);
+  mAppInfo.UAName.Assign(UAName);
+  mAppInfo.ID.Assign(ID);
+  mAppInfo.vendor.Assign(vendor);
+
+  return true;
 }
 
 bool
 ContentChild::RecvAppInit()
 {
-    if (!Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
-        return true;
-    }
-
-    // If we're part of the mozbrowser machinery, go ahead and start
-    // preloading things.  We can only do this for mozbrowser because
-    // PreloadSlowThings() may set the docshell of the first TabChild
-    // inactive, and we can only safely restore it to active from
-    // BrowserElementChild.js.
-    if (mIsForApp || mIsForBrowser) {
-        PreloadSlowThings();
-    }
+  if (!Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
+    return true;
+  }
+
+  // If we're part of the mozbrowser machinery, go ahead and start
+  // preloading things.  We can only do this for mozbrowser because
+  // PreloadSlowThings() may set the docshell of the first TabChild
+  // inactive, and we can only safely restore it to active from
+  // BrowserElementChild.js.
+  if (mIsForApp || mIsForBrowser) {
+    PreloadSlowThings();
+  }
 
 #ifdef MOZ_NUWA_PROCESS
-    if (IsNuwaProcess()) {
-        ContentChild::GetSingleton()->RecvGarbageCollect();
-        MessageLoop::current()->PostTask(
-            FROM_HERE, NewRunnableFunction(OnFinishNuwaPreparation));
-    }
+  if (IsNuwaProcess()) {
+    ContentChild::GetSingleton()->RecvGarbageCollect();
+    MessageLoop::current()->PostTask(
+      FROM_HERE, NewRunnableFunction(OnFinishNuwaPreparation));
+  }
 #endif
 
-    return true;
+  return true;
 }
 
 bool
 ContentChild::RecvLastPrivateDocShellDestroyed()
 {
-    nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-    obs->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
-    return true;
+  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
+  obs->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
+  return true;
 }
 
 bool
 ContentChild::RecvVolumes(nsTArray<VolumeInfo>&& aVolumes)
 {
 #ifdef MOZ_WIDGET_GONK
-    RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
-    if (vs) {
-        vs->RecvVolumesFromParent(aVolumes);
-    }
+  RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
+  if (vs) {
+    vs->RecvVolumesFromParent(aVolumes);
+  }
 #endif
-    return true;
+  return true;
 }
 
 bool
 ContentChild::RecvFilePathUpdate(const nsString& aStorageType,
                                  const nsString& aStorageName,
                                  const nsString& aPath,
                                  const nsCString& aReason)
 {
-    if (nsDOMDeviceStorage::InstanceCount() == 0) {
-        // No device storage instances in this process. Don't try and
-        // and create a DeviceStorageFile since it will fail.
-
-        return true;
-    }
-
-    RefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(aStorageType, aStorageName, aPath);
-
-    nsString reason;
-    CopyASCIItoUTF16(aReason, reason);
-    nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-    obs->NotifyObservers(dsf, "file-watcher-update", reason.get());
+  if (nsDOMDeviceStorage::InstanceCount() == 0) {
+    // No device storage instances in this process. Don't try and
+    // and create a DeviceStorageFile since it will fail.
+
     return true;
+  }
+
+  RefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(aStorageType, aStorageName, aPath);
+
+  nsString reason;
+  CopyASCIItoUTF16(aReason, reason);
+  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
+  obs->NotifyObservers(dsf, "file-watcher-update", reason.get());
+  return true;
 }
 
 bool
 ContentChild::RecvFileSystemUpdate(const nsString& aFsName,
                                    const nsString& aVolumeName,
                                    const int32_t& aState,
                                    const int32_t& aMountGeneration,
                                    const bool& aIsMediaPresent,
                                    const bool& aIsSharing,
                                    const bool& aIsFormatting,
                                    const bool& aIsFake,
                                    const bool& aIsUnmounting,
                                    const bool& aIsRemovable,
                                    const bool& aIsHotSwappable)
 {
 #ifdef MOZ_WIDGET_GONK
-    RefPtr<nsVolume> volume = new nsVolume(aFsName, aVolumeName, aState,
-                                             aMountGeneration, aIsMediaPresent,
-                                             aIsSharing, aIsFormatting, aIsFake,
-                                             aIsUnmounting, aIsRemovable, aIsHotSwappable);
-
-    RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
-    if (vs) {
-        vs->UpdateVolume(volume);
-    }
+  RefPtr<nsVolume> volume = new nsVolume(aFsName, aVolumeName, aState,
+                                         aMountGeneration, aIsMediaPresent,
+                                         aIsSharing, aIsFormatting, aIsFake,
+                                         aIsUnmounting, aIsRemovable, aIsHotSwappable);
+
+  RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
+  if (vs) {
+    vs->UpdateVolume(volume);
+  }
 #else
-    // Remove warnings about unused arguments
-    Unused << aFsName;
-    Unused << aVolumeName;
-    Unused << aState;
-    Unused << aMountGeneration;
-    Unused << aIsMediaPresent;
-    Unused << aIsSharing;
-    Unused << aIsFormatting;
-    Unused << aIsFake;
-    Unused << aIsUnmounting;
-    Unused << aIsRemovable;
-    Unused << aIsHotSwappable;
+  // Remove warnings about unused arguments
+  Unused << aFsName;
+  Unused << aVolumeName;
+  Unused << aState;
+  Unused << aMountGeneration;
+  Unused << aIsMediaPresent;
+  Unused << aIsSharing;
+  Unused << aIsFormatting;
+  Unused << aIsFake;
+  Unused << aIsUnmounting;
+  Unused << aIsRemovable;
+  Unused << aIsHotSwappable;
 #endif
-    return true;
+  return true;
 }
 
 bool
 ContentChild::RecvVolumeRemoved(const nsString& aFsName)
 {
 #ifdef MOZ_WIDGET_GONK
-    RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
-    if (vs) {
-        vs->RemoveVolumeByName(aFsName);
-    }
+  RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
+  if (vs) {
+    vs->RemoveVolumeByName(aFsName);
+  }
 #else
-    // Remove warnings about unused arguments
-    Unused << aFsName;
+  // Remove warnings about unused arguments
+  Unused << aFsName;
 #endif
-    return true;
+  return true;
 }
 
 bool
 ContentChild::RecvNotifyProcessPriorityChanged(
-    const hal::ProcessPriority& aPriority)
+  const hal::ProcessPriority& aPriority)
 {
-    nsCOMPtr<nsIObserverService> os = services::GetObserverService();
-    NS_ENSURE_TRUE(os, true);
-
-    RefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
-    props->SetPropertyAsInt32(NS_LITERAL_STRING("priority"),
-                              static_cast<int32_t>(aPriority));
-
-    os->NotifyObservers(static_cast<nsIPropertyBag2*>(props),
-                        "ipc:process-priority-changed",  nullptr);
-    return true;
+  nsCOMPtr<nsIObserverService> os = services::GetObserverService();
+  NS_ENSURE_TRUE(os, true);
+
+  RefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
+  props->SetPropertyAsInt32(NS_LITERAL_STRING("priority"),
+                            static_cast<int32_t>(aPriority));
+
+  os->NotifyObservers(static_cast<nsIPropertyBag2*>(props),
+                      "ipc:process-priority-changed",  nullptr);
+  return true;
 }
 
 bool
 ContentChild::RecvMinimizeMemoryUsage()
 {
 #ifdef MOZ_NUWA_PROCESS
-    MOZ_ASSERT(!IsNuwaProcess() || !IsNuwaReady());
+  MOZ_ASSERT(!IsNuwaProcess() || !IsNuwaReady());
 #endif
-    nsCOMPtr<nsIMemoryReporterManager> mgr =
-        do_GetService("@mozilla.org/memory-reporter-manager;1");
-    NS_ENSURE_TRUE(mgr, true);
-
-    mgr->MinimizeMemoryUsage(/* callback = */ nullptr);
-    return true;
+  nsCOMPtr<nsIMemoryReporterManager> mgr =
+    do_GetService("@mozilla.org/memory-reporter-manager;1");
+  NS_ENSURE_TRUE(mgr, true);
+
+  mgr->MinimizeMemoryUsage(/* callback = */ nullptr);
+  return true;
 }
 
 bool
 ContentChild::RecvNotifyPhoneStateChange(const nsString& aState)
 {
-    nsCOMPtr<nsIObserverService> os = services::GetObserverService();
-    if (os) {
-      os->NotifyObservers(nullptr, "phone-state-changed", aState.get());
-    }
-    return true;
+  nsCOMPtr<nsIObserverService> os = services::GetObserverService();
+  if (os) {
+    os->NotifyObservers(nullptr, "phone-state-changed", aState.get());
+  }
+  return true;
 }
 
 void
 ContentChild::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS)
 {
-    MOZ_ASSERT(aObserver, "null idle observer");
-    // Make sure aObserver isn't released while we wait for the parent
-    aObserver->AddRef();
-    SendAddIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
-    mIdleObservers.PutEntry(aObserver);
+  MOZ_ASSERT(aObserver, "null idle observer");
+  // Make sure aObserver isn't released while we wait for the parent
+  aObserver->AddRef();
+  SendAddIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
+  mIdleObservers.PutEntry(aObserver);
 }
 
 void
 ContentChild::RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS)
 {
-    MOZ_ASSERT(aObserver, "null idle observer");
-    SendRemoveIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
-    aObserver->Release();
-    mIdleObservers.RemoveEntry(aObserver);
+  MOZ_ASSERT(aObserver, "null idle observer");
+  SendRemoveIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
+  aObserver->Release();
+  mIdleObservers.RemoveEntry(aObserver);
 }
 
 bool
 ContentChild::RecvNotifyIdleObserver(const uint64_t& aObserver,
                                      const nsCString& aTopic,
                                      const nsString& aTimeStr)
 {
-    nsIObserver* observer = reinterpret_cast<nsIObserver*>(aObserver);
-    if (mIdleObservers.Contains(observer)) {
-        observer->Observe(nullptr, aTopic.get(), aTimeStr.get());
-    } else {
-        NS_WARNING("Received notification for an idle observer that was removed.");
-    }
-    return true;
+  nsIObserver* observer = reinterpret_cast<nsIObserver*>(aObserver);
+  if (mIdleObservers.Contains(observer)) {
+    observer->Observe(nullptr, aTopic.get(), aTimeStr.get());
+  } else {
+    NS_WARNING("Received notification for an idle observer that was removed.");
+  }
+  return true;
 }
 
 bool
 ContentChild::RecvLoadAndRegisterSheet(const URIParams& aURI, const uint32_t& aType)
 {
-    nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
-    if (!uri) {
-        return true;
-    }
-
-    nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
-    if (sheetService) {
-        sheetService->LoadAndRegisterSheet(uri, aType);
-    }
-
+  nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
+  if (!uri) {
     return true;
+  }
+
+  nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
+  if (sheetService) {
+    sheetService->LoadAndRegisterSheet(uri, aType);
+  }
+
+  return true;
 }
 
 bool
 ContentChild::RecvUnregisterSheet(const URIParams& aURI, const uint32_t& aType)
 {
-    nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
-    if (!uri) {
-        return true;
-    }
-
-    nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
-    if (sheetService) {
-        sheetService->UnregisterSheet(uri, aType);
-    }
-
+  nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
+  if (!uri) {
     return true;
+  }
+
+  nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
+  if (sheetService) {
+    sheetService->UnregisterSheet(uri, aType);
+  }
+
+  return true;
 }
 
 POfflineCacheUpdateChild*
 ContentChild::AllocPOfflineCacheUpdateChild(const URIParams& manifestURI,
                                             const URIParams& documentURI,
                                             const PrincipalInfo& aLoadingPrincipalInfo,
                                             const bool& stickDocument,
                                             const TabId& aTabId)
 {
-    NS_RUNTIMEABORT("unused");
-    return nullptr;
+  NS_RUNTIMEABORT("unused");
+  return nullptr;
 }
 
 bool
 ContentChild::DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* actor)
 {
-    OfflineCacheUpdateChild* offlineCacheUpdate =
-        static_cast<OfflineCacheUpdateChild*>(actor);
-    NS_RELEASE(offlineCacheUpdate);
-    return true;
+  OfflineCacheUpdateChild* offlineCacheUpdate =
+    static_cast<OfflineCacheUpdateChild*>(actor);
+  NS_RELEASE(offlineCacheUpdate);
+  return true;
 }
 
 bool
 ContentChild::RecvOnAppThemeChanged()
 {
-    nsCOMPtr<nsIObserverService> os = services::GetObserverService();
-    if (os) {
-        os->NotifyObservers(nullptr, "app-theme-changed", nullptr);
-    }
-    return true;
+  nsCOMPtr<nsIObserverService> os = services::GetObserverService();
+  if (os) {
+    os->NotifyObservers(nullptr, "app-theme-changed", nullptr);
+  }
+  return true;
 }
 
 bool
 ContentChild::RecvStartProfiler(const ProfilerInitParams& params)
 {
-    nsTArray<const char*> featureArray;
-    for (size_t i = 0; i < params.features().Length(); ++i) {
-        featureArray.AppendElement(params.features()[i].get());
-    }
-
-    nsTArray<const char*> threadNameFilterArray;
-    for (size_t i = 0; i < params.threadFilters().Length(); ++i) {
-        threadNameFilterArray.AppendElement(params.threadFilters()[i].get());
-    }
-
-    profiler_start(params.entries(), params.interval(),
-                   featureArray.Elements(), featureArray.Length(),
-                   threadNameFilterArray.Elements(), threadNameFilterArray.Length());
-
-    return true;
+  nsTArray<const char*> featureArray;
+  for (size_t i = 0; i < params.features().Length(); ++i) {
+    featureArray.AppendElement(params.features()[i].get());
+  }
+
+  nsTArray<const char*> threadNameFilterArray;
+  for (size_t i = 0; i < params.threadFilters().Length(); ++i) {
+    threadNameFilterArray.AppendElement(params.threadFilters()[i].get());
+  }
+
+  profiler_start(params.entries(), params.interval(),
+                 featureArray.Elements(), featureArray.Length(),
+                 threadNameFilterArray.Elements(),
+                 threadNameFilterArray.Length());
+
+ return true;
 }
 
 bool
 ContentChild::RecvStopProfiler()
 {
-    profiler_stop();
-    return true;
+  profiler_stop();
+  return true;
 }
 
 bool
 ContentChild::RecvPauseProfiler(const bool& aPause)
 {
-    if (aPause) {
-        profiler_pause();
-    } else {
-        profiler_resume();
-    }
-
-    return true;
+  if (aPause) {
+    profiler_pause();
+  } else {
+    profiler_resume();
+  }
+
+  return true;
 }
 
 bool
 ContentChild::RecvGatherProfile()
 {
-    nsCString profileCString;
-    UniquePtr<char[]> profile = profiler_get_profile();
-    if (profile) {
-        profileCString = nsCString(profile.get(), strlen(profile.get()));
-    } else {
-        profileCString = EmptyCString();
-    }
-
-    Unused << SendProfile(profileCString);
-    return true;
+  nsCString profileCString;
+  UniquePtr<char[]> profile = profiler_get_profile();
+  if (profile) {
+    profileCString = nsCString(profile.get(), strlen(profile.get()));
+  } else {
+    profileCString = EmptyCString();
+  }
+
+  Unused << SendProfile(profileCString);
+  return true;
 }
 
 bool
-ContentChild::RecvLoadPluginResult(const uint32_t& aPluginId, const bool& aResult)
+ContentChild::RecvLoadPluginResult(const uint32_t& aPluginId,
+                                   const bool& aResult)
 {
-    nsresult rv;
-    bool finalResult = aResult &&
-                       SendConnectPluginBridge(aPluginId, &rv) &&
-                       NS_SUCCEEDED(rv);
-    plugins::PluginModuleContentParent::OnLoadPluginResult(aPluginId,
-                                                           finalResult);
-    return true;
+  nsresult rv;
+  bool finalResult = aResult && SendConnectPluginBridge(aPluginId, &rv) &&
+                     NS_SUCCEEDED(rv);
+  plugins::PluginModuleContentParent::OnLoadPluginResult(aPluginId,
+                                                         finalResult);
+  return true;
 }
 
 bool
 ContentChild::RecvAssociatePluginId(const uint32_t& aPluginId,
                                     const base::ProcessId& aProcessId)
 {
-    plugins::PluginModuleContentParent::AssociatePluginId(aPluginId, aProcessId);
-    return true;
+  plugins::PluginModuleContentParent::AssociatePluginId(aPluginId, aProcessId);
+  return true;
 }
 
 bool
-ContentChild::RecvDomainSetChanged(const uint32_t& aSetType, const uint32_t& aChangeType,
+ContentChild::RecvDomainSetChanged(const uint32_t& aSetType,
+                                   const uint32_t& aChangeType,
                                    const OptionalURIParams& aDomain)
 {
-    if (aChangeType == ACTIVATE_POLICY) {
-        if (mPolicy) {
-            return true;
-        }
-        nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
-        MOZ_ASSERT(ssm);
-        ssm->ActivateDomainPolicyInternal(getter_AddRefs(mPolicy));
-        return !!mPolicy;
-    } else if (!mPolicy) {
-        MOZ_ASSERT_UNREACHABLE("If the domain policy is not active yet,"
-                               " the first message should be ACTIVATE_POLICY");
-        return false;
-    }
-
-    NS_ENSURE_TRUE(mPolicy, false);
-
-    if (aChangeType == DEACTIVATE_POLICY) {
-        mPolicy->Deactivate();
-        mPolicy = nullptr;
-        return true;
+  if (aChangeType == ACTIVATE_POLICY) {
+    if (mPolicy) {
+      return true;
     }
-
-    nsCOMPtr<nsIDomainSet> set;
-    switch(aSetType) {
-        case BLACKLIST:
-            mPolicy->GetBlacklist(getter_AddRefs(set));
-            break;
-        case SUPER_BLACKLIST:
-            mPolicy->GetSuperBlacklist(getter_AddRefs(set));
-            break;
-        case WHITELIST:
-            mPolicy->GetWhitelist(getter_AddRefs(set));
-            break;
-        case SUPER_WHITELIST:
-            mPolicy->GetSuperWhitelist(getter_AddRefs(set));
-            break;
-        default:
-            NS_NOTREACHED("Unexpected setType");
-            return false;
-    }
-
-    MOZ_ASSERT(set);
-
-    nsCOMPtr<nsIURI> uri = DeserializeURI(aDomain);
-
-    switch(aChangeType) {
-        case ADD_DOMAIN:
-            NS_ENSURE_TRUE(uri, false);
-            set->Add(uri);
-            break;
-        case REMOVE_DOMAIN:
-            NS_ENSURE_TRUE(uri, false);
-            set->Remove(uri);
-            break;
-        case CLEAR_DOMAINS:
-            set->Clear();
-            break;
-        default:
-            NS_NOTREACHED("Unexpected changeType");
-            return false;
-    }
-
+    nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
+    MOZ_ASSERT(ssm);
+    ssm->ActivateDomainPolicyInternal(getter_AddRefs(mPolicy));
+    return !!mPolicy;
+  } else if (!mPolicy) {
+    MOZ_ASSERT_UNREACHABLE("If the domain policy is not active yet,"
+                           " the first message should be ACTIVATE_POLICY");
+    return false;
+  }
+
+  NS_ENSURE_TRUE(mPolicy, false);
+
+  if (aChangeType == DEACTIVATE_POLICY) {
+    mPolicy->Deactivate();
+    mPolicy = nullptr;
     return true;
+  }
+
+  nsCOMPtr<nsIDomainSet> set;
+  switch(aSetType) {
+    case BLACKLIST:
+      mPolicy->GetBlacklist(getter_AddRefs(set));
+      break;
+    case SUPER_BLACKLIST:
+      mPolicy->GetSuperBlacklist(getter_AddRefs(set));
+      break;
+    case WHITELIST:
+      mPolicy->GetWhitelist(getter_AddRefs(set));
+      break;
+    case SUPER_WHITELIST:
+      mPolicy->GetSuperWhitelist(getter_AddRefs(set));
+      break;
+    default:
+      NS_NOTREACHED("Unexpected setType");
+      return false;
+  }
+
+  MOZ_ASSERT(set);
+
+  nsCOMPtr<nsIURI> uri = DeserializeURI(aDomain);
+
+  switch(aChangeType) {
+    case ADD_DOMAIN:
+      NS_ENSURE_TRUE(uri, false);
+      set->Add(uri);
+      break;
+    case REMOVE_DOMAIN:
+      NS_ENSURE_TRUE(uri, false);
+      set->Remove(uri);
+      break;
+    case CLEAR_DOMAINS:
+      set->Clear();
+      break;
+    default:
+      NS_NOTREACHED("Unexpected changeType");
+      return false;
+  }
+
+  return true;
 }
 
 bool
 ContentChild::RecvShutdown()
 {
-    if (mPolicy) {
-        mPolicy->Deactivate();
-        mPolicy = nullptr;
-    }
-
-    nsCOMPtr<nsIObserverService> os = services::GetObserverService();
-    if (os) {
-        os->NotifyObservers(static_cast<nsIContentChild*>(this),
-                            "content-child-shutdown", nullptr);
-    }
-
-    GetIPCChannel()->SetAbortOnError(false);
+  if (mPolicy) {
+    mPolicy->Deactivate();
+    mPolicy = nullptr;
+  }
+
+  nsCOMPtr<nsIObserverService> os = services::GetObserverService();
+  if (os) {
+    os->NotifyObservers(static_cast<nsIContentChild*>(this),
+                          "content-child-shutdown", nullptr);
+  }
+
+  GetIPCChannel()->SetAbortOnError(false);
 
 #ifdef MOZ_ENABLE_PROFILER_SPS
-    if (profiler_is_active()) {
-        // We're shutting down while we were profiling. Send the
-        // profile up to the parent so that we don't lose this
-        // information.
-        Unused << RecvGatherProfile();
-    }
+  if (profiler_is_active()) {
+    // We're shutting down while we were profiling. Send the
+    // profile up to the parent so that we don't lose this
+    // information.
+    Unused << RecvGatherProfile();
+  }
 #endif
 
-    // Ignore errors here. If this fails, the parent will kill us after a
-    // timeout.
-    Unused << SendFinishShutdown();
-    return true;
+  // Ignore errors here. If this fails, the parent will kill us after a
+  // timeout.
+  Unused << SendFinishShutdown();
+  return true;
 }
 
 PBrowserOrId
 ContentChild::GetBrowserOrId(TabChild* aTabChild)
 {
-    if (!aTabChild ||
-        this == aTabChild->Manager()) {
-        return PBrowserOrId(aTabChild);
-    }
-    else {
-        return PBrowserOrId(aTabChild->GetTabId());
-    }
+  if (!aTabChild ||
+    this == aTabChild->Manager()) {
+    return PBrowserOrId(aTabChild);
+  }
+  else {
+    return PBrowserOrId(aTabChild->GetTabId());
+  }
 }
 
 bool
 ContentChild::RecvUpdateWindow(const uintptr_t& aChildId)
 {
 #if defined(XP_WIN)
   NS_ASSERTION(aChildId, "Expected child hwnd value for remote plugin instance.");
   mozilla::plugins::PluginInstanceParent* parentInstance =
-    mozilla::plugins::PluginInstanceParent::LookupPluginInstanceByID(aChildId);
+  mozilla::plugins::PluginInstanceParent::LookupPluginInstanceByID(aChildId);
   NS_ASSERTION(parentInstance, "Expected matching plugin instance");
   if (parentInstance) {
-    // sync! update call to the plugin instance that forces the
-    // plugin to paint its child window.
-    parentInstance->CallUpdateWindow();
+  // sync! update call to the plugin instance that forces the
+  // plugin to paint its child window.
+  parentInstance->CallUpdateWindow();
   }
   return true;
 #else
   NS_NOTREACHED("ContentChild::RecvUpdateWindow calls unexpected on this platform.");
   return false;
 #endif
 }
 
 PContentPermissionRequestChild*
 ContentChild::AllocPContentPermissionRequestChild(const InfallibleTArray<PermissionRequest>& aRequests,
                                                   const IPC::Principal& aPrincipal,
                                                   const TabId& aTabId)
 {
-    NS_RUNTIMEABORT("unused");
-    return nullptr;
+  NS_RUNTIMEABORT("unused");
+  return nullptr;
 }
 
 bool
 ContentChild::DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor)
 {
-    nsContentPermissionUtils::NotifyRemoveContentPermissionRequestChild(actor);
-    auto child = static_cast<RemotePermissionRequest*>(actor);
-    child->IPDLRelease();
-    return true;
+  nsContentPermissionUtils::NotifyRemoveContentPermissionRequestChild(actor);
+  auto child = static_cast<RemotePermissionRequest*>(actor);
+  child->IPDLRelease();
+  return true;
 }
 
 PWebBrowserPersistDocumentChild*
 ContentChild::AllocPWebBrowserPersistDocumentChild(PBrowserChild* aBrowser,
                                                    const uint64_t& aOuterWindowID)
 {
   return new WebBrowserPersistDocumentChild();
 }
@@ -3076,22 +3084,22 @@ ContentChild::DeallocPWebBrowserPersistD
   delete aActor;
   return true;
 }
 
 bool
 ContentChild::RecvGamepadUpdate(const GamepadChangeEvent& aGamepadEvent)
 {
 #ifdef MOZ_GAMEPAD
-    RefPtr<GamepadService> svc(GamepadService::GetService());
-    if (svc) {
-        svc->Update(aGamepadEvent);
-    }
+  RefPtr<GamepadService> svc(GamepadService::GetService());
+  if (svc) {
+    svc->Update(aGamepadEvent);
+  }
 #endif
-    return true;
+  return true;
 }
 
 // This code goes here rather than nsGlobalWindow.cpp because nsGlobalWindow.cpp
 // can't include ContentChild.h since it includes windows.h.
 
 static uint64_t gNextWindowID = 0;
 
 // We use only 53 bits for the window ID so that it can be converted to and from
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -46,521 +46,608 @@ class ConsoleListener;
 class PStorageChild;
 class ClonedMessageData;
 class TabChild;
 
 class ContentChild final : public PContentChild
                          , public nsIWindowProvider
                          , public nsIContentChild
 {
-    typedef mozilla::dom::ClonedMessageData ClonedMessageData;
-    typedef mozilla::ipc::OptionalURIParams OptionalURIParams;
-    typedef mozilla::ipc::PFileDescriptorSetChild PFileDescriptorSetChild;
-    typedef mozilla::ipc::URIParams URIParams;
+  typedef mozilla::dom::ClonedMessageData ClonedMessageData;
+  typedef mozilla::ipc::OptionalURIParams OptionalURIParams;
+  typedef mozilla::ipc::PFileDescriptorSetChild PFileDescriptorSetChild;
+  typedef mozilla::ipc::URIParams URIParams;
 
 public:
-    NS_DECL_NSIWINDOWPROVIDER
+  NS_DECL_NSIWINDOWPROVIDER
 
-    ContentChild();
-    virtual ~ContentChild();
-    NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
-    NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override { return 1; }
-    NS_IMETHOD_(MozExternalRefCountType) Release(void) override { return 1; }
+  ContentChild();
+  virtual ~ContentChild();
+  NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
+  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override { return 1; }
+  NS_IMETHOD_(MozExternalRefCountType) Release(void) override { return 1; }
 
-    struct AppInfo
-    {
-        nsCString version;
-        nsCString buildID;
-        nsCString name;
-        nsCString UAName;
-        nsCString ID;
-        nsCString vendor;
-    };
+  struct AppInfo
+  {
+    nsCString version;
+    nsCString buildID;
+    nsCString name;
+    nsCString UAName;
+    nsCString ID;
+    nsCString vendor;
+  };
 
-    nsresult
-    ProvideWindowCommon(TabChild* aTabOpener,
-                        nsIDOMWindow* aOpener,
-                        bool aIframeMoz,
-                        uint32_t aChromeFlags,
-                        bool aCalledFromJS,
-                        bool aPositionSpecified,
-                        bool aSizeSpecified,
-                        nsIURI* aURI,
-                        const nsAString& aName,
-                        const nsACString& aFeatures,
-                        bool* aWindowIsNew,
-                        nsIDOMWindow** aReturn);
+  nsresult
+  ProvideWindowCommon(TabChild* aTabOpener,
+                      nsIDOMWindow* aOpener,
+                      bool aIframeMoz,
+                      uint32_t aChromeFlags,
+                      bool aCalledFromJS,
+                      bool aPositionSpecified,
+                      bool aSizeSpecified,
+                      nsIURI* aURI,
+                      const nsAString& aName,
+                      const nsACString& aFeatures,
+                      bool* aWindowIsNew,
+                      nsIDOMWindow** aReturn);
 
-    bool Init(MessageLoop* aIOLoop,
-              base::ProcessId aParentPid,
-              IPC::Channel* aChannel);
-    void InitProcessAttributes();
-    void InitXPCOM();
-    void InitGraphicsDeviceData();
+  bool Init(MessageLoop* aIOLoop,
+            base::ProcessId aParentPid,
+            IPC::Channel* aChannel);
 
-    static ContentChild* GetSingleton() {
-        return sSingleton;
-    }
+  void InitProcessAttributes();
+
+  void InitXPCOM();
+
+  void InitGraphicsDeviceData();
 
-    const AppInfo& GetAppInfo() {
-        return mAppInfo;
-    }
-    void SetProcessName(const nsAString& aName, bool aDontOverride = false);
-    void GetProcessName(nsAString& aName);
-    void GetProcessName(nsACString& aName);
-    bool IsAlive();
-    static void AppendProcessId(nsACString& aName);
+  static ContentChild* GetSingleton()
+  {
+    return sSingleton;
+  }
+
+  const AppInfo& GetAppInfo()
+  {
+    return mAppInfo;
+  }
 
-    ContentBridgeParent* GetLastBridge() {
-        MOZ_ASSERT(mLastBridge);
-        ContentBridgeParent* parent = mLastBridge;
-        mLastBridge = nullptr;
-        return parent;
-    }
-    RefPtr<ContentBridgeParent> mLastBridge;
+  void SetProcessName(const nsAString& aName, bool aDontOverride = false);
+
+  void GetProcessName(nsAString& aName) const;
 
-    PPluginModuleParent *
-    AllocPPluginModuleParent(mozilla::ipc::Transport* transport,
-                             base::ProcessId otherProcess) override;
+  void GetProcessName(nsACString& aName) const;
+
+  bool IsAlive() const;
+
+  static void AppendProcessId(nsACString& aName);
 
-    PContentBridgeParent*
-    AllocPContentBridgeParent(mozilla::ipc::Transport* transport,
-                              base::ProcessId otherProcess) override;
-    PContentBridgeChild*
-    AllocPContentBridgeChild(mozilla::ipc::Transport* transport,
-                             base::ProcessId otherProcess) override;
+  ContentBridgeParent* GetLastBridge()
+  {
+    MOZ_ASSERT(mLastBridge);
+    ContentBridgeParent* parent = mLastBridge;
+    mLastBridge = nullptr;
+    return parent;
+  }
 
-    PGMPServiceChild*
-    AllocPGMPServiceChild(mozilla::ipc::Transport* transport,
-                          base::ProcessId otherProcess) override;
+  RefPtr<ContentBridgeParent> mLastBridge;
 
-    PCompositorChild*
-    AllocPCompositorChild(mozilla::ipc::Transport* aTransport,
-                          base::ProcessId aOtherProcess) override;
+  PPluginModuleParent *
+  AllocPPluginModuleParent(mozilla::ipc::Transport* transport,
+                           base::ProcessId otherProcess) override;
 
-    PSharedBufferManagerChild*
-    AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
-                                    base::ProcessId aOtherProcess) override;
+  PContentBridgeParent*
+  AllocPContentBridgeParent(mozilla::ipc::Transport* transport,
+                            base::ProcessId otherProcess) override;
+  PContentBridgeChild*
+  AllocPContentBridgeChild(mozilla::ipc::Transport* transport,
+                           base::ProcessId otherProcess) override;
 
-    PImageBridgeChild*
-    AllocPImageBridgeChild(mozilla::ipc::Transport* aTransport,
-                           base::ProcessId aOtherProcess) override;
+  PGMPServiceChild*
+  AllocPGMPServiceChild(mozilla::ipc::Transport* transport,
+                        base::ProcessId otherProcess) override;
 
-    PProcessHangMonitorChild*
-    AllocPProcessHangMonitorChild(Transport* aTransport,
-                                  ProcessId aOtherProcess) override;
+  PCompositorChild*
+  AllocPCompositorChild(mozilla::ipc::Transport* aTransport,
+                        base::ProcessId aOtherProcess) override;
+
+  PSharedBufferManagerChild*
+  AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
+                                  base::ProcessId aOtherProcess) override;
 
-    PVRManagerChild*
-    AllocPVRManagerChild(Transport* aTransport,
-                         ProcessId aOtherProcess) override;
+  PImageBridgeChild*
+  AllocPImageBridgeChild(mozilla::ipc::Transport* aTransport,
+                         base::ProcessId aOtherProcess) override;
 
-    virtual bool RecvSetProcessSandbox(const MaybeFileDesc& aBroker) override;
+  PProcessHangMonitorChild*
+  AllocPProcessHangMonitorChild(Transport* aTransport,
+                                ProcessId aOtherProcess) override;
 
-    PBackgroundChild*
-    AllocPBackgroundChild(Transport* aTransport, ProcessId aOtherProcess)
-                          override;
+  PVRManagerChild*
+  AllocPVRManagerChild(Transport* aTransport,
+                       ProcessId aOtherProcess) override;
+
+  virtual bool RecvSetProcessSandbox(const MaybeFileDesc& aBroker) override;
 
-    virtual PBrowserChild* AllocPBrowserChild(const TabId& aTabId,
-                                              const IPCTabContext& aContext,
-                                              const uint32_t& aChromeFlags,
-                                              const ContentParentId& aCpID,
-                                              const bool& aIsForApp,
-                                              const bool& aIsForBrowser)
-                                              override;
-    virtual bool DeallocPBrowserChild(PBrowserChild*) override;
-
-    virtual PDeviceStorageRequestChild* AllocPDeviceStorageRequestChild(const DeviceStorageParams&)
-                                                                        override;
-    virtual bool DeallocPDeviceStorageRequestChild(PDeviceStorageRequestChild*)
-                                                   override;
+  PBackgroundChild*
+  AllocPBackgroundChild(Transport* aTransport, ProcessId aOtherProcess)
+                        override;
 
-    virtual PFileSystemRequestChild* AllocPFileSystemRequestChild(const FileSystemParams&)
-                                                                  override;
-    virtual bool DeallocPFileSystemRequestChild(PFileSystemRequestChild*) override;
-
-    virtual PBlobChild* AllocPBlobChild(const BlobConstructorParams& aParams)
-                                        override;
-    virtual bool DeallocPBlobChild(PBlobChild* aActor) override;
+  virtual PBrowserChild* AllocPBrowserChild(const TabId& aTabId,
+                                            const IPCTabContext& aContext,
+                                            const uint32_t& aChromeFlags,
+                                            const ContentParentId& aCpID,
+                                            const bool& aIsForApp,
+                                            const bool& aIsForBrowser)
+                                            override;
 
-    virtual PCrashReporterChild*
-    AllocPCrashReporterChild(const mozilla::dom::NativeThreadId& id,
-                             const uint32_t& processType) override;
-    virtual bool
-    DeallocPCrashReporterChild(PCrashReporterChild*) override;
+  virtual bool DeallocPBrowserChild(PBrowserChild*) override;
+
+  virtual PDeviceStorageRequestChild*
+  AllocPDeviceStorageRequestChild(const DeviceStorageParams&) override;
 
-    virtual PHalChild* AllocPHalChild() override;
-    virtual bool DeallocPHalChild(PHalChild*) override;
+  virtual bool
+  DeallocPDeviceStorageRequestChild(PDeviceStorageRequestChild*) override;
+
+  virtual PFileSystemRequestChild*
+  AllocPFileSystemRequestChild(const FileSystemParams&) override;
 
-    virtual PHeapSnapshotTempFileHelperChild* AllocPHeapSnapshotTempFileHelperChild() override;
-    virtual bool DeallocPHeapSnapshotTempFileHelperChild(PHeapSnapshotTempFileHelperChild*) override;
+  virtual bool
+  DeallocPFileSystemRequestChild(PFileSystemRequestChild*) override;
+
+  virtual PBlobChild*
+  AllocPBlobChild(const BlobConstructorParams& aParams) override;
+
+  virtual bool DeallocPBlobChild(PBlobChild* aActor) override;
 
-    PIccChild*
-    SendPIccConstructor(PIccChild* aActor, const uint32_t& aServiceId);
-    virtual PIccChild*
-    AllocPIccChild(const uint32_t& aClientId) override;
-    virtual bool
-    DeallocPIccChild(PIccChild* aActor) override;
+  virtual PCrashReporterChild*
+  AllocPCrashReporterChild(const mozilla::dom::NativeThreadId& id,
+                           const uint32_t& processType) override;
 
-    virtual PMemoryReportRequestChild*
-    AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
-                                   const bool& aAnonymize,
-                                   const bool& aMinimizeMemoryUsage,
-                                   const MaybeFileDesc& aDMDFile) override;
-    virtual bool
-    DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor) override;
+  virtual bool
+  DeallocPCrashReporterChild(PCrashReporterChild*) override;
+
+  virtual PHalChild* AllocPHalChild() override;
+  virtual bool DeallocPHalChild(PHalChild*) override;
+
+  virtual PHeapSnapshotTempFileHelperChild*
+  AllocPHeapSnapshotTempFileHelperChild() override;
 
-    virtual bool
-    RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* aChild,
-                                        const uint32_t& aGeneration,
-                                        const bool& aAnonymize,
-                                        const bool &aMinimizeMemoryUsage,
-                                        const MaybeFileDesc &aDMDFile) override;
+  virtual bool
+  DeallocPHeapSnapshotTempFileHelperChild(PHeapSnapshotTempFileHelperChild*) override;
+
+  PIccChild*
+  SendPIccConstructor(PIccChild* aActor, const uint32_t& aServiceId);
+
+  virtual PIccChild* AllocPIccChild(const uint32_t& aClientId) override;
+
+  virtual bool DeallocPIccChild(PIccChild* aActor) override;
 
-    virtual PCycleCollectWithLogsChild*
-    AllocPCycleCollectWithLogsChild(const bool& aDumpAllTraces,
-                                    const FileDescriptor& aGCLog,
-                                    const FileDescriptor& aCCLog) override;
-    virtual bool
-    DeallocPCycleCollectWithLogsChild(PCycleCollectWithLogsChild* aActor) override;
-    virtual bool
-    RecvPCycleCollectWithLogsConstructor(PCycleCollectWithLogsChild* aChild,
-                                         const bool& aDumpAllTraces,
-                                         const FileDescriptor& aGCLog,
-                                         const FileDescriptor& aCCLog) override;
+  virtual PMemoryReportRequestChild*
+  AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
+                                 const bool& aAnonymize,
+                                 const bool& aMinimizeMemoryUsage,
+                                 const MaybeFileDesc& aDMDFile) override;
 
-    virtual PWebBrowserPersistDocumentChild* AllocPWebBrowserPersistDocumentChild(PBrowserChild* aBrowser, const uint64_t& aOuterWindowID) override;
-    virtual bool RecvPWebBrowserPersistDocumentConstructor(PWebBrowserPersistDocumentChild *aActor,
-                                                           PBrowserChild *aBrowser,
-                                                           const uint64_t& aOuterWindowID) override;
-    virtual bool DeallocPWebBrowserPersistDocumentChild(PWebBrowserPersistDocumentChild* aActor) override;
+  virtual bool
+  DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor) override;
 
-    virtual bool
-    RecvDataStoreNotify(const uint32_t& aAppId, const nsString& aName,
-                        const nsString& aManifestURL) override;
+  virtual bool
+  RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* aChild,
+                                      const uint32_t& aGeneration,
+                                      const bool& aAnonymize,
+                                      const bool &aMinimizeMemoryUsage,
+                                      const MaybeFileDesc &aDMDFile) override;
 
-    virtual PTestShellChild* AllocPTestShellChild() override;
-    virtual bool DeallocPTestShellChild(PTestShellChild*) override;
-    virtual bool RecvPTestShellConstructor(PTestShellChild*) override;
-    jsipc::CPOWManager* GetCPOWManager() override;
+  virtual PCycleCollectWithLogsChild*
+  AllocPCycleCollectWithLogsChild(const bool& aDumpAllTraces,
+                                  const FileDescriptor& aGCLog,
+                                  const FileDescriptor& aCCLog) override;
+
+  virtual bool
+  DeallocPCycleCollectWithLogsChild(PCycleCollectWithLogsChild* aActor) override;
 
-    PMobileConnectionChild*
-    SendPMobileConnectionConstructor(PMobileConnectionChild* aActor,
-                                     const uint32_t& aClientId);
-    virtual PMobileConnectionChild*
-    AllocPMobileConnectionChild(const uint32_t& aClientId) override;
-    virtual bool
-    DeallocPMobileConnectionChild(PMobileConnectionChild* aActor) override;
+  virtual bool
+  RecvPCycleCollectWithLogsConstructor(PCycleCollectWithLogsChild* aChild,
+                                       const bool& aDumpAllTraces,
+                                       const FileDescriptor& aGCLog,
+                                       const FileDescriptor& aCCLog) override;
 
-    virtual PNeckoChild* AllocPNeckoChild() override;
-    virtual bool DeallocPNeckoChild(PNeckoChild*) override;
-
-    virtual PPrintingChild* AllocPPrintingChild() override;
-    virtual bool DeallocPPrintingChild(PPrintingChild*) override;
+  virtual PWebBrowserPersistDocumentChild*
+  AllocPWebBrowserPersistDocumentChild(PBrowserChild* aBrowser,
+                                       const uint64_t& aOuterWindowID) override;
 
-    virtual PScreenManagerChild*
-    AllocPScreenManagerChild(uint32_t* aNumberOfScreens,
-                             float* aSystemDefaultScale,
-                             bool* aSuccess) override;
-    virtual bool DeallocPScreenManagerChild(PScreenManagerChild*) override;
+  virtual bool
+  RecvPWebBrowserPersistDocumentConstructor(PWebBrowserPersistDocumentChild *aActor,
+                                            PBrowserChild *aBrowser,
+                                            const uint64_t& aOuterWindowID) override;
 
-    virtual PPSMContentDownloaderChild* AllocPPSMContentDownloaderChild(
-            const uint32_t& aCertType) override;
-    virtual bool DeallocPPSMContentDownloaderChild(PPSMContentDownloaderChild* aDownloader) override;
+  virtual bool
+  DeallocPWebBrowserPersistDocumentChild(PWebBrowserPersistDocumentChild* aActor) override;
+
+  virtual bool
+  RecvDataStoreNotify(const uint32_t& aAppId, const nsString& aName,
+                      const nsString& aManifestURL) override;
 
-    virtual PExternalHelperAppChild *AllocPExternalHelperAppChild(
-            const OptionalURIParams& uri,
-            const nsCString& aMimeContentType,
-            const nsCString& aContentDisposition,
-            const uint32_t& aContentDispositionHint,
-            const nsString& aContentDispositionFilename,
-            const bool& aForceSave,
-            const int64_t& aContentLength,
-            const OptionalURIParams& aReferrer,
-            PBrowserChild* aBrowser) override;
-    virtual bool DeallocPExternalHelperAppChild(PExternalHelperAppChild *aService) override;
+  virtual PTestShellChild* AllocPTestShellChild() override;
+
+  virtual bool DeallocPTestShellChild(PTestShellChild*) override;
+
+  virtual bool RecvPTestShellConstructor(PTestShellChild*) override;
 
-    virtual PHandlerServiceChild* AllocPHandlerServiceChild() override;
-    virtual bool DeallocPHandlerServiceChild(PHandlerServiceChild*) override;
+  jsipc::CPOWManager* GetCPOWManager() override;
+
+  PMobileConnectionChild*
+  SendPMobileConnectionConstructor(PMobileConnectionChild* aActor,
+                                   const uint32_t& aClientId);
+
+  virtual PMobileConnectionChild*
+  AllocPMobileConnectionChild(const uint32_t& aClientId) override;
 
-    virtual PCellBroadcastChild* AllocPCellBroadcastChild() override;
-    PCellBroadcastChild* SendPCellBroadcastConstructor(PCellBroadcastChild* aActor);
-    virtual bool DeallocPCellBroadcastChild(PCellBroadcastChild* aActor) override;
+  virtual bool
+  DeallocPMobileConnectionChild(PMobileConnectionChild* aActor) override;
 
-    virtual PSmsChild* AllocPSmsChild() override;
-    virtual bool DeallocPSmsChild(PSmsChild*) override;
+  virtual PNeckoChild* AllocPNeckoChild() override;
 
-    virtual PTelephonyChild* AllocPTelephonyChild() override;
-    virtual bool DeallocPTelephonyChild(PTelephonyChild*) override;
+  virtual bool DeallocPNeckoChild(PNeckoChild*) override;
+
+  virtual PPrintingChild* AllocPPrintingChild() override;
 
-    virtual PVoicemailChild* AllocPVoicemailChild() override;
-    PVoicemailChild* SendPVoicemailConstructor(PVoicemailChild* aActor);
-    virtual bool DeallocPVoicemailChild(PVoicemailChild*) override;
+  virtual bool DeallocPPrintingChild(PPrintingChild*) override;
 
-    virtual PMediaChild* AllocPMediaChild() override;
-    virtual bool DeallocPMediaChild(PMediaChild* aActor) override;
+  virtual PScreenManagerChild*
+  AllocPScreenManagerChild(uint32_t* aNumberOfScreens,
+                           float* aSystemDefaultScale,
+                           bool* aSuccess) override;
 
-    virtual PStorageChild* AllocPStorageChild() override;
-    virtual bool DeallocPStorageChild(PStorageChild* aActor) override;
+  virtual bool DeallocPScreenManagerChild(PScreenManagerChild*) override;
+
+  virtual PPSMContentDownloaderChild*
+  AllocPPSMContentDownloaderChild( const uint32_t& aCertType) override;
 
-    virtual PBluetoothChild* AllocPBluetoothChild() override;
-    virtual bool DeallocPBluetoothChild(PBluetoothChild* aActor) override;
-
-    virtual PFMRadioChild* AllocPFMRadioChild() override;
-    virtual bool DeallocPFMRadioChild(PFMRadioChild* aActor) override;
-
-    virtual PPresentationChild* AllocPPresentationChild() override;
-    virtual bool DeallocPPresentationChild(PPresentationChild* aActor) override;
-    virtual bool RecvNotifyPresentationReceiverLaunched(PBrowserChild* aIframe,
-                                                        const nsString& aSessionId) override;
-    virtual bool RecvNotifyPresentationReceiverCleanUp(const nsString& aSessionId) override;
+  virtual bool
+  DeallocPPSMContentDownloaderChild(PPSMContentDownloaderChild* aDownloader) override;
 
-    virtual bool RecvNotifyGMPsChanged() override;
-
-    virtual PSpeechSynthesisChild* AllocPSpeechSynthesisChild() override;
-    virtual bool DeallocPSpeechSynthesisChild(PSpeechSynthesisChild* aActor) override;
+  virtual PExternalHelperAppChild*
+  AllocPExternalHelperAppChild(const OptionalURIParams& uri,
+                               const nsCString& aMimeContentType,
+                               const nsCString& aContentDisposition,
+                               const uint32_t& aContentDispositionHint,
+                               const nsString& aContentDispositionFilename,
+                               const bool& aForceSave,
+                               const int64_t& aContentLength,
+                               const OptionalURIParams& aReferrer,
+                               PBrowserChild* aBrowser) override;
 
-    virtual bool RecvRegisterChrome(InfallibleTArray<ChromePackage>&& packages,
-                                    InfallibleTArray<SubstitutionMapping>&& resources,
-                                    InfallibleTArray<OverrideMapping>&& overrides,
-                                    const nsCString& locale,
-                                    const bool& reset) override;
-    virtual bool RecvRegisterChromeItem(const ChromeRegistryItem& item) override;
+  virtual bool
+  DeallocPExternalHelperAppChild(PExternalHelperAppChild *aService) override;
+
+  virtual PHandlerServiceChild* AllocPHandlerServiceChild() override;
+
+  virtual bool DeallocPHandlerServiceChild(PHandlerServiceChild*) override;
+
+  virtual PCellBroadcastChild* AllocPCellBroadcastChild() override;
+
+  PCellBroadcastChild* SendPCellBroadcastConstructor(PCellBroadcastChild* aActor);
 
-    virtual mozilla::jsipc::PJavaScriptChild* AllocPJavaScriptChild() override;
-    virtual bool DeallocPJavaScriptChild(mozilla::jsipc::PJavaScriptChild*) override;
-    virtual PRemoteSpellcheckEngineChild* AllocPRemoteSpellcheckEngineChild() override;
-    virtual bool DeallocPRemoteSpellcheckEngineChild(PRemoteSpellcheckEngineChild*) override;
+  virtual bool DeallocPCellBroadcastChild(PCellBroadcastChild* aActor) override;
+
+  virtual PSmsChild* AllocPSmsChild() override;
 
-    virtual bool RecvSetOffline(const bool& offline) override;
-    virtual bool RecvSetConnectivity(const bool& connectivity) override;
+  virtual bool DeallocPSmsChild(PSmsChild*) override;
 
-    virtual bool RecvSpeakerManagerNotify() override;
+  virtual PTelephonyChild* AllocPTelephonyChild() override;
+
+  virtual bool DeallocPTelephonyChild(PTelephonyChild*) override;
 
-    virtual bool RecvBidiKeyboardNotify(const bool& isLangRTL) override;
+  virtual PVoicemailChild* AllocPVoicemailChild() override;
+
+  PVoicemailChild* SendPVoicemailConstructor(PVoicemailChild* aActor);
+
+  virtual bool DeallocPVoicemailChild(PVoicemailChild*) override;
 
-    virtual bool RecvNotifyVisited(const URIParams& aURI) override;
-    // auto remove when alertfinished is received.
-    nsresult AddRemoteAlertObserver(const nsString& aData, nsIObserver* aObserver);
+  virtual PMediaChild* AllocPMediaChild() override;
 
-    virtual bool RecvSystemMemoryAvailable(const uint64_t& aGetterId,
-                                           const uint32_t& aMemoryAvailable) override;
+  virtual bool DeallocPMediaChild(PMediaChild* aActor) override;
 
-    virtual bool RecvPreferenceUpdate(const PrefSetting& aPref) override;
+  virtual PStorageChild* AllocPStorageChild() override;
 
-    virtual bool RecvDataStoragePut(const nsString& aFilename,
-                                    const DataStorageItem& aItem) override;
-    virtual bool RecvDataStorageRemove(const nsString& aFilename,
-                                       const nsCString& aKey,
-                                       const DataStorageType& aType) override;
-    virtual bool RecvDataStorageClear(const nsString& aFilename) override;
+  virtual bool DeallocPStorageChild(PStorageChild* aActor) override;
+
+  virtual PBluetoothChild* AllocPBluetoothChild() override;
 
-    virtual bool RecvNotifyAlertsObserver(const nsCString& aType,
-                                          const nsString& aData) override;
+  virtual bool DeallocPBluetoothChild(PBluetoothChild* aActor) override;
 
-    virtual bool RecvLoadProcessScript(const nsString& aURL) override;
+  virtual PFMRadioChild* AllocPFMRadioChild() override;
+
+  virtual bool DeallocPFMRadioChild(PFMRadioChild* aActor) override;
 
-    virtual bool RecvAsyncMessage(const nsString& aMsg,
-                                  const ClonedMessageData& aData,
-                                  InfallibleTArray<CpowEntry>&& aCpows,
-                                  const IPC::Principal& aPrincipal) override;
+  virtual PPresentationChild* AllocPPresentationChild() override;
+
+  virtual bool DeallocPPresentationChild(PPresentationChild* aActor) override;
 
-    virtual bool RecvGeolocationUpdate(const GeoPosition& somewhere) override;
-
-    virtual bool RecvGeolocationError(const uint16_t& errorCode) override;
+  virtual bool
+  RecvNotifyPresentationReceiverLaunched(PBrowserChild* aIframe,
+                                         const nsString& aSessionId) override;
 
-    virtual bool RecvUpdateDictionaryList(InfallibleTArray<nsString>&& aDictionaries) override;
+  virtual bool
+  RecvNotifyPresentationReceiverCleanUp(const nsString& aSessionId) override;
 
-    virtual bool RecvAddPermission(const IPC::Permission& permission) override;
+  virtual bool RecvNotifyGMPsChanged() override;
 
-    virtual bool RecvScreenSizeChanged(const gfx::IntSize &size) override;
+  virtual PSpeechSynthesisChild* AllocPSpeechSynthesisChild() override;
+
+  virtual bool DeallocPSpeechSynthesisChild(PSpeechSynthesisChild* aActor) override;
 
-    virtual bool RecvFlushMemory(const nsString& reason) override;
-
-    virtual bool RecvActivateA11y() override;
+  virtual bool RecvRegisterChrome(InfallibleTArray<ChromePackage>&& packages,
+                                  InfallibleTArray<SubstitutionMapping>&& resources,
+                                  InfallibleTArray<OverrideMapping>&& overrides,
+                                  const nsCString& locale,
+                                  const bool& reset) override;
+  virtual bool RecvRegisterChromeItem(const ChromeRegistryItem& item) override;
 
-    virtual bool RecvGarbageCollect() override;
-    virtual bool RecvCycleCollect() override;
+  virtual mozilla::jsipc::PJavaScriptChild* AllocPJavaScriptChild() override;
+
+  virtual bool DeallocPJavaScriptChild(mozilla::jsipc::PJavaScriptChild*) override;
+
+  virtual PRemoteSpellcheckEngineChild* AllocPRemoteSpellcheckEngineChild() override;
 
-    virtual bool RecvAppInfo(const nsCString& version, const nsCString& buildID,
-                             const nsCString& name, const nsCString& UAName,
-                             const nsCString& ID, const nsCString& vendor) override;
-    virtual bool RecvAppInit() override;
+  virtual bool DeallocPRemoteSpellcheckEngineChild(PRemoteSpellcheckEngineChild*) override;
 
-    virtual bool RecvLastPrivateDocShellDestroyed() override;
+  virtual bool RecvSetOffline(const bool& offline) override;
+
+  virtual bool RecvSetConnectivity(const bool& connectivity) override;
 
-    virtual bool RecvVolumes(InfallibleTArray<VolumeInfo>&& aVolumes) override;
-    virtual bool RecvFilePathUpdate(const nsString& aStorageType,
-                                    const nsString& aStorageName,
-                                    const nsString& aPath,
-                                    const nsCString& aReason) override;
-    virtual bool RecvFileSystemUpdate(const nsString& aFsName,
-                                      const nsString& aVolumeName,
-                                      const int32_t& aState,
-                                      const int32_t& aMountGeneration,
-                                      const bool& aIsMediaPresent,
-                                      const bool& aIsSharing,
-                                      const bool& aIsFormatting,
-                                      const bool& aIsFake,
-                                      const bool& aIsUnmounting,
-                                      const bool& aIsRemovable,
-                                      const bool& aIsHotSwappable) override;
-    virtual bool RecvVolumeRemoved(const nsString& aFsName) override;
+  virtual bool RecvSpeakerManagerNotify() override;
+
+  virtual bool RecvBidiKeyboardNotify(const bool& isLangRTL) override;
+
+  virtual bool RecvNotifyVisited(const URIParams& aURI) override;
+
+  // auto remove when alertfinished is received.
+  nsresult AddRemoteAlertObserver(const nsString& aData, nsIObserver* aObserver);
+
+  virtual bool RecvSystemMemoryAvailable(const uint64_t& aGetterId,
+                                         const uint32_t& aMemoryAvailable) override;
 
-    virtual bool
-    RecvNotifyProcessPriorityChanged(const hal::ProcessPriority& aPriority) override;
-    virtual bool RecvMinimizeMemoryUsage() override;
+  virtual bool RecvPreferenceUpdate(const PrefSetting& aPref) override;
+
+  virtual bool RecvDataStoragePut(const nsString& aFilename,
+                                  const DataStorageItem& aItem) override;
 
-    virtual bool RecvLoadAndRegisterSheet(const URIParams& aURI,
-                                          const uint32_t& aType) override;
-    virtual bool RecvUnregisterSheet(const URIParams& aURI, const uint32_t& aType) override;
+  virtual bool RecvDataStorageRemove(const nsString& aFilename,
+                                     const nsCString& aKey,
+                                     const DataStorageType& aType) override;
 
-    virtual bool RecvNotifyPhoneStateChange(const nsString& state) override;
+  virtual bool RecvDataStorageClear(const nsString& aFilename) override;
 
-    void AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
-    void RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
-    virtual bool RecvNotifyIdleObserver(const uint64_t& aObserver,
-                                        const nsCString& aTopic,
+  virtual bool RecvNotifyAlertsObserver(const nsCString& aType,
                                         const nsString& aData) override;
 
-    virtual bool RecvOnAppThemeChanged() override;
+  virtual bool RecvLoadProcessScript(const nsString& aURL) override;
+
+  virtual bool RecvAsyncMessage(const nsString& aMsg,
+                                const ClonedMessageData& aData,
+                                InfallibleTArray<CpowEntry>&& aCpows,
+                                const IPC::Principal& aPrincipal) override;
+
+  virtual bool RecvGeolocationUpdate(const GeoPosition& somewhere) override;
+
+  virtual bool RecvGeolocationError(const uint16_t& errorCode) override;
+
+  virtual bool RecvUpdateDictionaryList(InfallibleTArray<nsString>&& aDictionaries) override;
+
+  virtual bool RecvAddPermission(const IPC::Permission& permission) override;
+
+  virtual bool RecvScreenSizeChanged(const gfx::IntSize &size) override;
+
+  virtual bool RecvFlushMemory(const nsString& reason) override;
+
+  virtual bool RecvActivateA11y() override;
+
+  virtual bool RecvGarbageCollect() override;
+  virtual bool RecvCycleCollect() override;
 
-    virtual bool RecvAssociatePluginId(const uint32_t& aPluginId,
-                                       const base::ProcessId& aProcessId) override;
-    virtual bool RecvLoadPluginResult(const uint32_t& aPluginId,
-                                      const bool& aResult) override;
-    virtual bool RecvUpdateWindow(const uintptr_t& aChildId) override;
+  virtual bool RecvAppInfo(const nsCString& version, const nsCString& buildID,
+                           const nsCString& name, const nsCString& UAName,
+                           const nsCString& ID, const nsCString& vendor) override;
+
+  virtual bool RecvAppInit() override;
+
+  virtual bool RecvLastPrivateDocShellDestroyed() override;
+
+  virtual bool RecvVolumes(InfallibleTArray<VolumeInfo>&& aVolumes) override;
+
+  virtual bool RecvFilePathUpdate(const nsString& aStorageType,
+                                  const nsString& aStorageName,
+                                  const nsString& aPath,
+                                  const nsCString& aReason) override;
+
+  virtual bool RecvFileSystemUpdate(const nsString& aFsName,
+                                    const nsString& aVolumeName,
+                                    const int32_t& aState,
+                                    const int32_t& aMountGeneration,
+                                    const bool& aIsMediaPresent,
+                                    const bool& aIsSharing,
+                                    const bool& aIsFormatting,
+                                    const bool& aIsFake,
+                                    const bool& aIsUnmounting,
+                                    const bool& aIsRemovable,
+                                    const bool& aIsHotSwappable) override;
+
+  virtual bool RecvVolumeRemoved(const nsString& aFsName) override;
 
-    virtual bool RecvStartProfiler(const ProfilerInitParams& params) override;
-    virtual bool RecvPauseProfiler(const bool& aPause) override;
-    virtual bool RecvStopProfiler() override;
-    virtual bool RecvGatherProfile() override;
-    virtual bool RecvDomainSetChanged(const uint32_t& aSetType, const uint32_t& aChangeType,
-                                      const OptionalURIParams& aDomain) override;
-    virtual bool RecvShutdown() override;
+  virtual bool
+  RecvNotifyProcessPriorityChanged(const hal::ProcessPriority& aPriority) override;
+
+  virtual bool RecvMinimizeMemoryUsage() override;
+
+  virtual bool RecvLoadAndRegisterSheet(const URIParams& aURI,
+                                        const uint32_t& aType) override;
+
+  virtual bool RecvUnregisterSheet(const URIParams& aURI,
+                                   const uint32_t& aType) override;
+
+  virtual bool RecvNotifyPhoneStateChange(const nsString& aState) override;
+
+  void AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
+
+  void RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
+
+  virtual bool RecvNotifyIdleObserver(const uint64_t& aObserver,
+                                      const nsCString& aTopic,
+                                      const nsString& aData) override;
+
+  virtual bool RecvOnAppThemeChanged() override;
+
+  virtual bool RecvAssociatePluginId(const uint32_t& aPluginId,
+                                     const base::ProcessId& aProcessId) override;
 
-    virtual bool
-    RecvInvokeDragSession(nsTArray<IPCDataTransfer>&& aTransfers,
-                          const uint32_t& aAction) override;
-    virtual bool RecvEndDragSession(const bool& aDoneDrag,
-                                    const bool& aUserCancelled) override;
+  virtual bool RecvLoadPluginResult(const uint32_t& aPluginId,
+                                    const bool& aResult) override;
+
+  virtual bool RecvUpdateWindow(const uintptr_t& aChildId) override;
+
+  virtual bool RecvStartProfiler(const ProfilerInitParams& params) override;
+
+  virtual bool RecvPauseProfiler(const bool& aPause) override;
+
+  virtual bool RecvStopProfiler() override;
+
+  virtual bool RecvGatherProfile() override;
+
+  virtual bool RecvDomainSetChanged(const uint32_t& aSetType,
+                                    const uint32_t& aChangeType,
+                                    const OptionalURIParams& aDomain) override;
+
+  virtual bool RecvShutdown() override;
+
+  virtual bool
+  RecvInvokeDragSession(nsTArray<IPCDataTransfer>&& aTransfers,
+                        const uint32_t& aAction) override;
+
+  virtual bool RecvEndDragSession(const bool& aDoneDrag,
+                                  const bool& aUserCancelled) override;
+
 #ifdef ANDROID
-    gfx::IntSize GetScreenSize() { return mScreenSize; }
+  gfx::IntSize GetScreenSize() { return mScreenSize; }
 #endif
 
-    // Get the directory for IndexedDB files. We query the parent for this and
-    // cache the value
-    nsString &GetIndexedDBPath();
+  // Get the directory for IndexedDB files. We query the parent for this and
+  // cache the value
+  nsString &GetIndexedDBPath();
 
-    ContentParentId GetID() { return mID; }
+  ContentParentId GetID() const { return mID; }
 
-    bool IsForApp() { return mIsForApp; }
-    bool IsForBrowser() { return mIsForBrowser; }
+  bool IsForApp() const { return mIsForApp; }
+  bool IsForBrowser() const { return mIsForBrowser; }
 
-    virtual PBlobChild*
-    SendPBlobConstructor(PBlobChild* actor,
-                         const BlobConstructorParams& params) override;
+  virtual PBlobChild*
+  SendPBlobConstructor(PBlobChild* actor,
+                       const BlobConstructorParams& params) override;
 
-    virtual PFileDescriptorSetChild*
-    AllocPFileDescriptorSetChild(const FileDescriptor&) override;
+  virtual PFileDescriptorSetChild*
+  AllocPFileDescriptorSetChild(const FileDescriptor&) override;
 
-    virtual bool
-    DeallocPFileDescriptorSetChild(PFileDescriptorSetChild*) override;
+  virtual bool
+  DeallocPFileDescriptorSetChild(PFileDescriptorSetChild*) override;
 
-    virtual bool SendPBrowserConstructor(PBrowserChild* actor,
-                                         const TabId& aTabId,
-                                         const IPCTabContext& context,
-                                         const uint32_t& chromeFlags,
-                                         const ContentParentId& aCpID,
-                                         const bool& aIsForApp,
-                                         const bool& aIsForBrowser) override;
+  virtual bool SendPBrowserConstructor(PBrowserChild* actor,
+                                       const TabId& aTabId,
+                                       const IPCTabContext& context,
+                                       const uint32_t& chromeFlags,
+                                       const ContentParentId& aCpID,
+                                       const bool& aIsForApp,
+                                       const bool& aIsForBrowser) override;
 
-    virtual bool RecvPBrowserConstructor(PBrowserChild* aCctor,
-                                         const TabId& aTabId,
-                                         const IPCTabContext& aContext,
-                                         const uint32_t& aChromeFlags,
-                                         const ContentParentId& aCpID,
-                                         const bool& aIsForApp,
-                                         const bool& aIsForBrowser) override;
+  virtual bool RecvPBrowserConstructor(PBrowserChild* aCctor,
+                                       const TabId& aTabId,
+                                       const IPCTabContext& aContext,
+                                       const uint32_t& aChromeFlags,
+                                       const ContentParentId& aCpID,
+                                       const bool& aIsForApp,
+                                       const bool& aIsForBrowser) override;
 
-    void GetAvailableDictionaries(InfallibleTArray<nsString>& aDictionaries);
+  void GetAvailableDictionaries(InfallibleTArray<nsString>& aDictionaries);
 
-    PBrowserOrId
-    GetBrowserOrId(TabChild* aTabChild);
+  PBrowserOrId
+  GetBrowserOrId(TabChild* aTabChild);
 
-    virtual POfflineCacheUpdateChild* AllocPOfflineCacheUpdateChild(
-            const URIParams& manifestURI,
-            const URIParams& documentURI,
-            const PrincipalInfo& aLoadingPrincipalInfo,
-            const bool& stickDocument,
-            const TabId& aTabId) override;
-    virtual bool
-    DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* offlineCacheUpdate) override;
+  virtual POfflineCacheUpdateChild*
+  AllocPOfflineCacheUpdateChild(const URIParams& manifestURI,
+                                const URIParams& documentURI,
+                                const PrincipalInfo& aLoadingPrincipalInfo,
+                                const bool& stickDocument,
+                                const TabId& aTabId) override;
+
+  virtual bool
+  DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* offlineCacheUpdate) override;
+
+  virtual PWebrtcGlobalChild* AllocPWebrtcGlobalChild() override;
 
-    virtual PWebrtcGlobalChild* AllocPWebrtcGlobalChild() override;
-    virtual bool DeallocPWebrtcGlobalChild(PWebrtcGlobalChild *aActor) override;
+  virtual bool DeallocPWebrtcGlobalChild(PWebrtcGlobalChild *aActor) override;
 
-    virtual PContentPermissionRequestChild*
-    AllocPContentPermissionRequestChild(const InfallibleTArray<PermissionRequest>& aRequests,
-                                        const IPC::Principal& aPrincipal,
-                                        const TabId& aTabId) override;
-    virtual bool
-    DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor) override;
+  virtual PContentPermissionRequestChild*
+  AllocPContentPermissionRequestChild(const InfallibleTArray<PermissionRequest>& aRequests,
+                                      const IPC::Principal& aPrincipal,
+                                      const TabId& aTabId) override;
+  virtual bool
+  DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor) override;
 
-    virtual bool RecvGamepadUpdate(const GamepadChangeEvent& aGamepadEvent) override;
+  virtual bool RecvGamepadUpdate(const GamepadChangeEvent& aGamepadEvent) override;
 
-    virtual bool RecvTestGraphicsDeviceReset(const uint32_t& aResetReason) override;
+  virtual bool RecvTestGraphicsDeviceReset(const uint32_t& aResetReason) override;
 
 private:
-    virtual void ActorDestroy(ActorDestroyReason why) override;
+  virtual void ActorDestroy(ActorDestroyReason why) override;
 
-    virtual void ProcessingError(Result aCode, const char* aReason) override;
+  virtual void ProcessingError(Result aCode, const char* aReason) override;
 
-    /**
-     * Exit *now*.  Do not shut down XPCOM, do not pass Go, do not run
-     * static destructors, do not collect $200.
-     */
-    MOZ_NORETURN void QuickExit();
+  /**
+   * Exit *now*.  Do not shut down XPCOM, do not pass Go, do not run
+   * static destructors, do not collect $200.
+   */
+  MOZ_NORETURN void QuickExit();
 
-    InfallibleTArray<nsAutoPtr<AlertObserver> > mAlertObservers;
-    RefPtr<ConsoleListener> mConsoleListener;
+  InfallibleTArray<nsAutoPtr<AlertObserver> > mAlertObservers;
+  RefPtr<ConsoleListener> mConsoleListener;
 
-    nsTHashtable<nsPtrHashKey<nsIObserver>> mIdleObservers;
+  nsTHashtable<nsPtrHashKey<nsIObserver>> mIdleObservers;
 
-    InfallibleTArray<nsString> mAvailableDictionaries;
+  InfallibleTArray<nsString> mAvailableDictionaries;
 
-    /**
-     * An ID unique to the process containing our corresponding
-     * content parent.
-     *
-     * We expect our content parent to set this ID immediately after opening a
-     * channel to us.
-     */
-    ContentParentId mID;
+  /**
+   * An ID unique to the process containing our corresponding
+   * content parent.
+   *
+   * We expect our content parent to set this ID immediately after opening a
+   * channel to us.
+   */
+  ContentParentId mID;
 
-    AppInfo mAppInfo;
+  AppInfo mAppInfo;
 
 #ifdef ANDROID
-    gfx::IntSize mScreenSize;
+  gfx::IntSize mScreenSize;
 #endif
 
-    bool mIsForApp;
-    bool mIsForBrowser;
-    bool mCanOverrideProcessName;
-    bool mIsAlive;
-    nsString mProcessName;
+  bool mIsForApp;
+  bool mIsForBrowser;
+  bool mCanOverrideProcessName;
+  bool mIsAlive;
+  nsString mProcessName;
 
-    static ContentChild* sSingleton;
+  static ContentChild* sSingleton;
 
-    nsCOMPtr<nsIDomainPolicy> mPolicy;
+  nsCOMPtr<nsIDomainPolicy> mPolicy;
 
-    DISALLOW_EVIL_CONSTRUCTORS(ContentChild);
+  DISALLOW_EVIL_CONSTRUCTORS(ContentChild);
 };
 
 void
 InitOnContentProcessCreated();
 
 uint64_t
 NextWindowID();
 
 } // namespace dom
 } // namespace mozilla
 
-#endif
+#endif // mozilla_dom_ContentChild_h
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -308,133 +308,132 @@ using namespace mozilla::jsipc;
 using namespace mozilla::psm;
 using namespace mozilla::widget;
 
 #ifdef ENABLE_TESTS
 
 class BackgroundTester final : public nsIIPCBackgroundChildCreateCallback,
                                public nsIObserver
 {
-    static uint32_t sCallbackCount;
+  static uint32_t sCallbackCount;
 
 private:
-    ~BackgroundTester()
-    { }
-
-    virtual void
-    ActorCreated(PBackgroundChild* aActor) override
-    {
-        MOZ_RELEASE_ASSERT(aActor,
-                           "Failed to create a PBackgroundChild actor!");
-
-        NS_NAMED_LITERAL_CSTRING(testStr, "0123456789");
-
-        PBackgroundTestChild* testActor =
-            aActor->SendPBackgroundTestConstructor(testStr);
-        MOZ_RELEASE_ASSERT(testActor);
-
-        if (!sCallbackCount) {
-            PBackgroundChild* existingBackgroundChild =
-                BackgroundChild::GetForCurrentThread();
-
-            MOZ_RELEASE_ASSERT(existingBackgroundChild);
-            MOZ_RELEASE_ASSERT(existingBackgroundChild == aActor);
-
-            bool ok =
-                existingBackgroundChild->
-                    SendPBackgroundTestConstructor(testStr);
-            MOZ_RELEASE_ASSERT(ok);
-
-            // Callback 3.
-            ok = BackgroundChild::GetOrCreateForCurrentThread(this);
-            MOZ_RELEASE_ASSERT(ok);
-        }
-
-        sCallbackCount++;
-    }
-
-    virtual void
-    ActorFailed() override
-    {
-        MOZ_CRASH("Failed to create a PBackgroundChild actor!");
+  ~BackgroundTester()
+  { }
+
+  virtual void
+  ActorCreated(PBackgroundChild* aActor) override
+  {
+    MOZ_RELEASE_ASSERT(aActor,
+                       "Failed to create a PBackgroundChild actor!");
+
+    NS_NAMED_LITERAL_CSTRING(testStr, "0123456789");
+
+    PBackgroundTestChild* testActor =
+      aActor->SendPBackgroundTestConstructor(testStr);
+    MOZ_RELEASE_ASSERT(testActor);
+
+    if (!sCallbackCount) {
+      PBackgroundChild* existingBackgroundChild =
+        BackgroundChild::GetForCurrentThread();
+
+      MOZ_RELEASE_ASSERT(existingBackgroundChild);
+      MOZ_RELEASE_ASSERT(existingBackgroundChild == aActor);
+
+      bool ok =
+        existingBackgroundChild->
+          SendPBackgroundTestConstructor(testStr);
+      MOZ_RELEASE_ASSERT(ok);
+
+      // Callback 3.
+      ok = BackgroundChild::GetOrCreateForCurrentThread(this);
+      MOZ_RELEASE_ASSERT(ok);
     }
 
-    NS_IMETHOD
-    Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
-            override
-    {
-        nsCOMPtr<nsIObserverService> observerService =
-            mozilla::services::GetObserverService();
-        MOZ_RELEASE_ASSERT(observerService);
-
-        nsresult rv = observerService->RemoveObserver(this, aTopic);
+    sCallbackCount++;
+  }
+
+  virtual void
+  ActorFailed() override
+  {
+    MOZ_CRASH("Failed to create a PBackgroundChild actor!");
+  }
+
+  NS_IMETHOD
+  Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
+      override
+  {
+    nsCOMPtr<nsIObserverService> observerService =
+      mozilla::services::GetObserverService();
+    MOZ_RELEASE_ASSERT(observerService);
+
+    nsresult rv = observerService->RemoveObserver(this, aTopic);
+    MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
+
+    if (!strcmp(aTopic, "profile-after-change")) {
+      if (mozilla::Preferences::GetBool("pbackground.testing", false)) {
+        rv = observerService->AddObserver(this, "xpcom-shutdown", false);
         MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
 
-        if (!strcmp(aTopic, "profile-after-change")) {
-            if (mozilla::Preferences::GetBool("pbackground.testing", false)) {
-                rv = observerService->AddObserver(this, "xpcom-shutdown",
-                                                  false);
-                MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
-
-                // Callback 1.
-                bool ok = BackgroundChild::GetOrCreateForCurrentThread(this);
-                MOZ_RELEASE_ASSERT(ok);
-
-                BackgroundChildImpl::ThreadLocal* threadLocal =
-                  BackgroundChildImpl::GetThreadLocalForCurrentThread();
-                MOZ_RELEASE_ASSERT(threadLocal);
-
-                // Callback 2.
-                ok = BackgroundChild::GetOrCreateForCurrentThread(this);
-                MOZ_RELEASE_ASSERT(ok);
-            }
-
-            return NS_OK;
-        }
-
-        if (!strcmp(aTopic, "xpcom-shutdown")) {
-            MOZ_RELEASE_ASSERT(sCallbackCount == 3);
-
-            return NS_OK;
-        }
-
-        MOZ_CRASH("Unknown observer topic!");
+        // Callback 1.
+        bool ok = BackgroundChild::GetOrCreateForCurrentThread(this);
+        MOZ_RELEASE_ASSERT(ok);
+
+        BackgroundChildImpl::ThreadLocal* threadLocal =
+          BackgroundChildImpl::GetThreadLocalForCurrentThread();
+        MOZ_RELEASE_ASSERT(threadLocal);
+
+        // Callback 2.
+        ok = BackgroundChild::GetOrCreateForCurrentThread(this);
+        MOZ_RELEASE_ASSERT(ok);
+      }
+
+      return NS_OK;
     }
 
+    if (!strcmp(aTopic, "xpcom-shutdown")) {
+      MOZ_RELEASE_ASSERT(sCallbackCount == 3);
+
+      return NS_OK;
+    }
+
+    MOZ_CRASH("Unknown observer topic!");
+  }
+
 public:
-    NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS
 };
 
 uint32_t BackgroundTester::sCallbackCount = 0;
 
 NS_IMPL_ISUPPORTS(BackgroundTester, nsIIPCBackgroundChildCreateCallback,
                   nsIObserver)
 
 #endif // ENABLE_TESTS
 
 void
 MaybeTestPBackground()
 {
 #ifdef ENABLE_TESTS
-    // This test relies on running the event loop and XPCShell does not always
-    // do so. Bail out here if we detect that we're running in XPCShell.
-    if (PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR")) {
-        return;
-    }
-
-    // This is called too early at startup to test preferences directly. We have
-    // to install an observer to be notified when preferences are available.
-    nsCOMPtr<nsIObserverService> observerService =
-        mozilla::services::GetObserverService();
-    MOZ_RELEASE_ASSERT(observerService);
-
-    nsCOMPtr<nsIObserver> observer = new BackgroundTester();
-    nsresult rv = observerService->AddObserver(observer, "profile-after-change",
-                                               false);
-    MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
+  // This test relies on running the event loop and XPCShell does not always
+  // do so. Bail out here if we detect that we're running in XPCShell.
+  if (PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR")) {
+    return;
+  }
+
+  // This is called too early at startup to test preferences directly. We have
+  // to install an observer to be notified when preferences are available.
+  nsCOMPtr<nsIObserverService> observerService =
+    mozilla::services::GetObserverService();
+  MOZ_RELEASE_ASSERT(observerService);
+
+  nsCOMPtr<nsIObserver> observer = new BackgroundTester();
+  nsresult rv = observerService->AddObserver(observer, "profile-after-change",
+                                             false);
+  MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
 #endif
 }
 
 // XXX Workaround for bug 986973 to maintain the existing broken semantics
 template<>
 struct nsIConsoleService::COMTypeInfo<nsConsoleService, void> {
   static const nsIID kIID;
 };
@@ -449,218 +448,218 @@ bool ContentParent::sNuwaReady = false;
 #endif
 
 #define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
 #define NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC "ipc:network:set-connectivity"
 
 class MemoryReportRequestParent : public PMemoryReportRequestParent
 {
 public:
-    explicit MemoryReportRequestParent(uint32_t aGeneration);
-
-    virtual ~MemoryReportRequestParent();
-
-    virtual void ActorDestroy(ActorDestroyReason aWhy) override;
-
-    virtual bool RecvReport(const MemoryReport& aReport) override;
-    virtual bool Recv__delete__() override;
+  explicit MemoryReportRequestParent(uint32_t aGeneration);
+
+  virtual ~MemoryReportRequestParent();
+
+  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
+
+  virtual bool RecvReport(const MemoryReport& aReport) override;
+  virtual bool Recv__delete__() override;
 
 private:
-    const uint32_t mGeneration;
-    // Non-null if we haven't yet called EndProcessReport() on it.
-    RefPtr<nsMemoryReporterManager> mReporterManager;
-
-    ContentParent* Owner()
-    {
-        return static_cast<ContentParent*>(Manager());
-    }
+  const uint32_t mGeneration;
+  // Non-null if we haven't yet called EndProcessReport() on it.
+  RefPtr<nsMemoryReporterManager> mReporterManager;
+
+  ContentParent* Owner()
+  {
+    return static_cast<ContentParent*>(Manager());
+  }
 };
 
 MemoryReportRequestParent::MemoryReportRequestParent(uint32_t aGeneration)
-    : mGeneration(aGeneration)
-{
-    MOZ_COUNT_CTOR(MemoryReportRequestParent);
-    mReporterManager = nsMemoryReporterManager::GetOrCreate();
-    NS_WARN_IF(!mReporterManager);
+  : mGeneration(aGeneration)
+{
+  MOZ_COUNT_CTOR(MemoryReportRequestParent);
+  mReporterManager = nsMemoryReporterManager::GetOrCreate();
+  NS_WARN_IF(!mReporterManager);
 }
 
 bool
 MemoryReportRequestParent::RecvReport(const MemoryReport& aReport)
 {
-    if (mReporterManager) {
-        mReporterManager->HandleChildReport(mGeneration, aReport);
-    }
-    return true;
+  if (mReporterManager) {
+    mReporterManager->HandleChildReport(mGeneration, aReport);
+  }
+  return true;
 }
 
 bool
 MemoryReportRequestParent::Recv__delete__()
 {
-    // Notifying the reporter manager is done in ActorDestroy, because
-    // it needs to happen even if the child process exits mid-report.
-    // (The reporter manager will time out eventually, but let's avoid
-    // that if possible.)
-    return true;
+  // Notifying the reporter manager is done in ActorDestroy, because
+  // it needs to happen even if the child process exits mid-report.
+  // (The reporter manager will time out eventually, but let's avoid
+  // that if possible.)
+  return true;
 }
 
 void
 MemoryReportRequestParent::ActorDestroy(ActorDestroyReason aWhy)
 {
-    if (mReporterManager) {
-        mReporterManager->EndProcessReport(mGeneration, aWhy == Deletion);
-        mReporterManager = nullptr;
-    }
+  if (mReporterManager) {
+    mReporterManager->EndProcessReport(mGeneration, aWhy == Deletion);
+    mReporterManager = nullptr;
+  }
 }
 
 MemoryReportRequestParent::~MemoryReportRequestParent()
 {
-    MOZ_ASSERT(!mReporterManager);
-    MOZ_COUNT_DTOR(MemoryReportRequestParent);
+  MOZ_ASSERT(!mReporterManager);
+  MOZ_COUNT_DTOR(MemoryReportRequestParent);
 }
 
 // IPC receiver for remote GC/CC logging.
 class CycleCollectWithLogsParent final : public PCycleCollectWithLogsParent
 {
 public:
-    ~CycleCollectWithLogsParent()
-    {
-        MOZ_COUNT_DTOR(CycleCollectWithLogsParent);
+  ~CycleCollectWithLogsParent()
+  {
+    MOZ_COUNT_DTOR(CycleCollectWithLogsParent);
+  }
+
+  static bool AllocAndSendConstructor(ContentParent* aManager,
+                                      bool aDumpAllTraces,
+                                      nsICycleCollectorLogSink* aSink,
+                                      nsIDumpGCAndCCLogsCallback* aCallback)
+  {
+    CycleCollectWithLogsParent *actor;
+    FILE* gcLog;
+    FILE* ccLog;
+    nsresult rv;
+
+    actor = new CycleCollectWithLogsParent(aSink, aCallback);
+    rv = actor->mSink->Open(&gcLog, &ccLog);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      delete actor;
+      return false;
     }
 
-    static bool AllocAndSendConstructor(ContentParent* aManager,
-                                        bool aDumpAllTraces,
-                                        nsICycleCollectorLogSink* aSink,
-                                        nsIDumpGCAndCCLogsCallback* aCallback)
-    {
-        CycleCollectWithLogsParent *actor;
-        FILE* gcLog;
-        FILE* ccLog;
-        nsresult rv;
-
-        actor = new CycleCollectWithLogsParent(aSink, aCallback);
-        rv = actor->mSink->Open(&gcLog, &ccLog);
-        if (NS_WARN_IF(NS_FAILED(rv))) {
-            delete actor;
-            return false;
-        }
-
-        return aManager->
-            SendPCycleCollectWithLogsConstructor(actor,
-                                                 aDumpAllTraces,
-                                                 FILEToFileDescriptor(gcLog),
-                                                 FILEToFileDescriptor(ccLog));
-    }
+    return aManager->
+      SendPCycleCollectWithLogsConstructor(actor,
+                                           aDumpAllTraces,
+                                           FILEToFileDescriptor(gcLog),
+                                           FILEToFileDescriptor(ccLog));
+  }
 
 private:
-    virtual bool RecvCloseGCLog() override
-    {
-        Unused << mSink->CloseGCLog();
-        return true;
-    }
-
-    virtual bool RecvCloseCCLog() override
-    {
-        Unused << mSink->CloseCCLog();
-        return true;
-    }
-
-    virtual bool Recv__delete__() override
-    {
-        // Report completion to mCallback only on successful
-        // completion of the protocol.
-        nsCOMPtr<nsIFile> gcLog, ccLog;
-        mSink->GetGcLog(getter_AddRefs(gcLog));
-        mSink->GetCcLog(getter_AddRefs(ccLog));
-        Unused << mCallback->OnDump(gcLog, ccLog, /* parent = */ false);
-        return true;
-    }
-
-    virtual void ActorDestroy(ActorDestroyReason aReason) override
-    {
-        // If the actor is unexpectedly destroyed, we deliberately
-        // don't call Close[GC]CLog on the sink, because the logs may
-        // be incomplete.  See also the nsCycleCollectorLogSinkToFile
-        // implementaiton of those methods, and its destructor.
-    }
-
-    CycleCollectWithLogsParent(nsICycleCollectorLogSink *aSink,
-                               nsIDumpGCAndCCLogsCallback *aCallback)
-        : mSink(aSink), mCallback(aCallback)
-    {
-        MOZ_COUNT_CTOR(CycleCollectWithLogsParent);
-    }
-
-    nsCOMPtr<nsICycleCollectorLogSink> mSink;
-    nsCOMPtr<nsIDumpGCAndCCLogsCallback> mCallback;
+  virtual bool RecvCloseGCLog() override
+  {
+    Unused << mSink->CloseGCLog();
+    return true;
+  }
+
+  virtual bool RecvCloseCCLog() override
+  {
+    Unused << mSink->CloseCCLog();
+    return true;
+  }
+
+  virtual bool Recv__delete__() override
+  {
+    // Report completion to mCallback only on successful
+    // completion of the protocol.
+    nsCOMPtr<nsIFile> gcLog, ccLog;
+    mSink->GetGcLog(getter_AddRefs(gcLog));
+    mSink->GetCcLog(getter_AddRefs(ccLog));
+    Unused << mCallback->OnDump(gcLog, ccLog, /* parent = */ false);
+    return true;
+  }
+
+  virtual void ActorDestroy(ActorDestroyReason aReason) override
+  {
+    // If the actor is unexpectedly destroyed, we deliberately
+    // don't call Close[GC]CLog on the sink, because the logs may
+    // be incomplete.  See also the nsCycleCollectorLogSinkToFile
+    // implementaiton of those methods, and its destructor.
+  }
+
+  CycleCollectWithLogsParent(nsICycleCollectorLogSink *aSink,
+                             nsIDumpGCAndCCLogsCallback *aCallback)
+    : mSink(aSink), mCallback(aCallback)
+  {
+    MOZ_COUNT_CTOR(CycleCollectWithLogsParent);
+  }
+
+  nsCOMPtr<nsICycleCollectorLogSink> mSink;
+  nsCOMPtr<nsIDumpGCAndCCLogsCallback> mCallback;
 };
 
 // A memory reporter for ContentParent objects themselves.
 class ContentParentsMemoryReporter final : public nsIMemoryReporter
 {
-    ~ContentParentsMemoryReporter() {}
+  ~ContentParentsMemoryReporter() {}
 public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIMEMORYREPORTER
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIMEMORYREPORTER
 };
 
 NS_IMPL_ISUPPORTS(ContentParentsMemoryReporter, nsIMemoryReporter)
 
 NS_IMETHODIMP
 ContentParentsMemoryReporter::CollectReports(nsIMemoryReporterCallback* cb,
                                              nsISupports* aClosure,
                                              bool aAnonymize)
 {
-    nsAutoTArray<ContentParent*, 16> cps;
-    ContentParent::GetAllEvenIfDead(cps);
-
-    for (uint32_t i = 0; i < cps.Length(); i++) {
-        ContentParent* cp = cps[i];
-        MessageChannel* channel = cp->GetIPCChannel();
-
-        nsString friendlyName;
-        cp->FriendlyName(friendlyName, aAnonymize);
-
-        cp->AddRef();
-        nsrefcnt refcnt = cp->Release();
-
-        const char* channelStr = "no channel";
-        uint32_t numQueuedMessages = 0;
-        if (channel) {
-            if (channel->Unsound_IsClosed()) {
-                channelStr = "closed channel";
-            } else {
-                channelStr = "open channel";
-            }
-            numQueuedMessages = channel->Unsound_NumQueuedMessages();
-        }
-
-        nsPrintfCString path("queued-ipc-messages/content-parent"
-                             "(%s, pid=%d, %s, 0x%p, refcnt=%d)",
-                             NS_ConvertUTF16toUTF8(friendlyName).get(),
-                             cp->Pid(), channelStr,
-                             static_cast<nsIContentParent*>(cp), refcnt);
-
-        NS_NAMED_LITERAL_CSTRING(desc,
-            "The number of unset IPC messages held in this ContentParent's "
-            "channel.  A large value here might indicate that we're leaking "
-            "messages.  Similarly, a ContentParent object for a process that's no "
-            "longer running could indicate that we're leaking ContentParents.");
-
-        nsresult rv = cb->Callback(/* process */ EmptyCString(),
-                                   path,
-                                   KIND_OTHER,
-                                   UNITS_COUNT,
-                                   numQueuedMessages,
-                                   desc,
-                                   aClosure);
-
-        NS_ENSURE_SUCCESS(rv, rv);
+  nsAutoTArray<ContentParent*, 16> cps;
+  ContentParent::GetAllEvenIfDead(cps);
+
+  for (uint32_t i = 0; i < cps.Length(); i++) {
+    ContentParent* cp = cps[i];
+    MessageChannel* channel = cp->GetIPCChannel();
+
+    nsString friendlyName;
+    cp->FriendlyName(friendlyName, aAnonymize);
+
+    cp->AddRef();
+    nsrefcnt refcnt = cp->Release();
+
+    const char* channelStr = "no channel";
+    uint32_t numQueuedMessages = 0;
+    if (channel) {
+      if (channel->Unsound_IsClosed()) {
+        channelStr = "closed channel";
+      } else {
+        channelStr = "open channel";
+      }
+      numQueuedMessages = channel->Unsound_NumQueuedMessages();
     }
 
-    return NS_OK;
+    nsPrintfCString path("queued-ipc-messages/content-parent"
+                         "(%s, pid=%d, %s, 0x%p, refcnt=%d)",
+                         NS_ConvertUTF16toUTF8(friendlyName).get(),
+                         cp->Pid(), channelStr,
+                         static_cast<nsIContentParent*>(cp), refcnt);
+
+    NS_NAMED_LITERAL_CSTRING(desc,
+      "The number of unset IPC messages held in this ContentParent's "
+      "channel.  A large value here might indicate that we're leaking "
+      "messages.  Similarly, a ContentParent object for a process that's no "
+      "longer running could indicate that we're leaking ContentParents.");
+
+    nsresult rv = cb->Callback(/* process */ EmptyCString(),
+                               path,
+                               KIND_OTHER,
+                               UNITS_COUNT,
+                               numQueuedMessages,
+                               desc,
+                               aClosure);
+
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
+  return NS_OK;
 }
 
 nsDataHashtable<nsStringHashKey, ContentParent*>* ContentParent::sAppContentParents;
 nsTArray<ContentParent*>* ContentParent::sNonAppContentParents;
 nsTArray<ContentParent*>* ContentParent::sPrivateContent;
 StaticAutoPtr<LinkedList<ContentParent> > ContentParent::sContentParents;
 #if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
 UniquePtr<SandboxBrokerPolicyFactory> ContentParent::sSandboxBrokerPolicyFactory;
@@ -683,341 +682,339 @@ static bool sDisableUnsafeCPOWWarnings =
 static uint64_t gContentChildID = 1;
 
 // We want the prelaunched process to know that it's for apps, but not
 // actually for any app in particular.  Use a magic manifest URL.
 // Can't be a static constant.
 #define MAGIC_PREALLOCATED_APP_MANIFEST_URL NS_LITERAL_STRING("{{template}}")
 
 static const char* sObserverTopics[] = {
-    "xpcom-shutdown",
-    "profile-before-change",
-    NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC,
-    NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC,
-    "memory-pressure",
-    "child-gc-request",
-    "child-cc-request",
-    "child-mmu-request",
-    "last-pb-context-exited",
-    "file-watcher-update",
+  "xpcom-shutdown",
+  "profile-before-change",
+  NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC,
+  NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC,
+  "memory-pressure",
+  "child-gc-request",
+  "child-cc-request",
+  "child-mmu-request",
+  "last-pb-context-exited",
+  "file-watcher-update",
 #ifdef MOZ_WIDGET_GONK
-    NS_VOLUME_STATE_CHANGED,
-    NS_VOLUME_REMOVED,
-    "phone-state-changed",
+  NS_VOLUME_STATE_CHANGED,
+  NS_VOLUME_REMOVED,
+  "phone-state-changed",
 #endif
 #ifdef ACCESSIBILITY
-    "a11y-init-or-shutdown",
+  "a11y-init-or-shutdown",
 #endif
-    "app-theme-changed",
+  "app-theme-changed",
 #ifdef MOZ_ENABLE_PROFILER_SPS
-    "profiler-started",
-    "profiler-stopped",
-    "profiler-paused",
-    "profiler-resumed",
-    "profiler-subprocess-gather",
-    "profiler-subprocess",
+  "profiler-started",
+  "profiler-stopped",
+  "profiler-paused",
+  "profiler-resumed",
+  "profiler-subprocess-gather",
+  "profiler-subprocess",
 #endif
-    "gmp-changed",
+  "gmp-changed",
 };
 
 #ifdef MOZ_NUWA_PROCESS
 // Contains the observer topics that can be sent to the Nuwa process after it
 // becomes ready. The ContentParent instance will unregister sObserverTopics
 // if not listed in sNuwaSafeObserverTopics.
 static const char* sNuwaSafeObserverTopics[] = {
-    "xpcom-shutdown",
-    "profile-before-change",
+  "xpcom-shutdown",
+  "profile-before-change",
 #ifdef MOZ_WIDGET_GONK
-    "phone-state-changed",
+  "phone-state-changed",
 #endif
 #ifdef ACCESSIBILITY
-    "a11y-init-or-shutdown",
+  "a11y-init-or-shutdown",
 #endif
-    "nsPref:Changed"
+  "nsPref:Changed"
 };
 #endif
 /* static */ already_AddRefed<ContentParent>
 ContentParent::RunNuwaProcess()
 {
-    MOZ_ASSERT(NS_IsMainThread());
-    RefPtr<ContentParent> nuwaProcess =
-        new ContentParent(/* aApp = */ nullptr,
-                          /* aOpener = */ nullptr,
-                          /* aIsForBrowser = */ false,
-                          /* aIsForPreallocated = */ true,
-                          /* aIsNuwaProcess = */ true);
-
-    if (!nuwaProcess->LaunchSubprocess(PROCESS_PRIORITY_BACKGROUND)) {
-        return nullptr;
-    }
-
-    nuwaProcess->Init();
+  MOZ_ASSERT(NS_IsMainThread());
+  RefPtr<ContentParent> nuwaProcess =
+    new ContentParent(/* aApp = */ nullptr,
+                      /* aOpener = */ nullptr,
+                      /* aIsForBrowser = */ false,
+                      /* aIsForPreallocated = */ true,
+                      /* aIsNuwaProcess = */ true);
+
+  if (!nuwaProcess->LaunchSubprocess(PROCESS_PRIORITY_BACKGROUND)) {
+    return nullptr;
+  }
+
+  nuwaProcess->Init();
 #ifdef MOZ_NUWA_PROCESS
-    sNuwaPid = nuwaProcess->Pid();
-    sNuwaReady = false;
+  sNuwaPid = nuwaProcess->Pid();
+  sNuwaReady = false;
 #endif
-    return nuwaProcess.forget();
+  return nuwaProcess.forget();
 }
 
 // PreallocateAppProcess is called by the PreallocatedProcessManager.
 // ContentParent then takes this process back within
 // GetNewOrPreallocatedAppProcess.
 /*static*/ already_AddRefed<ContentParent>
 ContentParent::PreallocateAppProcess()
 {
-    RefPtr<ContentParent> process =
-        new ContentParent(/* app = */ nullptr,
-                          /* aOpener = */ nullptr,
-                          /* isForBrowserElement = */ false,
-                          /* isForPreallocated = */ true);
-
-    if (!process->LaunchSubprocess(PROCESS_PRIORITY_PREALLOC)) {
-        return nullptr;
-    }
-
-    process->Init();
-    return process.forget();
+  RefPtr<ContentParent> process =
+    new ContentParent(/* app = */ nullptr,
+                      /* aOpener = */ nullptr,
+                      /* isForBrowserElement = */ false,
+                      /* isForPreallocated = */ true);
+
+  if (!process->LaunchSubprocess(PROCESS_PRIORITY_PREALLOC)) {
+    return nullptr;
+  }
+
+  process->Init();
+  return process.forget();
 }
 
 /*static*/ already_AddRefed<ContentParent>
 ContentParent::GetNewOrPreallocatedAppProcess(mozIApplication* aApp,
                                               ProcessPriority aInitialPriority,
                                               ContentParent* aOpener,
                                               /*out*/ bool* aTookPreAllocated)
 {
-    MOZ_ASSERT(aApp);
-    RefPtr<ContentParent> process = PreallocatedProcessManager::Take();
-
-    if (process) {
-        if (!process->SetPriorityAndCheckIsAlive(aInitialPriority)) {
-            // Kill the process just in case it's not actually dead; we don't want
-            // to "leak" this process!
-            process->KillHard("GetNewOrPreallocatedAppProcess");
-        }
-        else {
-            nsAutoString manifestURL;
-            if (NS_FAILED(aApp->GetManifestURL(manifestURL))) {
-                NS_ERROR("Failed to get manifest URL");
-                return nullptr;
-            }
-            process->TransformPreallocatedIntoApp(aOpener,
-                                                  manifestURL);
-            process->ForwardKnownInfo();
-
-            if (aTookPreAllocated) {
-                *aTookPreAllocated = true;
-            }
-            return process.forget();
-        }
+  MOZ_ASSERT(aApp);
+  RefPtr<ContentParent> process = PreallocatedProcessManager::Take();
+
+  if (process) {
+    if (!process->SetPriorityAndCheckIsAlive(aInitialPriority)) {
+      // Kill the process just in case it's not actually dead; we don't want
+      // to "leak" this process!
+      process->KillHard("GetNewOrPreallocatedAppProcess");
+    }
+    else {
+      nsAutoString manifestURL;
+      if (NS_FAILED(aApp->GetManifestURL(manifestURL))) {
+        NS_ERROR("Failed to get manifest URL");
+        return nullptr;
+      }
+      process->TransformPreallocatedIntoApp(aOpener, manifestURL);
+      process->ForwardKnownInfo();
+
+      if (aTookPreAllocated) {
+        *aTookPreAllocated = true;
+      }
+      return process.forget();
     }
-
-    // XXXkhuey Nuwa wants the frame loader to try again later, but the
-    // frame loader is really not set up to do that ...
-    NS_WARNING("Unable to use pre-allocated app process");
-    process = new ContentParent(aApp,
-                                /* aOpener = */ aOpener,
-                                /* isForBrowserElement = */ false,
-                                /* isForPreallocated = */ false);
-
-    if (!process->LaunchSubprocess(aInitialPriority)) {
-        return nullptr;
-    }
-
-    process->Init();
-    process->ForwardKnownInfo();
-
-    if (aTookPreAllocated) {
-        *aTookPreAllocated = false;
-    }
-
-    return process.forget();
+  }
+
+  // XXXkhuey Nuwa wants the frame loader to try again later, but the
+  // frame loader is really not set up to do that ...
+  NS_WARNING("Unable to use pre-allocated app process");
+  process = new ContentParent(aApp,
+                              /* aOpener = */ aOpener,
+                              /* isForBrowserElement = */ false,
+                              /* isForPreallocated = */ false);
+
+  if (!process->LaunchSubprocess(aInitialPriority)) {
+    return nullptr;
+  }
+
+  process->Init();
+  process->ForwardKnownInfo();
+
+  if (aTookPreAllocated) {
+    *aTookPreAllocated = false;
+  }
+
+  return process.forget();
 }
 
 /*static*/ void
 ContentParent::StartUp()
 {
-    // We could launch sub processes from content process
-    // FIXME Bug 1023701 - Stop using ContentParent static methods in
-    // child process
-    sCanLaunchSubprocesses = true;
-
-    if (!XRE_IsParentProcess()) {
-        return;
-    }
+  // We could launch sub processes from content process
+  // FIXME Bug 1023701 - Stop using ContentParent static methods in
+  // child process
+  sCanLaunchSubprocesses = true;
+
+  if (!XRE_IsParentProcess()) {
+    return;
+  }
 
 #if defined(MOZ_CONTENT_SANDBOX) && defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 19
-    // Require sandboxing on B2G >= KitKat.  This condition must stay
-    // in sync with ContentChild::RecvSetProcessSandbox.
-    if (!SandboxInfo::Get().CanSandboxContent()) {
-        // MOZ_CRASH strings are only for debug builds; make sure the
-        // message is clear on non-debug builds as well:
-        printf_stderr("Sandboxing support is required on this platform.  "
-                      "Recompile kernel with CONFIG_SECCOMP_FILTER=y\n");
-        MOZ_CRASH("Sandboxing support is required on this platform.");
-    }
+  // Require sandboxing on B2G >= KitKat.  This condition must stay
+  // in sync with ContentChild::RecvSetProcessSandbox.
+  if (!SandboxInfo::Get().CanSandboxContent()) {
+    // MOZ_CRASH strings are only for debug builds; make sure the
+    // message is clear on non-debug builds as well:
+    printf_stderr("Sandboxing support is required on this platform.  "
+                  "Recompile kernel with CONFIG_SECCOMP_FILTER=y\n");
+    MOZ_CRASH("Sandboxing support is required on this platform.");
+  }
 #endif
 
-    // Note: This reporter measures all ContentParents.
-    RegisterStrongMemoryReporter(new ContentParentsMemoryReporter());
-
-    mozilla::dom::time::InitializeDateCacheCleaner();
-
-    BlobParent::Startup(BlobParent::FriendKey());
-
-    BackgroundChild::Startup();
-
-    // Try to preallocate a process that we can transform into an app later.
-    PreallocatedProcessManager::AllocateAfterDelay();
-
-    // Test the PBackground infrastructure on ENABLE_TESTS builds when a special
-    // testing preference is set.
-    MaybeTestPBackground();
-
-    sDisableUnsafeCPOWWarnings = PR_GetEnv("DISABLE_UNSAFE_CPOW_WARNINGS");
+  // Note: This reporter measures all ContentParents.
+  RegisterStrongMemoryReporter(new ContentParentsMemoryReporter());
+
+  mozilla::dom::time::InitializeDateCacheCleaner();
+
+  BlobParent::Startup(BlobParent::FriendKey());
+
+  BackgroundChild::Startup();
+
+  // Try to preallocate a process that we can transform into an app later.
+  PreallocatedProcessManager::AllocateAfterDelay();
+
+  // Test the PBackground infrastructure on ENABLE_TESTS builds when a special
+  // testing preference is set.
+  MaybeTestPBackground();
+
+  sDisableUnsafeCPOWWarnings = PR_GetEnv("DISABLE_UNSAFE_CPOW_WARNINGS");
 
 #if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
-    sSandboxBrokerPolicyFactory = MakeUnique<SandboxBrokerPolicyFactory>();
+  sSandboxBrokerPolicyFactory = MakeUnique<SandboxBrokerPolicyFactory>();
 #endif
 }
 
 /*static*/ void
 ContentParent::ShutDown()
 {
-    // No-op for now.  We rely on normal process shutdown and
-    // ClearOnShutdown() to clean up our state.
-    sCanLaunchSubprocesses = false;
+  // No-op for now.  We rely on normal process shutdown and
+  // ClearOnShutdown() to clean up our state.
+  sCanLaunchSubprocesses = false;
 
 #if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
-    sSandboxBrokerPolicyFactory = nullptr;
+  sSandboxBrokerPolicyFactory = nullptr;
 #endif
 }
 
 /*static*/ void
 ContentParent::JoinProcessesIOThread(const nsTArray<ContentParent*>* aProcesses,
                                      Monitor* aMonitor, bool* aDone)
 {
-    const nsTArray<ContentParent*>& processes = *aProcesses;
-    for (uint32_t i = 0; i < processes.Length(); ++i) {
-        if (GeckoChildProcessHost* process = processes[i]->mSubprocess) {
-            process->Join();
-        }
+  const nsTArray<ContentParent*>& processes = *aProcesses;
+  for (uint32_t i = 0; i < processes.Length(); ++i) {
+    if (GeckoChildProcessHost* process = processes[i]->mSubprocess) {
+      process->Join();
     }
-    {
-        MonitorAutoLock lock(*aMonitor);
-        *aDone = true;
-        lock.Notify();
-    }
-    // Don't touch any arguments to this function from now on.
+  }
+  {
+    MonitorAutoLock lock(*aMonitor);
+    *aDone = true;
+    lock.Notify();
+  }
+  // Don't touch any arguments to this function from now on.
 }
 
 /*static*/ void
 ContentParent::JoinAllSubprocesses()
 {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    nsAutoTArray<ContentParent*, 8> processes;
-    GetAll(processes);
-    if (processes.IsEmpty()) {
-        printf_stderr("There are no live subprocesses.");
-        return;
+  MOZ_ASSERT(NS_IsMainThread());
+
+  nsAutoTArray<ContentParent*, 8> processes;
+  GetAll(processes);
+  if (processes.IsEmpty()) {
+    printf_stderr("There are no live subprocesses.");
+    return;
+  }
+
+  printf_stderr("Subprocesses are still alive.  Doing emergency join.\n");
+
+  bool done = false;
+  Monitor monitor("mozilla.dom.ContentParent.JoinAllSubprocesses");
+  XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
+                                   NewRunnableFunction(
+                                     &ContentParent::JoinProcessesIOThread,
+                                     &processes, &monitor, &done));
+  {
+    MonitorAutoLock lock(monitor);
+    while (!done) {
+      lock.Wait();
     }
-
-    printf_stderr("Subprocesses are still alive.  Doing emergency join.\n");
-
-    bool done = false;
-    Monitor monitor("mozilla.dom.ContentParent.JoinAllSubprocesses");
-    XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
-                                     NewRunnableFunction(
-                                         &ContentParent::JoinProcessesIOThread,
-                                         &processes, &monitor, &done));
-    {
-        MonitorAutoLock lock(monitor);
-        while (!done) {
-            lock.Wait();
-        }
-    }
-
-    sCanLaunchSubprocesses = false;
+  }
+
+  sCanLaunchSubprocesses = false;
 }
 
 /*static*/ already_AddRefed<ContentParent>
 ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
                                           ProcessPriority aPriority,
                                           ContentParent* aOpener)
 {
-    if (!sNonAppContentParents)
-        sNonAppContentParents = new nsTArray<ContentParent*>();
-
-    int32_t maxContentProcesses = Preferences::GetInt("dom.ipc.processCount", 1);
-    if (maxContentProcesses < 1)
-        maxContentProcesses = 1;
-
-    if (sNonAppContentParents->Length() >= uint32_t(maxContentProcesses)) {
-      uint32_t startIdx = rand() % sNonAppContentParents->Length();
-      uint32_t currIdx = startIdx;
-      do {
-        RefPtr<ContentParent> p = (*sNonAppContentParents)[currIdx];
-        NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in sNonAppContntParents?");
-        if (p->mOpener == aOpener) {
-          return p.forget();
-        }
-        currIdx = (currIdx + 1) % sNonAppContentParents->Length();
-      } while (currIdx != startIdx);
+  if (!sNonAppContentParents)
+    sNonAppContentParents = new nsTArray<ContentParent*>();
+
+  int32_t maxContentProcesses = Preferences::GetInt("dom.ipc.processCount", 1);
+  if (maxContentProcesses < 1)
+    maxContentProcesses = 1;
+
+  if (sNonAppContentParents->Length() >= uint32_t(maxContentProcesses)) {
+    uint32_t startIdx = rand() % sNonAppContentParents->Length();
+    uint32_t currIdx = startIdx;
+    do {
+    RefPtr<ContentParent> p = (*sNonAppContentParents)[currIdx];
+    NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in sNonAppContntParents?");
+    if (p->mOpener == aOpener) {
+      return p.forget();
     }
-
-    // Try to take and transform the preallocated process into browser.
-    RefPtr<ContentParent> p = PreallocatedProcessManager::Take();
-    if (p) {
-        p->TransformPreallocatedIntoBrowser(aOpener);
-    } else {
-      // Failed in using the preallocated process: fork from the chrome process.
-        p = new ContentParent(/* app = */ nullptr,
-                              aOpener,
-                              aForBrowserElement,
-                              /* isForPreallocated = */ false);
-
-        if (!p->LaunchSubprocess(aPriority)) {
-            return nullptr;
-        }
-
-        p->Init();
+    currIdx = (currIdx + 1) % sNonAppContentParents->Length();
+    } while (currIdx != startIdx);
+  }
+
+  // Try to take and transform the preallocated process into browser.
+  RefPtr<ContentParent> p = PreallocatedProcessManager::Take();
+  if (p) {
+    p->TransformPreallocatedIntoBrowser(aOpener);
+  } else {
+    // Failed in using the preallocated process: fork from the chrome process.
+    p = new ContentParent(/* app = */ nullptr,
+                          aOpener,
+                          aForBrowserElement,
+                           /* isForPreallocated = */ false);
+
+    if (!p->LaunchSubprocess(aPriority)) {
+      return nullptr;
     }
-    p->ForwardKnownInfo();
-
-    sNonAppContentParents->AppendElement(p);
-    return p.forget();
+
+    p->Init();
+  }
+  p->ForwardKnownInfo();
+
+  sNonAppContentParents->AppendElement(p);
+  return p.forget();
 }
 
 /*static*/ ProcessPriority
 ContentParent::GetInitialProcessPriority(Element* aFrameElement)
 {
-    // Frames with mozapptype == critical which are expecting a system message
-    // get FOREGROUND_HIGH priority.
-
-    if (!aFrameElement) {
-        return PROCESS_PRIORITY_FOREGROUND;
-    }
-
-    if (aFrameElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozapptype,
-                                   NS_LITERAL_STRING("inputmethod"), eCaseMatters)) {
-        return PROCESS_PRIORITY_FOREGROUND_KEYBOARD;
-    } else if (!aFrameElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozapptype,
-                                           NS_LITERAL_STRING("critical"), eCaseMatters)) {
-        return PROCESS_PRIORITY_FOREGROUND;
-    }
-
-    nsCOMPtr<nsIMozBrowserFrame> browserFrame =
-        do_QueryInterface(aFrameElement);
-    if (!browserFrame) {
-        return PROCESS_PRIORITY_FOREGROUND;
-    }
-
-    return browserFrame->GetIsExpectingSystemMessage() ?
-               PROCESS_PRIORITY_FOREGROUND_HIGH :
-               PROCESS_PRIORITY_FOREGROUND;
+  // Frames with mozapptype == critical which are expecting a system message
+  // get FOREGROUND_HIGH priority.
+
+  if (!aFrameElement) {
+    return PROCESS_PRIORITY_FOREGROUND;
+  }
+
+  if (aFrameElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozapptype,
+                                 NS_LITERAL_STRING("inputmethod"), eCaseMatters)) {
+    return PROCESS_PRIORITY_FOREGROUND_KEYBOARD;
+  } else if (!aFrameElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozapptype,
+                                        NS_LITERAL_STRING("critical"), eCaseMatters)) {
+    return PROCESS_PRIORITY_FOREGROUND;
+  }
+
+  nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(aFrameElement);
+  if (!browserFrame) {
+    return PROCESS_PRIORITY_FOREGROUND;
+  }
+
+  return browserFrame->GetIsExpectingSystemMessage() ?
+           PROCESS_PRIORITY_FOREGROUND_HIGH :
+           PROCESS_PRIORITY_FOREGROUND;
 }
 
 #if defined(XP_WIN)
 extern const wchar_t* kPluginWidgetContentParentProperty;
 
 /*static*/ void
 ContentParent::SendAsyncUpdate(nsIWidget* aWidget)
 {
@@ -1034,1006 +1031,994 @@ ContentParent::SendAsyncUpdate(nsIWidget
   }
 }
 #endif // defined(XP_WIN)
 
 bool
 ContentParent::PreallocatedProcessReady()
 {
 #ifdef MOZ_NUWA_PROCESS
-    return PreallocatedProcessManager::PreallocatedProcessReady();
+  return PreallocatedProcessManager::PreallocatedProcessReady();
 #else
-    return true;
+  return true;
 #endif
 }
 
 bool
 ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
                                       const hal::ProcessPriority& aPriority,
                                       const TabId& aOpenerTabId,
                                       ContentParentId* aCpId,
                                       bool* aIsForApp,
                                       bool* aIsForBrowser,
                                       TabId* aTabId)
 {
 #if 0
-    if (!CanOpenBrowser(aContext)) {
-        return false;
-    }
+  if (!CanOpenBrowser(aContext)) {
+      return false;
+  }
 #endif
-    RefPtr<ContentParent> cp;
-    MaybeInvalidTabContext tc(aContext);
-    if (!tc.IsValid()) {
-        NS_ERROR(nsPrintfCString("Received an invalid TabContext from "
-                                 "the child process. (%s)",
-                                 tc.GetInvalidReason()).get());
-        return false;
-    }
-
-    nsCOMPtr<mozIApplication> ownApp = tc.GetTabContext().GetOwnApp();
-    if (ownApp) {
-        cp = GetNewOrPreallocatedAppProcess(ownApp,
-                                            aPriority,
-                                            this);
-    }
-    else {
-        cp = GetNewOrUsedBrowserProcess(/* isBrowserElement = */ true,
-                                        aPriority,
-                                        this);
-    }
-
-    if (!cp) {
-        *aCpId = 0;
-        *aIsForApp = false;
-        *aIsForBrowser = false;
-        return true;
-    }
-
-    *aCpId = cp->ChildID();
-    *aIsForApp = cp->IsForApp();
-    *aIsForBrowser = cp->IsForBrowser();
-
-    ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
-    cpm->AddContentProcess(cp, this->ChildID());
-
-    if (cpm->AddGrandchildProcess(this->ChildID(), cp->ChildID())) {
-        // Pre-allocate a TabId here to save one time IPC call at app startup.
-        *aTabId = AllocateTabId(aOpenerTabId,
-                                aContext,
-                                cp->ChildID());
-        return (*aTabId != 0);
-    }
-
+  RefPtr<ContentParent> cp;
+  MaybeInvalidTabContext tc(aContext);
+  if (!tc.IsValid()) {
+    NS_ERROR(nsPrintfCString("Received an invalid TabContext from "
+                             "the child process. (%s)",
+                             tc.GetInvalidReason()).get());
     return false;
+  }
+
+  nsCOMPtr<mozIApplication> ownApp = tc.GetTabContext().GetOwnApp();
+  if (ownApp) {
+    cp = GetNewOrPreallocatedAppProcess(ownApp, aPriority, this);
+  }
+  else {
+   cp = GetNewOrUsedBrowserProcess(/* isBrowserElement = */ true,
+                                   aPriority, this);
+  }
+
+  if (!cp) {
+    *aCpId = 0;
+    *aIsForApp = false;
+    *aIsForBrowser = false;
+    return true;
+  }
+
+  *aCpId = cp->ChildID();
+  *aIsForApp = cp->IsForApp();
+  *aIsForBrowser = cp->IsForBrowser();
+
+  ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
+  cpm->AddContentProcess(cp, this->ChildID());
+
+  if (cpm->AddGrandchildProcess(this->ChildID(), cp->ChildID())) {
+    // Pre-allocate a TabId here to save one time IPC call at app startup.
+    *aTabId = AllocateTabId(aOpenerTabId, aContext, cp->ChildID());
+    return (*aTabId != 0);
+  }
+
+  return false;
 }
 
 bool
 ContentParent::RecvBridgeToChildProcess(const ContentParentId& aCpId)
 {
-    ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
-    ContentParent* cp = cpm->GetContentProcessById(aCpId);
-
-    if (cp) {
-        ContentParentId parentId;
-        if (cpm->GetParentProcessId(cp->ChildID(), &parentId) &&
-            parentId == this->ChildID()) {
-            return NS_SUCCEEDED(PContentBridge::Bridge(this, cp));
-        }
+  ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
+  ContentParent* cp = cpm->GetContentProcessById(aCpId);
+
+  if (cp) {
+    ContentParentId parentId;
+    if (cpm->GetParentProcessId(cp->ChildID(), &parentId) &&
+      parentId == this->ChildID()) {
+      return NS_SUCCEEDED(PContentBridge::Bridge(this, cp));
     }
-
-    // You can't bridge to a process you didn't open!
-    KillHard("BridgeToChildProcess");
-    return false;
+  }
+
+  // You can't bridge to a process you didn't open!
+  KillHard("BridgeToChildProcess");
+  return false;
 }
 
 static nsIDocShell* GetOpenerDocShellHelper(Element* aFrameElement)
 {
-    // Propagate the private-browsing status of the element's parent
-    // docshell to the remote docshell, via the chrome flags.
-    nsCOMPtr<Element> frameElement = do_QueryInterface(aFrameElement);
-    MOZ_ASSERT(frameElement);
-    nsPIDOMWindow* win = frameElement->OwnerDoc()->GetWindow();
-    if (!win) {
-        NS_WARNING("Remote frame has no window");
-        return nullptr;
-    }
-    nsIDocShell* docShell = win->GetDocShell();
-    if (!docShell) {
-        NS_WARNING("Remote frame has no docshell");
-        return nullptr;
-    }
-
-    return docShell;
+  // Propagate the private-browsing status of the element's parent
+  // docshell to the remote docshell, via the chrome flags.
+  nsCOMPtr<Element> frameElement = do_QueryInterface(aFrameElement);
+  MOZ_ASSERT(frameElement);
+  nsPIDOMWindow* win = frameElement->OwnerDoc()->GetWindow();
+  if (!win) {
+    NS_WARNING("Remote frame has no window");
+    return nullptr;
+  }
+  nsIDocShell* docShell = win->GetDocShell();
+  if (!docShell) {
+    NS_WARNING("Remote frame has no docshell");
+    return nullptr;
+  }
+
+  return docShell;
 }
 
 bool
 ContentParent::RecvCreateGMPService()
 {
-    return PGMPService::Open(this);
+  return PGMPService::Open(this);
 }
 
 bool
 ContentParent::RecvGetGMPPluginVersionForAPI(const nsCString& aAPI,
                                              nsTArray<nsCString>&& aTags,
                                              bool* aHasVersion,
                                              nsCString* aVersion)
 {
-    return GMPServiceParent::RecvGetGMPPluginVersionForAPI(aAPI, Move(aTags),
-                                                           aHasVersion,
-                                                           aVersion);
+  return GMPServiceParent::RecvGetGMPPluginVersionForAPI(aAPI, Move(aTags),
+                                                         aHasVersion,
+                                                         aVersion);
 }
 
 bool
 ContentParent::RecvIsGMPPresentOnDisk(const nsString& aKeySystem,
                                       const nsCString& aVersion,
                                       bool* aIsPresent,
                                       nsCString* aMessage)
 {
 #ifdef MOZ_EME
-    *aIsPresent = MediaKeySystemAccess::IsGMPPresentOnDisk(aKeySystem,
-                                                           aVersion,
-                                                           *aMessage);
+  *aIsPresent = MediaKeySystemAccess::IsGMPPresentOnDisk(aKeySystem,
+                                                         aVersion,
+                                                         *aMessage);
 #else
-    *aIsPresent = false;
+  *aIsPresent = false;
 #endif
 
-    return true;
+  return true;
 }
 
 bool
 ContentParent::RecvLoadPlugin(const uint32_t& aPluginId, nsresult* aRv, uint32_t* aRunID)
 {
-    *aRv = NS_OK;
-    return mozilla::plugins::SetupBridge(aPluginId, this, false, aRv, aRunID);
+  *aRv = NS_OK;
+  return mozilla::plugins::SetupBridge(aPluginId, this, false, aRv, aRunID);
 }
 
 bool
 ContentParent::RecvUngrabPointer(const uint32_t& aTime)
 {
 #if !defined(MOZ_WIDGET_GTK)
-    NS_RUNTIMEABORT("This message only makes sense on GTK platforms");
-    return false;
+  NS_RUNTIMEABORT("This message only makes sense on GTK platforms");
+  return false;
 #else
-    gdk_pointer_ungrab(aTime);
-    return true;
+  gdk_pointer_ungrab(aTime);
+  return true;
 #endif
 }
 
 bool
 ContentParent::RecvConnectPluginBridge(const uint32_t& aPluginId, nsresult* aRv)
 {
-    *aRv = NS_OK;
-    // We don't need to get the run ID for the plugin, since we already got it
-    // in the first call to SetupBridge in RecvLoadPlugin, so we pass in a dummy
-    // pointer and just throw it away.
-    uint32_t dummy = 0;
-    return mozilla::plugins::SetupBridge(aPluginId, this, true, aRv, &dummy);
+  *aRv = NS_OK;
+  // We don't need to get the run ID for the plugin, since we already got it
+  // in the first call to SetupBridge in RecvLoadPlugin, so we pass in a dummy
+  // pointer and just throw it away.
+  uint32_t dummy = 0;
+  return mozilla::plugins::SetupBridge(aPluginId, this, true, aRv, &dummy);
 }
 
 bool
 ContentParent::RecvGetBlocklistState(const uint32_t& aPluginId,
                                      uint32_t* aState)
 {
-    *aState = nsIBlocklistService::STATE_BLOCKED;
-
-    RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
-    if (!pluginHost) {
-        NS_WARNING("Plugin host not found");
-        return false;
-    }
-    nsPluginTag* tag =  pluginHost->PluginWithId(aPluginId);
-
-    if (!tag) {
-        // Default state is blocked anyway
-        NS_WARNING("Plugin tag not found. This should never happen, but to avoid a crash we're forcibly blocking it");
-        return true;
-    }
-
-    return NS_SUCCEEDED(tag->GetBlocklistState(aState));
+  *aState = nsIBlocklistService::STATE_BLOCKED;
+
+  RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
+  if (!pluginHost) {
+    NS_WARNING("Plugin host not found");
+    return false;
+  }
+  nsPluginTag* tag =  pluginHost->PluginWithId(aPluginId);
+
+  if (!tag) {
+    // Default state is blocked anyway
+    NS_WARNING("Plugin tag not found. This should never happen, but to avoid a crash we're forcibly blocking it");
+    return true;
+  }
+
+  return NS_SUCCEEDED(tag->GetBlocklistState(aState));
 }
 
 bool
 ContentParent::RecvFindPlugins(const uint32_t& aPluginEpoch,
                                nsresult* aRv,
                                nsTArray<PluginTag>* aPlugins,
                                uint32_t* aNewPluginEpoch)
 {
-    *aRv = mozilla::plugins::FindPluginsForContent(aPluginEpoch, aPlugins, aNewPluginEpoch);
-    return true;
+  *aRv = mozilla::plugins::FindPluginsForContent(aPluginEpoch, aPlugins, aNewPluginEpoch);
+  return true;
 }
 
 /*static*/ TabParent*
 ContentParent::CreateBrowserOrApp(const TabContext& aContext,
                                   Element* aFrameElement,
                                   ContentParent* aOpenerContentParent)
 {
-    if (!sCanLaunchSubprocesses) {
-        return nullptr;
-    }
-
-    if (TabParent* parent = TabParent::GetNextTabParent()) {
-        parent->SetOwnerElement(aFrameElement);
-        return parent;
-    }
-
-    ProcessPriority initialPriority = GetInitialProcessPriority(aFrameElement);
-    bool isInContentProcess = !XRE_IsParentProcess();
-    TabId tabId;
-
-    nsIDocShell* docShell = GetOpenerDocShellHelper(aFrameElement);
-    TabId openerTabId;
-    if (docShell) {
-        openerTabId = TabParent::GetTabIdFrom(docShell);
-    }
-
-    if (aContext.IsBrowserElement() || !aContext.HasOwnApp()) {
-        RefPtr<TabParent> tp;
-        RefPtr<nsIContentParent> constructorSender;
-        if (isInContentProcess) {
-            MOZ_ASSERT(aContext.IsBrowserElement());
-            constructorSender = CreateContentBridgeParent(aContext,
-                                                          initialPriority,
-                                                          openerTabId,
-                                                          &tabId);
-        } else {
-            if (aOpenerContentParent) {
-                constructorSender = aOpenerContentParent;
-            } else {
-                constructorSender =
-                    GetNewOrUsedBrowserProcess(aContext.IsBrowserElement(),
-                                               initialPriority);
-                if (!constructorSender) {
-                    return nullptr;
-                }
-            }
-            tabId = AllocateTabId(openerTabId,
-                                  aContext.AsIPCTabContext(),
-                                  constructorSender->ChildID());
+  if (!sCanLaunchSubprocesses) {
+    return nullptr;
+  }
+
+  if (TabParent* parent = TabParent::GetNextTabParent()) {
+    parent->SetOwnerElement(aFrameElement);
+    return parent;
+  }
+
+  ProcessPriority initialPriority = GetInitialProcessPriority(aFrameElement);
+  bool isInContentProcess = !XRE_IsParentProcess();
+  TabId tabId;
+
+  nsIDocShell* docShell = GetOpenerDocShellHelper(aFrameElement);
+  TabId openerTabId;
+  if (docShell) {
+    openerTabId = TabParent::GetTabIdFrom(docShell);
+  }
+
+  if (aContext.IsBrowserElement() || !aContext.HasOwnApp()) {
+    RefPtr<TabParent> tp;
+    RefPtr<nsIContentParent> constructorSender;
+    if (isInContentProcess) {
+      MOZ_ASSERT(aContext.IsBrowserElement());
+      constructorSender = CreateContentBridgeParent(aContext, initialPriority,
+                                                    openerTabId, &tabId);
+    } else {
+      if (aOpenerContentParent) {
+        constructorSender = aOpenerContentParent;
+      } else {
+        constructorSender =
+          GetNewOrUsedBrowserProcess(aContext.IsBrowserElement(),
+                                     initialPriority);
+        if (!constructorSender) {
+          return nullptr;
         }
-        if (constructorSender) {
-            nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
-            docShell->GetTreeOwner(getter_AddRefs(treeOwner));
-            if (!treeOwner) {
-                return nullptr;
-            }
-
-            nsCOMPtr<nsIWebBrowserChrome> wbc = do_GetInterface(treeOwner);
-            if (!wbc) {
-                return nullptr;
-            }
-            uint32_t chromeFlags = 0;
-            wbc->GetChromeFlags(&chromeFlags);
-
-            nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
-            if (loadContext && loadContext->UsePrivateBrowsing()) {
-                chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
-            }
-            bool affectLifetime;
-            docShell->GetAffectPrivateSessionLifetime(&affectLifetime);
-            if (affectLifetime) {
-                chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
-            }
-
-            if (tabId == 0) {
-                return nullptr;
-            }
-            RefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
-                                                 aContext, chromeFlags));
-            tp->SetInitedByParent();
-            tp->SetOwnerElement(aFrameElement);
-
-            PBrowserParent* browser = constructorSender->SendPBrowserConstructor(
-                // DeallocPBrowserParent() releases this ref.
-                tp.forget().take(),
-                tabId,
-                aContext.AsIPCTabContext(),
-                chromeFlags,
-                constructorSender->ChildID(),
-                constructorSender->IsForApp(),
-                constructorSender->IsForBrowser());
-            return TabParent::GetFrom(browser);
-        }
-        return nullptr;
+      }
+      tabId = AllocateTabId(openerTabId,
+                            aContext.AsIPCTabContext(),
+                           constructorSender->ChildID());
     }
-
-    // If we got here, we have an app and we're not a browser element.  ownApp
-    // shouldn't be null, because we otherwise would have gone into the
-    // !HasOwnApp() branch above.
-    RefPtr<nsIContentParent> parent;
-    bool reused = false;
-    bool tookPreallocated = false;
-    nsAutoString manifestURL;
-
-    if (isInContentProcess) {
-      parent = CreateContentBridgeParent(aContext,
-                                         initialPriority,
-                                         openerTabId,
-                                         &tabId);
-    }
-    else {
-        nsCOMPtr<mozIApplication> ownApp = aContext.GetOwnApp();
-
-        if (!sAppContentParents) {
-            sAppContentParents =
-                new nsDataHashtable<nsStringHashKey, ContentParent*>();
-        }
-
-        // Each app gets its own ContentParent instance unless it shares it with
-        // a parent app.
-        if (NS_FAILED(ownApp->GetManifestURL(manifestURL))) {
-            NS_ERROR("Failed to get manifest URL");
-            return nullptr;
-        }
-
-        RefPtr<ContentParent> p = sAppContentParents->Get(manifestURL);
-
-        if (!p && Preferences::GetBool("dom.ipc.reuse_parent_app")) {
-            nsAutoString parentAppManifestURL;
-            aFrameElement->GetAttr(kNameSpaceID_None,
-                                   nsGkAtoms::parentapp, parentAppManifestURL);
-            nsAdoptingString systemAppManifestURL =
-                Preferences::GetString("b2g.system_manifest_url");
-            nsCOMPtr<nsIAppsService> appsService =
-                do_GetService(APPS_SERVICE_CONTRACTID);
-            if (!parentAppManifestURL.IsEmpty() &&
-                !parentAppManifestURL.Equals(systemAppManifestURL) &&
-                appsService) {
-                nsCOMPtr<mozIApplication> parentApp;
-                nsCOMPtr<mozIApplication> app;
-                appsService->GetAppByManifestURL(parentAppManifestURL,
-                                                getter_AddRefs(parentApp));
-                appsService->GetAppByManifestURL(manifestURL,
-                                                getter_AddRefs(app));
-
-                // Only let certified apps re-use the same process.
-                unsigned short parentAppStatus = 0;
-                unsigned short appStatus = 0;
-                if (app &&
-                    NS_SUCCEEDED(app->GetAppStatus(&appStatus)) &&
-                    appStatus == nsIPrincipal::APP_STATUS_CERTIFIED &&
-                    parentApp &&
-                    NS_SUCCEEDED(parentApp->GetAppStatus(&parentAppStatus)) &&
-                    parentAppStatus == nsIPrincipal::APP_STATUS_CERTIFIED) {
-                    // Check if we can re-use the process of the parent app.
-                    p = sAppContentParents->Get(parentAppManifestURL);
-                }
-            }
-        }
-
-        if (p) {
-            // Check that the process is still alive and set its priority.
-            // Hopefully the process won't die after this point, if this call
-            // succeeds.
-            if (!p->SetPriorityAndCheckIsAlive(initialPriority)) {
-                p = nullptr;
-            }
-        }
-
-        reused = !!p;
-        if (!p) {
-            p = GetNewOrPreallocatedAppProcess(ownApp,
-                                               initialPriority,
-                                               nullptr,
-                                               &tookPreallocated);
-            MOZ_ASSERT(p);
-            sAppContentParents->Put(manifestURL, p);
-        }
-        tabId = AllocateTabId(openerTabId,
-                              aContext.AsIPCTabContext(),
-                              p->ChildID());
-        parent = static_cast<nsIContentParent*>(p);
-    }
-
-    if (!parent || (tabId == 0)) {
+    if (constructorSender) {
+      nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
+      docShell->GetTreeOwner(getter_AddRefs(treeOwner));
+      if (!treeOwner) {
+        return nullptr;
+      }
+
+      nsCOMPtr<nsIWebBrowserChrome> wbc = do_GetInterface(treeOwner);
+      if (!wbc) {
         return nullptr;
-    }
-
-    uint32_t chromeFlags = 0;
-
-    RefPtr<TabParent> tp = new TabParent(parent, tabId, aContext, chromeFlags);
-    tp->SetInitedByParent();
-    tp->SetOwnerElement(aFrameElement);
-    PBrowserParent* browser = parent->SendPBrowserConstructor(
+      }
+      uint32_t chromeFlags = 0;
+      wbc->GetChromeFlags(&chromeFlags);
+
+      nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
+      if (loadContext && loadContext->UsePrivateBrowsing()) {
+        chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
+      }
+      bool affectLifetime;
+      docShell->GetAffectPrivateSessionLifetime(&affectLifetime);
+      if (affectLifetime) {
+        chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
+      }
+
+      if (tabId == 0) {
+        return nullptr;
+      }
+      RefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
+                                         aContext, chromeFlags));
+      tp->SetInitedByParent();
+      tp->SetOwnerElement(aFrameElement);
+
+      PBrowserParent* browser =
+      constructorSender->SendPBrowserConstructor(
         // DeallocPBrowserParent() releases this ref.
-        RefPtr<TabParent>(tp).forget().take(),
-        tabId,
+        tp.forget().take(), tabId,
         aContext.AsIPCTabContext(),
         chromeFlags,
-        parent->ChildID(),
-        parent->IsForApp(),
-        parent->IsForBrowser());
-
-    if (isInContentProcess) {
-        // Just return directly without the following check in content process.
-        return TabParent::GetFrom(browser);
+        constructorSender->ChildID(),
+        constructorSender->IsForApp(),
+        constructorSender->IsForBrowser());
+      return TabParent::GetFrom(browser);
+    }
+    return nullptr;
+  }
+
+  // If we got here, we have an app and we're not a browser element.  ownApp
+  // shouldn't be null, because we otherwise would have gone into the
+  // !HasOwnApp() branch above.
+  RefPtr<nsIContentParent> parent;
+  bool reused = false;
+  bool tookPreallocated = false;
+  nsAutoString manifestURL;
+
+  if (isInContentProcess) {
+    parent = CreateContentBridgeParent(aContext,
+                                       initialPriority,
+                                       openerTabId,
+                                       &tabId);
+  }
+  else {
+    nsCOMPtr<mozIApplication> ownApp = aContext.GetOwnApp();
+
+    if (!sAppContentParents) {
+      sAppContentParents =
+        new nsDataHashtable<nsStringHashKey, ContentParent*>();
     }
 
-    if (!browser) {
-        // We failed to actually start the PBrowser.  This can happen if the
-        // other process has already died.
-        if (!reused) {
-            // Don't leave a broken ContentParent in the hashtable.
-            parent->AsContentParent()->KillHard("CreateBrowserOrApp");
-            sAppContentParents->Remove(manifestURL);
-            parent = nullptr;
+    // Each app gets its own ContentParent instance unless it shares it with
+    // a parent app.
+    if (NS_FAILED(ownApp->GetManifestURL(manifestURL))) {
+      NS_ERROR("Failed to get manifest URL");
+      return nullptr;
+    }
+
+    RefPtr<ContentParent> p = sAppContentParents->Get(manifestURL);
+
+    if (!p && Preferences::GetBool("dom.ipc.reuse_parent_app")) {
+      nsAutoString parentAppManifestURL;
+      aFrameElement->GetAttr(kNameSpaceID_None,
+                             nsGkAtoms::parentapp, parentAppManifestURL);
+      nsAdoptingString systemAppManifestURL =
+        Preferences::GetString("b2g.system_manifest_url");
+      nsCOMPtr<nsIAppsService> appsService =
+        do_GetService(APPS_SERVICE_CONTRACTID);
+      if (!parentAppManifestURL.IsEmpty() &&
+        !parentAppManifestURL.Equals(systemAppManifestURL) &&
+        appsService) {
+        nsCOMPtr<mozIApplication> parentApp;
+        nsCOMPtr<mozIApplication> app;
+        appsService->GetAppByManifestURL(parentAppManifestURL,
+                                         getter_AddRefs(parentApp));
+        appsService->GetAppByManifestURL(manifestURL,
+                                         getter_AddRefs(app));
+
+        // Only let certified apps re-use the same process.
+        unsigned short parentAppStatus = 0;
+        unsigned short appStatus = 0;
+        if (app &&
+          NS_SUCCEEDED(app->GetAppStatus(&appStatus)) &&
+          appStatus == nsIPrincipal::APP_STATUS_CERTIFIED &&
+          parentApp &&
+          NS_SUCCEEDED(parentApp->GetAppStatus(&parentAppStatus)) &&
+          parentAppStatus == nsIPrincipal::APP_STATUS_CERTIFIED) {
+          // Check if we can re-use the process of the parent app.
+          p = sAppContentParents->Get(parentAppManifestURL);
         }
-
-        // If we took the preallocated process and it was already dead, try
-        // again with a non-preallocated process.  We can be sure this won't
-        // loop forever, because the next time through there will be no
-        // preallocated process to take.
-        if (tookPreallocated) {
-          return ContentParent::CreateBrowserOrApp(aContext,
-                                                   aFrameElement,
-                                                   aOpenerContentParent);
-        }
-
-        // Otherwise just give up.
-        return nullptr;
+      }
+    }
+
+    if (p) {
+      // Check that the process is still alive and set its priority.
+      // Hopefully the process won't die after this point, if this call
+      // succeeds.
+      if (!p->SetPriorityAndCheckIsAlive(initialPriority)) {
+        p = nullptr;
+      }
+    }
+
+    reused = !!p;
+    if (!p) {
+      p = GetNewOrPreallocatedAppProcess(ownApp, initialPriority, nullptr,
+                                         &tookPreallocated);
+      MOZ_ASSERT(p);
+      sAppContentParents->Put(manifestURL, p);
     }
-
-    parent->AsContentParent()->MaybeTakeCPUWakeLock(aFrameElement);
-
+    tabId = AllocateTabId(openerTabId, aContext.AsIPCTabContext(),
+                          p->ChildID());
+    parent = static_cast<nsIContentParent*>(p);
+  }
+
+  if (!parent || (tabId == 0)) {
+    return nullptr;
+  }
+
+  uint32_t chromeFlags = 0;
+
+  RefPtr<TabParent> tp = new TabParent(parent, tabId, aContext, chromeFlags);
+  tp->SetInitedByParent();
+  tp->SetOwnerElement(aFrameElement);
+  PBrowserParent* browser = parent->SendPBrowserConstructor(
+    // DeallocPBrowserParent() releases this ref.
+    RefPtr<TabParent>(tp).forget().take(),
+    tabId,
+    aContext.AsIPCTabContext(),
+    chromeFlags,
+    parent->ChildID(),
+    parent->IsForApp(),
+    parent->IsForBrowser());
+
+  if (isInContentProcess) {
+    // Just return directly without the following check in content process.
     return TabParent::GetFrom(browser);
+  }
+
+  if (!browser) {
+    // We failed to actually start the PBrowser.  This can happen if the
+    // other process has already died.
+    if (!reused) {
+      // Don't leave a broken ContentParent in the hashtable.
+      parent->AsContentParent()->KillHard("CreateBrowserOrApp");
+      sAppContentParents->Remove(manifestURL);
+      parent = nullptr;
+    }
+
+    // If we took the preallocated process and it was already dead, try
+    // again with a non-preallocated process.  We can be sure this won't
+    // loop forever, because the next time through there will be no
+    // preallocated process to take.
+    if (tookPreallocated) {
+      return ContentParent::CreateBrowserOrApp(aContext, aFrameElement,
+                                               aOpenerContentParent);
+    }
+
+    // Otherwise just give up.
+    return nullptr;
+  }
+
+  parent->AsContentParent()->MaybeTakeCPUWakeLock(aFrameElement);
+
+  return TabParent::GetFrom(browser);
 }
 
 /*static*/ ContentBridgeParent*
 ContentParent::CreateContentBridgeParent(const TabContext& aContext,
                                          const hal::ProcessPriority& aPriority,
                                          const TabId& aOpenerTabId,
                                          /*out*/ TabId* aTabId)
 {
-    MOZ_ASSERT(aTabId);
-
-    ContentChild* child = ContentChild::GetSingleton();
-    ContentParentId cpId;
-    bool isForApp;
-    bool isForBrowser;
-    if (!child->SendCreateChildProcess(aContext.AsIPCTabContext(),
-                                       aPriority,
-                                       aOpenerTabId,
-                                       &cpId,
-                                       &isForApp,
-                                       &isForBrowser,
-                                       aTabId)) {
-        return nullptr;
-    }
-    if (cpId == 0) {
-        return nullptr;
-    }
-    if (!child->SendBridgeToChildProcess(cpId)) {
-        return nullptr;
-    }
-    ContentBridgeParent* parent = child->GetLastBridge();
-    parent->SetChildID(cpId);
-    parent->SetIsForApp(isForApp);
-    parent->SetIsForBrowser(isForBrowser);
-    return parent;
+  MOZ_ASSERT(aTabId);
+
+  ContentChild* child = ContentChild::GetSingleton();
+  ContentParentId cpId;
+  bool isForApp;
+  bool isForBrowser;
+  if (!child->SendCreateChildProcess(aContext.AsIPCTabContext(),
+                                     aPriority,
+                                     aOpenerTabId,
+                                     &cpId,
+                                     &isForApp,
+                                     &isForBrowser,
+                                     aTabId)) {
+    return nullptr;
+  }
+  if (cpId == 0) {
+    return nullptr;
+  }
+  if (!child->SendBridgeToChildProcess(cpId)) {
+    return nullptr;
+  }
+  ContentBridgeParent* parent = child->GetLastBridge();
+  parent->SetChildID(cpId);
+  parent->SetIsForApp(isForApp);
+  parent->SetIsForBrowser(isForBrowser);
+  return parent;
 }
 
 void
 ContentParent::GetAll(nsTArray<ContentParent*>& aArray)
 {
-    aArray.Clear();
-
-    if (!sContentParents) {
-        return;
+  aArray.Clear();
+
+  if (!sContentParents) {
+    return;
+  }
+
+  for (ContentParent* cp = sContentParents->getFirst(); cp;
+     cp = cp->LinkedListElement<ContentParent>::getNext()) {
+    if (cp->mIsAlive) {
+      aArray.AppendElement(cp);
     }
-
-    for (ContentParent* cp = sContentParents->getFirst(); cp;
-         cp = cp->LinkedListElement<ContentParent>::getNext()) {
-        if (cp->mIsAlive) {
-            aArray.AppendElement(cp);
-        }
-    }
+  }
 }
 
 void
 ContentParent::GetAllEvenIfDead(nsTArray<ContentParent*>& aArray)
 {
-    aArray.Clear();
-
-    if (!sContentParents) {
-        return;
-    }
-
-    for (ContentParent* cp = sContentParents->getFirst(); cp;
-         cp = cp->LinkedListElement<ContentParent>::getNext()) {
-        aArray.AppendElement(cp);
-    }
+  aArray.Clear();
+
+  if (!sContentParents) {
+    return;
+  }
+
+  for (ContentParent* cp = sContentParents->getFirst(); cp;
+     cp = cp->LinkedListElement<ContentParent>::getNext()) {
+    aArray.AppendElement(cp);
+  }
 }
 
 void
 ContentParent::Init()
 {
-    nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-    if (obs) {
-        size_t length = ArrayLength(sObserverTopics);
-        for (size_t i = 0; i < length; ++i) {
-            obs->AddObserver(this, sObserverTopics[i], false);
-        }
+  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
+  if (obs) {
+    size_t length = ArrayLength(sObserverTopics);
+    for (size_t i = 0; i < length; ++i) {
+      obs->AddObserver(this, sObserverTopics[i], false);
     }
-    Preferences::AddStrongObserver(this, "");
-    if (obs) {
-        nsAutoString cpId;
-        cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
-        obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-created", cpId.get());
-    }
+  }
+  Preferences::AddStrongObserver(this, "");
+  if (obs) {
+    nsAutoString cpId;
+    cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
+    obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-created", cpId.get());
+  }
 
 #ifdef ACCESSIBILITY
-    // If accessibility is running in chrome process then start it in content
-    // process.
-    if (nsIPresShell::IsAccessibilityActive()) {
+  // If accessibility is running in chrome process then start it in content
+  // process.
+  if (nsIPresShell::IsAccessibilityActive()) {
 #if !defined(XP_WIN)
-        Unused << SendActivateA11y();
+    Unused << SendActivateA11y();
 #else
-        // On Windows we currently only enable a11y in the content process
-        // for testing purposes.
-        if (Preferences::GetBool(kForceEnableE10sPref, false)) {
-            Unused << SendActivateA11y();
-        }
+    // On Windows we currently only enable a11y in the content process
+    // for testing purposes.
+    if (Preferences::GetBool(kForceEnableE10sPref, false)) {
+      Unused << SendActivateA11y();
+    }
 #endif
-    }
+  }
 #endif
 
 #ifdef MOZ_ENABLE_PROFILER_SPS
-    nsCOMPtr<nsIProfiler> profiler(do_GetService("@mozilla.org/tools/profiler;1"));
-    bool profilerActive = false;
-    DebugOnly<nsresult> rv = profiler->IsActive(&profilerActive);
+  nsCOMPtr<nsIProfiler> profiler(do_GetService("@mozilla.org/tools/profiler;1"));
+  bool profilerActive = false;
+  DebugOnly<nsresult> rv = profiler->IsActive(&profilerActive);
+  MOZ_ASSERT(NS_SUCCEEDED(rv));
+
+  if (profilerActive) {
+    nsCOMPtr<nsIProfilerStartParams> currentProfilerParams;
+    rv = profiler->GetStartParams(getter_AddRefs(currentProfilerParams));
     MOZ_ASSERT(NS_SUCCEEDED(rv));
 
-    if (profilerActive) {
-        nsCOMPtr<nsIProfilerStartParams> currentProfilerParams;
-        rv = profiler->GetStartParams(getter_AddRefs(currentProfilerParams));
-        MOZ_ASSERT(NS_SUCCEEDED(rv));
-
-        nsCOMPtr<nsISupports> gatherer;
-        rv = profiler->GetProfileGatherer(getter_AddRefs(gatherer));
-        MOZ_ASSERT(NS_SUCCEEDED(rv));
-        mGatherer = static_cast<ProfileGatherer*>(gatherer.get());
-
-        StartProfiler(currentProfilerParams);
-    }
+    nsCOMPtr<nsISupports> gatherer;
+    rv = profiler->GetProfileGatherer(getter_AddRefs(gatherer));
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
+    mGatherer = static_cast<ProfileGatherer*>(gatherer.get());
+
+    StartProfiler(currentProfilerParams);
+  }
 #endif
 }
 
 void
 ContentParent::ForwardKnownInfo()
 {
-    MOZ_ASSERT(mMetamorphosed);
-    if (!mMetamorphosed) {
-        return;
-    }
+  MOZ_ASSERT(mMetamorphosed);
+  if (!mMetamorphosed) {
+    return;
+  }
 #ifdef MOZ_WIDGET_GONK
-    InfallibleTArray<VolumeInfo> volumeInfo;
-    RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
-    if (vs) {
-        vs->GetVolumesForIPC(&volumeInfo);
-        Unused << SendVolumes(volumeInfo);
+  InfallibleTArray<VolumeInfo> volumeInfo;
+  RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
+  if (vs) {
+    vs->GetVolumesForIPC(&volumeInfo);
+    Unused << SendVolumes(volumeInfo);
+  }
+#endif /* MOZ_WIDGET_GONK */
+
+  nsCOMPtr<nsISystemMessagesInternal> systemMessenger =
+    do_GetService("@mozilla.org/system-message-internal;1");
+  if (systemMessenger && !mIsForBrowser) {
+    nsCOMPtr<nsIURI> manifestURI;
+    nsresult rv = NS_NewURI(getter_AddRefs(manifestURI), mAppManifestURL);
+    if (NS_SUCCEEDED(rv)) {
+      systemMessenger->RefreshCache(mMessageManager, manifestURI);
     }
-#endif /* MOZ_WIDGET_GONK */
-
-    nsCOMPtr<nsISystemMessagesInternal> systemMessenger =
-        do_GetService("@mozilla.org/system-message-internal;1");
-    if (systemMessenger && !mIsForBrowser) {
-        nsCOMPtr<nsIURI> manifestURI;
-        nsresult rv = NS_NewURI(getter_AddRefs(manifestURI), mAppManifestURL);
-        if (NS_SUCCEEDED(rv)) {
-            systemMessenger->RefreshCache(mMessageManager, manifestURI);
-        }
-    }
+  }
 }
 
 namespace {
 
 class SystemMessageHandledListener final
-    : public nsITimerCallback
-    , public LinkedListElement<SystemMessageHandledListener>
+  : public nsITimerCallback
+  , public LinkedListElement<SystemMessageHandledListener>
 {
 public:
-    NS_DECL_ISUPPORTS
-
-    SystemMessageHandledListener() {}
-
-    static void OnSystemMessageHandled()
-    {
-        if (!sListeners) {
-            return;
-        }
-
-        SystemMessageHandledListener* listener = sListeners->popFirst();
-        if (!listener) {
-            return;
-        }
-
-        // Careful: ShutDown() may delete |this|.
-        listener->ShutDown();
+  NS_DECL_ISUPPORTS
+
+  SystemMessageHandledListener() {}
+
+  static void OnSystemMessageHandled()
+  {
+    if (!sListeners) {
+      return;
+    }
+
+    SystemMessageHandledListener* listener = sListeners->popFirst();
+    if (!listener) {
+      return;
     }
 
-    void Init(WakeLock* aWakeLock)
-    {
-        MOZ_ASSERT(!mWakeLock);
-        MOZ_ASSERT(!mTimer);
-
-        // mTimer keeps a strong reference to |this|.  When this object's
-        // destructor runs, it will remove itself from the LinkedList.
-
-        if (!sListeners) {
-            sListeners = new LinkedList<SystemMessageHandledListener>();
-            ClearOnShutdown(&sListeners);
-        }
-        sListeners->insertBack(this);
-
-        mWakeLock = aWakeLock;
-
-        mTimer = do_CreateInstance("@mozilla.org/timer;1");
-
-        uint32_t timeoutSec =
-            Preferences::GetInt("dom.ipc.systemMessageCPULockTimeoutSec", 30);
-        mTimer->InitWithCallback(this, timeoutSec * 1000,
-                                 nsITimer::TYPE_ONE_SHOT);
+    // Careful: ShutDown() may delete |this|.
+    listener->ShutDown();
+  }
+
+  void Init(WakeLock* aWakeLock)
+  {
+    MOZ_ASSERT(!mWakeLock);
+    MOZ_ASSERT(!mTimer);
+
+    // mTimer keeps a strong reference to |this|.  When this object's
+    // destructor runs, it will remove itself from the LinkedList.
+
+    if (!sListeners) {
+      sListeners = new LinkedList<SystemMessageHandledListener>();
+      ClearOnShutdown(&sListeners);
     }
-
-    NS_IMETHOD Notify(nsITimer* aTimer) override
-    {
-        // Careful: ShutDown() may delete |this|.
-        ShutDown();
-        return NS_OK;
-    }
+    sListeners->insertBack(this);
+
+    mWakeLock = aWakeLock;
+
+    mTimer = do_CreateInstance("@mozilla.org/timer;1");
+
+    uint32_t timeoutSec =
+      Preferences::GetInt("dom.ipc.systemMessageCPULockTimeoutSec", 30);
+    mTimer->InitWithCallback(this, timeoutSec * 1000, nsITimer::TYPE_ONE_SHOT);
+  }
+
+  NS_IMETHOD Notify(nsITimer* aTimer) override
+  {
+    // Careful: ShutDown() may delete |this|.
+    ShutDown();
+    return NS_OK;
+  }
 
 private:
-    ~SystemMessageHandledListener() {}
-
-    static StaticAutoPtr<LinkedList<SystemMessageHandledListener> > sListeners;
-
-    void ShutDown()
-    {
-        RefPtr<SystemMessageHandledListener> kungFuDeathGrip = this;
-
-        ErrorResult rv;
-        mWakeLock->Unlock(rv);
-
-        if (mTimer) {
-            mTimer->Cancel();
-            mTimer = nullptr;
-        }
+  ~SystemMessageHandledListener() {}
+
+  static StaticAutoPtr<LinkedList<SystemMessageHandledListener> > sListeners;
+
+  void ShutDown()
+  {
+    RefPtr<SystemMessageHandledListener> kungFuDeathGrip = this;
+
+    ErrorResult rv;
+    mWakeLock->Unlock(rv);
+
+    if (mTimer) {
+      mTimer->Cancel();
+      mTimer = nullptr;
     }
-
-    RefPtr<WakeLock> mWakeLock;
-    nsCOMPtr<nsITimer> mTimer;
+  }
+
+  RefPtr<WakeLock> mWakeLock;
+  nsCOMPtr<nsITimer> mTimer;
 };
 
 StaticAutoPtr<LinkedList<SystemMessageHandledListener> >
-    SystemMessageHandledListener::sListeners;
+  SystemMessageHandledListener::sListeners;
 
 NS_IMPL_ISUPPORTS(SystemMessageHandledListener,
                   nsITimerCallback)
 
 
 class RemoteWindowContext final : public nsIRemoteWindowContext
                                 , public nsIInterfaceRequestor
 {
 public:
-    explicit RemoteWindowContext(TabParent* aTabParent)
-    : mTabParent(aTabParent)
-    {
-    }
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIINTERFACEREQUESTOR
-    NS_DECL_NSIREMOTEWINDOWCONTEXT
+  explicit RemoteWindowContext(TabParent* aTabParent)
+  : mTabParent(aTabParent)
+  {
+  }
+
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIINTERFACEREQUESTOR
+  NS_DECL_NSIREMOTEWINDOWCONTEXT
 
 private:
-    ~RemoteWindowContext();
-    RefPtr<TabParent> mTabParent;
+  ~RemoteWindowContext();
+  RefPtr<TabParent> mTabParent;
 };
 
 NS_IMPL_ISUPPORTS(RemoteWindowContext, nsIRemoteWindowContext, nsIInterfaceRequestor)
 
 RemoteWindowContext::~RemoteWindowContext()
 {
 }
 
 NS_IMETHODIMP
 RemoteWindowContext::GetInterface(const nsIID& aIID, void** aSink)
 {
-    return QueryInterface(aIID, aSink);
+  return QueryInterface(aIID, aSink);
 }
 
 NS_IMETHODIMP
 RemoteWindowContext::OpenURI(nsIURI* aURI, uint32_t aFlags)
 {
-    URIParams uri;
-    SerializeURI(aURI, uri);
-
-    Unused << mTabParent->SendOpenURI(uri, aFlags);
-    return NS_OK;
+  URIParams uri;
+  SerializeURI(aURI, uri);
+
+  Unused << mTabParent->SendOpenURI(uri, aFlags);
+  return NS_OK;
 }
 
 } // namespace
 
 void
 ContentParent::MaybeTakeCPUWakeLock(Element* aFrameElement)
 {
-    // Take the CPU wake lock on behalf of this processs if it's expecting a
-    // system message.  We'll release the CPU lock once the message is
-    // delivered, or after some period of time, which ever comes first.
-
-    nsCOMPtr<nsIMozBrowserFrame> browserFrame =
-        do_QueryInterface(aFrameElement);
-    if (!browserFrame ||
-        !browserFrame->GetIsExpectingSystemMessage()) {
-        return;
-    }
-
-    RefPtr<PowerManagerService> pms = PowerManagerService::GetInstance();
-    RefPtr<WakeLock> lock =
-        pms->NewWakeLockOnBehalfOfProcess(NS_LITERAL_STRING("cpu"), this);
-
-    // This object's Init() function keeps it alive.
-    RefPtr<SystemMessageHandledListener> listener =
-        new SystemMessageHandledListener();
-    listener->Init(lock);
+  // Take the CPU wake lock on behalf of this processs if it's expecting a
+  // system message.  We'll release the CPU lock once the message is
+  // delivered, or after some period of time, which ever comes first.
+
+  nsCOMPtr<nsIMozBrowserFrame> browserFrame =
+    do_QueryInterface(aFrameElement);
+  if (!browserFrame ||
+    !browserFrame->GetIsExpectingSystemMessage()) {
+    return;
+  }
+
+  RefPtr<PowerManagerService> pms = PowerManagerService::GetInstance();
+  RefPtr<WakeLock> lock =
+    pms->NewWakeLockOnBehalfOfProcess(NS_LITERAL_STRING("cpu"), this);
+
+  // This object's Init() function keeps it alive.
+  RefPtr<SystemMessageHandledListener> listener =
+    new SystemMessageHandledListener();
+  listener->Init(lock);
 }
 
 bool
 ContentParent::SetPriorityAndCheckIsAlive(ProcessPriority aPriority)
 {
-    ProcessPriorityManager::SetProcessPriority(this, aPriority);
-
-    // Now that we've set this process's priority, check whether the process is
-    // still alive.  Hopefully we've set the priority to FOREGROUND*, so the
-    // process won't unexpectedly crash after this point!
-    //
-    // Bug 943174: use waitid() with WNOWAIT so that, if the process
-    // did exit, we won't consume its zombie and confuse the
-    // GeckoChildProcessHost dtor.  Also, if the process isn't a
-    // direct child because of Nuwa this will fail with ECHILD, and we
-    // need to assume the child is alive in that case rather than
-    // assuming it's dead (as is otherwise a reasonable fallback).
+  ProcessPriorityManager::SetProcessPriority(this, aPriority);
+
+  // Now that we've set this process's priority, check whether the process is
+  // still alive.  Hopefully we've set the priority to FOREGROUND*, so the
+  // process won't unexpectedly crash after this point!
+  //
+  // Bug 943174: use waitid() with WNOWAIT so that, if the process
+  // did exit, we won't consume its zombie and confuse the
+  // GeckoChildProcessHost dtor.  Also, if the process isn't a
+  // direct child because of Nuwa this will fail with ECHILD, and we
+  // need to assume the child is alive in that case rather than
+  // assuming it's dead (as is otherwise a reasonable fallback).
 #ifdef MOZ_WIDGET_GONK
-    siginfo_t info;
-    info.si_pid = 0;
-    if (waitid(P_PID, Pid(), &info, WNOWAIT | WNOHANG | WEXITED) == 0
-        && info.si_pid != 0) {
-        return false;
-    }
+  siginfo_t info;
+  info.si_pid = 0;
+  if (waitid(P_PID, Pid(), &info, WNOWAIT | WNOHANG | WEXITED) == 0
+    && info.si_pid != 0) {
+    return false;
+  }
 #endif
 
-    return true;
+  return true;
 }
 
 // Helper for ContentParent::TransformPreallocatedIntoApp.
 static void
 TryGetNameFromManifestURL(const nsAString& aManifestURL,
-                          nsAString& aName)
-{
-    aName.Truncate();
-    if (aManifestURL.IsEmpty() ||
-        aManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL) {
-        return;
-    }
-
-    nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
-    NS_ENSURE_TRUE_VOID(appsService);
-
-    nsCOMPtr<mozIApplication> app;
-    appsService->GetAppByManifestURL(aManifestURL, getter_AddRefs(app));
-
-    if (!app) {
-        return;
-    }
-
-    app->GetName(aName);
+              nsAString& aName)
+{
+  aName.Truncate();
+  if (aManifestURL.IsEmpty() ||
+    aManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL) {
+    return;
+  }
+
+  nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
+  NS_ENSURE_TRUE_VOID(appsService);
+
+  nsCOMPtr<mozIApplication> app;
+  appsService->GetAppByManifestURL(aManifestURL, getter_AddRefs(app));
+
+  if (!app) {
+    return;
+  }
+
+  app->GetName(aName);
 }
 
 void
 ContentParent::TransformPreallocatedIntoApp(ContentParent* aOpener,
                                             const nsAString& aAppManifestURL)
 {
-    MOZ_ASSERT(IsPreallocated());
-    mMetamorphosed = true;
-    mOpener = aOpener;
-    mAppManifestURL = aAppManifestURL;
-    TryGetNameFromManifestURL(aAppManifestURL, mAppName);
+  MOZ_ASSERT(IsPreallocated());
+  mMetamorphosed = true;
+  mOpener = aOpener;
+  mAppManifestURL = aAppManifestURL;
+  TryGetNameFromManifestURL(aAppManifestURL, mAppName);
 }
 
 void
 ContentParent::TransformPreallocatedIntoBrowser(ContentParent* aOpener)
 {
-    // Reset mAppManifestURL, mIsForBrowser and mOSPrivileges for browser.
-    mMetamorphosed = true;
-    mOpener = aOpener;
-    mAppManifestURL.Truncate();
-    mIsForBrowser = true;
+  // Reset mAppManifestURL, mIsForBrowser and mOSPrivileges for browser.
+  mMetamorphosed = true;
+  mOpener = aOpener;
+  mAppManifestURL.Truncate();
+  mIsForBrowser = true;
 }
 
 void
 ContentParent::ShutDownProcess(ShutDownMethod aMethod)
 {
 #ifdef MOZ_NUWA_PROCESS
-    if (aMethod == SEND_SHUTDOWN_MESSAGE && IsNuwaProcess()) {
-        // We shouldn't send shutdown messages to frozen Nuwa processes,
-        // so just close the channel.
-        aMethod = CLOSE_CHANNEL;
+  if (aMethod == SEND_SHUTDOWN_MESSAGE && IsNuwaProcess()) {
+    // We shouldn't send shutdown messages to frozen Nuwa processes,
+    // so just close the channel.
+    aMethod = CLOSE_CHANNEL;
+  }
+#endif
+
+  // Shutting down by sending a shutdown message works differently than the
+  // other methods. We first call Shutdown() in the child. After the child is
+  // ready, it calls FinishShutdown() on us. Then we close the channel.
+  if (aMethod == SEND_SHUTDOWN_MESSAGE) {
+    if (mIPCOpen && !mShutdownPending && SendShutdown()) {
+      mShutdownPending = true;
+      // Start the force-kill timer if we haven't already.
+      StartForceKillTimer();
+    }
+
+    // If call was not successful, the channel must have been broken
+    // somehow, and we will clean up the error in ActorDestroy.
+    return;
+  }
+
+  using mozilla::dom::quota::QuotaManagerService;
+
+  if (QuotaManagerService* quotaManagerService = QuotaManagerService::Get()) {
+    quotaManagerService->AbortOperationsForProcess(mChildID);
+  }
+
+  // If Close() fails with an error, we'll end up back in this function, but
+  // with aMethod = CLOSE_CHANNEL_WITH_ERROR.  It's important that we call
+  // CloseWithError() in this case; see bug 895204.
+
+  if (aMethod == CLOSE_CHANNEL && !mCalledClose) {
+    // Close() can only be called once: It kicks off the destruction
+    // sequence.
+    mCalledClose = true;
+    Close();
+#ifdef MOZ_NUWA_PROCESS
+    // Kill Nuwa process forcibly to break its IPC channels and finalize
+    // corresponding parents.
+    if (IsNuwaProcess()) {
+      KillHard("ShutDownProcess");
     }
 #endif
-
-    // Shutting down by sending a shutdown message works differently than the
-    // other methods. We first call Shutdown() in the child. After the child is
-    // ready, it calls FinishShutdown() on us. Then we close the channel.
-    if (aMethod == SEND_SHUTDOWN_MESSAGE) {
-        if (mIPCOpen && !mShutdownPending && SendShutdown()) {
-            mShutdownPending = true;
-            // Start the force-kill timer if we haven't already.
-            StartForceKillTimer();
-        }
-
-        // If call was not successful, the channel must have been broken
-        // somehow, and we will clean up the error in ActorDestroy.
-        return;
-    }
-
-    using mozilla::dom::quota::QuotaManagerService;
-
-    if (QuotaManagerService* quotaManagerService = QuotaManagerService::Get()) {
-        quotaManagerService->AbortOperationsForProcess(mChildID);
+  }
+
+  if (aMethod == CLOSE_CHANNEL_WITH_ERROR && !mCalledCloseWithError) {
+    MessageChannel* channel = GetIPCChannel();
+    if (channel) {
+      mCalledCloseWithError = true;
+      channel->CloseWithError();
     }
-
-    // If Close() fails with an error, we'll end up back in this function, but
-    // with aMethod = CLOSE_CHANNEL_WITH_ERROR.  It's important that we call
-    // CloseWithError() in this case; see bug 895204.
-
-    if (aMethod == CLOSE_CHANNEL && !mCalledClose) {
-        // Close() can only be called once: It kicks off the destruction
-        // sequence.
-        mCalledClose = true;
-        Close();
-#ifdef MOZ_NUWA_PROCESS
-        // Kill Nuwa process forcibly to break its IPC channels and finalize
-        // corresponding parents.
-        if (IsNuwaProcess()) {
-            KillHard("ShutDownProcess");
-        }
-#endif
-    }
-
-    if (aMethod == CLOSE_CHANNEL_WITH_ERROR && !mCalledCloseWithError) {
-        MessageChannel* channel = GetIPCChannel();
-        if (channel) {
-            mCalledCloseWithError = true;
-            channel->CloseWithError();
-        }
-    }
-
-    const ManagedContainer<POfflineCacheUpdateParent>& ocuParents =
-        ManagedPOfflineCacheUpdateParent();
-    for (auto iter = ocuParents.ConstIter(); !iter.Done(); iter.Next()) {
-        RefPtr<mozilla::docshell::OfflineCacheUpdateParent> ocuParent =
-            static_cast<mozilla::docshell::OfflineCacheUpdateParent*>(iter.Get()->GetKey());
-        ocuParent->StopSendingMessagesToChild();
-    }
-
-    // NB: must MarkAsDead() here so that this isn't accidentally
-    // returned from Get*() while in the midst of shutdown.
-    MarkAsDead();
-
-    // A ContentParent object might not get freed until after XPCOM shutdown has
-    // shut down the cycle collector.  But by then it's too late to release any
-    // CC'ed objects, so we need to null them out here, while we still can.  See
-    // bug 899761.
-    ShutDownMessageManager();
+  }
+
+  const ManagedContainer<POfflineCacheUpdateParent>& ocuParents =
+    ManagedPOfflineCacheUpdateParent();
+  for (auto iter = ocuParents.ConstIter(); !iter.Done(); iter.Next()) {
+    RefPtr<mozilla::docshell::OfflineCacheUpdateParent> ocuParent =
+      static_cast<mozilla::docshell::OfflineCacheUpdateParent*>(iter.Get()->GetKey());
+    ocuParent->StopSendingMessagesToChild();
+  }
+
+  // NB: must MarkAsDead() here so that this isn't accidentally
+  // returned from Get*() while in the midst of shutdown.
+  MarkAsDead();
+
+  // A ContentParent object might not get freed until after XPCOM shutdown has
+  // shut down the cycle collector.  But by then it's too late to release any
+  // CC'ed objects, so we need to null them out here, while we still can.  See
+  // bug 899761.
+  ShutDownMessageManager();
 }
 
 bool
 ContentParent::RecvFinishShutdown()
 {
-    // At this point, we already called ShutDownProcess once with
-    // SEND_SHUTDOWN_MESSAGE. To actually close the channel, we call
-    // ShutDownProcess again with CLOSE_CHANNEL.
-    MOZ_ASSERT(mShutdownPending);
-    ShutDownProcess(CLOSE_CHANNEL);
-    return true;
+  // At this point, we already called ShutDownProcess once with
+  // SEND_SHUTDOWN_MESSAGE. To actually close the channel, we call
+  // ShutDownProcess again with CLOSE_CHANNEL.
+  MOZ_ASSERT(mShutdownPending);
+  ShutDownProcess(CLOSE_CHANNEL);
+  return true;
 }
 
 void
 ContentParent::ShutDownMessageManager()
 {
   if (!mMessageManager) {
-    return;
+  return;
   }
 
   mMessageManager->ReceiveMessage(
-            static_cast<nsIContentFrameMessageManager*>(mMessageManager.get()), nullptr,
-            CHILD_PROCESS_SHUTDOWN_MESSAGE, false,
-            nullptr, nullptr, nullptr, nullptr);
+      static_cast<nsIContentFrameMessageManager*>(mMessageManager.get()), nullptr,
+      CHILD_PROCESS_SHUTDOWN_MESSAGE, false,
+      nullptr, nullptr, nullptr, nullptr);
 
   mMessageManager->Disconnect();
   mMessageManager = nullptr;
 }
 
 void
 ContentParent::MarkAsDead()
 {
-    if (!mAppManifestURL.IsEmpty()) {
-        if (sAppContentParents) {
-            sAppContentParents->Remove(mAppManifestURL);
-            if (!sAppContentParents->Count()) {
-                delete sAppContentParents;
-                sAppContentParents = nullptr;
-            }
-        }
-    } else if (sNonAppContentParents) {
-        sNonAppContentParents->RemoveElement(this);
-        if (!sNonAppContentParents->Length()) {
-            delete sNonAppContentParents;
-            sNonAppContentParents = nullptr;
-        }
+  if (!mAppManifestURL.IsEmpty()) {
+    if (sAppContentParents) {
+      sAppContentParents->Remove(mAppManifestURL);
+      if (!sAppContentParents->Count()) {
+        delete sAppContentParents;
+        sAppContentParents = nullptr;
+      }
     }
-
-    if (sPrivateContent) {
-        sPrivateContent->RemoveElement(this);
-        if (!sPrivateContent->Length()) {
-            delete sPrivateContent;
-            sPrivateContent = nullptr;
-        }
+  } else if (sNonAppContentParents) {
+    sNonAppContentParents->RemoveElement(this);
+    if (!sNonAppContentParents->Length()) {
+      delete sNonAppContentParents;
+      sNonAppContentParents = nullptr;
     }
-
-    mIsAlive = false;
+  }
+
+  if (sPrivateContent) {
+    sPrivateContent->RemoveElement(this);
+    if (!sPrivateContent->Length()) {
+      delete sPrivateContent;
+      sPrivateContent = nullptr;
+    }
+  }
+
+  mIsAlive = false;
 }
 
 void
 ContentParent::OnChannelError()
 {
-    RefPtr<ContentParent> content(this);
+  RefPtr<ContentParent> content(this);
 #ifdef MOZ_NUWA_PROCESS
-    // Handle app or Nuwa process exit before normal channel error handling.
-    PreallocatedProcessManager::MaybeForgetSpare(this);
+  // Handle app or Nuwa process exit before normal channel error handling.
+  PreallocatedProcessManager::MaybeForgetSpare(this);
 #endif
-    PContentParent::OnChannelError();
+  PContentParent::OnChannelError();
 }
 
 void
 ContentParent::OnChannelConnected(int32_t pid)
 {
-    SetOtherProcessId(pid);
+  SetOtherProcessId(pid);
 
 #if defined(ANDROID) || defined(LINUX)
-    // Check nice preference
-    int32_t nice = Preferences::GetInt("dom.ipc.content.nice", 0);
-
-    // Environment variable overrides preference
-    char* relativeNicenessStr = getenv("MOZ_CHILD_PROCESS_RELATIVE_NICENESS");
-    if (relativeNicenessStr) {
-        nice = atoi(relativeNicenessStr);
+  // Check nice preference
+  int32_t nice = Preferences::GetInt("dom.ipc.content.nice", 0);
+
+  // Environment variable overrides preference
+  char* relativeNicenessStr = getenv("MOZ_CHILD_PROCESS_RELATIVE_NICENESS");
+  if (relativeNicenessStr) {
+    nice = atoi(relativeNicenessStr);
+  }
+
+  /* make the GUI thread have higher priority on single-cpu devices */
+  nsCOMPtr<nsIPropertyBag2> infoService = do_GetService(NS_SYSTEMINFO_CONTRACTID);
+  if (infoService) {
+    int32_t cpus;
+    nsresult rv = infoService->GetPropertyAsInt32(NS_LITERAL_STRING("cpucount"), &cpus);
+    if (NS_FAILED(rv)) {
+      cpus = 1;
     }
-
-    /* make the GUI thread have higher priority on single-cpu devices */
-    nsCOMPtr<nsIPropertyBag2> infoService = do_GetService(NS_SYSTEMINFO_CONTRACTID);
-    if (infoService) {
-        int32_t cpus;
-        nsresult rv = infoService->GetPropertyAsInt32(NS_LITERAL_STRING("cpucount"), &cpus);
-        if (NS_FAILED(rv)) {
-            cpus = 1;
-        }
-        if (nice != 0 && cpus == 1) {
-            setpriority(PRIO_PROCESS, pid, getpriority(PRIO_PROCESS, pid) + nice);
-        }
+    if (nice != 0 && cpus == 1) {
+      setpriority(PRIO_PROCESS, pid, getpriority(PRIO_PROCESS, pid) + nice);
     }
+  }
 #endif
 }
 
 void
 ContentParent::ProcessingError(Result aCode, const char* aReason)
 {
-    if (MsgDropped == aCode) {
-        return;
-    }
-    // Other errors are big deals.
-    KillHard(aReason);
+  if (MsgDropped == aCode) {
+    return;
+  }
+  // Other errors are big deals.
+  KillHard(aReason);
 }
 
 typedef std::pair<ContentParent*, std::set<uint64_t> > IDPair;
 
 namespace {
 std::map<ContentParent*, std::set<uint64_t> >&
 NestedBrowserLayerIds()
 {
@@ -2041,239 +2026,239 @@ NestedBrowserLayerIds()
   static std::map<ContentParent*, std::set<uint64_t> > sNestedBrowserIds;
   return sNestedBrowserIds;
 }
 } // namespace
 
 bool
 ContentParent::RecvAllocateLayerTreeId(uint64_t* aId)
 {
-    *aId = CompositorParent::AllocateLayerTreeId();
-
-    auto iter = NestedBrowserLayerIds().find(this);
-    if (iter == NestedBrowserLayerIds().end()) {
-        std::set<uint64_t> ids;
-        ids.insert(*aId);
-        NestedBrowserLayerIds().insert(IDPair(this, ids));
-    } else {
-        iter->second.insert(*aId);
-    }
-    return true;
+  *aId = CompositorParent::AllocateLayerTreeId();
+
+  auto iter = NestedBrowserLayerIds().find(this);
+  if (iter == NestedBrowserLayerIds().end()) {
+    std::set<uint64_t> ids;
+    ids.insert(*aId);
+    NestedBrowserLayerIds().insert(IDPair(this, ids));
+  } else {
+    iter->second.insert(*aId);
+  }
+  return true;
 }
 
 bool
 ContentParent::RecvDeallocateLayerTreeId(const uint64_t& aId)
 {
-    auto iter = NestedBrowserLayerIds().find(this);
-    if (iter != NestedBrowserLayerIds().end() &&
-        iter->second.find(aId) != iter->second.end()) {
-        CompositorParent::DeallocateLayerTreeId(aId);
-    } else {
-        // You can't deallocate layer tree ids that you didn't allocate
-        KillHard("DeallocateLayerTreeId");
-    }
-    return true;
+  auto iter = NestedBrowserLayerIds().find(this);
+  if (iter != NestedBrowserLayerIds().end() &&
+    iter->second.find(aId) != iter->second.end()) {
+    CompositorParent::DeallocateLayerTreeId(aId);
+  } else {
+    // You can't deallocate layer tree ids that you didn't allocate
+    KillHard("DeallocateLayerTreeId");
+  }
+  return true;
 }
 
 namespace {
 
 void
 DelayedDeleteSubprocess(GeckoChildProcessHost* aSubprocess)
 {
-    XRE_GetIOMessageLoop()
-        ->PostTask(FROM_HERE,
-                   new DeleteTask<GeckoChildProcessHost>(aSubprocess));
+  XRE_GetIOMessageLoop()
+    ->PostTask(FROM_HERE,
+           new DeleteTask<GeckoChildProcessHost>(aSubprocess));
 }
 
 // This runnable only exists to delegate ownership of the
 // ContentParent to this runnable, until it's deleted by the event
 // system.
 struct DelayedDeleteContentParentTask : public nsRunnable
 {
-    explicit DelayedDeleteContentParentTask(ContentParent* aObj) : mObj(aObj) { }
-
-    // No-op
-    NS_IMETHODIMP Run() { return NS_OK; }
-
-    RefPtr<ContentParent> mObj;
+  explicit DelayedDeleteContentParentTask(ContentParent* aObj) : mObj(aObj) { }
+
+  // No-op
+  NS_IMETHODIMP Run() { return NS_OK; }
+
+  RefPtr<ContentParent> mObj;
 };
 
 } // namespace
 
 void
 ContentParent::ActorDestroy(ActorDestroyReason why)
 {
-    if (mForceKillTimer) {
-        mForceKillTimer->Cancel();
-        mForceKillTimer = nullptr;
-    }
-
-    // Signal shutdown completion regardless of error state, so we can
-    // finish waiting in the xpcom-shutdown/profile-before-change observer.
-    mIPCOpen = false;
-
-    if (mHangMonitorActor) {
-        ProcessHangMonitor::RemoveProcess(mHangMonitorActor);
-        mHangMonitorActor = nullptr;
+  if (mForceKillTimer) {
+    mForceKillTimer->Cancel();
+    mForceKillTimer = nullptr;
+  }
+
+  // Signal shutdown completion regardless of error state, so we can
+  // finish waiting in the xpcom-shutdown/profile-before-change observer.
+  mIPCOpen = false;
+
+  if (mHangMonitorActor) {
+    ProcessHangMonitor::RemoveProcess(mHangMonitorActor);
+    mHangMonitorActor = nullptr;
+  }
+
+  if (why == NormalShutdown && !mCalledClose) {
+    // If we shut down normally but haven't called Close, assume somebody
+    // else called Close on us. In that case, we still need to call
+    // ShutDownProcess below to perform other necessary clean up.
+    mCalledClose = true;
+  }
+
+  // Make sure we always clean up.
+  ShutDownProcess(why == NormalShutdown ? CLOSE_CHANNEL
+                                        : CLOSE_CHANNEL_WITH_ERROR);
+
+  RefPtr<ContentParent> kungFuDeathGrip(this);
+  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
+  if (obs) {
+    size_t length = ArrayLength(sObserverTopics);
+    for (size_t i = 0; i < length; ++i) {
+      obs->RemoveObserver(static_cast<nsIObserver*>(this),
+                          sObserverTopics[i]);
     }
-
-    if (why == NormalShutdown && !mCalledClose) {
-        // If we shut down normally but haven't called Close, assume somebody
-        // else called Close on us. In that case, we still need to call
-        // ShutDownProcess below to perform other necessary clean up.
-        mCalledClose = true;
-    }
-
-    // Make sure we always clean up.
-    ShutDownProcess(why == NormalShutdown ? CLOSE_CHANNEL
-                                          : CLOSE_CHANNEL_WITH_ERROR);
-
-    RefPtr<ContentParent> kungFuDeathGrip(this);
-    nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-    if (obs) {
-        size_t length = ArrayLength(sObserverTopics);
-        for (size_t i = 0; i < length; ++i) {
-            obs->RemoveObserver(static_cast<nsIObserver*>(this),
-                                sObserverTopics[i]);
-        }
-    }
-
-    // remove the global remote preferences observers
-    Preferences::RemoveObserver(this, "");
+  }
+
+  // remove the global remote preferences observers
+  Preferences::RemoveObserver(this, "");
 
 #ifdef MOZ_NUWA_PROCESS
-    // Remove the pref update requests.
-    if (IsNuwaProcess() && sNuwaPrefUpdates) {
-        delete sNuwaPrefUpdates;
-        sNuwaPrefUpdates = nullptr;
-    }
+  // Remove the pref update requests.
+  if (IsNuwaProcess() && sNuwaPrefUpdates) {
+    delete sNuwaPrefUpdates;
+    sNuwaPrefUpdates = nullptr;
+  }
 #endif
 
-    RecvRemoveGeolocationListener();
-
-    mConsoleService = nullptr;
+  RecvRemoveGeolocationListener();
+
+  mConsoleService = nullptr;
 
 #ifdef MOZ_ENABLE_PROFILER_SPS
-    if (mGatherer && !mProfile.IsEmpty()) {
-        mGatherer->OOPExitProfile(mProfile);
-    }
+  if (mGatherer && !mProfile.IsEmpty()) {
+    mGatherer->OOPExitProfile(mProfile);
+  }
 #endif
 
-    if (obs) {
-        RefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
-
-        props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), mChildID);
-
-        if (AbnormalShutdown == why) {
-            Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
-                                  NS_LITERAL_CSTRING("content"), 1);
-
-            props->SetPropertyAsBool(NS_LITERAL_STRING("abnormal"), true);
+  if (obs) {
+    RefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
+
+    props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), mChildID);
+
+    if (AbnormalShutdown == why) {
+      Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
+                            NS_LITERAL_CSTRING("content"), 1);
+
+      props->SetPropertyAsBool(NS_LITERAL_STRING("abnormal"), true);
 
 #ifdef MOZ_CRASHREPORTER
-            // There's a window in which child processes can crash
-            // after IPC is established, but before a crash reporter
-            // is created.
-            if (PCrashReporterParent* p = LoneManagedOrNullAsserts(ManagedPCrashReporterParent())) {
-                CrashReporterParent* crashReporter =
-                    static_cast<CrashReporterParent*>(p);
-
-                // If we're an app process, always stomp the latest URI
-                // loaded in the child process with our manifest URL.  We
-                // would rather associate the crashes with apps than
-                // random child windows loaded in them.
-                //
-                // XXX would be nice if we could get both ...
-                if (!mAppManifestURL.IsEmpty()) {
-                    crashReporter->AnnotateCrashReport(NS_LITERAL_CSTRING("URL"),
-                                                       NS_ConvertUTF16toUTF8(mAppManifestURL));
-                }
-
-                // if mCreatedPairedMinidumps is true, we've already generated
-                // parent/child dumps for dekstop crashes.
-                if (!mCreatedPairedMinidumps) {
-                    crashReporter->GenerateCrashReport(this, nullptr);
-                }
-
-                nsAutoString dumpID(crashReporter->ChildDumpID());
-                props->SetPropertyAsAString(NS_LITERAL_STRING("dumpID"), dumpID);
-            }
+      // There's a window in which child processes can crash
+      // after IPC is established, but before a crash reporter
+      // is created.
+      if (PCrashReporterParent* p = LoneManagedOrNullAsserts(ManagedPCrashReporterParent())) {
+        CrashReporterParent* crashReporter =
+          static_cast<CrashReporterParent*>(p);
+
+        // If we're an app process, always stomp the latest URI
+        // loaded in the child process with our manifest URL.  We
+        // would rather associate the crashes with apps than
+        // random child windows loaded in them.
+        //
+        // XXX would be nice if we could get both ...
+        if (!mAppManifestURL.IsEmpty()) {
+          crashReporter->AnnotateCrashReport(NS_LITERAL_CSTRING("URL"),
+                                             NS_ConvertUTF16toUTF8(mAppManifestURL));
+        }
+
+        // if mCreatedPairedMinidumps is true, we've already generated
+        // parent/child dumps for dekstop crashes.
+        if (!mCreatedPairedMinidumps) {
+          crashReporter->GenerateCrashReport(this, nullptr);
+        }
+
+        nsAutoString dumpID(crashReporter->ChildDumpID());
+        props->SetPropertyAsAString(NS_LITERAL_STRING("dumpID"), dumpID);
+      }
 #endif
-        }
-        nsAutoString cpId;
-        cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
-        obs->NotifyObservers((nsIPropertyBag2*) props, "ipc:content-shutdown", cpId.get());
     }
-
-    // Remove any and all idle listeners.
-    nsCOMPtr<nsIIdleService> idleService =
-        do_GetService("@mozilla.org/widget/idleservice;1");
-    MOZ_ASSERT(idleService);
-    RefPtr<ParentIdleListener> listener;
-    for (int32_t i = mIdleListeners.Length() - 1; i >= 0; --i) {
-        listener = static_cast<ParentIdleListener*>(mIdleListeners[i].get());
-        idleService->RemoveIdleObserver(listener, listener->mTime);
-    }
-    mIdleListeners.Clear();
-
-    MessageLoop::current()->
-        PostTask(FROM_HERE,
-                 NewRunnableFunction(DelayedDeleteSubprocess, mSubprocess));
-    mSubprocess = nullptr;
-
-    // IPDL rules require actors to live on past ActorDestroy, but it
-    // may be that the kungFuDeathGrip above is the last reference to
-    // |this|.  If so, when we go out of scope here, we're deleted and
-    // all hell breaks loose.
-    //
-    // This runnable ensures that a reference to |this| lives on at
-    // least until after the current task finishes running.
-    NS_DispatchToCurrentThread(new DelayedDeleteContentParentTask(this));
-
-    // Release the appId's reference count of any processes
-    // created by this ContentParent and the frame opened by this ContentParent
-    // if this ContentParent crashes.
-    ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
-    nsTArray<ContentParentId> childIDArray =
-        cpm->GetAllChildProcessById(this->ChildID());
-    if (why == AbnormalShutdown) {
-      nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
-      if(permMgr) {
-        // Release the appId's reference count of its child-processes
-        for (uint32_t i = 0; i < childIDArray.Length(); i++) {
-          nsTArray<TabContext> tabCtxs = cpm->GetTabContextByContentProcess(childIDArray[i]);
-          for (uint32_t j = 0 ; j < tabCtxs.Length() ; j++) {
-            if (tabCtxs[j].OwnOrContainingAppId() != nsIScriptSecurityManager::NO_APP_ID) {
-              permMgr->ReleaseAppId(tabCtxs[j].OwnOrContainingAppId());
-            }
-          }
-        }
-        // Release the appId's reference count belong to itself
-        nsTArray<TabContext> tabCtxs = cpm->GetTabContextByContentProcess(mChildID);
-        for (uint32_t i = 0; i < tabCtxs.Length() ; i++) {
-          if (tabCtxs[i].OwnOrContainingAppId()!= nsIScriptSecurityManager::NO_APP_ID) {
-            permMgr->ReleaseAppId(tabCtxs[i].OwnOrContainingAppId());
-          }
-        }
+    nsAutoString cpId;
+    cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
+    obs->NotifyObservers((nsIPropertyBag2*) props, "ipc:content-shutdown", cpId.get());
+  }
+
+  // Remove any and all idle listeners.
+  nsCOMPtr<nsIIdleService> idleService =
+    do_GetService("@mozilla.org/widget/idleservice;1");
+  MOZ_ASSERT(idleService);
+  RefPtr<ParentIdleListener> listener;
+  for (int32_t i = mIdleListeners.Length() - 1; i >= 0; --i) {
+    listener = static_cast<ParentIdleListener*>(mIdleListeners[i].get());
+    idleService->RemoveIdleObserver(listener, listener->mTime);
+  }
+  mIdleListeners.Clear();
+
+  MessageLoop::current()->
+    PostTask(FROM_HERE,
+             NewRunnableFunction(DelayedDeleteSubprocess, mSubprocess));
+  mSubprocess = nullptr;
+
+  // IPDL rules require actors to live on past ActorDestroy, but it
+  // may be that the kungFuDeathGrip above is the last reference to
+  // |this|.  If so, when we go out of scope here, we're deleted and
+  // all hell breaks loose.
+  //
+  // This runnable ensures that a reference to |this| lives on at
+  // least until after the current task finishes running.
+  NS_DispatchToCurrentThread(new DelayedDeleteContentParentTask(this));
+
+  // Release the appId's reference count of any processes
+  // created by this ContentParent and the frame opened by this ContentParent
+  // if this ContentParent crashes.
+  ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
+  nsTArray<ContentParentId> childIDArray =
+    cpm->GetAllChildProcessById(this->ChildID());
+  if (why == AbnormalShutdown) {
+    nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
+    if(permMgr) {
+    // Release the appId's reference count of its child-processes
+    for (uint32_t i = 0; i < childIDArray.Length(); i++) {
+      nsTArray<TabContext> tabCtxs = cpm->GetTabContextByContentProcess(childIDArray[i]);
+      for (uint32_t j = 0 ; j < tabCtxs.Length() ; j++) {
+      if (tabCtxs[j].OwnOrContainingAppId() != nsIScriptSecurityManager::NO_APP_ID) {
+        permMgr->ReleaseAppId(tabCtxs[j].OwnOrContainingAppId());
+      }
       }
     }
-
-    // Destroy any processes created by this ContentParent
-    for(uint32_t i = 0; i < childIDArray.Length(); i++) {
-        ContentParent* cp = cpm->GetContentProcessById(childIDArray[i]);
-        MessageLoop::current()->PostTask(
-            FROM_HERE,
-            NewRunnableMethod(cp, &ContentParent::ShutDownProcess,
-                              SEND_SHUTDOWN_MESSAGE));
+    // Release the appId's reference count belong to itself
+    nsTArray<TabContext> tabCtxs = cpm->GetTabContextByContentProcess(mChildID);
+    for (uint32_t i = 0; i < tabCtxs.Length() ; i++) {
+      if (tabCtxs[i].OwnOrContainingAppId()!= nsIScriptSecurityManager::NO_APP_ID) {
+      permMgr->ReleaseAppId(tabCtxs[i].OwnOrContainingAppId());
+      }
+    }
     }
-    cpm->RemoveContentProcess(this->ChildID());
-
-    if (mDriverCrashGuard) {
-      mDriverCrashGuard->NotifyCrashed();
-    }
+  }
+
+  // Destroy any processes created by this ContentParent
+  for(uint32_t i = 0; i < childIDArray.Length(); i++) {
+    ContentParent* cp = cpm->GetContentProcessById(childIDArray[i]);
+    MessageLoop::current()->PostTask(
+      FROM_HERE,
+      NewRunnableMethod(cp, &ContentParent::ShutDownProcess,
+                        SEND_SHUTDOWN_MESSAGE));
+  }
+  cpm->RemoveContentProcess(this->ChildID());
+
+  if (mDriverCrashGuard) {
+    mDriverCrashGuard->NotifyCrashed();
+  }
 }
 
 void
 ContentParent::NotifyTabDestroying(const TabId& aTabId,
                                    const ContentParentId& aCpId)
 {
   if (XRE_IsParentProcess()) {
     // There can be more than one PBrowser for a given app process
@@ -2299,759 +2284,758 @@ ContentParent::NotifyTabDestroying(const
   } else {
     ContentChild::GetSingleton()->SendNotifyTabDestroying(aTabId, aCpId);
   }
 }
 
 void
 ContentParent::StartForceKillTimer()
 {
-    if (mForceKillTimer || !mIPCOpen) {
-        return;
-    }
-
-    int32_t timeoutSecs = Preferences::GetInt("dom.ipc.tabs.shutdownTimeoutSecs", 5);
-    if (timeoutSecs > 0) {
-        mForceKillTimer = do_CreateInstance("@mozilla.org/timer;1");
-        MOZ_ASSERT(mForceKillTimer);
-        mForceKillTimer->InitWithFuncCallback(ContentParent::ForceKillTimerCallback,
-                                              this,
-                                              timeoutSecs * 1000,
-                                              nsITimer::TYPE_ONE_SHOT);
-    }
+  if (mForceKillTimer || !mIPCOpen) {
+    return;
+  }
+
+  int32_t timeoutSecs = Preferences::GetInt("dom.ipc.tabs.shutdownTimeoutSecs", 5);
+  if (timeoutSecs > 0) {
+    mForceKillTimer = do_CreateInstance("@mozilla.org/timer;1");
+    MOZ_ASSERT(mForceKillTimer);
+    mForceKillTimer->InitWithFuncCallback(ContentParent::ForceKillTimerCallback,
+                                          this,
+                                          timeoutSecs * 1000,
+                                          nsITimer::TYPE_ONE_SHOT);
+  }
 }
 
 void
 ContentParent::NotifyTabDestroyed(const TabId& aTabId,
                                   bool aNotifiedDestroying)
 {
-    if (aNotifiedDestroying) {
-        --mNumDestroyingTabs;
-    }
-
-    nsTArray<PContentPermissionRequestParent*> parentArray =
-        nsContentPermissionUtils::GetContentPermissionRequestParentById(aTabId);
-
-    // Need to close undeleted ContentPermissionRequestParents before tab is closed.
-    for (auto& permissionRequestParent : parentArray) {
-        Unused << PContentPermissionRequestParent::Send__delete__(permissionRequestParent);
-    }
-
-    // There can be more than one PBrowser for a given app process
-    // because of popup windows.  When the last one closes, shut
-    // us down.
-    ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
-    nsTArray<TabId> tabIds = cpm->GetTabParentsByProcessId(this->ChildID());
-    if (tabIds.Length() == 1) {
-        // In the case of normal shutdown, send a shutdown message to child to
-        // allow it to perform shutdown tasks.
-        MessageLoop::current()->PostTask(
-            FROM_HERE,
-            NewRunnableMethod(this, &ContentParent::ShutDownProcess,
-                              SEND_SHUTDOWN_MESSAGE));
-    }
+  if (aNotifiedDestroying) {
+    --mNumDestroyingTabs;
+  }
+
+  nsTArray<PContentPermissionRequestParent*> parentArray =
+    nsContentPermissionUtils::GetContentPermissionRequestParentById(aTabId);
+
+  // Need to close undeleted ContentPermissionRequestParents before tab is closed.
+  for (auto& permissionRequestParent : parentArray) {
+    Unused << PContentPermissionRequestParent::Send__delete__(permissionRequestParent);
+  }
+
+  // There can be more than one PBrowser for a given app process
+  // because of popup windows.  When the last one closes, shut
+  // us down.
+  ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
+  nsTArray<TabId> tabIds = cpm->GetTabParentsByProcessId(this->ChildID());
+  if (tabIds.Length() == 1) {
+    // In the case of normal shutdown, send a shutdown message to child to
+    // allow it to perform shutdown tasks.
+    MessageLoop::current()->PostTask(
+      FROM_HERE,
+      NewRunnableMethod(this, &ContentParent::ShutDownProcess,
+                        SEND_SHUTDOWN_MESSAGE));
+  }
 }
 
 jsipc::CPOWManager*
 ContentParent::GetCPOWManager()
 {
-    if (PJavaScriptParent* p = LoneManagedOrNullAsserts(ManagedPJavaScriptParent())) {
-        return CPOWManagerFor(p);
-    }
-    return nullptr;
+  if (PJavaScriptParent* p = LoneManagedOrNullAsserts(ManagedPJavaScriptParent())) {
+    return CPOWManagerFor(p);
+  }
+  return nullptr;
 }
 
 TestShellParent*
 ContentParent::CreateTestShell()
 {
   return static_cast<TestShellParent*>(SendPTestShellConstructor());
 }
 
 bool
 ContentParent::DestroyTestShell(TestShellParent* aTestShell)
 {
-    return PTestShellParent::Send__delete__(aTestShell);
+  return PTestShellParent::Send__delete__(aTestShell);
 }
 
 TestShellParent*
 ContentParent::GetTestShellSingleton()
 {
-    PTestShellParent* p = LoneManagedOrNullAsserts(ManagedPTestShellParent());
-    return static_cast<TestShellParent*>(p);
+  PTestShellParent* p = LoneManagedOrNullAsserts(ManagedPTestShellParent());
+  return static_cast<TestShellParent*>(p);
 }
 
 void
 ContentParent::InitializeMembers()
 {
-    mSubprocess = nullptr;
-    mChildID = gContentChildID++;
-    mGeolocationWatchID = -1;
-    mNumDestroyingTabs = 0;
-    mIsAlive = true;
-    mMetamorphosed = false;
-    mSendPermissionUpdates = false;
-    mSendDataStoreInfos = false;
-    mCalledClose = false;
-    mCalledCloseWithError = false;
-    mCalledKillHard = false;
-    mCreatedPairedMinidumps = false;
-    mShutdownPending = false;
-    mIPCOpen = true;
-    mHangMonitorActor = nullptr;
+  mSubprocess = nullptr;
+  mChildID = gContentChildID++;
+  mGeolocationWatchID = -1;
+  mNumDestroyingTabs = 0;
+  mIsAlive = true;
+  mMetamorphosed = false;
+  mSendPermissionUpdates = false;
+  mSendDataStoreInfos = false;
+  mCalledClose = false;
+  mCalledCloseWithError = false;
+  mCalledKillHard = false;
+  mCreatedPairedMinidumps = false;
+  mShutdownPending = false;
+  mIPCOpen = true;
+  mHangMonitorActor = nullptr;
 }
 
 bool
 ContentParent::LaunchSubprocess(ProcessPriority aInitialPriority /* = PROCESS_PRIORITY_FOREGROUND */)
 {
-    std::vector<std::string> extraArgs;
-    if (mIsNuwaProcess) {
-        extraArgs.push_back("-nuwa");
-    }
-
-    if (!mSubprocess->LaunchAndWaitForProcessHandle(extraArgs)) {
-        MarkAsDead();
-        return false;
-    }
-
-    Open(mSubprocess->GetChannel(),
-         base::GetProcId(mSubprocess->GetChildProcessHandle()));
-
-    InitInternal(aInitialPriority,
-                 true, /* Setup off-main thread compositing */
-                 true  /* Send registered chrome */);
-
-    ContentProcessManager::GetSingleton()->AddContentProcess(this);
-
-    ProcessHangMonitor::AddProcess(this);
-
-    // Set a reply timeout for CPOWs.
-    SetReplyTimeoutMs(Preferences::GetInt("dom.ipc.cpow.timeout", 0));
-
-    return true;
+  std::vector<std::string> extraArgs;
+  if (mIsNuwaProcess) {
+    extraArgs.push_back("-nuwa");
+  }
+
+  if (!mSubprocess->LaunchAndWaitForProcessHandle(extraArgs)) {
+    MarkAsDead();
+    return false;
+  }
+
+  Open(mSubprocess->GetChannel(),
+     base::GetProcId(mSubprocess->GetChildProcessHandle()));
+
+  InitInternal(aInitialPriority,
+               true, /* Setup off-main thread compositing */
+               true  /* Send registered chrome */);
+
+  ContentProcessManager::GetSingleton()->AddContentProcess(this);
+
+  ProcessHangMonitor::AddProcess(this);
+
+  // Set a reply timeout for CPOWs.
+  SetReplyTimeoutMs(Preferences::GetInt("dom.ipc.cpow.timeout", 0));
+
+  return true;
 }
 
 ContentParent::ContentParent(mozIApplication* aApp,
                              ContentParent* aOpener,
                              bool aIsForBrowser,
                              bool aIsForPreallocated,
                              bool aIsNuwaProcess /* = false */)
-    : nsIContentParent()
-    , mOpener(aOpener)
-    , mIsForBrowser(aIsForBrowser)
-    , mIsNuwaProcess(aIsNuwaProcess)
-    , mHasGamepadListener(false)
-{
-    InitializeMembers();  // Perform common initialization.
-
-    // No more than one of !!aApp, aIsForBrowser, aIsForPreallocated should be
-    // true.
-    MOZ_ASSERT(!!aApp + aIsForBrowser + aIsForPreallocated <= 1);
-
-    // Only the preallocated process uses Nuwa.
-    MOZ_ASSERT_IF(aIsNuwaProcess, aIsForPreallocated);
-
-    if (!aIsNuwaProcess && !aIsForPreallocated) {
-        mMetamorphosed = true;
-    }
-
-    // Insert ourselves into the global linked list of ContentParent objects.
-    if (!sContentParents) {
-        sContentParents = new LinkedList<ContentParent>();
-    }
-    if (!aIsNuwaProcess) {
-        sContentParents->insertBack(this);
-    }
-
-    if (aApp) {
-        aApp->GetManifestURL(mAppManifestURL);
-        aApp->GetName(mAppName);
-    } else if (aIsForPreallocated) {
-        mAppManifestURL = MAGIC_PREALLOCATED_APP_MANIFEST_URL;
-    }
-
-    // From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the
-    // PID along with the warning.
-    nsDebugImpl::SetMultiprocessMode("Parent");
+  : nsIContentParent()
+  , mOpener(aOpener)
+  , mIsForBrowser(aIsForBrowser)
+  , mIsNuwaProcess(aIsNuwaProcess)
+  , mHasGamepadListener(false)
+{
+  InitializeMembers();  // Perform common initialization.
+
+  // No more than one of !!aApp, aIsForBrowser, aIsForPreallocated should be
+  // true.
+  MOZ_ASSERT(!!aApp + aIsForBrowser + aIsForPreallocated <= 1);
+
+  // Only the preallocated process uses Nuwa.
+  MOZ_ASSERT_IF(aIsNuwaProcess, aIsForPreallocated);
+
+  if (!aIsNuwaProcess && !aIsForPreallocated) {
+    mMetamorphosed = true;
+  }
+
+  // Insert ourselves into the global linked list of ContentParent objects.
+  if (!sContentParents) {
+    sContentParents = new LinkedList<ContentParent>();
+  }
+  if (!aIsNuwaProcess) {
+    sContentParents->insertBack(this);
+  }
+
+  if (aApp) {
+    aApp->GetManifestURL(mAppManifestURL);
+    aApp->GetName(mAppName);
+  } else if (aIsForPreallocated) {
+    mAppManifestURL = MAGIC_PREALLOCATED_APP_MANIFEST_URL;
+  }
+
+  // From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the
+  // PID along with the warning.
+  nsDebugImpl::SetMultiprocessMode("Parent");
 
 #if defined(XP_WIN) && !defined(MOZ_B2G)
-    // Request Windows message deferral behavior on our side of the PContent
-    // channel. Generally only applies to the situation where we get caught in
-    // a deadlock with the plugin process when sending CPOWs.
-    GetIPCChannel()->SetChannelFlags(MessageChannel::REQUIRE_DEFERRED_MESSAGE_PROTECTION);
+  // Request Windows message deferral behavior on our side of the PContent
+  // channel. Generally only applies to the situation where we get caught in
+  // a deadlock with the plugin process when sending CPOWs.
+  GetIPCChannel()->SetChannelFlags(MessageChannel::REQUIRE_DEFERRED_MESSAGE_PROTECTION);
 #endif
 
-    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-    ChildPrivileges privs = aIsNuwaProcess
-        ? base::PRIVILEGES_INHERIT
-        : base::PRIVILEGES_DEFAULT;
-    mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, privs);
-
-    IToplevelProtocol::SetTransport(mSubprocess->GetChannel());
+  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
+  ChildPrivileges privs = aIsNuwaProcess
+    ? base::PRIVILEGES_INHERIT
+    : base::PRIVILEGES_DEFAULT;
+  mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, privs);
+
+  IToplevelProtocol::SetTransport(mSubprocess->GetChannel());
 }
 
 #ifdef MOZ_NUWA_PROCESS
 static const mozilla::ipc::FileDescriptor*
 FindFdProtocolFdMapping(const nsTArray<ProtocolFdMapping>& aFds,
                         ProtocolId aProtoId)
 {
-    for (unsigned int i = 0; i < aFds.Length(); i++) {
-        if (aFds[i].protocolId() == aProtoId) {
-            return &aFds[i].fd();
-        }
+  for (unsigned int i = 0; i < aFds.Length(); i++) {
+    if (aFds[i].protocolId() == aProtoId) {
+      return &aFds[i].fd();
     }
-    return nullptr;
+  }
+  return nullptr;
 }
 
 /**
  * This constructor is used for new content process cloned from a template.
  *
  * For Nuwa.
  */
 ContentParent::ContentParent(ContentParent* aTemplate,
                              const nsAString& aAppManifestURL,
                              base::ProcessHandle aPid,
                              InfallibleTArray<ProtocolFdMapping>&& aFds)
-    : mAppManifestURL(aAppManifestURL)
-    , mIsForBrowser(false)
-    , mIsNuwaProcess(false)
-{
-    InitializeMembers();  // Perform common initialization.
-
-    sContentParents->insertBack(this);
-
-    // From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the
-    // PID along with the warning.
-    nsDebugImpl::SetMultiprocessMode("Parent");
-
-    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
-    const FileDescriptor* fd = FindFdProtocolFdMapping(aFds, GetProtocolId());
-
-    NS_ASSERTION(fd != nullptr, "IPC Channel for PContent is necessary!");
-    mSubprocess = new GeckoExistingProcessHost(GeckoProcessType_Content,
-                                               aPid,
-                                               *fd);
-
-    mSubprocess->LaunchAndWaitForProcessHandle();
-
-    // Clone actors routed by aTemplate for this instance.
-    IToplevelProtocol::SetTransport(mSubprocess->GetChannel());
-    ProtocolCloneContext cloneContext;
-    cloneContext.SetContentParent(this);
-    CloneManagees(aTemplate, &cloneContext);
-    CloneOpenedToplevels(aTemplate, aFds, aPid, &cloneContext);
-
-    Open(mSubprocess->GetChannel(),
-         base::GetProcId(mSubprocess->GetChildProcessHandle()));
-
-    // Set the subprocess's priority (bg if we're a preallocated process, fg
-    // otherwise).  We do this first because we're likely /lowering/ its CPU and
-    // memory priority, which it has inherited from this process.
-    ProcessPriority priority;
-    if (IsPreallocated()) {
-        priority = PROCESS_PRIORITY_PREALLOC;
-    } else {
-        priority = PROCESS_PRIORITY_FOREGROUND;
-    }
-
-    InitInternal(priority,
-                 false, /* Setup Off-main thread compositing */
-                 false  /* Send registered chrome */);
-
-    ContentProcessManager::GetSingleton()->AddContentProcess(this);
+  : mAppManifestURL(aAppManifestURL)
+  , mIsForBrowser(false)
+  , mIsNuwaProcess(false)
+{
+  InitializeMembers();  // Perform common initialization.
+
+  sContentParents->insertBack(this);
+
+  // From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the
+  // PID along with the warning.
+  nsDebugImpl::SetMultiprocessMode("Parent");
+
+  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
+
+  const FileDescriptor* fd = FindFdProtocolFdMapping(aFds, GetProtocolId());
+
+  NS_ASSERTION(fd != nullptr, "IPC Channel for PContent is necessary!");
+  mSubprocess = new GeckoExistingProcessHost(GeckoProcessType_Content,
+                                             aPid, *fd);
+
+  mSubprocess->LaunchAndWaitForProcessHandle();
+
+  // Clone actors routed by aTemplate for this instance.
+  IToplevelProtocol::SetTransport(mSubprocess->GetChannel());
+  ProtocolCloneContext cloneContext;
+  cloneContext.SetContentParent(this);
+  CloneManagees(aTemplate, &cloneContext);
+  CloneOpenedToplevels(aTemplate, aFds, aPid, &cloneContext);
+
+  Open(mSubprocess->GetChannel(),
+     base::GetProcId(mSubprocess->GetChildProcessHandle()));
+
+  // Set the subprocess's priority (bg if we're a preallocated process, fg
+  // otherwise).  We do this first because we're likely /lowering/ its CPU and
+  // memory priority, which it has inherited from this process.
+  ProcessPriority priority;
+  if (IsPreallocated()) {
+    priority = PROCESS_PRIORITY_PREALLOC;
+  } else {
+    priority = PROCESS_PRIORITY_FOREGROUND;
+  }
+
+  InitInternal(priority,
+               false, /* Setup Off-main thread compositing */
+               false  /* Send registered chrome */);
+
+  ContentProcessManager::GetSingleton()->AddContentProcess(this);
 }
 #endif  // MOZ_NUWA_PROCESS
 
 ContentParent::~ContentParent()
 {
-    if (mForceKillTimer) {
-        mForceKillTimer->Cancel();
-    }
-
-    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
-    // We should be removed from all these lists in ActorDestroy.
-    MOZ_ASSERT(!sPrivateContent || !sPrivateContent->Contains(this));
-    if (mAppManifestURL.IsEmpty()) {
-        MOZ_ASSERT(!sNonAppContentParents ||
-                   !sNonAppContentParents->Contains(this));
-    } else {
-        // In general, we expect sAppContentParents->Get(mAppManifestURL) to be
-        // nullptr.  But it could be that we created another ContentParent for
-        // this app after we did this->ActorDestroy(), so the right check is
-        // that sAppContentParents->Get(mAppManifestURL) != this.
-        MOZ_ASSERT(!sAppContentParents ||
-                   sAppContentParents->Get(mAppManifestURL) != this);
-    }
+  if (mForceKillTimer) {
+    mForceKillTimer->Cancel();
+  }
+
+  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
+
+  // We should be removed from all these lists in ActorDestroy.
+  MOZ_ASSERT(!sPrivateContent || !sPrivateContent->Contains(this));
+  if (mAppManifestURL.IsEmpty()) {
+    MOZ_ASSERT(!sNonAppContentParents ||
+               !sNonAppContentParents->Contains(this));
+  } else {
+    // In general, we expect sAppContentParents->Get(mAppManifestURL) to be
+    // nullptr.  But it could be that we created another ContentParent for
+    // this app after we did this->ActorDestroy(), so the right check is
+    // that sAppContentParents->Get(mAppManifestURL) != this.
+    MOZ_ASSERT(!sAppContentParents ||
+               sAppContentParents->Get(mAppManifestURL) != this);
+  }
 
 #ifdef MOZ_NUWA_PROCESS
-    if (IsNuwaProcess()) {
-        sNuwaReady = false;
-        sNuwaPid = 0;
-    }
+  if (IsNuwaProcess()) {
+    sNuwaReady = false;
+    sNuwaPid = 0;
+  }
 #endif
 }
 
 void
 ContentParent::InitInternal(ProcessPriority aInitialPriority,
                             bool aSetupOffMainThreadCompositing,
                             bool aSendRegisteredChrome)
 {
-    if (aSendRegisteredChrome) {
-        nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
-        nsChromeRegistryChrome* chromeRegistry =
-            static_cast<nsChromeRegistryChrome*>(registrySvc.get());
-        chromeRegistry->SendRegisteredChrome(this);
-    }
-
-    if (gAppData) {
-        nsCString version(gAppData->version);
-        nsCString buildID(gAppData->buildID);
-        nsCString name(gAppData->name);
-        nsCString UAName(gAppData->UAName);
-        nsCString ID(gAppData->ID);
-        nsCString vendor(gAppData->vendor);
-
-        // Sending all information to content process.
-        Unused << SendAppInfo(version, buildID, name, UAName, ID, vendor);
+  if (aSendRegisteredChrome) {
+    nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
+    nsChromeRegistryChrome* chromeRegistry =
+      static_cast<nsChromeRegistryChrome*>(registrySvc.get());
+    chromeRegistry->SendRegisteredChrome(this);
+  }
+
+  if (gAppData) {
+    nsCString version(gAppData->version);
+    nsCString buildID(gAppData->buildID);
+    nsCString name(gAppData->name);
+    nsCString UAName(gAppData->UAName);
+    nsCString ID(gAppData->ID);
+    nsCString vendor(gAppData->vendor);
+
+    // Sending all information to content process.
+    Unused << SendAppInfo(version, buildID, name, UAName, ID, vendor);
+  }
+
+  // Initialize the message manager (and load delayed scripts) now that we
+  // have established communications with the child.
+  mMessageManager->InitWithCallback(this);
+
+  // Set the subprocess's priority.  We do this early on because we're likely
+  // /lowering/ the process's CPU and memory priority, which it has inherited
+  // from this process.
+  //
+  // This call can cause us to send IPC messages to the child process, so it
+  // must come after the Open() call above.
+  ProcessPriorityManager::SetProcessPriority(this, aInitialPriority);
+
+  if (aSetupOffMainThreadCompositing) {
+    // NB: internally, this will send an IPC message to the child
+    // process to get it to create the CompositorChild.  This
+    // message goes through the regular IPC queue for this
+    // channel, so delivery will happen-before any other messages
+    // we send.  The CompositorChild must be created before any
+    // PBrowsers are created, because they rely on the Compositor
+    // already being around.  (Creation is async, so can't happen
+    // on demand.)
+    bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
+    if (useOffMainThreadCompositing) {
+      DebugOnly<bool> opened = PCompositor::Open(this);
+      MOZ_ASSERT(opened);
+
+      opened = PImageBridge::Open(this);
+      MOZ_ASSERT(opened);
+
+      opened = gfx::PVRManager::Open(this);
+      MOZ_ASSERT(opened);
     }
-
-    // Initialize the message manager (and load delayed scripts) now that we
-    // have established communications with the child.
-    mMessageManager->InitWithCallback(this);
-
-    // Set the subprocess's priority.  We do this early on because we're likely
-    // /lowering/ the process's CPU and memory priority, which it has inherited
-    // from this process.
-    //
-    // This call can cause us to send IPC messages to the child process, so it
-    // must come after the Open() call above.
-    ProcessPriorityManager::SetProcessPriority(this, aInitialPriority);
-
-    if (aSetupOffMainThreadCompositing) {
-        // NB: internally, this will send an IPC message to the child
-        // process to get it to create the CompositorChild.  This
-        // message goes through the regular IPC queue for this
-        // channel, so delivery will happen-before any other messages
-        // we send.  The CompositorChild must be created before any
-        // PBrowsers are created, because they rely on the Compositor
-        // already being around.  (Creation is async, so can't happen
-        // on demand.)
-        bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
-        if (useOffMainThreadCompositing) {
-            DebugOnly<bool> opened = PCompositor::Open(this);
-            MOZ_ASSERT(opened);
-
-            opened = PImageBridge::Open(this);
-            MOZ_ASSERT(opened);
-
-            opened = gfx::PVRManager::Open(this);
-            MOZ_ASSERT(opened);
-        }
 #ifdef MOZ_WIDGET_GONK
-        DebugOnly<bool> opened = PSharedBufferManager::Open(this);
-        MOZ_ASSERT(opened);
+    DebugOnly<bool> opened = PSharedBufferManager::Open(this);
+    MOZ_ASSERT(opened);
 #endif
-    }
-
-    if (gAppData) {
-        // Sending all information to content process.
-        Unused << SendAppInit();
+  }
+
+  if (gAppData) {
+    // Sending all information to content process.
+    Unused << SendAppInit();
+  }
+
+  nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
+  if (sheetService) {
+    // This looks like a lot of work, but in a normal browser session we just
+    // send two loads.
+
+    for (CSSStyleSheet* sheet : *sheetService->AgentStyleSheets()) {
+      URIParams uri;
+      SerializeURI(sheet->GetSheetURI(), uri);
+      Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET);
     }
 
-    nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
-    if (sheetService) {
-        // This looks like a lot of work, but in a normal browser session we just
-        // send two loads.
-
-        for (CSSStyleSheet* sheet : *sheetService->AgentStyleSheets()) {
-            URIParams uri;
-            SerializeURI(sheet->GetSheetURI(), uri);
-            Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET);
-        }
-
-        for (CSSStyleSheet* sheet : *sheetService->UserStyleSheets()) {
-            URIParams uri;
-            SerializeURI(sheet->GetSheetURI(), uri);
-            Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET);
-        }
-
-        for (CSSStyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
-            URIParams uri;
-            SerializeURI(sheet->GetSheetURI(), uri);
-            Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
-        }
+    for (CSSStyleSheet* sheet : *sheetService->UserStyleSheets()) {
+      URIParams uri;
+      SerializeURI(sheet->GetSheetURI(), uri);
+      Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET);
     }
 
+    for (CSSStyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
+      URIParams uri;
+      SerializeURI(sheet->GetSheetURI(), uri);
+      Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
+    }
+  }
+
 #ifdef MOZ_CONTENT_SANDBOX
-    bool shouldSandbox = true;
+  bool shouldSandbox = true;
 #ifdef MOZ_NUWA_PROCESS
-    if (IsNuwaProcess()) {
-        shouldSandbox = false;
-    }
+  if (IsNuwaProcess()) {
+    shouldSandbox = false;
+  }
 #endif
-    MaybeFileDesc brokerFd = void_t();
+  MaybeFileDesc brokerFd = void_t();
 #ifdef XP_LINUX
-    if (shouldSandbox) {
-        MOZ_ASSERT(!mSandboxBroker);
-        UniquePtr<SandboxBroker::Policy> policy =
-            sSandboxBrokerPolicyFactory->GetContentPolicy(Pid());
-        if (policy) {
-            brokerFd = FileDescriptor();
-            mSandboxBroker = SandboxBroker::Create(Move(policy), Pid(),
-                                                   brokerFd);
-            if (!mSandboxBroker) {
-                KillHard("SandboxBroker::Create failed");
-                return;
-            }
-            MOZ_ASSERT(static_cast<const FileDescriptor&>(brokerFd).IsValid());
-        }
+  if (shouldSandbox) {
+    MOZ_ASSERT(!mSandboxBroker);
+    UniquePtr<SandboxBroker::Policy> policy =
+      sSandboxBrokerPolicyFactory->GetContentPolicy(Pid());
+    if (policy) {
+      brokerFd = FileDescriptor();
+      mSandboxBroker = SandboxBroker::Create(Move(policy), Pid(), brokerFd);
+      if (!mSandboxBroker) {
+        KillHard("SandboxBroker::Create failed");
+        return;
+      }
+      MOZ_ASSERT(static_cast<const FileDescriptor&>(brokerFd).IsValid());
     }
+  }
 #endif
-    if (shouldSandbox && !SendSetProcessSandbox(brokerFd)) {
-        KillHard("SandboxInitFailed");
-    }
+  if (shouldSandbox && !SendSetProcessSandbox(brokerFd)) {
+    KillHard("SandboxInitFailed");
+  }
 #endif
 }
 
 bool
-ContentParent::IsAlive()
-{
-    return mIsAlive;
+ContentParent::IsAlive() const
+{
+  return mIsAlive;
 }
 
 bool
-ContentParent::IsForApp()
-{
-    return !mAppManifestURL.IsEmpty();
+ContentParent::IsForApp() const
+{
+  return !mAppManifestURL.IsEmpty();
 }
 
 #ifdef MOZ_NUWA_PROCESS
 bool
-ContentParent::IsNuwaProcess()
-{
-    return mIsNuwaProcess;
+ContentParent::IsNuwaProcess() const
+{
+  return mIsNuwaProcess;
 }
 #endif
 
 int32_t
-ContentParent::Pid()
-{
-    if (!mSubprocess || !mSubprocess->GetChildProcessHandle()) {
-        return -1;
-    }
-    return base::GetProcId(mSubprocess->GetChildProcessHandle());
+ContentParent::Pid() const
+{
+  if (!mSubprocess || !mSubprocess->GetChildProcessHandle()) {
+    return -1;
+  }
+  return base::GetProcId(mSubprocess->GetChildProcessHandle());
 }
 
 bool
 ContentParent::RecvReadPrefsArray(InfallibleTArray<PrefSetting>* aPrefs)
 {
-    Preferences::GetPreferences(aPrefs);
-    return true;
+  Preferences::GetPreferences(aPrefs);
+  return true;
 }
 
 bool
 ContentParent::RecvReadFontList(InfallibleTArray<FontListEntry>* retValue)
 {
 #ifdef ANDROID
-    gfxAndroidPlatform::GetPlatform()->GetSystemFontList(retValue);
+  gfxAndroidPlatform::GetPlatform()->GetSystemFontList(retValue);
 #endif
-    return true;
+  return true;
 }
 
 bool
 ContentParent::RecvReadDataStorageArray(const nsString& aFilename,
                                         InfallibleTArray<DataStorageItem>* aValues)
 {
-    // Ensure the SSS is initialized before we try to use its storage.
-    nsCOMPtr<nsISiteSecurityService> sss = do_GetService("@mozilla.org/ssservice;1");
-
-    RefPtr<DataStorage> storage = DataStorage::Get(aFilename);
-    storage->GetAll(aValues);
-    return true;
+  // Ensure the SSS is initialized before we try to use its storage.
+  nsCOMPtr<nsISiteSecurityService> sss = do_GetService("@mozilla.org/ssservice;1");
+
+  RefPtr<DataStorage> storage = DataStorage::Get(aFilename);
+  storage->GetAll(aValues);
+  return true;
 }
 
 bool
 ContentParent::RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissions)
 {
 #ifdef MOZ_PERMISSIONS
-    nsCOMPtr<nsIPermissionManager> permissionManagerIface =
-        services::GetPermissionManager();
-    nsPermissionManager* permissionManager =
-        static_cast<nsPermissionManager*>(permissionManagerIface.get());
-    MOZ_ASSERT(permissionManager,
-               "We have no permissionManager in the Chrome process !");
-
-    nsCOMPtr<nsISimpleEnumerator> enumerator;
-    DebugOnly<nsresult> rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator));
-    MOZ_ASSERT(NS_SUCCEEDED(rv), "Could not get enumerator!");
-    while(1) {
-        bool hasMore;
-        enumerator->HasMoreElements(&hasMore);
-        if (!hasMore)
-            break;
-
-        nsCOMPtr<nsISupports> supp;
-        enumerator->GetNext(getter_AddRefs(supp));
-        nsCOMPtr<nsIPermission> perm = do_QueryInterface(supp);
-
-        nsCOMPtr<nsIPrincipal> principal;
-        perm->GetPrincipal(getter_AddRefs(principal));
-        nsCString origin;
-        if (principal) {
-            principal->GetOrigin(origin);
-        }
-        nsCString type;
-        perm->GetType(type);
-        uint32_t capability;
-        perm->GetCapability(&capability);
-        uint32_t expireType;
-        perm->GetExpireType(&expireType);
-        int64_t expireTime;
-        perm->GetExpireTime(&expireTime);
-
-        aPermissions->AppendElement(IPC::Permission(origin, type,
-                                                    capability, expireType,
-                                                    expireTime));
+  nsCOMPtr<nsIPermissionManager> permissionManagerIface =
+    services::GetPermissionManager();
+  nsPermissionManager* permissionManager =
+    static_cast<nsPermissionManager*>(permissionManagerIface.get());
+  MOZ_ASSERT(permissionManager,
+             "We have no permissionManager in the Chrome process !");
+
+  nsCOMPtr<nsISimpleEnumerator> enumerator;
+  DebugOnly<nsresult> rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator));
+  MOZ_ASSERT(NS_SUCCEEDED(rv), "Could not get enumerator!");
+  while(1) {
+    bool hasMore;
+    enumerator->HasMoreElements(&hasMore);
+    if (!hasMore)
+      break;
+
+    nsCOMPtr<nsISupports> supp;
+    enumerator->GetNext(getter_AddRefs(supp));
+    nsCOMPtr<nsIPermission> perm = do_QueryInterface(supp);
+
+    nsCOMPtr<nsIPrincipal> principal;
+    perm->GetPrincipal(getter_AddRefs(principal));
+    nsCString origin;
+    if (principal) {
+      principal->GetOrigin(origin);
     }
-
-    // Ask for future changes
-    mSendPermissionUpdates = true;
+    nsCString type;
+    perm->GetType(type);
+    uint32_t capability;
+    perm->GetCapability(&capability);
+    uint32_t expireType;
+    perm->GetExpireType(&expireType);
+    int64_t expireTime;
+    perm->GetExpireTime(&expireTime);
+
+    aPermissions->AppendElement(IPC::Permission(origin, type,
+                                                capability, expireType,
+                                                expireTime));
+  }
+
+  // Ask for future changes
+  mSendPermissionUpdates = true;
 #endif
 
-    return true;
+  return true;
 }
 
 bool
 ContentParent::RecvSetClipboard(const IPCDataTransfer& aDataTransfer,
                                 const bool& aIsPrivateData,
                                 const int32_t& aWhichClipboard)
 {
-    nsresult rv;
-    nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
+  nsresult rv;
+  nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
+  NS_ENSURE_SUCCESS(rv, true);
+
+  nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
+  NS_ENSURE_SUCCESS(rv, true);
+  trans->Init(nullptr);
+
+  const nsTArray<IPCDataTransferItem>& items = aDataTransfer.items();
+  for (uint32_t j = 0; j < items.Length(); ++j) {
+    const IPCDataTransferItem& item = items[j];
+
+    trans->AddDataFlavor(item.flavor().get());
+
+    if (item.data().type() == IPCDataTransferData::TnsString) {
+    nsCOMPtr<nsISupportsString> dataWrapper =
+      do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, true);
 
-    nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
+    nsString text = item.data().get_nsString();
+    rv = dataWrapper->SetData(text);
+    NS_ENSURE_SUCCESS(rv, true);
+
+    rv = trans->SetTransferData(item.flavor().get(), dataWrapper,
+                                text.Length() * sizeof(char16_t));
+
     NS_ENSURE_SUCCESS(rv, true);
-    trans->Init(nullptr);
-
-    const nsTArray<IPCDataTransferItem>& items = aDataTransfer.items();
-    for (uint32_t j = 0; j < items.Length(); ++j) {
-      const IPCDataTransferItem& item = items[j];
-
-      trans->AddDataFlavor(item.flavor().get());
-
-      if (item.data().type() == IPCDataTransferData::TnsString) {
-        nsCOMPtr<nsISupportsString> dataWrapper =
-          do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
-        NS_ENSURE_SUCCESS(rv, true);
-
-        nsString text = item.data().get_nsString();
-        rv = dataWrapper->SetData(text);
-        NS_ENSURE_SUCCESS(rv, true);
-
-        rv = trans->SetTransferData(item.flavor().get(), dataWrapper,
-                                    text.Length() * sizeof(char16_t));
-
-        NS_ENSURE_SUCCESS(rv, true);
-      } else if (item.data().type() == IPCDataTransferData::TnsCString) {
-        if (item.flavor().EqualsLiteral(kNativeImageMime) ||
-            item.flavor().EqualsLiteral(kJPEGImageMime) ||
-            item.flavor().EqualsLiteral(kJPGImageMime) ||
-            item.flavor().EqualsLiteral(kPNGImageMime) ||
-            item.flavor().EqualsLiteral(kGIFImageMime)) {
-          const IPCDataTransferImage& imageDetails = item.imageDetails();
-          const gfx::IntSize size(imageDetails.width(), imageDetails.height());
-          if (!size.width || !size.height) {
-            return true;
-          }
-
-          nsCString text = item.data().get_nsCString();
-          RefPtr<gfx::DataSourceSurface> image =
-            new mozilla::gfx::SourceSurfaceRawData();
-          mozilla::gfx::SourceSurfaceRawData* raw =
-            static_cast<mozilla::gfx::SourceSurfaceRawData*>(image.get());
-          raw->InitWrappingData(
-            reinterpret_cast<uint8_t*>(const_cast<nsCString&>(text).BeginWriting()),
-            size, imageDetails.stride(),
-            static_cast<mozilla::gfx::SurfaceFormat>(imageDetails.format()), false);
-          raw->GuaranteePersistance();
-
-          RefPtr<gfxDrawable> drawable = new gfxSurfaceDrawable(image, size);
-          nsCOMPtr<imgIContainer> imageContainer(image::ImageOps::CreateFromDrawable(drawable));
-
-          nsCOMPtr<nsISupportsInterfacePointer>
-            imgPtr(do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv));
-
-          rv = imgPtr->SetData(imageContainer);
-          NS_ENSURE_SUCCESS(rv, true);
-
-          trans->SetTransferData(item.flavor().get(), imgPtr, sizeof(nsISupports*));
-        } else {
-          nsCOMPtr<nsISupportsCString> dataWrapper =
-            do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
-          NS_ENSURE_SUCCESS(rv, true);
-
-          const nsCString& text = item.data().get_nsCString();
-          rv = dataWrapper->SetData(text);
-          NS_ENSURE_SUCCESS(rv, true);
-
-          rv = trans->SetTransferData(item.flavor().get(), dataWrapper,
-                                      text.Length());
-
-          NS_ENSURE_SUCCESS(rv, true);
-        }
+    } else if (item.data().type() == IPCDataTransferData::TnsCString) {
+    if (item.flavor().EqualsLiteral(kNativeImageMime) ||
+        item.flavor().EqualsLiteral(kJPEGImageMime) ||
+        item.flavor().EqualsLiteral(kJPGImageMime) ||
+        item.flavor().EqualsLiteral(kPNGImageMime) ||
+        item.flavor().EqualsLiteral(kGIFImageMime)) {
+      const IPCDataTransferImage& imageDetails = item.imageDetails();
+      const gfx::IntSize size(imageDetails.width(), imageDetails.height());
+      if (!size.width || !size.height) {
+      return true;
       }
+
+      nsCString text = item.data().get_nsCString();
+      RefPtr<gfx::DataSourceSurface> image =
+      new mozilla::gfx::SourceSurfaceRawData();
+      mozilla::gfx::SourceSurfaceRawData* raw =
+      static_cast<mozilla::gfx::SourceSurfaceRawData*>(image.get());
+      raw->InitWrappingData(
+      reinterpret_cast<uint8_t*>(const_cast<nsCString&>(text).BeginWriting()),
+      size, imageDetails.stride(),
+      static_cast<mozilla::gfx::SurfaceFormat>(imageDetails.format()), false);
+      raw->GuaranteePersistance();
+
+      RefPtr<gfxDrawable> drawable = new gfxSurfaceDrawable(image, size);
+      nsCOMPtr<imgIContainer> imageContainer(image::ImageOps::CreateFromDrawable(drawable));
+
+      nsCOMPtr<nsISupportsInterfacePointer>
+      imgPtr(do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv));
+
+      rv = imgPtr->SetData(imageContainer);
+      NS_ENSURE_SUCCESS(rv, true);
+
+      trans->SetTransferData(item.flavor().get(), imgPtr, sizeof(nsISupports*));
+    } else {
+      nsCOMPtr<nsISupportsCString> dataWrapper =
+      do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
+      NS_ENSURE_SUCCESS(rv, true);
+
+      const nsCString& text = item.data().get_nsCString();
+      rv = dataWrapper->SetData(text);
+      NS_ENSURE_SUCCESS(rv, true);
+
+      rv = trans->SetTransferData(item.flavor().get(), dataWrapper, text.Length());
+
+      NS_ENSURE_SUCCESS(rv, true);
     }
-
-    trans->SetIsPrivateData(aIsPrivateData);
-
-    clipboard->SetData(trans, nullptr, aWhichClipboard);
-    return true;
+    }
+  }
+
+  trans->SetIsPrivateData(aIsPrivateData);
+
+  clipboard->SetData(trans, nullptr, aWhichClipboard);
+  return true;
 }
 
 bool
 ContentParent::RecvGetClipboard(nsTArray<nsCString>&& aTypes,
                                 const int32_t& aWhichClipboard,
                                 IPCDataTransfer* aDataTransfer)
 {
-    nsresult rv;
-    nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
-    NS_ENSURE_SUCCESS(rv, true);
-
-    nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
-    NS_ENSURE_SUCCESS(rv, true);
-    trans->Init(nullptr);
-
-    for (uint32_t t = 0; t < aTypes.Length(); t++) {
-      trans->AddDataFlavor(aTypes[t].get());
-    }
-
-    clipboard->GetData(trans, aWhichClipboard);
-    nsContentUtils::TransferableToIPCTransferable(trans, aDataTransfer,
-                                                  true, nullptr, this);
-    return true;
+  nsresult rv;
+  nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
+  NS_ENSURE_SUCCESS(rv, true);
+
+  nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
+  NS_ENSURE_SUCCESS(rv, true);
+  trans->Init(nullptr);
+
+  for (uint32_t t = 0; t < aTypes.Length(); t++) {
+    trans->AddDataFlavor(aTypes[t].get());
+  }
+
+  clipboard->GetData(trans, aWhichClipboard);
+  nsContentUtils::TransferableToIPCTransferable(trans, aDataTransfer,
+                                                true, nullptr, this);
+  return true;
 }
 
 bool
 ContentParent::RecvEmptyClipboard(const int32_t& aWhichClipboard)
 {
-    nsresult rv;
-    nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
-    NS_ENSURE_SUCCESS(rv, true);
-
-    clipboard->EmptyClipboard(aWhichClipboard);
-
-    return true;
+  nsresult rv;
+  nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
+  NS_ENSURE_SUCCESS(rv, true);
+
+  clipboard->EmptyClipboard(aWhichClipboard);
+
+  return true;
 }
 
 bool
 ContentParent::RecvClipboardHasType(nsTArray<nsCString>&& aTypes,
                                     const int32_t& aWhichClipboard,
                                     bool* aHasType)
 {
-    nsresult rv;
-    nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
-    NS_ENSURE_SUCCESS(rv, true);
-
-    const char** typesChrs = new const char *[aTypes.Length()];
-    for (uint32_t t = 0; t < aTypes.Length(); t++) {
-      typesChrs[t] = aTypes[t].get();
-    }
-
-    clipboard->HasDataMatchingFlavors(typesChrs, aTypes.Length(),
-                                      aWhichClipboard, aHasType);
-
-    delete [] typesChrs;
-    return true;
+  nsresult rv;
+  nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
+  NS_ENSURE_SUCCESS(rv, true);
+
+  const char** typesChrs = new const char *[aTypes.Length()];
+  for (uint32_t t = 0; t < aTypes.Length(); t++) {
+    typesChrs[t] = aTypes[t].get();
+  }
+
+  clipboard->HasDataMatchingFlavors(typesChrs, aTypes.Length(),
+                                    aWhichClipboard, aHasType);
+
+  delete [] typesChrs;
+  return true;
 }
 
 bool
-ContentParent::RecvGetSystemColors(const uint32_t& colorsCount, InfallibleTArray<uint32_t>* colors)
+ContentParent::RecvGetSystemColors(const uint32_t& colorsCount,
+                                   InfallibleTArray<uint32_t>* colors)
 {
 #ifdef MOZ_WIDGET_ANDROID
-    NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
-    if (AndroidBridge::Bridge() == nullptr) {
-        // Do not fail - the colors won't be right, but it's not critical
-        return true;
-    }
-
-    colors->AppendElements(colorsCount);
-
-    // The array elements correspond to the members of AndroidSystemColors structure,
-    // so just pass the pointer to the elements buffer
-    AndroidBridge::Bridge()->GetSystemColors((AndroidSystemColors*)colors->Elements());
+  NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
+  if (AndroidBridge::Bridge() == nullptr) {
+    // Do not fail - the colors won't be right, but it's not critical
+    return true;
+  }
+
+  colors->AppendElements(colorsCount);
+
+  // The array elements correspond to the members of AndroidSystemColors structure,
+  // so just pass the pointer to the elements buffer
+  AndroidBridge::Bridge()->GetSystemColors((AndroidSystemColors*)colors->Elements());
 #endif
-    return true;
+  return true;
 }
 
 bool
-ContentParent::RecvGetIconForExtension(const nsCString& aFileExt, const uint32_t& aIconSize, InfallibleTArray<uint8_t>* bits)
+ContentParent::RecvGetIconForExtension(const nsCString& aFileExt,
+                                       const uint32_t& aIconSize,
+                                       InfallibleTArray<uint8_t>* bits)
 {
 #ifdef MOZ_WIDGET_ANDROID
-    NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
-    if (AndroidBridge::Bridge() == nullptr) {
-        // Do not fail - just no icon will be shown
-        return true;
-    }
-
-    bits->AppendElements(aIconSize * aIconSize * 4);
-
-    AndroidBridge::Bridge()->GetIconForExtension(aFileExt, aIconSize, bits->Elements());
+  NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
+  if (AndroidBridge::Bridge() == nullptr) {
+    // Do not fail - just no icon will be shown
+    return true;
+  }
+
+  bits->AppendElements(aIconSize * aIconSize * 4);
+
+  AndroidBridge::Bridge()->GetIconForExtension(aFileExt, aIconSize, bits->Elements());
 #endif
-    return true;
+  return true;
 }
 
 bool
 ContentParent::RecvGetShowPasswordSetting(bool* showPassword)
 {
-    // default behavior is to show the last password character
-    *showPassword = true;
+  // default behavior is to show the last password character
+  *showPassword = true;
 #ifdef MOZ_WIDGET_ANDROID
-    NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
-
-    *showPassword = mozilla::widget::GeckoAppShell::GetShowPasswordSetting();
+  NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
+
+  *showPassword = mozilla::widget::GeckoAppShell::GetShowPasswordSetting();
 #endif
-    return true;
+  return true;
 }
 
 bool
 ContentParent::RecvFirstIdle()
 {
-    // When the ContentChild goes idle, it sends us a FirstIdle message
-    // which we use as a good time to prelaunch another process. If we
-    // prelaunch any sooner than this, then we'll be competing with the
-    // child process and slowing it down.
-    PreallocatedProcessManager::AllocateAfterDelay();
-    return true;
+  // When the ContentChild goes idle, it sends us a FirstIdle message
+  // which we use as a good time to prelaunch another process. If we
+  // prelaunch any sooner than this, then we'll be competing with the
+  // child process and slowing it down.
+  PreallocatedProcessManager::AllocateAfterDelay();
+  return true;
 }
 
 bool
 ContentParent::RecvAudioChannelChangeDefVolChannel(const int32_t& aChannel,
                                                    const bool& aHidden)
 {
-    RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
-    MOZ_ASSERT(service);
-    service->SetDefaultVolumeControlChannelInternal(aChannel,
-                                                    aHidden, mChildID);
-    return true;
+  RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
+  MOZ_ASSERT(service);
+  service->SetDefaultVolumeControlChannelInternal(aChannel, aHidden, mChildID);
+  return true;
 }
 
 bool
 ContentParent::RecvAudioChannelServiceStatus(
                                            const bool& aTelephonyChannel,
                                            const bool& aContentOrNormalChannel,
                                            const bool& aAnyChannel)
 {
-    RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
-    MOZ_ASSERT(service);
-
-    service->ChildStatusReceived(mChildID, aTelephonyChannel,
-                                 aContentOrNormalChannel, aAnyChannel);
-    return true;
+  RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
+  MOZ_ASSERT(service);
+
+  service->ChildStatusReceived(mChildID, aTelephonyChannel,
+                               aContentOrNormalChannel, aAnyChannel);
+  return true;
 }
 
 bool
 ContentParent::RecvDataStoreGetStores(
                                     const nsString& aName,
                                     const nsString& aOwner,
                                     const IPC::Principal& aPrincipal,
                                     InfallibleTArray<DataStoreSetting>* aValue)
@@ -3113,84 +3097,83 @@ KeepNuwaSafeObserverTopics(ContentParent
               break;
           }
       }
 
       if (!nuwaSafe) {
           obs->RemoveObserver(aNuwaContentParent, sObserverTopics[i]);
       }
   }
-
 }
 #endif
 
 void
 ContentParent::OnNuwaReady()
 {
 #ifdef MOZ_NUWA_PROCESS
-    // Protection from unauthorized IPC message is done in PNuwa protocol.
-    // Just assert that this actor is really for the Nuwa process.
-    MOZ_ASSERT(IsNuwaProcess());
-
-    sNuwaReady = true;
-    KeepNuwaSafeObserverTopics(this);
-
-    PreallocatedProcessManager::OnNuwaReady();
-    return;
+  // Protection from unauthorized IPC message is done in PNuwa protocol.
+  // Just assert that this actor is really for the Nuwa process.
+  MOZ_ASSERT(IsNuwaProcess());
+
+  sNuwaReady = true;
+  KeepNuwaSafeObserverTopics(this);
+
+  PreallocatedProcessManager::OnNuwaReady();
+  return;
 #else
-    NS_ERROR("ContentParent::OnNuwaReady() not implemented!");
-    return;
+  NS_ERROR("ContentParent::OnNuwaReady() not implemented!");
+  return;
 #endif
 }
 
 void
 ContentParent::OnNewProcessCreated(uint32_t aPid,
                                    UniquePtr<nsTArray<ProtocolFdMapping>>&& aFds)
 {
 #ifdef MOZ_NUWA_PROCESS
-    // Protection from unauthorized IPC message is done in PNuwa protocol.
-    // Just assert that this actor is really for the Nuwa process.
-    MOZ_ASSERT(IsNuwaProcess());
-
-    RefPtr<ContentParent> content;
-    content = new ContentParent(this,
-                                MAGIC_PREALLOCATED_APP_MANIFEST_URL,
-                                aPid,
-                                Move(*aFds.get()));
-    content->Init();
-
-    size_t numNuwaPrefUpdates = sNuwaPrefUpdates ?
-                                sNuwaPrefUpdates->Length() : 0;
-    // Resend pref updates to the forked child.
-    for (size_t i = 0; i < numNuwaPrefUpdates; i++) {
-        mozilla::Unused << content->SendPreferenceUpdate(sNuwaPrefUpdates->ElementAt(i));
-    }
-
-    // Update offline settings.
-    bool isOffline, isLangRTL;
-    bool isConnected;
-    InfallibleTArray<nsString> unusedDictionaries;
-    ClipboardCapabilities clipboardCaps;
-    DomainPolicyClone domainPolicy;
-    StructuredCloneData initialData;
-
-    RecvGetXPCOMProcessAttributes(&isOffline, &isConnected,
-                                  &isLangRTL, &unusedDictionaries,
-                                  &clipboardCaps, &domainPolicy, &initialData);
-    mozilla::Unused << content->SendSetOffline(isOffline);
-    mozilla::Unused << content->SendSetConnectivity(isConnected);
-    MOZ_ASSERT(!clipboardCaps.supportsSelectionClipboard() &&
-               !clipboardCaps.supportsFindClipboard(),
-               "Unexpected values");
-
-    PreallocatedProcessManager::PublishSpareProcess(content);
-    return;
+  // Protection from unauthorized IPC message is done in PNuwa protocol.
+  // Just assert that this actor is really for the Nuwa process.
+  MOZ_ASSERT(IsNuwaProcess());
+
+  RefPtr<ContentParent> content;
+  content = new ContentParent(this,
+                              MAGIC_PREALLOCATED_APP_MANIFEST_URL,
+                              aPid,
+                              Move(*aFds.get()));
+  content->Init();
+
+  size_t numNuwaPrefUpdates = sNuwaPrefUpdates ?
+                              sNuwaPrefUpdates->Length() : 0;
+  // Resend pref updates to the forked child.
+  for (size_t i = 0; i < numNuwaPrefUpdates; i++) {
+    mozilla::Unused << content->SendPreferenceUpdate(sNuwaPrefUpdates->ElementAt(i));
+  }
+
+  // Update offline settings.
+  bool isOffline, isLangRTL;
+  bool isConnected;
+  InfallibleTArray<nsString> unusedDictionaries;
+  ClipboardCapabilities clipboardCaps;
+  DomainPolicyClone domainPolicy;
+  StructuredCloneData initialData;
+
+  RecvGetXPCOMProcessAttributes(&isOffline, &isConnected,
+                                &isLangRTL, &unusedDictionaries,
+                                &clipboardCaps, &domainPolicy, &initialData);
+  mozilla::Unused << content->SendSetOffline(isOffline);
+  mozilla::Unused << content->SendSetConnectivity(isConnected);
+  MOZ_ASSERT(!clipboardCaps.supportsSelectionClipboard() &&
+             !clipboardCaps.supportsFindClipboard(),
+             "Unexpected values");
+
+  PreallocatedProcessManager::PublishSpareProcess(content);
+  return;
 #else
-    NS_ERROR("ContentParent::OnNewProcessCreated() not implemented!");
-    return;
+  NS_ERROR("ContentParent::OnNewProcessCreated() not implemented!");
+  return;
 #endif
 }
 
 // We want ContentParent to show up in CC logs for debugging purposes, but we
 // don't actually cycle collect it.
 NS_IMPL_CYCLE_COLLECTION_0(ContentParent)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(ContentParent)
@@ -3204,420 +3187,420 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
 ContentParent::Observe(nsISupports* aSubject,
                        const char* aTopic,
                        const char16_t* aData)
 {
-    if (mSubprocess && (!strcmp(aTopic, "profile-before-change") ||
-                        !strcmp(aTopic, "xpcom-shutdown"))) {
-        // Okay to call ShutDownProcess multiple times.
-        ShutDownProcess(SEND_SHUTDOWN_MESSAGE);
-
-        // Wait for shutdown to complete, so that we receive any shutdown
-        // data (e.g. telemetry) from the child before we quit.
-        // This loop terminate prematurely based on mForceKillTimer.
-        while (mIPCOpen && !mCalledKillHard) {
-            NS_ProcessNextEvent(nullptr, true);
-        }
-        NS_ASSERTION(!mSubprocess, "Close should have nulled mSubprocess");
-    }
-
-    if (!mIsAlive || !mSubprocess)
-        return NS_OK;
-
-    // The Nuwa process unregisters the topics after it becomes ready except for
-    // the ones listed in sNuwaSafeObserverTopics. If the topic needs to be
-    // observed by the Nuwa process, either for:
-    // 1. The topic is safe for the Nuwa process, either:
-    // 1.1 The state can safely happen (only run on the main thread) in the Nuwa
-    //     process (e.g. "a11y-init-or-shutdown"), or
-    // 1.2 The topic doesn't send an IPC message (e.g. "xpcom-shutdown").
-    // 2. The topic needs special handling (e.g. nsPref:Changed),
-    // add the topic to sNuwaSafeObserverTopics and then handle it if necessary.
-
-    // listening for memory pressure event
-    if (!strcmp(aTopic, "memory-pressure") &&
-        !StringEndsWith(nsDependentString(aData),
-                        NS_LITERAL_STRING("-no-forward"))) {
-        Unused << SendFlushMemory(nsDependentString(aData));
-    }
-    // listening for remotePrefs...
-    else if (!strcmp(aTopic, "nsPref:changed")) {
-        // We know prefs are ASCII here.
-        NS_LossyConvertUTF16toASCII strData(aData);
-
-        PrefSetting pref(strData, null_t(), null_t());
-        Preferences::GetPreference(&pref);
-#ifdef MOZ_NUWA_PROCESS
-        if (IsReadyNuwaProcess()) {
-            // Don't send the pref update to the Nuwa process. Save the update
-            // to send to the forked child.
-            if (!sNuwaPrefUpdates) {
-                sNuwaPrefUpdates = new nsTArray<PrefSetting>();
-            }
-            sNuwaPrefUpdates->AppendElement(pref);
-        } else if (!SendPreferenceUpdate(pref)) {
-            return NS_ERROR_NOT_AVAILABLE;
-        }
-#else
-        if (!SendPreferenceUpdate(pref)) {
-            return NS_ERROR_NOT_AVAILABLE;
-        }
-#endif
-    }
-    else if (!strcmp(aTopic, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC)) {
-        NS_ConvertUTF16toUTF8 dataStr(aData);
-        const char *offline = dataStr.get();
-        if (!SendSetOffline(!strcmp(offline, "true") ? true : false)) {
-            return NS_ERROR_NOT_AVAILABLE;
-        }
-    }
-    else if (!strcmp(aTopic, NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC)) {
-        if (!SendSetConnectivity(NS_LITERAL_STRING("true").Equals(aData))) {
-            return NS_ERROR_NOT_AVAILABLE;
-        }
+  if (mSubprocess && (!strcmp(aTopic, "profile-before-change") ||
+                      !strcmp(aTopic, "xpcom-shutdown"))) {
+    // Okay to call ShutDownProcess multiple times.
+    ShutDownProcess(SEND_SHUTDOWN_MESSAGE);
+
+    // Wait for shutdown to complete, so that we receive any shutdown
+    // data (e.g. telemetry) from the child before we quit.
+    // This loop terminate prematurely based on mForceKillTimer.
+    while (mIPCOpen && !mCalledKillHard) {
+      NS_ProcessNextEvent(nullptr, true);
     }
-    // listening for alert notifications
-    else if (!strcmp(aTopic, "alertfinished") ||
-             !strcmp(aTopic, "alertclickcallback") ||
-             !strcmp(aTopic, "alertshow") ||
-             !strcmp(aTopic, "alertdisablecallback") ||
-             !strcmp(aTopic, "alertsettingscallback")) {
-        if (!SendNotifyAlertsObserver(nsDependentCString(aTopic),
-                                      nsDependentString(aData)))
-            return NS_ERROR_NOT_AVAILABLE;
-    }
-    else if (!strcmp(aTopic, "child-gc-request")){
-        Unused << SendGarbageCollect();
-    }
-    else if (!strcmp(aTopic, "child-cc-request")){
-        Unused << SendCycleCollect();
-    }
-    else if (!strcmp(aTopic, "child-mmu-request")){
-        Unused << SendMinimizeMemoryUsage();
-    }
-    else if (!strcmp(aTopic, "last-pb-context-exited")) {
-        Unused << SendLastPrivateDocShellDestroyed();
-    }