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

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

Issue 1143603004: [Media Router] Add Media Router Mojo impl code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Xiaohan's comments 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
« 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 // Creates a media route from |source_id| 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_id,
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 the 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;
62 }; 67 };
63 68
64 protected: 69 private:
70 friend class IssuesObserver;
65 friend class MediaSinksObserver; 71 friend class MediaSinksObserver;
66 friend class MediaRoutesObserver; 72 friend class MediaRoutesObserver;
67 73
68 // The following APIs are called by MediaSinksObserver/MediaRoutesObserver 74 // The following functions are called by IssuesObserver, MediaSinksObserver,
69 // and implementations of MediaRouter only. 75 // and MediaRoutesObserver.
70 76
71 // Registers |observer| with this MediaRouter. |observer| specifies a media 77 // Registers |observer| with this MediaRouter. |observer| specifies a media
72 // source and will receive updates with media sinks that are compatible with 78 // source and will receive updates with media sinks that are compatible with
73 // that source. The initial update may happen synchronously. 79 // that source. The initial update may happen synchronously.
74 // NOTE: This class does not assume ownership of |observer|. Callers must 80 // NOTE: This class does not assume ownership of |observer|. Callers must
75 // manage |observer| and make sure |UnregisterObserver()| is called 81 // manage |observer| and make sure |UnregisterObserver()| is called
76 // before the observer is destroyed. 82 // before the observer is destroyed.
77 // Returns true if registration succeeded. 83 // It is invalid to register the same observer more than once and will result
78 // It is invalid to request the same observer more than once and will result
79 // in undefined behavior. 84 // in undefined behavior.
80 // If the MRPM Host is not available, the registration request will fail 85 // If the MRPM Host is not available, the registration request will fail
81 // immediately. 86 // immediately.
82 virtual bool RegisterMediaSinksObserver(MediaSinksObserver* observer) = 0; 87 virtual void RegisterMediaSinksObserver(MediaSinksObserver* observer) = 0;
83 88
84 // Removes a previously added MediaSinksObserver. |observer| will stop 89 // Removes a previously added MediaSinksObserver. |observer| will stop
85 // receiving further updates. 90 // receiving further updates.
86 virtual void UnregisterMediaSinksObserver(MediaSinksObserver* observer) = 0; 91 virtual void UnregisterMediaSinksObserver(MediaSinksObserver* observer) = 0;
87 92
88 // Adds a MediaRoutesObserver to listen for updates on MediaRoutes. 93 // Adds a MediaRoutesObserver to listen for updates on MediaRoutes.
89 // The initial update may happen synchronously. 94 // The initial update may happen synchronously.
90 // MediaRouter does not own |observer|. |RemoveMediaRoutesObserver| should 95 // MediaRouter does not own |observer|. |RemoveMediaRoutesObserver| should
91 // be called before |observer| is destroyed. 96 // be called before |observer| is destroyed.
92 virtual bool RegisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0; 97 // It is invalid to register the same observer more than once and will result
98 // in undefined behavior.
99 virtual void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0;
93 100
94 // Removes a previously added MediaRoutesObserver. |observer| will stop 101 // Removes a previously added MediaRoutesObserver. |observer| will stop
95 // receiving further updates. 102 // receiving further updates.
96 virtual void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0; 103 virtual void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0;
104
105 // Adds the IssuesObserver |observer|.
106 // It is invalid to register the same observer more than once and will result
107 // in undefined behavior.
108 virtual void AddIssuesObserver(IssuesObserver* observer) = 0;
109
110 // Removes the IssuesObserver |observer|.
111 virtual void RemoveIssuesObserver(IssuesObserver* observer) = 0;
97 }; 112 };
98 113
99 } // namespace media_router 114 } // namespace media_router
100 115
101 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ 116 #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