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

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

Issue 2056973002: Add renderer-side client for LeakDetectorRemoteController Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Import sources from gypi into BUILD.gn; Unregister observer; Check that params were decoded Created 4 years, 6 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
« no previous file with comments | « chrome/renderer/leak_detector_remote_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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)));
22 }
23
24 LeakDetectorRemoteClient::~LeakDetectorRemoteClient() {
25 metrics::LeakDetector::GetInstance()->RemoveObserver(this);
Ilya Sherman 2016/06/16 18:14:20 Is it safe to call RemoveObserver() if AddObserver
Simon Que 2016/06/17 01:30:38 Yes, the observers are added to base::ObserverList
Ilya Sherman 2016/06/17 01:32:50 Okay. In that case, LGTM with the added documenta
26 }
27
28 void LeakDetectorRemoteClient::OnParamsReceived(mojo::String result) {
29 if (result.empty())
30 return;
31
32 metrics::MemoryLeakReportProto::Params params;
33 bool params_decoded = params.ParseFromString(result.get());
34 DCHECK(params_decoded);
35
36 metrics::LeakDetector* detector = metrics::LeakDetector::GetInstance();
37 detector->AddObserver(this);
38 detector->Init(params, base::ThreadTaskRunnerHandle::Get());
39 }
40
41 void LeakDetectorRemoteClient::OnLeaksFound(
42 const std::vector<metrics::MemoryLeakReportProto>& reports) {
43 // TODO(sque): Handle reports.
44 }
OLDNEW
« no previous file with comments | « chrome/renderer/leak_detector_remote_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698