OLD | NEW |
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 "base/callback_list.h" |
12 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
13 #include "chrome/browser/media/router/issue.h" | 14 #include "chrome/browser/media/router/issue.h" |
14 #include "chrome/browser/media/router/media_route.h" | 15 #include "chrome/browser/media/router/media_route.h" |
15 #include "chrome/browser/media/router/media_sink.h" | 16 #include "chrome/browser/media/router/media_sink.h" |
16 #include "chrome/browser/media/router/media_source.h" | 17 #include "chrome/browser/media/router/media_source.h" |
17 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
| 19 #include "content/public/browser/presentation_service_delegate.h" |
18 #include "content/public/browser/presentation_session_message.h" | 20 #include "content/public/browser/presentation_session_message.h" |
19 | 21 |
20 namespace content { | 22 namespace content { |
21 class WebContents; | 23 class WebContents; |
22 } | 24 } |
23 | 25 |
24 namespace media_router { | 26 namespace media_router { |
25 | 27 |
26 class IssuesObserver; | 28 class IssuesObserver; |
27 class LocalMediaRoutesObserver; | 29 class LocalMediaRoutesObserver; |
(...skipping 13 matching lines...) Expand all Loading... |
41 // |error|: Empty string. | 43 // |error|: Empty string. |
42 // On failure: | 44 // On failure: |
43 // |route|: nullptr | 45 // |route|: nullptr |
44 // |presentation_id|: Empty string. | 46 // |presentation_id|: Empty string. |
45 // |error|: Non-empty string describing the error. | 47 // |error|: Non-empty string describing the error. |
46 using MediaRouteResponseCallback = | 48 using MediaRouteResponseCallback = |
47 base::Callback<void(const MediaRoute* route, | 49 base::Callback<void(const MediaRoute* route, |
48 const std::string& presentation_id, | 50 const std::string& presentation_id, |
49 const std::string& error)>; | 51 const std::string& error)>; |
50 | 52 |
| 53 // Subscription object returned by calling |
| 54 // |AddPresentationConnectionStateChangedCallback|. See the method comments for |
| 55 // details. |
| 56 using PresentationConnectionStateSubscription = base::CallbackList<void( |
| 57 content::PresentationConnectionState)>::Subscription; |
| 58 |
51 // An interface for handling resources related to media routing. | 59 // An interface for handling resources related to media routing. |
52 // Responsible for registering observers for receiving sink availability | 60 // Responsible for registering observers for receiving sink availability |
53 // updates, handling route requests/responses, and operating on routes (e.g. | 61 // updates, handling route requests/responses, and operating on routes (e.g. |
54 // posting messages or closing). | 62 // posting messages or closing). |
55 class MediaRouter : public KeyedService { | 63 class MediaRouter : public KeyedService { |
56 public: | 64 public: |
57 using PresentationSessionMessageCallback = base::Callback<void( | 65 using PresentationSessionMessageCallback = base::Callback<void( |
58 scoped_ptr<ScopedVector<content::PresentationSessionMessage>>)>; | 66 scoped_ptr<ScopedVector<content::PresentationSessionMessage>>)>; |
59 using SendRouteMessageCallback = base::Callback<void(bool sent)>; | 67 using SendRouteMessageCallback = base::Callback<void(bool sent)>; |
60 | 68 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 123 |
116 // Indicates that a presentation session has detached from the underlying | 124 // Indicates that a presentation session has detached from the underlying |
117 // MediaRoute |route_id| (due to navigation, garbage collection, etc.) | 125 // MediaRoute |route_id| (due to navigation, garbage collection, etc.) |
118 virtual void OnPresentationSessionDetached( | 126 virtual void OnPresentationSessionDetached( |
119 const MediaRoute::Id& route_id) = 0; | 127 const MediaRoute::Id& route_id) = 0; |
120 | 128 |
121 // Returns whether or not there is currently an active local displayable | 129 // Returns whether or not there is currently an active local displayable |
122 // route. | 130 // route. |
123 virtual bool HasLocalDisplayRoute() const = 0; | 131 virtual bool HasLocalDisplayRoute() const = 0; |
124 | 132 |
| 133 // Adds |callback| to listen for state changes for presentation connected to |
| 134 // |route_id|. The returned Subscription object is owned by the caller. |
| 135 // |callback| will be invoked whenever there are state changes, until the |
| 136 // caller destroys the Subscription object. |
| 137 virtual scoped_ptr<PresentationConnectionStateSubscription> |
| 138 AddPresentationConnectionStateChangedCallback( |
| 139 const MediaRoute::Id& route_id, |
| 140 const content::PresentationConnectionStateChangedCallback& callback) = 0; |
| 141 |
125 private: | 142 private: |
126 friend class IssuesObserver; | 143 friend class IssuesObserver; |
127 friend class LocalMediaRoutesObserver; | 144 friend class LocalMediaRoutesObserver; |
128 friend class MediaSinksObserver; | 145 friend class MediaSinksObserver; |
129 friend class MediaRoutesObserver; | 146 friend class MediaRoutesObserver; |
130 friend class PresentationConnectionStateObserver; | 147 friend class PresentationConnectionStateObserver; |
131 friend class PresentationSessionMessagesObserver; | 148 friend class PresentationSessionMessagesObserver; |
132 | 149 |
133 // The following functions are called by friend Observer classes above. | 150 // The following functions are called by friend Observer classes above. |
134 | 151 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 PresentationSessionMessagesObserver* observer) = 0; | 202 PresentationSessionMessagesObserver* observer) = 0; |
186 | 203 |
187 // Adds the LocalMediaRoutesObserver |observer| to listen for newly created | 204 // Adds the LocalMediaRoutesObserver |observer| to listen for newly created |
188 // MediaRoutes. | 205 // MediaRoutes. |
189 virtual void RegisterLocalMediaRoutesObserver( | 206 virtual void RegisterLocalMediaRoutesObserver( |
190 LocalMediaRoutesObserver* observer) = 0; | 207 LocalMediaRoutesObserver* observer) = 0; |
191 | 208 |
192 // Removes the LocalMediaRoutesObserver |observer|. | 209 // Removes the LocalMediaRoutesObserver |observer|. |
193 virtual void UnregisterLocalMediaRoutesObserver( | 210 virtual void UnregisterLocalMediaRoutesObserver( |
194 LocalMediaRoutesObserver* observer) = 0; | 211 LocalMediaRoutesObserver* observer) = 0; |
195 | |
196 // Registers/unregisters a PresentationConnectionStateObserver to receive | |
197 // updates on state changes for a PresentationConnection. MediaRouter does | |
198 // not own |observer|. When |observer| is about to be destroyed, it must be | |
199 // unregistered from MediaRouter. | |
200 virtual void RegisterPresentationConnectionStateObserver( | |
201 PresentationConnectionStateObserver* observer) = 0; | |
202 virtual void UnregisterPresentationConnectionStateObserver( | |
203 PresentationConnectionStateObserver* observer) = 0; | |
204 }; | 212 }; |
205 | 213 |
206 } // namespace media_router | 214 } // namespace media_router |
207 | 215 |
208 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ | 216 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ |
OLD | NEW |