Chromium Code Reviews| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/callback_list.h" | 14 #include "base/callback_list.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "chrome/browser/media/router/issue.h" | 17 #include "chrome/browser/media/router/issue.h" |
| 18 #include "chrome/browser/media/router/media_route.h" | 18 #include "chrome/browser/media/router/media_route.h" |
| 19 #include "chrome/browser/media/router/media_sink.h" | 19 #include "chrome/browser/media/router/media_sink.h" |
| 20 #include "chrome/browser/media/router/media_sink_internal.h" | |
| 20 #include "chrome/browser/media/router/media_source.h" | 21 #include "chrome/browser/media/router/media_source.h" |
| 21 #include "chrome/browser/media/router/route_message_observer.h" | 22 #include "chrome/browser/media/router/route_message_observer.h" |
| 22 #include "components/keyed_service/core/keyed_service.h" | 23 #include "components/keyed_service/core/keyed_service.h" |
| 23 #include "content/public/browser/presentation_service_delegate.h" | 24 #include "content/public/browser/presentation_service_delegate.h" |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 class WebContents; | 27 class WebContents; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace url { | 30 namespace url { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 56 const content::PresentationConnectionStateChangeInfo&)>::Subscription; | 57 const content::PresentationConnectionStateChangeInfo&)>::Subscription; |
| 57 | 58 |
| 58 // An interface for handling resources related to media routing. | 59 // An interface for handling resources related to media routing. |
| 59 // Responsible for registering observers for receiving sink availability | 60 // Responsible for registering observers for receiving sink availability |
| 60 // updates, handling route requests/responses, and operating on routes (e.g. | 61 // updates, handling route requests/responses, and operating on routes (e.g. |
| 61 // posting messages or closing). | 62 // posting messages or closing). |
| 62 // TODO(imcheng): Reduce number of parameters by putting them into structs. | 63 // TODO(imcheng): Reduce number of parameters by putting them into structs. |
| 63 class MediaRouter : public KeyedService { | 64 class MediaRouter : public KeyedService { |
| 64 public: | 65 public: |
| 65 using SendRouteMessageCallback = base::Callback<void(bool sent)>; | 66 using SendRouteMessageCallback = base::Callback<void(bool sent)>; |
| 67 using MediaSinkList = std::vector<MediaSinkInternal>; | |
|
mark a. foltz
2017/03/01 06:31:43
Nit: For consistency with other APIs, use std::vec
zhaobin
2017/03/02 20:24:04
Done.
| |
| 66 | 68 |
| 67 ~MediaRouter() override = default; | 69 ~MediaRouter() override = default; |
| 68 | 70 |
| 69 // Creates a media route from |source_id| to |sink_id|. | 71 // Creates a media route from |source_id| to |sink_id|. |
| 70 // |origin| is the origin of requestor's page. | 72 // |origin| is the origin of requestor's page. |
| 71 // |web_contents| is the WebContents of the tab in which the request was made. | 73 // |web_contents| is the WebContents of the tab in which the request was made. |
| 72 // |origin| and |web_contents| are used for enforcing same-origin and/or | 74 // |origin| and |web_contents| are used for enforcing same-origin and/or |
| 73 // same-tab scope for JoinRoute() requests. (e.g., if enforced, the page | 75 // same-tab scope for JoinRoute() requests. (e.g., if enforced, the page |
| 74 // requesting JoinRoute() must have the same origin as the page that requested | 76 // requesting JoinRoute() must have the same origin as the page that requested |
| 75 // CreateRoute()). | 77 // CreateRoute()). |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 // the user has no domain or is not signed in. |sink_callback| will be called | 167 // the user has no domain or is not signed in. |sink_callback| will be called |
| 166 // either with the ID of the new sink when it is found or with an empty string | 168 // either with the ID of the new sink when it is found or with an empty string |
| 167 // if no sink was found. | 169 // if no sink was found. |
| 168 virtual void SearchSinks( | 170 virtual void SearchSinks( |
| 169 const MediaSink::Id& sink_id, | 171 const MediaSink::Id& sink_id, |
| 170 const MediaSource::Id& source_id, | 172 const MediaSource::Id& source_id, |
| 171 const std::string& search_input, | 173 const std::string& search_input, |
| 172 const std::string& domain, | 174 const std::string& domain, |
| 173 const MediaSinkSearchResponseCallback& sink_callback) = 0; | 175 const MediaSinkSearchResponseCallback& sink_callback) = 0; |
| 174 | 176 |
| 177 // Called when DIAL or CAST MediaSinkService finishes sink discovery. | |
|
imcheng
2017/03/01 23:28:36
How about:
Notifies the Media Router that the lis
zhaobin
2017/03/02 20:24:04
Done.
| |
| 178 // |sinks|: sinks discovered by MediaSinkService. | |
| 179 virtual void ProvideSinks(const std::string& provider_name, | |
| 180 const MediaSinkList& sinks) = 0; | |
| 181 | |
| 175 // Adds |callback| to listen for state changes for presentation connected to | 182 // Adds |callback| to listen for state changes for presentation connected to |
| 176 // |route_id|. The returned Subscription object is owned by the caller. | 183 // |route_id|. The returned Subscription object is owned by the caller. |
| 177 // |callback| will be invoked whenever there are state changes, until the | 184 // |callback| will be invoked whenever there are state changes, until the |
| 178 // caller destroys the Subscription object. | 185 // caller destroys the Subscription object. |
| 179 virtual std::unique_ptr<PresentationConnectionStateSubscription> | 186 virtual std::unique_ptr<PresentationConnectionStateSubscription> |
| 180 AddPresentationConnectionStateChangedCallback( | 187 AddPresentationConnectionStateChangedCallback( |
| 181 const MediaRoute::Id& route_id, | 188 const MediaRoute::Id& route_id, |
| 182 const content::PresentationConnectionStateChangedCallback& callback) = 0; | 189 const content::PresentationConnectionStateChangedCallback& callback) = 0; |
| 183 | 190 |
| 184 // Called when the incognito profile for this instance is being shut down. | 191 // Called when the incognito profile for this instance is being shut down. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 | 252 |
| 246 // Unregisters a previously registered RouteMessagesObserver. |observer| will | 253 // Unregisters a previously registered RouteMessagesObserver. |observer| will |
| 247 // stop receiving further updates. | 254 // stop receiving further updates. |
| 248 virtual void UnregisterRouteMessageObserver( | 255 virtual void UnregisterRouteMessageObserver( |
| 249 RouteMessageObserver* observer) = 0; | 256 RouteMessageObserver* observer) = 0; |
| 250 }; | 257 }; |
| 251 | 258 |
| 252 } // namespace media_router | 259 } // namespace media_router |
| 253 | 260 |
| 254 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ | 261 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ |
| OLD | NEW |