From b953cadaaa40f819e4b76449cef60582e6218b2f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 26 Jan 2017 16:35:53 -0800 Subject: [PATCH] Remove the MemoryReportRequestChild dependency on ContentChild. (bug 1321492 part 2, r=erahm) --- dom/ipc/ContentChild.cpp | 6 +++++- dom/ipc/MemoryReportRequest.cpp | 15 +++++---------- dom/ipc/MemoryReportRequest.h | 4 +++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 0730fb3396d1..f8ccc6777dea 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -1023,8 +1023,12 @@ ContentChild::AllocPMemoryReportRequestChild(const uint32_t& aGeneration, const bool &aMinimizeMemoryUsage, const MaybeFileDesc& aDMDFile) { + nsCString process; + GetProcessName(process); + AppendProcessId(process); + auto *actor = - new MemoryReportRequestChild(aAnonymize, aDMDFile); + new MemoryReportRequestChild(aAnonymize, aDMDFile, process); actor->AddRef(); return actor; } diff --git a/dom/ipc/MemoryReportRequest.cpp b/dom/ipc/MemoryReportRequest.cpp index 9ed0a6292453..0be772d8ea6e 100644 --- a/dom/ipc/MemoryReportRequest.cpp +++ b/dom/ipc/MemoryReportRequest.cpp @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "MemoryReportRequest.h" -#include "mozilla/dom/ContentChild.h" namespace mozilla { namespace dom { @@ -55,8 +54,10 @@ MemoryReportRequestParent::~MemoryReportRequestParent() NS_IMPL_ISUPPORTS(MemoryReportRequestChild, nsIRunnable) MemoryReportRequestChild::MemoryReportRequestChild( - bool aAnonymize, const MaybeFileDesc& aDMDFile) -: mAnonymize(aAnonymize) + bool aAnonymize, const MaybeFileDesc& aDMDFile, + const nsACString& aProcessString) + : mAnonymize(aAnonymize), + mProcessString(aProcessString) { if (aDMDFile.type() == MaybeFileDesc::TFileDescriptor) { mDMDFile = aDMDFile.get_FileDescriptor(); @@ -127,21 +128,15 @@ NS_IMPL_ISUPPORTS( , nsIFinishReportingCallback ) - NS_IMETHODIMP MemoryReportRequestChild::Run() { - ContentChild *child = static_cast(Manager()); nsCOMPtr 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 handleReport = - new HandleReportCallback(this, process); + new HandleReportCallback(this, mProcessString); RefPtr finishReporting = new FinishReportingCallback(this); diff --git a/dom/ipc/MemoryReportRequest.h b/dom/ipc/MemoryReportRequest.h index 8a6c3b747108..f6df2ede8b2f 100644 --- a/dom/ipc/MemoryReportRequest.h +++ b/dom/ipc/MemoryReportRequest.h @@ -41,7 +41,8 @@ public: NS_DECL_ISUPPORTS MemoryReportRequestChild(bool aAnonymize, - const MaybeFileDesc& aDMDFile); + const MaybeFileDesc& aDMDFile, + const nsACString& aProcessString); NS_IMETHOD Run() override; private: @@ -49,6 +50,7 @@ private: bool mAnonymize; FileDescriptor mDMDFile; + nsCString mProcessString; }; } // namespace dom