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

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

Issue 2755813002: Begin to wean child processes off reliance on a persistent service_manager::Connection to the brows… (Closed)
Patch Set: . Created 3 years, 9 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/leak_detector/leak_detector_remote_client.h" 5 #include "chrome/renderer/leak_detector/leak_detector_remote_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "components/metrics/leak_detector/protobuf_to_mojo_converter.h" 9 #include "components/metrics/leak_detector/protobuf_to_mojo_converter.h"
10 #include "components/metrics/proto/memory_leak_report.pb.h" 10 #include "components/metrics/proto/memory_leak_report.pb.h"
11 #include "content/public/common/service_names.mojom.h"
11 #include "content/public/renderer/render_thread.h" 12 #include "content/public/renderer/render_thread.h"
12 #include "mojo/public/cpp/bindings/interface_request.h" 13 #include "mojo/public/cpp/bindings/interface_request.h"
13 #include "services/service_manager/public/cpp/interface_provider.h" 14 #include "services/service_manager/public/cpp/connector.h"
14 15
15 LeakDetectorRemoteClient::LeakDetectorRemoteClient() { 16 LeakDetectorRemoteClient::LeakDetectorRemoteClient() {
16 // Connect to Mojo service. 17 // Connect to Mojo service.
17 content::RenderThread::Get()->GetRemoteInterfaces()->GetInterface( 18 content::RenderThread::Get()->GetConnector()->BindInterface(
18 &remote_service_); 19 content::mojom::kBrowserServiceName, &remote_service_);
19 20
20 // It is safe to use "base::Unretained(this)" because |this| owns 21 // It is safe to use "base::Unretained(this)" because |this| owns
21 // |remote_service_|. See example at: 22 // |remote_service_|. See example at:
22 // https://www.chromium.org/developers/design-documents/mojo/validation 23 // https://www.chromium.org/developers/design-documents/mojo/validation
23 remote_service_->GetParams(base::Bind( 24 remote_service_->GetParams(base::Bind(
24 &LeakDetectorRemoteClient::OnParamsReceived, base::Unretained(this))); 25 &LeakDetectorRemoteClient::OnParamsReceived, base::Unretained(this)));
25 } 26 }
26 27
27 LeakDetectorRemoteClient::~LeakDetectorRemoteClient() { 28 LeakDetectorRemoteClient::~LeakDetectorRemoteClient() {
28 metrics::LeakDetector::GetInstance()->RemoveObserver(this); 29 metrics::LeakDetector::GetInstance()->RemoveObserver(this);
(...skipping 23 matching lines...) Expand all
52 metrics::MemoryLeakReportProto::Params params; 53 metrics::MemoryLeakReportProto::Params params;
53 metrics::leak_detector::protobuf_to_mojo_converter::MojoToParams(*result, 54 metrics::leak_detector::protobuf_to_mojo_converter::MojoToParams(*result,
54 &params); 55 &params);
55 56
56 if (params.sampling_rate() > 0) { 57 if (params.sampling_rate() > 0) {
57 metrics::LeakDetector* detector = metrics::LeakDetector::GetInstance(); 58 metrics::LeakDetector* detector = metrics::LeakDetector::GetInstance();
58 detector->AddObserver(this); 59 detector->AddObserver(this);
59 detector->Init(params, base::ThreadTaskRunnerHandle::Get()); 60 detector->Init(params, base::ThreadTaskRunnerHandle::Get());
60 } 61 }
61 } 62 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_thread_observer.cc ('k') | chrome/renderer/net_benchmarking_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698