Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_METRICS_LEAK_DETECTOR_REMOTE_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_METRICS_LEAK_DETECTOR_REMOTE_CONTROLLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "components/metrics/leak_detector/leak_detector_remote.mojom.h" | |
| 13 #include "components/metrics/proto/memory_leak_report.pb.h" | |
| 14 #include "mojo/public/cpp/bindings/interface_request.h" | |
| 15 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 16 | |
| 17 namespace metrics { | |
| 18 | |
| 19 // This class acts as an interface to LeakDetector clients running on processes | |
| 20 // other than its own (the browser process). | |
| 21 class LeakDetectorRemoteController : public LeakDetectorRemote { | |
| 22 public: | |
| 23 // Interface class to be implemented by a local controller class that provides | |
| 24 // leak detector parameters and can pass leak reports to UMA. | |
| 25 class LocalController { | |
| 26 public: | |
| 27 // Returns a set of leak detection params to be used when initializing the | |
| 28 // leak detector on a remote process. | |
| 29 virtual MemoryLeakReportProto_Params GetParams() const = 0; | |
| 30 | |
| 31 // Pass a vector of memory leak reports provided by a remote process to the | |
| 32 // local controller class. | |
| 33 virtual void SendLeakReports( | |
| 34 const std::vector<MemoryLeakReportProto>& reports) = 0; | |
| 35 }; | |
| 36 | |
| 37 ~LeakDetectorRemoteController() override; | |
| 38 | |
| 39 static void Create(LeakDetectorRemoteRequest request); | |
| 40 | |
| 41 // LeakDetectorRemote: | |
| 42 void GetParams(const LeakDetectorRemote::GetParamsCallback& callback) override ; | |
| 43 void SendLeakReports(mojo::Array<mojo::String>) override; | |
| 44 | |
| 45 // Sets a global pointer to a LocalController implementation. The global | |
| 46 // pointer is defined in the .cc file. | |
| 47 static void set_local_controller_instance(LocalController* controller); | |
|
Ilya Sherman
2016/06/08 02:49:21
Now that this is moved to the .cc file, please res
Simon Que
2016/06/08 06:30:06
Done.
| |
| 48 | |
| 49 private: | |
| 50 explicit LeakDetectorRemoteController(LeakDetectorRemoteRequest request); | |
| 51 | |
| 52 // Single instance of LocalController. All remote LeakDetector clients will | |
| 53 // get their params from and send leak reports to this instance. | |
| 54 static LocalController* controller_; | |
|
Ilya Sherman
2016/06/08 02:49:21
nit: Please remove this.
Simon Que
2016/06/08 06:30:06
Done.
| |
| 55 | |
| 56 mojo::StrongBinding<metrics::LeakDetectorRemote> binding_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(LeakDetectorRemoteController); | |
| 59 }; | |
| 60 | |
| 61 } // namespace metrics | |
| 62 | |
| 63 #endif // CHROME_BROWSER_METRICS_LEAK_DETECTOR_REMOTE_CONTROLLER_H_ | |
| OLD | NEW |