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

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

Issue 1566603003: Dummy patch to try out Mojo connection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize from RegisterRenderProcessMojoServices Created 4 years, 11 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/leak_detector_monitor_client.h ('k') | components/metrics.gypi » ('j') | 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/leak_detector_monitor_client.h"
6
7 #include "content/public/common/service_registry.h"
8 #include "content/public/renderer/render_thread.h"
9
10 namespace metrics {
11
12 static LeakDetectorMonitorClient* g_leak_detector_service = NULL;
13
14 // static
15 void LeakDetectorMonitorClient::Initialize() {
16 CHECK(!g_leak_detector_service);
17 g_leak_detector_service = new LeakDetectorMonitorClient();
18 }
19
20 // static
21 void LeakDetectorMonitorClient::Shutdown() {
22 CHECK(g_leak_detector_service);
23 delete g_leak_detector_service;
24 g_leak_detector_service = NULL;
25 }
26
27 // static
28 LeakDetectorMonitorClient* LeakDetectorMonitorClient::GetInstance() {
29 CHECK(g_leak_detector_service)
30 << "LoginState::Get() called before Initialize()";
31 return g_leak_detector_service;
32 }
33
34 // static
35 bool LeakDetectorMonitorClient::IsInitialized() {
36 return g_leak_detector_service;
37 }
38
39 LeakDetectorMonitorClient::LeakDetectorMonitorClient() {
40 content::ServiceRegistry* registry =
41 content::RenderThread::Get()->GetServiceRegistry();
42 if (registry) {
43 // Registry can be null during testing.
44 LOG(ERROR) << "Connecting to remote service";
45 registry->ConnectToRemoteService(mojo::GetProxy(&leak_detector_monitor_));
46 LOG(ERROR) << " result: " << leak_detector_monitor_;
47
48 OnLeakFound();
49 }
50 }
51
52 LeakDetectorMonitorClient::~LeakDetectorMonitorClient() {
53 }
54
55 void LeakDetectorMonitorClient::OnLeakFound() {
56 LOG(ERROR) << "LeakDetectorMonitorClient::OnLeakFound";
57 leak_detector_monitor_->StoreLeakReport();
58 LOG(ERROR) << "Done";
59 }
60
61 } // namespace metrics
OLDNEW
« no previous file with comments | « chrome/renderer/leak_detector/leak_detector_monitor_client.h ('k') | components/metrics.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698