| 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_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 // MediaRouter implementation. | 68 // MediaRouter implementation. |
| 69 // Execution of the requests is delegated to the Do* methods, which can be | 69 // Execution of the requests is delegated to the Do* methods, which can be |
| 70 // enqueued for later use if the extension is temporarily suspended. | 70 // enqueued for later use if the extension is temporarily suspended. |
| 71 void CreateRoute(const MediaSource::Id& source_id, | 71 void CreateRoute(const MediaSource::Id& source_id, |
| 72 const MediaSink::Id& sink_id, | 72 const MediaSink::Id& sink_id, |
| 73 const GURL& origin, | 73 const GURL& origin, |
| 74 content::WebContents* web_contents, | 74 content::WebContents* web_contents, |
| 75 const std::vector<MediaRouteResponseCallback>& callbacks, | 75 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 76 base::TimeDelta timeout, | 76 base::TimeDelta timeout, |
| 77 bool off_the_record) override; | 77 bool incognito) override; |
| 78 void JoinRoute(const MediaSource::Id& source_id, | 78 void JoinRoute(const MediaSource::Id& source_id, |
| 79 const std::string& presentation_id, | 79 const std::string& presentation_id, |
| 80 const GURL& origin, | 80 const GURL& origin, |
| 81 content::WebContents* web_contents, | 81 content::WebContents* web_contents, |
| 82 const std::vector<MediaRouteResponseCallback>& callbacks, | 82 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 83 base::TimeDelta timeout, | 83 base::TimeDelta timeout, |
| 84 bool off_the_record) override; | 84 bool incognito) override; |
| 85 void ConnectRouteByRouteId( | 85 void ConnectRouteByRouteId( |
| 86 const MediaSource::Id& source, | 86 const MediaSource::Id& source, |
| 87 const MediaRoute::Id& route_id, | 87 const MediaRoute::Id& route_id, |
| 88 const GURL& origin, | 88 const GURL& origin, |
| 89 content::WebContents* web_contents, | 89 content::WebContents* web_contents, |
| 90 const std::vector<MediaRouteResponseCallback>& callbacks, | 90 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 91 base::TimeDelta timeout, | 91 base::TimeDelta timeout, |
| 92 bool off_the_record) override; | 92 bool incognito) override; |
| 93 void TerminateRoute(const MediaRoute::Id& route_id) override; | 93 void TerminateRoute(const MediaRoute::Id& route_id) override; |
| 94 void DetachRoute(const MediaRoute::Id& route_id) override; | 94 void DetachRoute(const MediaRoute::Id& route_id) override; |
| 95 void SendRouteMessage(const MediaRoute::Id& route_id, | 95 void SendRouteMessage(const MediaRoute::Id& route_id, |
| 96 const std::string& message, | 96 const std::string& message, |
| 97 const SendRouteMessageCallback& callback) override; | 97 const SendRouteMessageCallback& callback) override; |
| 98 void SendRouteBinaryMessage( | 98 void SendRouteBinaryMessage( |
| 99 const MediaRoute::Id& route_id, | 99 const MediaRoute::Id& route_id, |
| 100 std::unique_ptr<std::vector<uint8_t>> data, | 100 std::unique_ptr<std::vector<uint8_t>> data, |
| 101 const SendRouteMessageCallback& callback) override; | 101 const SendRouteMessageCallback& callback) override; |
| 102 void AddIssue(const Issue& issue) override; | 102 void AddIssue(const Issue& issue) override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 117 instance_id_ = instance_id; | 117 instance_id_ = instance_id; |
| 118 } | 118 } |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 friend class MediaRouterFactory; | 121 friend class MediaRouterFactory; |
| 122 friend class MediaRouterMojoExtensionTest; | 122 friend class MediaRouterMojoExtensionTest; |
| 123 friend class MediaRouterMojoTest; | 123 friend class MediaRouterMojoTest; |
| 124 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, JoinRoute); | 124 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, JoinRoute); |
| 125 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, JoinRouteTimedOutFails); | 125 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, JoinRouteTimedOutFails); |
| 126 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 126 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 127 JoinRouteOffTheRecordMismatchFails); | 127 JoinRouteIncognitoMismatchFails); |
| 128 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 128 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 129 OffTheRecordRoutesTerminatedOnProfileShutdown); | 129 IncognitoRoutesTerminatedOnProfileShutdown); |
| 130 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 130 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 131 RegisterAndUnregisterMediaSinksObserver); | 131 RegisterAndUnregisterMediaSinksObserver); |
| 132 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 132 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 133 RegisterMediaSinksObserverWithAvailabilityChange); | 133 RegisterMediaSinksObserverWithAvailabilityChange); |
| 134 FRIEND_TEST_ALL_PREFIXES( | 134 FRIEND_TEST_ALL_PREFIXES( |
| 135 MediaRouterMojoImplTest, | 135 MediaRouterMojoImplTest, |
| 136 RegisterAndUnregisterMediaSinksObserverWithAvailabilityChange); | 136 RegisterAndUnregisterMediaSinksObserverWithAvailabilityChange); |
| 137 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 137 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 138 RegisterAndUnregisterMediaRoutesObserver); | 138 RegisterAndUnregisterMediaRoutesObserver); |
| 139 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 139 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 void UnregisterPresentationSessionMessagesObserver( | 234 void UnregisterPresentationSessionMessagesObserver( |
| 235 PresentationSessionMessagesObserver* observer) override; | 235 PresentationSessionMessagesObserver* observer) override; |
| 236 | 236 |
| 237 // These calls invoke methods in the component extension via Mojo. | 237 // These calls invoke methods in the component extension via Mojo. |
| 238 void DoCreateRoute(const MediaSource::Id& source_id, | 238 void DoCreateRoute(const MediaSource::Id& source_id, |
| 239 const MediaSink::Id& sink_id, | 239 const MediaSink::Id& sink_id, |
| 240 const std::string& origin, | 240 const std::string& origin, |
| 241 int tab_id, | 241 int tab_id, |
| 242 const std::vector<MediaRouteResponseCallback>& callbacks, | 242 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 243 base::TimeDelta timeout, | 243 base::TimeDelta timeout, |
| 244 bool off_the_record); | 244 bool incognito); |
| 245 void DoJoinRoute(const MediaSource::Id& source_id, | 245 void DoJoinRoute(const MediaSource::Id& source_id, |
| 246 const std::string& presentation_id, | 246 const std::string& presentation_id, |
| 247 const std::string& origin, | 247 const std::string& origin, |
| 248 int tab_id, | 248 int tab_id, |
| 249 const std::vector<MediaRouteResponseCallback>& callbacks, | 249 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 250 base::TimeDelta timeout, | 250 base::TimeDelta timeout, |
| 251 bool off_the_record); | 251 bool incognito); |
| 252 void DoConnectRouteByRouteId( | 252 void DoConnectRouteByRouteId( |
| 253 const MediaSource::Id& source_id, | 253 const MediaSource::Id& source_id, |
| 254 const MediaRoute::Id& route_id, | 254 const MediaRoute::Id& route_id, |
| 255 const std::string& origin, | 255 const std::string& origin, |
| 256 int tab_id, | 256 int tab_id, |
| 257 const std::vector<MediaRouteResponseCallback>& callbacks, | 257 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 258 base::TimeDelta timeout, | 258 base::TimeDelta timeout, |
| 259 bool off_the_record); | 259 bool incognito); |
| 260 void DoTerminateRoute(const MediaRoute::Id& route_id); | 260 void DoTerminateRoute(const MediaRoute::Id& route_id); |
| 261 void DoDetachRoute(const MediaRoute::Id& route_id); | 261 void DoDetachRoute(const MediaRoute::Id& route_id); |
| 262 void DoSendSessionMessage(const MediaRoute::Id& route_id, | 262 void DoSendSessionMessage(const MediaRoute::Id& route_id, |
| 263 const std::string& message, | 263 const std::string& message, |
| 264 const SendRouteMessageCallback& callback); | 264 const SendRouteMessageCallback& callback); |
| 265 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, | 265 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, |
| 266 std::unique_ptr<std::vector<uint8_t>> data, | 266 std::unique_ptr<std::vector<uint8_t>> data, |
| 267 const SendRouteMessageCallback& callback); | 267 const SendRouteMessageCallback& callback); |
| 268 void DoStartListeningForRouteMessages(const MediaRoute::Id& route_id); | 268 void DoStartListeningForRouteMessages(const MediaRoute::Id& route_id); |
| 269 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); | 269 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // Result callback when Mojo terminateRoute is invoked. |route_id| is bound | 309 // Result callback when Mojo terminateRoute is invoked. |route_id| is bound |
| 310 // to the ID of the route that was terminated. | 310 // to the ID of the route that was terminated. |
| 311 void OnTerminateRouteResult(const MediaRoute::Id& route_id, | 311 void OnTerminateRouteResult(const MediaRoute::Id& route_id, |
| 312 mojo::String error_text, | 312 mojo::String error_text, |
| 313 interfaces::RouteRequestResultCode result_code); | 313 interfaces::RouteRequestResultCode result_code); |
| 314 | 314 |
| 315 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() | 315 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() |
| 316 // into a local callback. | 316 // into a local callback. |
| 317 void RouteResponseReceived( | 317 void RouteResponseReceived( |
| 318 const std::string& presentation_id, | 318 const std::string& presentation_id, |
| 319 bool off_the_record, | 319 bool incognito, |
| 320 const std::vector<MediaRouteResponseCallback>& callbacks, | 320 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 321 interfaces::MediaRoutePtr media_route, | 321 interfaces::MediaRoutePtr media_route, |
| 322 mojo::String error_text, | 322 mojo::String error_text, |
| 323 interfaces::RouteRequestResultCode result_code); | 323 interfaces::RouteRequestResultCode result_code); |
| 324 | 324 |
| 325 // Callback invoked by |event_page_tracker_| after an attempt to wake the | 325 // Callback invoked by |event_page_tracker_| after an attempt to wake the |
| 326 // component extension. If |success| is false, the pending request queue is | 326 // component extension. If |success| is false, the pending request queue is |
| 327 // drained. | 327 // drained. |
| 328 void EventPageWakeComplete(bool success); | 328 void EventPageWakeComplete(bool success); |
| 329 | 329 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 #endif | 433 #endif |
| 434 | 434 |
| 435 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 435 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 436 | 436 |
| 437 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 437 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 438 }; | 438 }; |
| 439 | 439 |
| 440 } // namespace media_router | 440 } // namespace media_router |
| 441 | 441 |
| 442 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 442 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |