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 #include "chrome/browser/metrics/leak_detector_remote_controller.h" | |
6 | |
7 #include "content/public/browser/browser_thread.h" | |
8 | |
9 namespace metrics { | |
10 | |
11 LeakDetectorRemoteController::~LeakDetectorRemoteController() {} | |
12 | |
13 // static | |
14 void LeakDetectorRemoteController::Create(LeakDetectorRemoteRequest request) { | |
15 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
16 new LeakDetectorRemoteController(std::move(request)); | |
17 } | |
18 | |
19 void LeakDetectorRemoteController::GetParams( | |
20 const LeakDetectorRemote::GetParamsCallback& cb) { | |
Ilya Sherman
2016/06/07 23:03:38
nit: s/cb/callback
Simon Que
2016/06/08 01:14:18
Done.
| |
21 // If no controller exists, send an empty param protobuf. The remote caller | |
22 // should not initialize anything if the params are empty. | |
Ilya Sherman
2016/06/07 23:03:38
Would it be reasonable to instead just DCHECK that
Simon Que
2016/06/08 01:14:18
The intended operation is that the LocalController
| |
23 MemoryLeakReportProto_Params params; | |
24 if (controller_) { | |
25 controller_->GetParams(¶ms); | |
26 } | |
27 | |
28 // Serialize the params before sending it to the Mojo client. | |
29 std::string serialized_params; | |
30 params.SerializeToString(&serialized_params); | |
31 | |
32 cb.Run(serialized_params); | |
33 } | |
34 | |
35 void LeakDetectorRemoteController::SendLeakReports( | |
36 mojo::Array<mojo::String> reports) { | |
37 std::vector<MemoryLeakReportProto> report_protos; | |
38 report_protos.reserve(reports.size()); | |
39 | |
40 for (const mojo::String& serialized_report : reports) { | |
41 report_protos.push_back(MemoryLeakReportProto()); | |
42 report_protos.back().ParseFromString(serialized_report); | |
43 } | |
44 DCHECK(controller_); | |
45 controller_->SendLeakReports(report_protos); | |
46 } | |
47 | |
48 LeakDetectorRemoteController::LeakDetectorRemoteController( | |
49 LeakDetectorRemoteRequest request) | |
50 : binding_(this, std::move(request)) {} | |
51 | |
52 // static | |
53 LeakDetectorRemoteController::LocalController* | |
54 LeakDetectorRemoteController::controller_ = nullptr; | |
55 | |
56 } // namespace metrics | |
Ilya Sherman
2016/06/07 23:03:38
It looks like this code could live within //compon
| |
OLD | NEW |