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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 // initialization is done synchronously. | 354 // initialization is done synchronously. |
355 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 355 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
356 InitializeDeviceManagersOnIOThread(); | 356 InitializeDeviceManagersOnIOThread(); |
357 } else { | 357 } else { |
358 BrowserThread::PostTask( | 358 BrowserThread::PostTask( |
359 BrowserThread::IO, FROM_HERE, | 359 BrowserThread::IO, FROM_HERE, |
360 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread, | 360 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread, |
361 base::Unretained(this))); | 361 base::Unretained(this))); |
362 } | 362 } |
363 | 363 |
364 base::PowerMonitor::AddObserver(this); | 364 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
| 365 // BrowserMainLoop always creates the PowerMonitor instance before creating |
| 366 // MediaStreamManager, but power_monitor may be NULL in unit tests. |
| 367 if (power_monitor) |
| 368 power_monitor->AddObserver(this); |
365 } | 369 } |
366 | 370 |
367 MediaStreamManager::~MediaStreamManager() { | 371 MediaStreamManager::~MediaStreamManager() { |
368 DVLOG(1) << "~MediaStreamManager"; | 372 DVLOG(1) << "~MediaStreamManager"; |
369 DCHECK(requests_.empty()); | 373 DCHECK(requests_.empty()); |
370 DCHECK(!device_task_runner_); | 374 DCHECK(!device_task_runner_); |
371 | 375 |
372 base::PowerMonitor::RemoveObserver(this); | 376 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
| 377 // The PowerMonitor instance owned by BrowserMainLoops always outlives the |
| 378 // MediaStreamManager, but it may be NULL in unit tests. |
| 379 if (power_monitor) |
| 380 power_monitor->RemoveObserver(this); |
373 } | 381 } |
374 | 382 |
375 VideoCaptureManager* MediaStreamManager::video_capture_manager() { | 383 VideoCaptureManager* MediaStreamManager::video_capture_manager() { |
376 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 384 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
377 DCHECK(video_capture_manager_.get()); | 385 DCHECK(video_capture_manager_.get()); |
378 return video_capture_manager_.get(); | 386 return video_capture_manager_.get(); |
379 } | 387 } |
380 | 388 |
381 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() { | 389 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() { |
382 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 390 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { | 1920 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { |
1913 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, | 1921 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, |
1914 window_id); | 1922 window_id); |
1915 break; | 1923 break; |
1916 } | 1924 } |
1917 } | 1925 } |
1918 } | 1926 } |
1919 } | 1927 } |
1920 | 1928 |
1921 } // namespace content | 1929 } // namespace content |
OLD | NEW |