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

Unified Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 226263008: Revert of Attempting to resolve a race condition with PowerMonitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « content/browser/power_monitor_message_broadcaster_unittest.cc ('k') | content/child/child_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/media_stream_manager.cc
diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc
index ea0d546b193f3d7f0eb3cb86db3a4fd03c449a05..af543fc26d562756c7c3a4a2aa2e42cfd572ab9f 100644
--- a/content/browser/renderer_host/media/media_stream_manager.cc
+++ b/content/browser/renderer_host/media/media_stream_manager.cc
@@ -361,7 +361,11 @@
base::Unretained(this)));
}
- base::PowerMonitor::AddObserver(this);
+ base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
+ // BrowserMainLoop always creates the PowerMonitor instance before creating
+ // MediaStreamManager, but power_monitor may be NULL in unit tests.
+ if (power_monitor)
+ power_monitor->AddObserver(this);
}
MediaStreamManager::~MediaStreamManager() {
@@ -369,7 +373,11 @@
DCHECK(requests_.empty());
DCHECK(!device_task_runner_);
- base::PowerMonitor::RemoveObserver(this);
+ base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
+ // The PowerMonitor instance owned by BrowserMainLoops always outlives the
+ // MediaStreamManager, but it may be NULL in unit tests.
+ if (power_monitor)
+ power_monitor->RemoveObserver(this);
}
VideoCaptureManager* MediaStreamManager::video_capture_manager() {
« no previous file with comments | « content/browser/power_monitor_message_broadcaster_unittest.cc ('k') | content/child/child_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698