Commit 4c4b30a9 authored by perkj@chromium.org's avatar perkj@chromium.org

Refactor how the MediaStreamManager::DeviceMonitor is started.

Review URL: https://codereview.chromium.org/57913002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238409 0039d316-1c4b-4281-b951-d872f2087c98
parent 88fa18e8
...@@ -12,10 +12,7 @@ namespace content { ...@@ -12,10 +12,7 @@ namespace content {
namespace { namespace {
void EnsureMonitorCaptureDevicesInternal( void EnsureMonitorCaptureDevicesInternal(
MediaStreamManager* media_stream_manager) { MediaStreamManager* media_stream_manager) {
// TODO(perkj): The argument list suggests that this is the wrong design. Can media_stream_manager->EnsureDeviceMonitorStarted();
// we add a separate method for device monitoring?
media_stream_manager->EnumerateDevices(
NULL, -1, -1, NULL, -1, MEDIA_DEVICE_AUDIO_CAPTURE, GURL());
} }
} }
......
...@@ -413,18 +413,10 @@ std::string MediaStreamManager::EnumerateDevices( ...@@ -413,18 +413,10 @@ std::string MediaStreamManager::EnumerateDevices(
MediaStreamType type, MediaStreamType type,
const GURL& security_origin) { const GURL& security_origin) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(requester);
DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE ||
type == MEDIA_DEVICE_VIDEO_CAPTURE); type == MEDIA_DEVICE_VIDEO_CAPTURE);
// When the requester is NULL, the request is made by the UI to ensure MSM
// starts monitoring devices.
if (!requester) {
if (!monitoring_started_)
StartMonitoring();
return std::string();
}
// Create a new request. // Create a new request.
StreamOptions options; StreamOptions options;
if (type == MEDIA_DEVICE_AUDIO_CAPTURE) { if (type == MEDIA_DEVICE_AUDIO_CAPTURE) {
...@@ -534,6 +526,12 @@ std::string MediaStreamManager::OpenDevice( ...@@ -534,6 +526,12 @@ std::string MediaStreamManager::OpenDevice(
return label; return label;
} }
void MediaStreamManager::EnsureDeviceMonitorStarted() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!monitoring_started_)
StartMonitoring();
}
void MediaStreamManager::StopRemovedDevices( void MediaStreamManager::StopRemovedDevices(
const StreamDeviceInfoArray& old_devices, const StreamDeviceInfoArray& old_devices,
const StreamDeviceInfoArray& new_devices) { const StreamDeviceInfoArray& new_devices) {
......
...@@ -138,6 +138,10 @@ class CONTENT_EXPORT MediaStreamManager ...@@ -138,6 +138,10 @@ class CONTENT_EXPORT MediaStreamManager
MediaStreamType type, MediaStreamType type,
const GURL& security_origin); const GURL& security_origin);
// Called by UI to make sure the device monitor is started so that UI receive
// notifications about device changes.
void EnsureDeviceMonitorStarted();
// Implements MediaStreamProviderListener. // Implements MediaStreamProviderListener.
virtual void Opened(MediaStreamType stream_type, virtual void Opened(MediaStreamType stream_type,
int capture_session_id) OVERRIDE; int capture_session_id) OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment