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

Side by Side 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, 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/media/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <list> 7 #include <list>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/power_monitor/power_monitor.h"
14 #include "base/rand_util.h" 15 #include "base/rand_util.h"
15 #include "base/run_loop.h" 16 #include "base/run_loop.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "content/browser/browser_main_loop.h" 19 #include "content/browser/browser_main_loop.h"
19 #include "content/browser/media/capture/web_contents_capture_util.h" 20 #include "content/browser/media/capture/web_contents_capture_util.h"
20 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 21 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
21 #include "content/browser/renderer_host/media/device_request_message_filter.h" 22 #include "content/browser/renderer_host/media/device_request_message_filter.h"
22 #include "content/browser/renderer_host/media/media_capture_devices_impl.h" 23 #include "content/browser/renderer_host/media/media_capture_devices_impl.h"
23 #include "content/browser/renderer_host/media/media_stream_requester.h" 24 #include "content/browser/renderer_host/media/media_stream_requester.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // Some unit tests create the MSM in the IO thread and assumes the 347 // Some unit tests create the MSM in the IO thread and assumes the
347 // initialization is done synchronously. 348 // initialization is done synchronously.
348 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { 349 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
349 InitializeDeviceManagersOnIOThread(); 350 InitializeDeviceManagersOnIOThread();
350 } else { 351 } else {
351 BrowserThread::PostTask( 352 BrowserThread::PostTask(
352 BrowserThread::IO, FROM_HERE, 353 BrowserThread::IO, FROM_HERE,
353 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread, 354 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread,
354 base::Unretained(this))); 355 base::Unretained(this)));
355 } 356 }
357
358 base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
359 // BrowserMainLoop always creates the PowerMonitor instance before creating
360 // MediaStreamManager, but power_monitor may be NULL in unit tests.
361 if (power_monitor)
362 power_monitor->AddObserver(this);
356 } 363 }
357 364
358 MediaStreamManager::~MediaStreamManager() { 365 MediaStreamManager::~MediaStreamManager() {
359 DVLOG(1) << "~MediaStreamManager"; 366 DVLOG(1) << "~MediaStreamManager";
360 DCHECK(requests_.empty()); 367 DCHECK(requests_.empty());
361 DCHECK(!device_task_runner_); 368 DCHECK(!device_task_runner_);
369
370 base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
371 // The PowerMonitor instance owned by BrowserMainLoops always outlives the
372 // MediaStreamManager, but it may be NULL in unit tests.
373 if (power_monitor)
374 power_monitor->RemoveObserver(this);
362 } 375 }
363 376
364 VideoCaptureManager* MediaStreamManager::video_capture_manager() { 377 VideoCaptureManager* MediaStreamManager::video_capture_manager() {
365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 378 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
366 DCHECK(video_capture_manager_.get()); 379 DCHECK(video_capture_manager_.get());
367 return video_capture_manager_.get(); 380 return video_capture_manager_.get();
368 } 381 }
369 382
370 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() { 383 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() {
371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 384 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 DCHECK_GE(active_enumeration_ref_count_[stream_type], 0); 1587 DCHECK_GE(active_enumeration_ref_count_[stream_type], 0);
1575 } 1588 }
1576 1589
1577 // static 1590 // static
1578 void MediaStreamManager::SendMessageToNativeLog(const std::string& message) { 1591 void MediaStreamManager::SendMessageToNativeLog(const std::string& message) {
1579 BrowserThread::PostTask( 1592 BrowserThread::PostTask(
1580 BrowserThread::UI, FROM_HERE, 1593 BrowserThread::UI, FROM_HERE,
1581 base::Bind(DoAddLogMessage, message)); 1594 base::Bind(DoAddLogMessage, message));
1582 } 1595 }
1583 1596
1597 void MediaStreamManager::OnSuspend() {
1598 SendMessageToNativeLog("Power state suspended.");
1599 }
1600
1601 void MediaStreamManager::OnResume() {
1602 SendMessageToNativeLog("Power state resumed.");
1603 }
1604
1584 void MediaStreamManager::AddLogMessageOnIOThread(const std::string& message) { 1605 void MediaStreamManager::AddLogMessageOnIOThread(const std::string& message) {
1585 // Get render process ids on the IO thread. 1606 // Get render process ids on the IO thread.
1586 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1607 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1587 1608
1588 // Grab all unique process ids that request a MediaStream or have a 1609 // Grab all unique process ids that request a MediaStream or have a
1589 // MediaStream running. 1610 // MediaStream running.
1590 std::set<int> requesting_process_ids; 1611 std::set<int> requesting_process_ids;
1591 for (DeviceRequests::const_iterator it = requests_.begin(); 1612 for (DeviceRequests::const_iterator it = requests_.begin();
1592 it != requests_.end(); ++it) { 1613 it != requests_.end(); ++it) {
1593 DeviceRequest* request = it->second; 1614 DeviceRequest* request = it->second;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { 1902 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) {
1882 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, 1903 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id,
1883 window_id); 1904 window_id);
1884 break; 1905 break;
1885 } 1906 }
1886 } 1907 }
1887 } 1908 }
1888 } 1909 }
1889 1910
1890 } // namespace content 1911 } // namespace content
OLDNEW
« 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