OLD | NEW |
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/renderer/render_thread.h" | 11 #include "content/public/renderer/render_thread.h" |
12 #include "mojo/public/cpp/bindings/interface_request.h" | 12 #include "mojo/public/cpp/bindings/interface_request.h" |
13 #include "services/shell/public/cpp/interface_provider.h" | 13 #include "services/service_manager/public/cpp/interface_provider.h" |
14 | 14 |
15 LeakDetectorRemoteClient::LeakDetectorRemoteClient() { | 15 LeakDetectorRemoteClient::LeakDetectorRemoteClient() { |
16 // Connect to Mojo service. | 16 // Connect to Mojo service. |
17 content::RenderThread::Get()->GetRemoteInterfaces()->GetInterface( | 17 content::RenderThread::Get()->GetRemoteInterfaces()->GetInterface( |
18 &remote_service_); | 18 &remote_service_); |
19 | 19 |
20 // It is safe to use "base::Unretained(this)" because |this| owns | 20 // It is safe to use "base::Unretained(this)" because |this| owns |
21 // |remote_service_|. See example at: | 21 // |remote_service_|. See example at: |
22 // https://www.chromium.org/developers/design-documents/mojo/validation | 22 // https://www.chromium.org/developers/design-documents/mojo/validation |
23 remote_service_->GetParams(base::Bind( | 23 remote_service_->GetParams(base::Bind( |
(...skipping 28 matching lines...) Expand all Loading... |
52 metrics::MemoryLeakReportProto::Params params; | 52 metrics::MemoryLeakReportProto::Params params; |
53 metrics::leak_detector::protobuf_to_mojo_converter::MojoToParams(*result, | 53 metrics::leak_detector::protobuf_to_mojo_converter::MojoToParams(*result, |
54 ¶ms); | 54 ¶ms); |
55 | 55 |
56 if (params.sampling_rate() > 0) { | 56 if (params.sampling_rate() > 0) { |
57 metrics::LeakDetector* detector = metrics::LeakDetector::GetInstance(); | 57 metrics::LeakDetector* detector = metrics::LeakDetector::GetInstance(); |
58 detector->AddObserver(this); | 58 detector->AddObserver(this); |
59 detector->Init(params, base::ThreadTaskRunnerHandle::Get()); | 59 detector->Init(params, base::ThreadTaskRunnerHandle::Get()); |
60 } | 60 } |
61 } | 61 } |
OLD | NEW |