2017-01-27 03:35:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_MemoryReportRequest_h_
|
|
|
|
#define mozilla_dom_MemoryReportRequest_h_
|
|
|
|
|
2017-01-27 03:35:54 +03:00
|
|
|
#include "mozilla/dom/MemoryReportTypes.h"
|
|
|
|
#include "mozilla/ipc/FileDescriptor.h"
|
2017-01-27 03:35:53 +03:00
|
|
|
#include "nsISupports.h"
|
|
|
|
|
2019-01-03 00:18:13 +03:00
|
|
|
#include <functional>
|
|
|
|
|
2017-01-27 03:35:53 +03:00
|
|
|
class nsMemoryReporterManager;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2019-01-03 00:18:13 +03:00
|
|
|
class MemoryReport;
|
2017-01-27 03:35:54 +03:00
|
|
|
|
|
|
|
class MemoryReportRequestHost final {
|
2017-01-27 03:35:53 +03:00
|
|
|
public:
|
2017-01-27 03:35:54 +03:00
|
|
|
explicit MemoryReportRequestHost(uint32_t aGeneration);
|
|
|
|
~MemoryReportRequestHost();
|
2017-01-27 03:35:53 +03:00
|
|
|
|
2017-01-27 03:35:54 +03:00
|
|
|
void RecvReport(const MemoryReport& aReport);
|
|
|
|
void Finish(uint32_t aGeneration);
|
2017-01-27 03:35:53 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
const uint32_t mGeneration;
|
|
|
|
// Non-null if we haven't yet called EndProcessReport() on it.
|
|
|
|
RefPtr<nsMemoryReporterManager> mReporterManager;
|
2017-01-27 03:35:54 +03:00
|
|
|
bool mSuccess;
|
2017-01-27 03:35:53 +03:00
|
|
|
};
|
|
|
|
|
2017-01-27 03:35:54 +03:00
|
|
|
class MemoryReportRequestClient final : public nsIRunnable {
|
2017-01-27 03:35:53 +03:00
|
|
|
public:
|
2019-01-03 00:18:13 +03:00
|
|
|
using ReportCallback = std::function<void(const MemoryReport&)>;
|
|
|
|
using FinishCallback = std::function<bool(const uint32_t&)>;
|
|
|
|
|
2017-01-27 03:35:53 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2017-01-27 03:35:54 +03:00
|
|
|
static void Start(uint32_t aGeneration, bool aAnonymize,
|
2019-03-01 00:20:40 +03:00
|
|
|
bool aMinimizeMemoryUsage,
|
|
|
|
const Maybe<mozilla::ipc::FileDescriptor>& aDMDFile,
|
2019-01-03 00:18:13 +03:00
|
|
|
const nsACString& aProcessString,
|
|
|
|
const ReportCallback& aReportCallback,
|
|
|
|
const FinishCallback& aFinishCallback);
|
2017-01-27 03:35:54 +03:00
|
|
|
|
2017-01-27 03:35:53 +03:00
|
|
|
NS_IMETHOD Run() override;
|
|
|
|
|
|
|
|
private:
|
2017-01-27 03:35:54 +03:00
|
|
|
MemoryReportRequestClient(uint32_t aGeneration, bool aAnonymize,
|
2019-03-01 00:20:40 +03:00
|
|
|
const Maybe<mozilla::ipc::FileDescriptor>& aDMDFile,
|
2019-01-03 00:18:13 +03:00
|
|
|
const nsACString& aProcessString,
|
|
|
|
const ReportCallback& aReportCallback,
|
|
|
|
const FinishCallback& aFinishCallback);
|
2017-01-27 03:35:54 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
~MemoryReportRequestClient();
|
2017-01-27 03:35:53 +03:00
|
|
|
|
2017-01-27 03:35:54 +03:00
|
|
|
uint32_t mGeneration;
|
|
|
|
bool mAnonymize;
|
|
|
|
mozilla::ipc::FileDescriptor mDMDFile;
|
2017-01-27 03:35:53 +03:00
|
|
|
nsCString mProcessString;
|
2019-01-03 00:18:13 +03:00
|
|
|
ReportCallback mReportCallback;
|
|
|
|
FinishCallback mFinishCallback;
|
2017-01-27 03:35:53 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_MemoryReportRequest_h_
|