diff options
Diffstat (limited to 'chrome/browser/media/router/media_router.h')
-rw-r--r-- | chrome/browser/media/router/media_router.h | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/chrome/browser/media/router/media_router.h b/chrome/browser/media/router/media_router.h index 7fd66fa..7405f4f 100644 --- a/chrome/browser/media/router/media_router.h +++ b/chrome/browser/media/router/media_router.h @@ -21,15 +21,25 @@ namespace media_router { class IssuesObserver; class MediaRoutesObserver; class MediaSinksObserver; - -// Type of callback used in |CreateRoute()|. Callback is invoked when the -// route request either succeeded or failed. -// The first argument is the route created. If the route request failed, this -// will be a nullptr. -// The second argument is the error string, which will be nonempty if the route -// request failed. +class PresentationSessionMessagesObserver; + +// Type of callback used in |CreateRoute()| and |JoinRoute()|. Callback is +// invoked when the route request either succeeded or failed. +// On success: +// |route|: The route created or joined. +// |presentation_id|: +// The presentation ID of the route created or joined. In the case of +// |CreateRoute()|, the ID is generated by MediaRouter and is guaranteed to +// be unique. +// |error|: Empty string. +// On failure: +// |route|: nullptr +// |presentation_id|: Empty string. +// |error|: Non-empty string describing the error. using MediaRouteResponseCallback = - base::Callback<void(const MediaRoute*, const std::string&)>; + base::Callback<void(const MediaRoute* route, + const std::string& presentation_id, + const std::string& error)>; // Used in cases where a tab ID is not applicable in CreateRoute/JoinRoute. const int kInvalidTabId = -1; @@ -93,14 +103,6 @@ class MediaRouter : public KeyedService { scoped_ptr<std::vector<uint8>> data, const SendRouteMessageCallback& callback) = 0; - // Gets the next batch of messages from one of the routes in |route_ids|. - // |message_cb|: Invoked with a non-empty list of messages when there are - // messages, an empty list when messaging channel had error. - // It is not invoked until there are messages available or error. - virtual void ListenForRouteMessages( - const std::vector<MediaRoute::Id>& route_ids, - const PresentationSessionMessageCallback& message_cb) = 0; - // Clears the issue with the id |issue_id|. virtual void ClearIssue(const Issue::Id& issue_id) = 0; @@ -108,9 +110,9 @@ class MediaRouter : public KeyedService { friend class IssuesObserver; friend class MediaSinksObserver; friend class MediaRoutesObserver; + friend class PresentationSessionMessagesObserver; - // The following functions are called by IssuesObserver, MediaSinksObserver, - // and MediaRoutesObserver. + // The following functions are called by friend Observer classes above. // Registers |observer| with this MediaRouter. |observer| specifies a media // source and will receive updates with media sinks that are compatible with @@ -130,7 +132,7 @@ class MediaRouter : public KeyedService { // Adds a MediaRoutesObserver to listen for updates on MediaRoutes. // The initial update may happen synchronously. - // MediaRouter does not own |observer|. |RemoveMediaRoutesObserver| should + // MediaRouter does not own |observer|. |UnregisterMediaRoutesObserver| should // be called before |observer| is destroyed. // It is invalid to register the same observer more than once and will result // in undefined behavior. @@ -147,6 +149,20 @@ class MediaRouter : public KeyedService { // Removes the IssuesObserver |observer|. virtual void UnregisterIssuesObserver(IssuesObserver* observer) = 0; + + // Registers |observer| with this MediaRouter. |observer| specifies a media + // route corresponding to a presentation and will receive messages from the + // MediaSink connected to the route. Note that MediaRouter does not own + // |observer|. |observer| should be unregistered before it is destroyed. + // Registering the same observer more than once will result in undefined + // behavior. + virtual void RegisterPresentationSessionMessagesObserver( + PresentationSessionMessagesObserver* observer) = 0; + + // Unregisters a previously registered PresentationSessionMessagesObserver. + // |observer| will stop receiving further updates. + virtual void UnregisterPresentationSessionMessagesObserver( + PresentationSessionMessagesObserver* observer) = 0; }; } // namespace media_router |