OLD | NEW |
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" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | 389 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
390 // BrowserMainLoop always creates the PowerMonitor instance before creating | 390 // BrowserMainLoop always creates the PowerMonitor instance before creating |
391 // MediaStreamManager, but power_monitor may be NULL in unit tests. | 391 // MediaStreamManager, but power_monitor may be NULL in unit tests. |
392 if (power_monitor) | 392 if (power_monitor) |
393 power_monitor->AddObserver(this); | 393 power_monitor->AddObserver(this); |
394 } | 394 } |
395 | 395 |
396 MediaStreamManager::~MediaStreamManager() { | 396 MediaStreamManager::~MediaStreamManager() { |
397 DVLOG(1) << "~MediaStreamManager"; | 397 DVLOG(1) << "~MediaStreamManager"; |
398 DCHECK(requests_.empty()); | 398 DCHECK(requests_.empty()); |
399 DCHECK(!device_task_runner_); | 399 DCHECK(!device_task_runner_.get()); |
400 | 400 |
401 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | 401 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
402 // The PowerMonitor instance owned by BrowserMainLoops always outlives the | 402 // The PowerMonitor instance owned by BrowserMainLoops always outlives the |
403 // MediaStreamManager, but it may be NULL in unit tests. | 403 // MediaStreamManager, but it may be NULL in unit tests. |
404 if (power_monitor) | 404 if (power_monitor) |
405 power_monitor->RemoveObserver(this); | 405 power_monitor->RemoveObserver(this); |
406 } | 406 } |
407 | 407 |
408 VideoCaptureManager* MediaStreamManager::video_capture_manager() { | 408 VideoCaptureManager* MediaStreamManager::video_capture_manager() { |
409 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 409 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 const MediaStreamDevices& devices) { | 1522 const MediaStreamDevices& devices) { |
1523 if (!request->callback.is_null()) | 1523 if (!request->callback.is_null()) |
1524 request->callback.Run(devices, request->ui_proxy.Pass()); | 1524 request->callback.Run(devices, request->ui_proxy.Pass()); |
1525 | 1525 |
1526 // Delete the request since it is done. | 1526 // Delete the request since it is done. |
1527 DeleteRequest(label); | 1527 DeleteRequest(label); |
1528 } | 1528 } |
1529 | 1529 |
1530 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { | 1530 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { |
1531 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1531 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1532 if (device_task_runner_) | 1532 if (device_task_runner_.get()) |
1533 return; | 1533 return; |
1534 | 1534 |
1535 device_task_runner_ = audio_manager_->GetWorkerTaskRunner(); | 1535 device_task_runner_ = audio_manager_->GetWorkerTaskRunner(); |
1536 | 1536 |
1537 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_); | 1537 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_); |
1538 audio_input_device_manager_->Register(this, device_task_runner_); | 1538 audio_input_device_manager_->Register(this, device_task_runner_); |
1539 | 1539 |
1540 // We want to be notified of IO message loop destruction to delete the thread | 1540 // We want to be notified of IO message loop destruction to delete the thread |
1541 // and the device managers. | 1541 // and the device managers. |
1542 io_loop_ = base::MessageLoop::current(); | 1542 io_loop_ = base::MessageLoop::current(); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) { | 1919 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) { |
1920 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1920 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1921 use_fake_ui_ = true; | 1921 use_fake_ui_ = true; |
1922 fake_ui_ = fake_ui.Pass(); | 1922 fake_ui_ = fake_ui.Pass(); |
1923 } | 1923 } |
1924 | 1924 |
1925 void MediaStreamManager::WillDestroyCurrentMessageLoop() { | 1925 void MediaStreamManager::WillDestroyCurrentMessageLoop() { |
1926 DVLOG(3) << "MediaStreamManager::WillDestroyCurrentMessageLoop()"; | 1926 DVLOG(3) << "MediaStreamManager::WillDestroyCurrentMessageLoop()"; |
1927 DCHECK_EQ(base::MessageLoop::current(), io_loop_); | 1927 DCHECK_EQ(base::MessageLoop::current(), io_loop_); |
1928 DCHECK(requests_.empty()); | 1928 DCHECK(requests_.empty()); |
1929 if (device_task_runner_) { | 1929 if (device_task_runner_.get()) { |
1930 StopMonitoring(); | 1930 StopMonitoring(); |
1931 | 1931 |
1932 video_capture_manager_->Unregister(); | 1932 video_capture_manager_->Unregister(); |
1933 audio_input_device_manager_->Unregister(); | 1933 audio_input_device_manager_->Unregister(); |
1934 device_task_runner_ = NULL; | 1934 device_task_runner_ = NULL; |
1935 } | 1935 } |
1936 | 1936 |
1937 audio_input_device_manager_ = NULL; | 1937 audio_input_device_manager_ = NULL; |
1938 video_capture_manager_ = NULL; | 1938 video_capture_manager_ = NULL; |
1939 } | 1939 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2039 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { | 2039 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { |
2040 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, | 2040 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, |
2041 window_id); | 2041 window_id); |
2042 break; | 2042 break; |
2043 } | 2043 } |
2044 } | 2044 } |
2045 } | 2045 } |
2046 } | 2046 } |
2047 | 2047 |
2048 } // namespace content | 2048 } // namespace content |
OLD | NEW |