Backed out changeset 1d9301697aa0 (bug 1887752) for causing failures on browser_all_f...
[gecko.git] / dom / ipc / MemoryReportRequest.h
blob1e81a39bf6c862fb2bd0b5e9715e8c807183dd04
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"
14 #include <functional>
16 class nsMemoryReporterManager;
18 namespace mozilla::dom {
20 class MemoryReport;
22 class MemoryReportRequestHost final {
23 public:
24 explicit MemoryReportRequestHost(uint32_t aGeneration);
25 ~MemoryReportRequestHost();
27 void RecvReport(const MemoryReport& aReport);
28 void Finish(uint32_t aGeneration);
30 private:
31 const uint32_t mGeneration;
32 // Non-null if we haven't yet called EndProcessReport() on it.
33 RefPtr<nsMemoryReporterManager> mReporterManager;
34 bool mSuccess;
37 class MemoryReportRequestClient final : public nsIRunnable {
38 public:
39 using ReportCallback = std::function<void(const MemoryReport&)>;
40 using FinishCallback = std::function<void(const uint32_t&)>;
42 NS_DECL_ISUPPORTS
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;
53 private:
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);
60 private:
61 ~MemoryReportRequestClient();
63 uint32_t mGeneration;
64 bool mAnonymize;
65 mozilla::ipc::FileDescriptor mDMDFile;
66 nsCString mProcessString;
67 ReportCallback mReportCallback;
68 FinishCallback mFinishCallback;
71 } // namespace mozilla::dom
73 #endif // mozilla_dom_MemoryReportRequest_h_