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

Unified Diff: chrome/browser/media/router/media_router.h

Issue 1259073004: [Presentation API] Change ListenForSessionMessages API to client-style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 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: chrome/browser/media/router/media_router.h
diff --git a/chrome/browser/media/router/media_router.h b/chrome/browser/media/router/media_router.h
index 7fd66fa4017a62531b7d508fd9043eab1f48f168..3d9f1bb419587a0318ff609c16199349204fa531 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.
mark a. foltz 2015/08/04 23:47:02 created or joined.
imcheng 2015/08/05 21:38:35 Done.
+// |presentation_id|:
+// The presentation ID of the route created. In the case of
mark a. foltz 2015/08/04 23:47:02 .. of the route created or joined.
imcheng 2015/08/05 21:38:35 Done.
+// |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

Powered by Google App Engine
This is Rietveld 408576698