| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 base::TimeDelta timeout, | 253 base::TimeDelta timeout, |
| 254 bool off_the_record); | 254 bool off_the_record); |
| 255 void DoTerminateRoute(const MediaRoute::Id& route_id); | 255 void DoTerminateRoute(const MediaRoute::Id& route_id); |
| 256 void DoDetachRoute(const MediaRoute::Id& route_id); | 256 void DoDetachRoute(const MediaRoute::Id& route_id); |
| 257 void DoSendSessionMessage(const MediaRoute::Id& route_id, | 257 void DoSendSessionMessage(const MediaRoute::Id& route_id, |
| 258 const std::string& message, | 258 const std::string& message, |
| 259 const SendRouteMessageCallback& callback); | 259 const SendRouteMessageCallback& callback); |
| 260 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, | 260 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, |
| 261 std::unique_ptr<std::vector<uint8_t>> data, | 261 std::unique_ptr<std::vector<uint8_t>> data, |
| 262 const SendRouteMessageCallback& callback); | 262 const SendRouteMessageCallback& callback); |
| 263 void DoListenForRouteMessages(const MediaRoute::Id& route_id); | 263 void DoStartListeningForRouteMessages(const MediaRoute::Id& route_id); |
| 264 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); | 264 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); |
| 265 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); | 265 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); |
| 266 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); | 266 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); |
| 267 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id); | 267 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id); |
| 268 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id); | 268 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id); |
| 269 void DoSearchSinks( | 269 void DoSearchSinks( |
| 270 const MediaSink::Id& sink_id, | 270 const MediaSink::Id& sink_id, |
| 271 const MediaSource::Id& source_id, | 271 const MediaSource::Id& source_id, |
| 272 const std::string& search_input, | 272 const std::string& search_input, |
| 273 const std::string& domain, | 273 const std::string& domain, |
| 274 const MediaSinkSearchResponseCallback& sink_callback); | 274 const MediaSinkSearchResponseCallback& sink_callback); |
| 275 | 275 |
| 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_|. | 276 // Error handler callback for |binding_| and |media_route_provider_|. |
| 286 void OnConnectionError(); | 277 void OnConnectionError(); |
| 287 | 278 |
| 288 // interfaces::MediaRouter implementation. | 279 // interfaces::MediaRouter implementation. |
| 289 void RegisterMediaRouteProvider( | 280 void RegisterMediaRouteProvider( |
| 290 interfaces::MediaRouteProviderPtr media_route_provider_ptr, | 281 interfaces::MediaRouteProviderPtr media_route_provider_ptr, |
| 291 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& | 282 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& |
| 292 callback) override; | 283 callback) override; |
| 293 void OnIssue(interfaces::IssuePtr issue) override; | 284 void OnIssue(interfaces::IssuePtr issue) override; |
| 294 void OnSinksReceived(const mojo::String& media_source, | 285 void OnSinksReceived(const mojo::String& media_source, |
| 295 mojo::Array<interfaces::MediaSinkPtr> sinks, | 286 mojo::Array<interfaces::MediaSinkPtr> sinks, |
| 296 mojo::Array<mojo::String> origins) override; | 287 mojo::Array<mojo::String> origins) override; |
| 297 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes, | 288 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes, |
| 298 const mojo::String& media_source, | 289 const mojo::String& media_source, |
| 299 mojo::Array<mojo::String> joinable_route_ids) override; | 290 mojo::Array<mojo::String> joinable_route_ids) override; |
| 300 void OnSinkAvailabilityUpdated( | 291 void OnSinkAvailabilityUpdated( |
| 301 interfaces::MediaRouter::SinkAvailability availability) override; | 292 interfaces::MediaRouter::SinkAvailability availability) override; |
| 302 void OnPresentationConnectionStateChanged( | 293 void OnPresentationConnectionStateChanged( |
| 303 const mojo::String& route_id, | 294 const mojo::String& route_id, |
| 304 interfaces::MediaRouter::PresentationConnectionState state) override; | 295 interfaces::MediaRouter::PresentationConnectionState state) override; |
| 305 void OnPresentationConnectionClosed( | 296 void OnPresentationConnectionClosed( |
| 306 const mojo::String& route_id, | 297 const mojo::String& route_id, |
| 307 interfaces::MediaRouter::PresentationConnectionCloseReason reason, | 298 interfaces::MediaRouter::PresentationConnectionCloseReason reason, |
| 308 const mojo::String& message) override; | 299 const mojo::String& message) override; |
| 300 void OnRouteMessagesReceived( |
| 301 const mojo::String& route_id, |
| 302 mojo::Array<interfaces::RouteMessagePtr> messages) override; |
| 309 | 303 |
| 310 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() | 304 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() |
| 311 // into a local callback. | 305 // into a local callback. |
| 312 void RouteResponseReceived( | 306 void RouteResponseReceived( |
| 313 const std::string& presentation_id, | 307 const std::string& presentation_id, |
| 314 bool off_the_record, | 308 bool off_the_record, |
| 315 const std::vector<MediaRouteResponseCallback>& callbacks, | 309 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 316 interfaces::MediaRoutePtr media_route, | 310 interfaces::MediaRoutePtr media_route, |
| 317 mojo::String error_text, | 311 mojo::String error_text, |
| 318 interfaces::RouteRequestResultCode result_code); | 312 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>> | 364 base::ScopedPtrHashMap<MediaSource::Id, std::unique_ptr<MediaRoutesQuery>> |
| 371 routes_queries_; | 365 routes_queries_; |
| 372 | 366 |
| 373 using PresentationSessionMessagesObserverList = | 367 using PresentationSessionMessagesObserverList = |
| 374 base::ObserverList<PresentationSessionMessagesObserver>; | 368 base::ObserverList<PresentationSessionMessagesObserver>; |
| 375 base::ScopedPtrHashMap< | 369 base::ScopedPtrHashMap< |
| 376 MediaRoute::Id, | 370 MediaRoute::Id, |
| 377 std::unique_ptr<PresentationSessionMessagesObserverList>> | 371 std::unique_ptr<PresentationSessionMessagesObserverList>> |
| 378 messages_observers_; | 372 messages_observers_; |
| 379 | 373 |
| 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_; | 374 IssueManager issue_manager_; |
| 387 | 375 |
| 388 // Binds |this| to a Mojo connection stub for interfaces::MediaRouter. | 376 // Binds |this| to a Mojo connection stub for interfaces::MediaRouter. |
| 389 std::unique_ptr<mojo::Binding<interfaces::MediaRouter>> binding_; | 377 std::unique_ptr<mojo::Binding<interfaces::MediaRouter>> binding_; |
| 390 | 378 |
| 391 // Mojo proxy object for the Media Route Provider Manager. | 379 // Mojo proxy object for the Media Route Provider Manager. |
| 392 // Set to null initially, and later set to the Provider Manager proxy object | 380 // Set to null initially, and later set to the Provider Manager proxy object |
| 393 // passed in via |RegisterMediaRouteProvider()|. | 381 // passed in via |RegisterMediaRouteProvider()|. |
| 394 // This is set to null again when the component extension is suspended | 382 // This is set to null again when the component extension is suspended |
| 395 // if or a Mojo channel error occured. | 383 // if or a Mojo channel error occured. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 #endif | 422 #endif |
| 435 | 423 |
| 436 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 424 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 437 | 425 |
| 438 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 426 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 439 }; | 427 }; |
| 440 | 428 |
| 441 } // namespace media_router | 429 } // namespace media_router |
| 442 | 430 |
| 443 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 431 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |