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/renderer/leak_detector_remote_client.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/threading/thread_task_runner_handle.h" | |
9 #include "components/metrics/proto/memory_leak_report.pb.h" | |
10 #include "content/public/common/service_registry.h" | |
11 #include "content/public/renderer/render_thread.h" | |
12 #include "mojo/public/cpp/bindings/interface_request.h" | |
13 | |
14 LeakDetectorRemoteClient::LeakDetectorRemoteClient() { | |
15 // Connect to Mojo service. | |
16 content::RenderThread::Get()->GetServiceRegistry()->ConnectToRemoteService( | |
17 mojo::GetProxy(&remote_service_)); | |
18 | |
19 remote_service_->GetParams( | |
20 base::Bind(&LeakDetectorRemoteClient::OnParamsReceived, | |
21 base::Unretained(this))); | |
Ilya Sherman
2016/06/10 21:27:35
Why is base::Unretained safe? Is it because |this
Simon Que
2016/06/16 07:13:27
I'm actually not sure if this is the correct patte
Ilya Sherman
2016/06/16 18:14:20
Okay, sounds like the conclusion on that thread is
| |
22 } | |
23 | |
24 LeakDetectorRemoteClient::~LeakDetectorRemoteClient() {} | |
25 | |
26 void LeakDetectorRemoteClient::OnParamsReceived(mojo::String result) { | |
27 metrics::MemoryLeakReportProto::Params params; | |
28 if (!params.ParseFromString(result.get())) | |
29 return; | |
Ilya Sherman
2016/06/10 21:27:35
Should this be some sort of DCHECK that either the
Simon Que
2016/06/16 07:13:27
Done. However, the interface might change to sendi
| |
30 | |
31 metrics::LeakDetector* detector = metrics::LeakDetector::GetInstance(); | |
32 detector->AddObserver(this); | |
Ilya Sherman
2016/06/10 21:27:35
Should you unregister as an observer somewhere?
Simon Que
2016/06/16 07:13:27
Done.
| |
33 detector->Init(params, base::ThreadTaskRunnerHandle::Get()); | |
34 } | |
35 | |
36 void LeakDetectorRemoteClient::OnLeaksFound( | |
37 const std::vector<metrics::MemoryLeakReportProto>& reports) { | |
38 // TODO(sque): Handle reports. | |
39 } | |
OLD | NEW |