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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/leak_detector_remote_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/leak_detector_remote_client.cc
diff --git a/chrome/renderer/leak_detector_remote_client.cc b/chrome/renderer/leak_detector_remote_client.cc
new file mode 100644
index 0000000000000000000000000000000000000000..94c72bd0790c3279b5a85908185df68185852958
--- /dev/null
+++ b/chrome/renderer/leak_detector_remote_client.cc
@@ -0,0 +1,44 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/leak_detector_remote_client.h"
+
+#include "base/bind.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "components/metrics/proto/memory_leak_report.pb.h"
+#include "content/public/common/service_registry.h"
+#include "content/public/renderer/render_thread.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+
+LeakDetectorRemoteClient::LeakDetectorRemoteClient() {
+ // Connect to Mojo service.
+ content::RenderThread::Get()->GetServiceRegistry()->ConnectToRemoteService(
+ mojo::GetProxy(&remote_service_));
+
+ remote_service_->GetParams(
+ base::Bind(&LeakDetectorRemoteClient::OnParamsReceived,
+ base::Unretained(this)));
+}
+
+LeakDetectorRemoteClient::~LeakDetectorRemoteClient() {
+ 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
+}
+
+void LeakDetectorRemoteClient::OnParamsReceived(mojo::String result) {
+ if (result.empty())
+ return;
+
+ metrics::MemoryLeakReportProto::Params params;
+ bool params_decoded = params.ParseFromString(result.get());
+ DCHECK(params_decoded);
+
+ metrics::LeakDetector* detector = metrics::LeakDetector::GetInstance();
+ detector->AddObserver(this);
+ detector->Init(params, base::ThreadTaskRunnerHandle::Get());
+}
+
+void LeakDetectorRemoteClient::OnLeaksFound(
+ const std::vector<metrics::MemoryLeakReportProto>& reports) {
+ // TODO(sque): Handle reports.
+}
« 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