| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 OffTheRecordRoutesTerminatedOnProfileShutdown); | 128 OffTheRecordRoutesTerminatedOnProfileShutdown); |
| 129 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 129 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 130 RegisterAndUnregisterMediaSinksObserver); | 130 RegisterAndUnregisterMediaSinksObserver); |
| 131 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 131 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 132 RegisterMediaSinksObserverWithAvailabilityChange); | 132 RegisterMediaSinksObserverWithAvailabilityChange); |
| 133 FRIEND_TEST_ALL_PREFIXES( | 133 FRIEND_TEST_ALL_PREFIXES( |
| 134 MediaRouterMojoImplTest, | 134 MediaRouterMojoImplTest, |
| 135 RegisterAndUnregisterMediaSinksObserverWithAvailabilityChange); | 135 RegisterAndUnregisterMediaSinksObserverWithAvailabilityChange); |
| 136 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 136 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 137 RegisterAndUnregisterMediaRoutesObserver); | 137 RegisterAndUnregisterMediaRoutesObserver); |
| 138 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 139 PresentationSessionMessagesSingleObserver); |
| 140 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 141 PresentationSessionMessagesMultipleObservers); |
| 138 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, HandleIssue); | 142 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, HandleIssue); |
| 139 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 143 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 140 DeferredBindingAndSuspension); | 144 DeferredBindingAndSuspension); |
| 141 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 145 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 142 DrainPendingRequestQueue); | 146 DrainPendingRequestQueue); |
| 143 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 147 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 144 DropOldestPendingRequest); | 148 DropOldestPendingRequest); |
| 145 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 149 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 146 AttemptedWakeupTooManyTimes); | 150 AttemptedWakeupTooManyTimes); |
| 147 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 151 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 base::TimeDelta timeout, | 257 base::TimeDelta timeout, |
| 254 bool off_the_record); | 258 bool off_the_record); |
| 255 void DoTerminateRoute(const MediaRoute::Id& route_id); | 259 void DoTerminateRoute(const MediaRoute::Id& route_id); |
| 256 void DoDetachRoute(const MediaRoute::Id& route_id); | 260 void DoDetachRoute(const MediaRoute::Id& route_id); |
| 257 void DoSendSessionMessage(const MediaRoute::Id& route_id, | 261 void DoSendSessionMessage(const MediaRoute::Id& route_id, |
| 258 const std::string& message, | 262 const std::string& message, |
| 259 const SendRouteMessageCallback& callback); | 263 const SendRouteMessageCallback& callback); |
| 260 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, | 264 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, |
| 261 std::unique_ptr<std::vector<uint8_t>> data, | 265 std::unique_ptr<std::vector<uint8_t>> data, |
| 262 const SendRouteMessageCallback& callback); | 266 const SendRouteMessageCallback& callback); |
| 263 void DoListenForRouteMessages(const MediaRoute::Id& route_id); | 267 void DoStartListeningForRouteMessages(const MediaRoute::Id& route_id); |
| 264 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); | 268 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); |
| 265 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); | 269 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); |
| 266 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); | 270 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); |
| 267 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id); | 271 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id); |
| 268 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id); | 272 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id); |
| 269 void DoSearchSinks( | 273 void DoSearchSinks( |
| 270 const MediaSink::Id& sink_id, | 274 const MediaSink::Id& sink_id, |
| 271 const MediaSource::Id& source_id, | 275 const MediaSource::Id& source_id, |
| 272 const std::string& search_input, | 276 const std::string& search_input, |
| 273 const std::string& domain, | 277 const std::string& domain, |
| 274 const MediaSinkSearchResponseCallback& sink_callback); | 278 const MediaSinkSearchResponseCallback& sink_callback); |
| 275 | 279 |
| 276 // Invoked when the next batch of messages arrives. | |
| 277 // |route_id|: ID of route of the messages. | |
| 278 // |messages|: A list of messages received. | |
| 279 // |error|: true if an error occurred. | |
| 280 void OnRouteMessagesReceived( | |
| 281 const MediaRoute::Id& route_id, | |
| 282 mojo::Array<interfaces::RouteMessagePtr> messages, | |
| 283 bool error); | |
| 284 | |
| 285 // Error handler callback for |binding_| and |media_route_provider_|. | 280 // Error handler callback for |binding_| and |media_route_provider_|. |
| 286 void OnConnectionError(); | 281 void OnConnectionError(); |
| 287 | 282 |
| 288 // interfaces::MediaRouter implementation. | 283 // interfaces::MediaRouter implementation. |
| 289 void RegisterMediaRouteProvider( | 284 void RegisterMediaRouteProvider( |
| 290 interfaces::MediaRouteProviderPtr media_route_provider_ptr, | 285 interfaces::MediaRouteProviderPtr media_route_provider_ptr, |
| 291 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& | 286 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& |
| 292 callback) override; | 287 callback) override; |
| 293 void OnIssue(interfaces::IssuePtr issue) override; | 288 void OnIssue(interfaces::IssuePtr issue) override; |
| 294 void OnSinksReceived(const mojo::String& media_source, | 289 void OnSinksReceived(const mojo::String& media_source, |
| 295 mojo::Array<interfaces::MediaSinkPtr> sinks, | 290 mojo::Array<interfaces::MediaSinkPtr> sinks, |
| 296 mojo::Array<mojo::String> origins) override; | 291 mojo::Array<mojo::String> origins) override; |
| 297 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes, | 292 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes, |
| 298 const mojo::String& media_source, | 293 const mojo::String& media_source, |
| 299 mojo::Array<mojo::String> joinable_route_ids) override; | 294 mojo::Array<mojo::String> joinable_route_ids) override; |
| 300 void OnSinkAvailabilityUpdated( | 295 void OnSinkAvailabilityUpdated( |
| 301 interfaces::MediaRouter::SinkAvailability availability) override; | 296 interfaces::MediaRouter::SinkAvailability availability) override; |
| 302 void OnPresentationConnectionStateChanged( | 297 void OnPresentationConnectionStateChanged( |
| 303 const mojo::String& route_id, | 298 const mojo::String& route_id, |
| 304 interfaces::MediaRouter::PresentationConnectionState state) override; | 299 interfaces::MediaRouter::PresentationConnectionState state) override; |
| 305 void OnPresentationConnectionClosed( | 300 void OnPresentationConnectionClosed( |
| 306 const mojo::String& route_id, | 301 const mojo::String& route_id, |
| 307 interfaces::MediaRouter::PresentationConnectionCloseReason reason, | 302 interfaces::MediaRouter::PresentationConnectionCloseReason reason, |
| 308 const mojo::String& message) override; | 303 const mojo::String& message) override; |
| 304 void OnRouteMessagesReceived( |
| 305 const mojo::String& route_id, |
| 306 mojo::Array<interfaces::RouteMessagePtr> messages) override; |
| 309 | 307 |
| 310 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() | 308 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() |
| 311 // into a local callback. | 309 // into a local callback. |
| 312 void RouteResponseReceived( | 310 void RouteResponseReceived( |
| 313 const std::string& presentation_id, | 311 const std::string& presentation_id, |
| 314 bool off_the_record, | 312 bool off_the_record, |
| 315 const std::vector<MediaRouteResponseCallback>& callbacks, | 313 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 316 interfaces::MediaRoutePtr media_route, | 314 interfaces::MediaRoutePtr media_route, |
| 317 mojo::String error_text, | 315 mojo::String error_text, |
| 318 interfaces::RouteRequestResultCode result_code); | 316 interfaces::RouteRequestResultCode result_code); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 base::ScopedPtrHashMap<MediaSource::Id, std::unique_ptr<MediaRoutesQuery>> | 368 base::ScopedPtrHashMap<MediaSource::Id, std::unique_ptr<MediaRoutesQuery>> |
| 371 routes_queries_; | 369 routes_queries_; |
| 372 | 370 |
| 373 using PresentationSessionMessagesObserverList = | 371 using PresentationSessionMessagesObserverList = |
| 374 base::ObserverList<PresentationSessionMessagesObserver>; | 372 base::ObserverList<PresentationSessionMessagesObserver>; |
| 375 base::ScopedPtrHashMap< | 373 base::ScopedPtrHashMap< |
| 376 MediaRoute::Id, | 374 MediaRoute::Id, |
| 377 std::unique_ptr<PresentationSessionMessagesObserverList>> | 375 std::unique_ptr<PresentationSessionMessagesObserverList>> |
| 378 messages_observers_; | 376 messages_observers_; |
| 379 | 377 |
| 380 // IDs of MediaRoutes being listened for messages. Note that this is | |
| 381 // different from |message_observers_| because we might be waiting for | |
| 382 // |OnRouteMessagesReceived()| to be invoked after all observers for that | |
| 383 // route have been removed. | |
| 384 std::set<MediaRoute::Id> route_ids_listening_for_messages_; | |
| 385 | |
| 386 IssueManager issue_manager_; | 378 IssueManager issue_manager_; |
| 387 | 379 |
| 388 // Binds |this| to a Mojo connection stub for interfaces::MediaRouter. | 380 // Binds |this| to a Mojo connection stub for interfaces::MediaRouter. |
| 389 std::unique_ptr<mojo::Binding<interfaces::MediaRouter>> binding_; | 381 std::unique_ptr<mojo::Binding<interfaces::MediaRouter>> binding_; |
| 390 | 382 |
| 391 // Mojo proxy object for the Media Route Provider Manager. | 383 // Mojo proxy object for the Media Route Provider Manager. |
| 392 // Set to null initially, and later set to the Provider Manager proxy object | 384 // Set to null initially, and later set to the Provider Manager proxy object |
| 393 // passed in via |RegisterMediaRouteProvider()|. | 385 // passed in via |RegisterMediaRouteProvider()|. |
| 394 // This is set to null again when the component extension is suspended | 386 // This is set to null again when the component extension is suspended |
| 395 // if or a Mojo channel error occured. | 387 // if or a Mojo channel error occured. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 #endif | 426 #endif |
| 435 | 427 |
| 436 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 428 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 437 | 429 |
| 438 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 430 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 439 }; | 431 }; |
| 440 | 432 |
| 441 } // namespace media_router | 433 } // namespace media_router |
| 442 | 434 |
| 443 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 435 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |