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

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

Issue 34393006: Refactor MediaStreamManager to never output real device id. It now always output sourceId in the fo… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change TranslateDeviceIdToSourceId to check for the request type instead of device type. Created 7 years, 2 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
Index: content/browser/renderer_host/media/media_stream_manager.h
diff --git a/content/browser/renderer_host/media/media_stream_manager.h b/content/browser/renderer_host/media/media_stream_manager.h
index 4349a7046fefe5d176a0d2d11dd91d355e8700a6..9b5061bb3d142d1ddb246c248d598888b86f7548 100644
--- a/content/browser/renderer_host/media/media_stream_manager.h
+++ b/content/browser/renderer_host/media/media_stream_manager.h
@@ -141,9 +141,6 @@ class CONTENT_EXPORT MediaStreamManager
int capture_session_id) OVERRIDE;
virtual void DevicesEnumerated(MediaStreamType stream_type,
const StreamDeviceInfoArray& devices) OVERRIDE;
- virtual void Error(MediaStreamType stream_type,
- int capture_session_id,
- MediaStreamProviderError error) OVERRIDE;
// Implements base::SystemMonitor::DevicesChangedObserver.
virtual void OnDevicesChanged(
@@ -158,12 +155,23 @@ class CONTENT_EXPORT MediaStreamManager
// generated stream (or when using --use-fake-ui-for-media-stream).
void UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui);
+ // Used by test to find a StreamDeviceInfo that currently has been
+ // requested and match the input arguments. If such a StreamDeviceInfo is
+ // found it is copied to |device_info|.
+ const StreamDeviceInfo* FindRequestedDeviceInfoForTest(
+ const std::string& source_id,
+ int render_process_id,
+ int render_view_id,
+ MediaStreamRequestType type);
+
// This object gets deleted on the UI thread after the IO thread has been
// destroyed. So we need to know when IO thread is being destroyed so that
- // we can delete VideoCaptureManager and AudioInputDeviceManager.
- // We also must call this function explicitly in tests which use
- // TestBrowserThreadBundle, because the notification happens too late in that
- // case (see http://crbug.com/247525#c14).
+ // we can delete VideoCaptureManager and AudioInputDeviceManager. Normally
+ // this is handled by
+ // base::MessageLoop::DestructionObserver::WillDestroyCurrentMessageLoop.
+ // But for some tests which use TestBrowserThreadBundle, we need to call
+ // WillDestroyCurrentMessageLoop explicitly because the notification happens
+ // too late. (see http://crbug.com/247525#c14).
virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
protected:
@@ -171,8 +179,6 @@ class CONTENT_EXPORT MediaStreamManager
MediaStreamManager();
private:
- friend class MockMediaStreamDispatcherHost;
-
// Contains all data needed to keep track of requests.
class DeviceRequest;
@@ -187,6 +193,11 @@ class CONTENT_EXPORT MediaStreamManager
typedef std::map<std::string, DeviceRequest*> DeviceRequests;
+ // This object gets deleted on the UI thread after the IO thread has been
miu 2013/11/02 03:22:42 Good comment to add! :) Though, does this class-
perkj_chrome 2013/11/04 09:32:02 oops. This should be removed. I did not intend to
+ // destroyed. So we need to know when the IO thread is being destroyed so
+ // that we can delete VideoCaptureManager and AudioInputDeviceManager.
+
+
// Initializes the device managers on IO thread. Auto-starts the device
// thread and registers this as a listener with the device managers.
void InitializeDeviceManagersOnIOThread();
@@ -196,16 +207,23 @@ class CONTENT_EXPORT MediaStreamManager
void NotifyDevicesChanged(MediaStreamType stream_type,
const StreamDeviceInfoArray& devices);
-
void HandleAccessRequestResponse(const std::string& label,
const MediaStreamDevices& devices);
void StopStreamFromUI(const std::string& label);
+ void DoCancelRequest(const std::string& label);
+
+ void DoStopStreamDevice(int render_process_id,
+ int render_view_id,
+ const std::string& device_id);
+
+ void DoEnumerateDevices(const std::string& label);
+
// Helpers.
// Checks if all devices that was requested in the request identififed by
// |label| has been opened and set the request state accordingly.
void HandleRequestDone(const std::string& label,
- DeviceRequest* request);
+ DeviceRequest* request);
void StopDevice(const StreamDeviceInfo& device_info);
// Returns true if a request for devices has been completed and the devices
// has either been opened or an error has occurred.
@@ -213,36 +231,53 @@ class CONTENT_EXPORT MediaStreamManager
MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type);
void StartEnumeration(DeviceRequest* request);
std::string AddRequest(DeviceRequest* request);
- void RemoveRequest(DeviceRequests::iterator it);
+ DeviceRequest* FindRequest(const std::string& label);
+ void DeleteRequest(const std::string& label);
void ClearEnumerationCache(EnumerationCache* cache);
void PostRequestToUI(const std::string& label);
void HandleRequest(const std::string& label);
+ bool SetupTabCaptureRequest(DeviceRequest* request);
+ bool SetupScreenCaptureRequest(DeviceRequest* request);
// Returns true if a device with |device_id| has already been requested by
// |render_process_id| and |render_view_id| of type |type|. If it has been
- // requested, |device_info| contain information about the the device.
+ // requested, |device_info| contain information about the device.
bool FindExistingRequestedDeviceInfo(int render_process_id,
int render_view_id,
+ const GURL& security_origin,
MediaStreamRequestType type,
const std::string& device_id,
+ MediaStreamType device_type,
StreamDeviceInfo* device_info,
MediaRequestState* request_state) const;
- // Sends cached device list to a client corresponding to the request
- // identified by |label|.
- void SendCachedDeviceList(EnumerationCache* cache, const std::string& label);
+ void FinalizeGenerateStream(const std::string& label,
+ DeviceRequest* request);
+ void FinalizeRequestFailed(const std::string& label,
+ DeviceRequest* request);
+ void FinalizeOpenDevice(const std::string& label,
+ DeviceRequest* request);
+ void FinalizeMediaAccessRequest(const std::string& label,
+ DeviceRequest* request,
+ const MediaStreamDevices& devices);
+ void FinalizeEnumerateDevices(const std::string& label,
+ DeviceRequest* request);
// Helpers to start and stop monitoring devices.
void StartMonitoring();
void StopMonitoring();
- // Finds and returns the raw device id corresponding to the given
- // |device_guid|. Returns true if there was a raw device id that matched the
- // given |device_guid|, false if nothing matched it.
- bool TranslateGUIDToRawId(
+ bool TranslateRequestedSourceIdToDeviceId(MediaStreamRequest* request);
+ void TranslateDeviceIdToSourceId(const MediaStreamRequest& request,
+ MediaStreamDevice* device);
+
+ // Finds and returns the device id corresponding to the given
+ // |source_id|. Returns true if there was a raw device id that matched the
+ // given |source_id|, false if nothing matched it.
+ bool TranslateSourceIdToDeviceId(
MediaStreamType stream_type,
const GURL& security_origin,
- const std::string& device_guid,
- std::string* raw_device_id);
+ const std::string& source_id,
+ std::string* device_id);
// Device thread shared by VideoCaptureManager and AudioInputDeviceManager.
scoped_ptr<base::Thread> device_thread_;

Powered by Google App Engine
This is Rietveld 408576698