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

Side by Side Diff: chrome/browser/media/router/media_router.h

Issue 1173753003: [Media Router] Implement JoinRoute + update CreateRoute API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 11 matching lines...) Expand all
22 22
23 // Type of callback used in |CreateRoute()|. Callback is invoked when the 23 // Type of callback used in |CreateRoute()|. Callback is invoked when the
24 // route request either succeeded or failed. 24 // route request either succeeded or failed.
25 // The first argument is the route created. If the route request failed, this 25 // The first argument is the route created. If the route request failed, this
26 // will be a nullptr. 26 // will be a nullptr.
27 // The second argument is the error string, which will be nonempty if the route 27 // The second argument is the error string, which will be nonempty if the route
28 // request failed. 28 // request failed.
29 using MediaRouteResponseCallback = 29 using MediaRouteResponseCallback =
30 base::Callback<void(scoped_ptr<MediaRoute>, const std::string&)>; 30 base::Callback<void(scoped_ptr<MediaRoute>, const std::string&)>;
31 31
32 // Used in cases where a tab ID is not applicable in CreateRoute/JoinRoute.
33 const int kInvalidTabId = -1;
34
32 // An interface for handling resources related to media routing. 35 // An interface for handling resources related to media routing.
33 // Responsible for registering observers for receiving sink availability 36 // Responsible for registering observers for receiving sink availability
34 // updates, handling route requests/responses, and operating on routes (e.g. 37 // updates, handling route requests/responses, and operating on routes (e.g.
35 // posting messages or closing). 38 // posting messages or closing).
36 class MediaRouter { 39 class MediaRouter {
37 public: 40 public:
38 virtual ~MediaRouter() {} 41 virtual ~MediaRouter() {}
39 42
40 // Creates a media route from |source_id| to |sink_id|. 43 // Creates a media route from |source_id| to |sink_id|.
44 // |origin| and |tab_id| are used for enforcing same-origin and/or same-tab
45 // scope, and are optional.
mark a. foltz 2015/06/10 23:18:51 Since this API is for creating a new route, it's a
imcheng (use chromium acct) 2015/06/11 22:49:12 Ok, I added some comments on the values of |origin
46 // The caller may pass in empty GURL for |origin| and/or |kInvalidTabId| for
47 // |tab_id| if not enforcing same-origin and/or same-tab scope.
mark a. foltz 2015/06/10 23:18:51 The caller doesn't know if the provider is going t
imcheng (use chromium acct) 2015/06/11 22:49:12 Good point. We can make them mandatory. I left the
41 // |callback| is invoked with a response indicating success or failure. 48 // |callback| is invoked with a response indicating success or failure.
42 virtual void CreateRoute(const MediaSource::Id& source_id, 49 virtual void CreateRoute(const MediaSource::Id& source_id,
43 const MediaSink::Id& sink_id, 50 const MediaSink::Id& sink_id,
51 const GURL& origin,
52 int tab_id,
44 const MediaRouteResponseCallback& callback) = 0; 53 const MediaRouteResponseCallback& callback) = 0;
45 54
55 // Joins an existing route identified by |presentation_id|.
56 // |source|: The source to route to the existing route.
57 // |presentation_id|: Presentation ID of the existing route.
58 // |origin|, |tab_id|: Origin and tab of the join route request. Used for
59 // validation when enforcing same-origin and/or same-tab scope, and
60 // are optional. (See CreateRoute documentation).
mark a. foltz 2015/06/10 23:18:51 Similar comment about mandatory vs optional for or
imcheng (use chromium acct) 2015/06/11 22:49:12 Done.
61 // |callback| is invoked with a response indicating success or failure.
62 virtual void JoinRoute(const MediaSource::Id& source,
63 const std::string& presentation_id,
64 const GURL& origin,
65 int tab_id,
66 const MediaRouteResponseCallback& callback) = 0;
67
46 // Closes the media route specified by |route_id|. 68 // Closes the media route specified by |route_id|.
47 virtual void CloseRoute(const MediaRoute::Id& route_id) = 0; 69 virtual void CloseRoute(const MediaRoute::Id& route_id) = 0;
48 70
49 // Posts |message| to a MediaSink connected via MediaRoute with |route_id|. 71 // Posts |message| to a MediaSink connected via MediaRoute with |route_id|.
50 // TODO(imcheng): Support additional data types: Blob, ArrayBuffer, 72 // TODO(imcheng): Support additional data types: Blob, ArrayBuffer,
51 // ArrayBufferView. 73 // ArrayBufferView.
52 virtual void PostMessage(const MediaRoute::Id& route_id, 74 virtual void PostMessage(const MediaRoute::Id& route_id,
53 const std::string& message) = 0; 75 const std::string& message) = 0;
54 76
55 // Clears the issue with the id |issue_id|. 77 // Clears the issue with the id |issue_id|.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // in undefined behavior. 128 // in undefined behavior.
107 virtual void AddIssuesObserver(IssuesObserver* observer) = 0; 129 virtual void AddIssuesObserver(IssuesObserver* observer) = 0;
108 130
109 // Removes the IssuesObserver |observer|. 131 // Removes the IssuesObserver |observer|.
110 virtual void RemoveIssuesObserver(IssuesObserver* observer) = 0; 132 virtual void RemoveIssuesObserver(IssuesObserver* observer) = 0;
111 }; 133 };
112 134
113 } // namespace media_router 135 } // namespace media_router
114 136
115 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ 137 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698