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

Unified Diff: content/renderer/media/media_stream_dispatcher.h

Issue 1918173002: Add support for device-change notifications to MediaStreamDispatcher and MediaStreamDispatcherHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hta comments Created 4 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/media_stream_dispatcher.h
diff --git a/content/renderer/media/media_stream_dispatcher.h b/content/renderer/media/media_stream_dispatcher.h
index 6c0220e20700f80670de663ded1fb11af660a17b..73936796761144f373d236c890aaa6b7c26a9901 100644
--- a/content/renderer/media/media_stream_dispatcher.h
+++ b/content/renderer/media/media_stream_dispatcher.h
@@ -9,6 +9,7 @@
#include <map>
#include <memory>
#include <string>
+#include <vector>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
@@ -78,6 +79,17 @@ class CONTENT_EXPORT MediaStreamDispatcher
// Close a started device. |label| is provided in OnDeviceOpened.
void CloseDevice(const std::string& label);
+ // Register and unregister event handlers for device-change notifications.
+ // It is an error to try to subscribe a handler that is already subscribed or
+ // to cancel the subscription of a handler that is not subscribed. Also,
+ // each subscribed handler must make sure to invoke
+ // CancelDeviceChangeNotifications() before the handler is destroyed.
+ void SubscribeToDeviceChangeNotifications(
+ const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
+ const GURL& security_origin);
+ void CancelDeviceChangeNotifications(
+ const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler);
+
// Check if the label is a valid stream.
virtual bool IsStream(const std::string& label);
// Get the video session_id given a label. The label identifies a stream.
@@ -124,6 +136,7 @@ class CONTENT_EXPORT MediaStreamDispatcher
const std::string& label,
const StreamDeviceInfo& device_info);
void OnDeviceOpenFailed(int request_id);
+ void OnDevicesChanged();
// Used for DCHECKs so methods calls won't execute in the wrong thread.
base::ThreadChecker thread_checker_;
@@ -137,6 +150,9 @@ class CONTENT_EXPORT MediaStreamDispatcher
typedef std::list<Request> RequestList;
RequestList requests_;
+ std::vector<base::WeakPtr<MediaStreamDispatcherEventHandler>>
+ device_change_subscribers_;
+
DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher);
};

Powered by Google App Engine
This is Rietveld 408576698