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

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

Issue 1055403006: Upstreaming review for Media Router Mojo interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate latest changes to MR API. Created 5 years, 7 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
« no previous file with comments | « chrome/browser/media/router/BUILD.gn ('k') | chrome/browser/media/router/media_router.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "chrome/browser/media/router/issue.h"
12 #include "chrome/browser/media/router/media_route.h" 13 #include "chrome/browser/media/router/media_route.h"
13 #include "chrome/browser/media/router/media_route_id.h" 14 #include "chrome/browser/media/router/media_route_id.h"
14 #include "chrome/browser/media/router/media_sink.h" 15 #include "chrome/browser/media/router/media_sink.h"
15 #include "chrome/browser/media/router/media_source.h" 16 #include "chrome/browser/media/router/media_source.h"
16 17
17 namespace media_router { 18 namespace media_router {
18 19
20 class IssuesObserver;
19 class MediaRoutesObserver; 21 class MediaRoutesObserver;
20 class MediaSinksObserver; 22 class MediaSinksObserver;
21 23
22 // Type of callback used in |RequestRoute()|. Callback is invoked when the 24 // Type of callback used in |CreateRoute()|. Callback is invoked when the
23 // route request either succeeded or failed. 25 // route request either succeeded or failed.
24 // The first argument is the route created. If the route request failed, this 26 // The first argument is the route created. If the route request failed, this
25 // will be a nullptr. 27 // will be a nullptr.
26 // The second argument is the error string, which will be nonempty if the route 28 // The second argument is the error string, which will be nonempty if the route
27 // request failed. 29 // request failed.
28 using MediaRouteResponseCallback = 30 using MediaRouteResponseCallback =
29 base::Callback<void(scoped_ptr<MediaRoute>, const std::string&)>; 31 base::Callback<void(scoped_ptr<MediaRoute>, const std::string&)>;
30 32
31 // An interface for handling resources related to media routing. 33 // An interface for handling resources related to media routing.
32 // Responsible for registering observers for receiving sink availability 34 // Responsible for registering observers for receiving sink availability
33 // updates, handling route requests/responses, and operating on routes (e.g. 35 // updates, handling route requests/responses, and operating on routes (e.g.
34 // posting messages or closing). 36 // posting messages or closing).
35 class MediaRouter { 37 class MediaRouter {
36 public: 38 public:
37 virtual ~MediaRouter() {} 39 virtual ~MediaRouter() {}
38 40
39 // Requests a media route from |source| to |sink_id|. 41 // Requests a media route from |source| to |sink_id|.
40 // |callback| is invoked with a response indicating success or failure. 42 // |callback| is invoked with a response indicating success or failure.
41 virtual void RequestRoute(const MediaSourceId& source, 43 virtual void CreateRoute(const MediaSourceId& source,
42 const MediaSinkId& sink_id, 44 const MediaSinkId& sink_id,
43 const MediaRouteResponseCallback& callback) = 0; 45 const MediaRouteResponseCallback& callback) = 0;
44 46
45 // Closes the media route specified by |route_id|. 47 // Closes the media route specified by |route_id|.
46 virtual void CloseRoute(const MediaRouteId& route_id) = 0; 48 virtual void CloseRoute(const MediaRouteId& route_id) = 0;
47 49
48 // Posts |message| to a MediaSink connected via MediaRoute with |route_id|. 50 // Posts |message| to a MediaSink connected via MediaRoute with |route_id|.
49 // TODO(imcheng): Support additional data types: Blob, ArrayBuffer, 51 // TODO(imcheng): Support additional data types: Blob, ArrayBuffer,
50 // ArrayBufferView. 52 // ArrayBufferView.
51 virtual void PostMessage(const MediaRouteId& route_id, 53 virtual void PostMessage(const MediaRouteId& route_id,
52 const std::string& message) = 0; 54 const std::string& message) = 0;
53 55
56 // Clears the issue with id |issue_id|.
57 virtual void ClearIssue(const Issue::IssueId& issue_id) = 0;
58
54 // Receives updates from a MediaRouter instance. 59 // Receives updates from a MediaRouter instance.
55 class Delegate { 60 class Delegate {
56 public: 61 public:
57 // Called when there is a message from a route. 62 // Called when there is a message from a route.
58 // |route_id|: The route ID. 63 // |route_id|: The route ID.
59 // |message|: The message. 64 // |message|: The message.
60 virtual void OnMessage(const MediaRouteId& route_id, 65 virtual void OnMessage(const MediaRouteId& route_id,
61 const std::string& message) = 0; 66 const std::string& message) = 0;
67
68 // Called when there is an issue.
69 // |issue|: The issue.
70 virtual void OnIssue(const Issue& issue) = 0;
62 }; 71 };
63 72
64 protected: 73 // Adds the IssuesObserver |observer|.
74 virtual void AddIssuesObserver(IssuesObserver* observer) = 0;
75
76 // Removes the IssuesObserver |observer|.
77 virtual void RemoveIssuesObserver(IssuesObserver* observer) = 0;
78
79 private:
80 friend class IssuesObserver;
65 friend class MediaSinksObserver; 81 friend class MediaSinksObserver;
66 friend class MediaRoutesObserver; 82 friend class MediaRoutesObserver;
83 friend class MediaRouterImpl;
67 84
68 // The following APIs are called by MediaSinksObserver/MediaRoutesObserver 85 // The following APIs are called by the friend observer classes
69 // and implementations of MediaRouter only. 86 // and implementations of MediaRouter only.
70 87
71 // Registers |observer| with this MediaRouter. |observer| specifies a media 88 // Registers |observer| with this MediaRouter. |observer| specifies a media
72 // source and will receive updates with media sinks that are compatible with 89 // source and will receive updates with media sinks that are compatible with
73 // that source. The initial update may happen synchronously. 90 // that source. The initial update may happen synchronously.
74 // NOTE: This class does not assume ownership of |observer|. Callers must 91 // NOTE: This class does not assume ownership of |observer|. Callers must
75 // manage |observer| and make sure |UnregisterObserver()| is called 92 // manage |observer| and make sure |UnregisterObserver()| is called
76 // before the observer is destroyed. 93 // before the observer is destroyed.
77 // Returns true if registration succeeded. 94 // Returns true if registration succeeded.
78 // It is invalid to request the same observer more than once and will result 95 // It is invalid to request the same observer more than once and will result
(...skipping 13 matching lines...) Expand all
92 virtual bool RegisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0; 109 virtual bool RegisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0;
93 110
94 // Removes a previously added MediaRoutesObserver. |observer| will stop 111 // Removes a previously added MediaRoutesObserver. |observer| will stop
95 // receiving further updates. 112 // receiving further updates.
96 virtual void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0; 113 virtual void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0;
97 }; 114 };
98 115
99 } // namespace media_router 116 } // namespace media_router
100 117
101 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ 118 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/router/BUILD.gn ('k') | chrome/browser/media/router/media_router.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698