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 <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/issue.h" |
| 13 #include "chrome/browser/media/router/media_route.h" | 13 #include "chrome/browser/media/router/media_route.h" |
| 14 #include "chrome/browser/media/router/media_sink.h" | 14 #include "chrome/browser/media/router/media_sink.h" |
| 15 #include "chrome/browser/media/router/media_source.h" | 15 #include "chrome/browser/media/router/media_source.h" |
| 16 #include "components/keyed_service/core/keyed_service.h" | |
| 16 #include "content/public/browser/presentation_session_message.h" | 17 #include "content/public/browser/presentation_session_message.h" |
| 17 | 18 |
| 18 namespace media_router { | 19 namespace media_router { |
| 19 | 20 |
| 20 class IssuesObserver; | 21 class IssuesObserver; |
| 21 class MediaRoutesObserver; | 22 class MediaRoutesObserver; |
| 22 class MediaSinksObserver; | 23 class MediaSinksObserver; |
| 23 | 24 |
| 24 // Type of callback used in |CreateRoute()|. Callback is invoked when the | 25 // Type of callback used in |CreateRoute()|. Callback is invoked when the |
| 25 // route request either succeeded or failed. | 26 // route request either succeeded or failed. |
| 26 // The first argument is the route created. If the route request failed, this | 27 // The first argument is the route created. If the route request failed, this |
| 27 // will be a nullptr. | 28 // will be a nullptr. |
| 28 // The second argument is the error string, which will be nonempty if the route | 29 // The second argument is the error string, which will be nonempty if the route |
| 29 // request failed. | 30 // request failed. |
| 30 using MediaRouteResponseCallback = | 31 using MediaRouteResponseCallback = |
| 31 base::Callback<void(scoped_ptr<MediaRoute>, const std::string&)>; | 32 base::Callback<void(scoped_ptr<MediaRoute>, const std::string&)>; |
| 32 | 33 |
| 33 // Used in cases where a tab ID is not applicable in CreateRoute/JoinRoute. | 34 // Used in cases where a tab ID is not applicable in CreateRoute/JoinRoute. |
| 34 const int kInvalidTabId = -1; | 35 const int kInvalidTabId = -1; |
| 35 | 36 |
| 36 // An interface for handling resources related to media routing. | 37 // An interface for handling resources related to media routing. |
| 37 // Responsible for registering observers for receiving sink availability | 38 // Responsible for registering observers for receiving sink availability |
| 38 // updates, handling route requests/responses, and operating on routes (e.g. | 39 // updates, handling route requests/responses, and operating on routes (e.g. |
| 39 // posting messages or closing). | 40 // posting messages or closing). Is a KeyedService. |
|
imcheng
2015/07/16 18:28:19
This comment is redundant as the reader can easily
whywhat
2015/07/16 20:17:18
Done.
| |
| 40 class MediaRouter { | 41 class MediaRouter : public KeyedService { |
| 41 public: | 42 public: |
| 42 using PresentationSessionMessageCallback = base::Callback<void( | 43 using PresentationSessionMessageCallback = base::Callback<void( |
| 43 scoped_ptr<ScopedVector<content::PresentationSessionMessage>>)>; | 44 scoped_ptr<ScopedVector<content::PresentationSessionMessage>>)>; |
| 44 using SendRouteMessageCallback = base::Callback<void(bool sent)>; | 45 using SendRouteMessageCallback = base::Callback<void(bool sent)>; |
| 45 | 46 |
| 46 virtual ~MediaRouter() {} | 47 ~MediaRouter() override = default; |
| 47 | 48 |
| 48 // Creates a media route from |source_id| to |sink_id|. | 49 // Creates a media route from |source_id| to |sink_id|. |
| 49 // |origin| is the URL of requestor's page. | 50 // |origin| is the URL of requestor's page. |
| 50 // |tab_id| is the ID of the tab in which the request was made. | 51 // |tab_id| is the ID of the tab in which the request was made. |
| 51 // |origin| and |tab_id| are used for enforcing same-origin and/or same-tab | 52 // |origin| and |tab_id| are used for enforcing same-origin and/or same-tab |
| 52 // scope for JoinRoute() requests. (e.g., if enforced, the page | 53 // scope for JoinRoute() requests. (e.g., if enforced, the page |
| 53 // requesting JoinRoute() must have the same origin as the page that requested | 54 // requesting JoinRoute() must have the same origin as the page that requested |
| 54 // CreateRoute()). | 55 // CreateRoute()). |
| 55 // The caller may pass in|kInvalidTabId| if tab is not applicable. | 56 // The caller may pass in|kInvalidTabId| if tab is not applicable. |
| 56 // |callback| is invoked with a response indicating success or failure. | 57 // |callback| is invoked with a response indicating success or failure. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 // in undefined behavior. | 136 // in undefined behavior. |
| 136 virtual void RegisterIssuesObserver(IssuesObserver* observer) = 0; | 137 virtual void RegisterIssuesObserver(IssuesObserver* observer) = 0; |
| 137 | 138 |
| 138 // Removes the IssuesObserver |observer|. | 139 // Removes the IssuesObserver |observer|. |
| 139 virtual void UnregisterIssuesObserver(IssuesObserver* observer) = 0; | 140 virtual void UnregisterIssuesObserver(IssuesObserver* observer) = 0; |
| 140 }; | 141 }; |
| 141 | 142 |
| 142 } // namespace media_router | 143 } // namespace media_router |
| 143 | 144 |
| 144 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ | 145 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_ |
| OLD | NEW |