1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_MemoryReportRequest_h_
8 #define mozilla_dom_MemoryReportRequest_h_
10 #include "mozilla/dom/MemoryReportTypes.h"
11 #include "mozilla/ipc/FileDescriptor.h"
12 #include "nsISupports.h"
16 class nsMemoryReporterManager
;
18 namespace mozilla::dom
{
22 class MemoryReportRequestHost final
{
24 explicit MemoryReportRequestHost(uint32_t aGeneration
);
25 ~MemoryReportRequestHost();
27 void RecvReport(const MemoryReport
& aReport
);
28 void Finish(uint32_t aGeneration
);
31 const uint32_t mGeneration
;
32 // Non-null if we haven't yet called EndProcessReport() on it.
33 RefPtr
<nsMemoryReporterManager
> mReporterManager
;
37 class MemoryReportRequestClient final
: public nsIRunnable
{
39 using ReportCallback
= std::function
<void(const MemoryReport
&)>;
40 using FinishCallback
= std::function
<void(const uint32_t&)>;
44 static void Start(uint32_t aGeneration
, bool aAnonymize
,
45 bool aMinimizeMemoryUsage
,
46 const Maybe
<mozilla::ipc::FileDescriptor
>& aDMDFile
,
47 const nsACString
& aProcessString
,
48 const ReportCallback
& aReportCallback
,
49 const FinishCallback
& aFinishCallback
);
51 NS_IMETHOD
Run() override
;
54 MemoryReportRequestClient(uint32_t aGeneration
, bool aAnonymize
,
55 const Maybe
<mozilla::ipc::FileDescriptor
>& aDMDFile
,
56 const nsACString
& aProcessString
,
57 const ReportCallback
& aReportCallback
,
58 const FinishCallback
& aFinishCallback
);
61 ~MemoryReportRequestClient();
65 mozilla::ipc::FileDescriptor mDMDFile
;
66 nsCString mProcessString
;
67 ReportCallback mReportCallback
;
68 FinishCallback mFinishCallback
;
71 } // namespace mozilla::dom
73 #endif // mozilla_dom_MemoryReportRequest_h_