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

Unified Diff: chrome/browser/metrics/leak_detector/leak_detector_remote_controller.cc

Issue 2295413002: Detach LeakDetectorController from remote controller on shutdown (Closed)
Patch Set: Fix for unit testing Created 4 years, 3 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/browser/metrics/leak_detector/leak_detector_controller_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/leak_detector/leak_detector_remote_controller.cc
diff --git a/chrome/browser/metrics/leak_detector/leak_detector_remote_controller.cc b/chrome/browser/metrics/leak_detector/leak_detector_remote_controller.cc
index e02182bbf995c50ca1eee93e7301fb8738b7552f..669b14c40a8e98b1157e6e79eeba4051674441b5 100644
--- a/chrome/browser/metrics/leak_detector/leak_detector_remote_controller.cc
+++ b/chrome/browser/metrics/leak_detector/leak_detector_remote_controller.cc
@@ -57,13 +57,13 @@ void LeakDetectorRemoteController::SendLeakReports(
leak_detector::protobuf_to_mojo_converter::MojoToReport(*report, proto);
}
- DCHECK(g_local_controller);
- g_local_controller->SendLeakReports(report_protos);
+ if (g_local_controller) {
+ g_local_controller->SendLeakReports(report_protos);
+ }
}
void LeakDetectorRemoteController::OnRemoteProcessShutdown() {
- if (leak_detector_enabled_on_remote_process_) {
- DCHECK(g_local_controller);
+ if (leak_detector_enabled_on_remote_process_ && g_local_controller) {
g_local_controller->OnRemoteProcessShutdown();
}
}
@@ -80,6 +80,9 @@ LeakDetectorRemoteController::LeakDetectorRemoteController(
// static
void LeakDetectorRemoteController::SetLocalControllerInstance(
LocalController* controller) {
+ // This must be on the same thread as the Mojo-based functions of this class,
+ // to avoid race conditions on |g_local_controller|.
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
g_local_controller = controller;
}
« no previous file with comments | « chrome/browser/metrics/leak_detector/leak_detector_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698