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

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

Issue 217303002: Adds power state suspend/resume messages to the webrtc native log. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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/renderer_host/media/media_stream_manager.h ('k') | no next file » | 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 839c0cb1411e529a53086eba615f945380d7ddc9..c6a4c25ce04e4b3d976c56623b26dd95e4b0dba0 100644
--- a/content/browser/renderer_host/media/media_stream_manager.cc
+++ b/content/browser/renderer_host/media/media_stream_manager.cc
@@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
+#include "base/power_monitor/power_monitor.h"
#include "base/rand_util.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
@@ -353,12 +354,24 @@ MediaStreamManager::MediaStreamManager(media::AudioManager* audio_manager)
base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread,
base::Unretained(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() {
DVLOG(1) << "~MediaStreamManager";
DCHECK(requests_.empty());
DCHECK(!device_task_runner_);
+
+ 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() {
@@ -1581,6 +1594,14 @@ void MediaStreamManager::SendMessageToNativeLog(const std::string& message) {
base::Bind(DoAddLogMessage, message));
}
+void MediaStreamManager::OnSuspend() {
+ SendMessageToNativeLog("Power state suspended.");
+}
+
+void MediaStreamManager::OnResume() {
+ SendMessageToNativeLog("Power state resumed.");
+}
+
void MediaStreamManager::AddLogMessageOnIOThread(const std::string& message) {
// Get render process ids on the IO thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
« no previous file with comments | « content/browser/renderer_host/media/media_stream_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698