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

Side by Side Diff: chrome/renderer/leak_detector/leak_detector_remote_client.cc

Issue 2166553003: Revert of Mojo interface/service for Leak Detector on remote process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(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/renderer/leak_detector/leak_detector_remote_client.h"
6
7 #include "base/bind.h"
8 #include "base/threading/thread_task_runner_handle.h"
9 #include "components/metrics/leak_detector/protobuf_to_mojo_converter.h"
10 #include "components/metrics/proto/memory_leak_report.pb.h"
11 #include "content/public/renderer/render_thread.h"
12 #include "mojo/public/cpp/bindings/interface_request.h"
13 #include "services/shell/public/cpp/interface_provider.h"
14
15 LeakDetectorRemoteClient::LeakDetectorRemoteClient() {
16 // Connect to Mojo service.
17 content::RenderThread::Get()->GetRemoteInterfaces()->GetInterface(
18 &remote_service_);
19
20 // It is safe to use "base::Unretained(this)" because |this| owns
21 // |remote_service_|. See example at:
22 // https://www.chromium.org/developers/design-documents/mojo/validation
23 remote_service_->GetParams(base::Bind(
24 &LeakDetectorRemoteClient::OnParamsReceived, base::Unretained(this)));
25 }
26
27 LeakDetectorRemoteClient::~LeakDetectorRemoteClient() {
28 metrics::LeakDetector::GetInstance()->RemoveObserver(this);
29 }
30
31 void LeakDetectorRemoteClient::OnParamsReceived(
32 mojo::StructPtr<metrics::mojom::LeakDetectorParams> result) {
33 metrics::MemoryLeakReportProto::Params params;
34 metrics::leak_detector::protobuf_to_mojo_converter::MojoToParams(*result,
35 &params);
36
37 metrics::LeakDetector* detector = metrics::LeakDetector::GetInstance();
38 detector->AddObserver(this);
39 detector->Init(params, base::ThreadTaskRunnerHandle::Get());
40 }
41
42 void LeakDetectorRemoteClient::OnLeaksFound(
43 const std::vector<metrics::MemoryLeakReportProto>& reports) {
44 std::vector<mojo::StructPtr<metrics::mojom::MemoryLeakReport>> result;
45
46 for (const metrics::MemoryLeakReportProto& report : reports) {
47 metrics::mojom::MemoryLeakReportPtr mojo_report =
48 metrics::mojom::MemoryLeakReport::New();
49 metrics::leak_detector::protobuf_to_mojo_converter::ReportToMojo(
50 report, mojo_report.get());
51 result.push_back(std::move(mojo_report));
52 }
53
54 remote_service_->SendLeakReports(std::move(result));
55 }
OLDNEW
« no previous file with comments | « chrome/renderer/leak_detector/leak_detector_remote_client.h ('k') | components/components_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698