Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: chrome/browser/metrics/leak_detector_remote_controller.h

Issue 2030883004: Add LeakDetectorRemoteController as a Mojo service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/metrics/leak_detector_remote_controller.h
diff --git a/chrome/browser/metrics/leak_detector_remote_controller.h b/chrome/browser/metrics/leak_detector_remote_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..c7c4696b04db747c84f99a57761c9aa4a71ec37f
--- /dev/null
+++ b/chrome/browser/metrics/leak_detector_remote_controller.h
@@ -0,0 +1,65 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_METRICS_LEAK_DETECTOR_REMOTE_CONTROLLER_H_
+#define CHROME_BROWSER_METRICS_LEAK_DETECTOR_REMOTE_CONTROLLER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "components/metrics/leak_detector/leak_detector_remote.mojom.h"
+#include "components/metrics/proto/memory_leak_report.pb.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+namespace metrics {
+
+// This class acts as an interface to LeakDetector clients running on processes
+// other than its own (the browser process).
+class LeakDetectorRemoteController : public LeakDetectorRemote {
+ public:
+ // Interface class to be implemented by a local controller class that provides
+ // leak detector parameters and can pass leak reports to UMA.
+ class LocalController {
+ public:
+ // Returns a set of leak detection params to be used when initializing the
+ // leak detector on a remote process.
+ virtual void GetParams(MemoryLeakReportProto_Params* params) const = 0;
Ilya Sherman 2016/06/07 23:03:38 Why does this function fill a pointer, rather than
Simon Que 2016/06/08 01:14:18 Done.
+
+ // Pass a vector of memory leak reports provided by a remote process to the
+ // local controller class.
+ virtual void SendLeakReports(
+ const std::vector<MemoryLeakReportProto>& reports) = 0;
+ };
+
+ ~LeakDetectorRemoteController() override;
+
+ static void Create(LeakDetectorRemoteRequest request);
+
+ // LeakDetectorRemote
Ilya Sherman 2016/06/07 23:03:38 nit: Please add a trailing colon, ':'
Simon Que 2016/06/08 01:14:18 Done.
+ void GetParams(const LeakDetectorRemote::GetParamsCallback& cb) override;
+
+ // LeakDetectorRemote
Ilya Sherman 2016/06/07 23:03:38 nit: Please remove this line and the one above (li
Simon Que 2016/06/08 01:14:18 Done.
+ void SendLeakReports(mojo::Array<mojo::String>) override;
+
+ static void SetLocalControllerInstance(LocalController* controller) {
Ilya Sherman 2016/06/07 23:03:38 nit: Please use hacker_case
Simon Que 2016/06/08 01:14:18 Done.
+ controller_ = controller;
+ }
+
+ private:
+ explicit LeakDetectorRemoteController(LeakDetectorRemoteRequest request);
+
+ // Single instance of LocalController. All remote LeakDetector clients will
+ // get their params from and send leak reports to this instance.
+ static LocalController* controller_;
Ilya Sherman 2016/06/07 23:03:38 Optional nit: I think it's slightly preferable to
Simon Que 2016/06/08 01:14:18 Done.
+
+ mojo::StrongBinding<metrics::LeakDetectorRemote> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(LeakDetectorRemoteController);
+};
+
+} // namespace metrics
+
+#endif // CHROME_BROWSER_METRICS_LEAK_DETECTOR_REMOTE_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698