| Index: chrome/renderer/leak_detector/leak_detector_monitor_client.cc
|
| diff --git a/chrome/renderer/leak_detector/leak_detector_monitor_client.cc b/chrome/renderer/leak_detector/leak_detector_monitor_client.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..40f9011760fb7bc99fe14420a123e94cf8c83dae
|
| --- /dev/null
|
| +++ b/chrome/renderer/leak_detector/leak_detector_monitor_client.cc
|
| @@ -0,0 +1,61 @@
|
| +// 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/leak_detector_monitor_client.h"
|
| +
|
| +#include "content/public/common/service_registry.h"
|
| +#include "content/public/renderer/render_thread.h"
|
| +
|
| +namespace metrics {
|
| +
|
| +static LeakDetectorMonitorClient* g_leak_detector_service = NULL;
|
| +
|
| +// static
|
| +void LeakDetectorMonitorClient::Initialize() {
|
| + CHECK(!g_leak_detector_service);
|
| + g_leak_detector_service = new LeakDetectorMonitorClient();
|
| +}
|
| +
|
| +// static
|
| +void LeakDetectorMonitorClient::Shutdown() {
|
| + CHECK(g_leak_detector_service);
|
| + delete g_leak_detector_service;
|
| + g_leak_detector_service = NULL;
|
| +}
|
| +
|
| +// static
|
| +LeakDetectorMonitorClient* LeakDetectorMonitorClient::GetInstance() {
|
| + CHECK(g_leak_detector_service)
|
| + << "LoginState::Get() called before Initialize()";
|
| + return g_leak_detector_service;
|
| +}
|
| +
|
| +// static
|
| +bool LeakDetectorMonitorClient::IsInitialized() {
|
| + return g_leak_detector_service;
|
| +}
|
| +
|
| +LeakDetectorMonitorClient::LeakDetectorMonitorClient() {
|
| + content::ServiceRegistry* registry =
|
| + content::RenderThread::Get()->GetServiceRegistry();
|
| + if (registry) {
|
| + // Registry can be null during testing.
|
| + LOG(ERROR) << "Connecting to remote service";
|
| + registry->ConnectToRemoteService(mojo::GetProxy(&leak_detector_monitor_));
|
| + LOG(ERROR) << " result: " << leak_detector_monitor_;
|
| +
|
| + OnLeakFound();
|
| + }
|
| +}
|
| +
|
| +LeakDetectorMonitorClient::~LeakDetectorMonitorClient() {
|
| +}
|
| +
|
| +void LeakDetectorMonitorClient::OnLeakFound() {
|
| + LOG(ERROR) << "LeakDetectorMonitorClient::OnLeakFound";
|
| + leak_detector_monitor_->StoreLeakReport();
|
| + LOG(ERROR) << "Done";
|
| +}
|
| +
|
| +} // namespace metrics
|
|
|