| 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> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <unordered_map> |
| 15 #include <vector> | 16 #include <vector> |
| 16 | 17 |
| 17 #include "base/containers/hash_tables.h" | 18 #include "base/containers/hash_tables.h" |
| 18 #include "base/containers/scoped_ptr_hash_map.h" | 19 #include "base/containers/scoped_ptr_hash_map.h" |
| 19 #include "base/gtest_prod_util.h" | 20 #include "base/gtest_prod_util.h" |
| 20 #include "base/macros.h" | 21 #include "base/macros.h" |
| 21 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
| 22 #include "base/observer_list.h" | 23 #include "base/observer_list.h" |
| 23 #include "base/thread_task_runner_handle.h" | 24 #include "base/thread_task_runner_handle.h" |
| 24 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 void SendRouteMessage(const MediaRoute::Id& route_id, | 94 void SendRouteMessage(const MediaRoute::Id& route_id, |
| 94 const std::string& message, | 95 const std::string& message, |
| 95 const SendRouteMessageCallback& callback) override; | 96 const SendRouteMessageCallback& callback) override; |
| 96 void SendRouteBinaryMessage( | 97 void SendRouteBinaryMessage( |
| 97 const MediaRoute::Id& route_id, | 98 const MediaRoute::Id& route_id, |
| 98 std::unique_ptr<std::vector<uint8_t>> data, | 99 std::unique_ptr<std::vector<uint8_t>> data, |
| 99 const SendRouteMessageCallback& callback) override; | 100 const SendRouteMessageCallback& callback) override; |
| 100 void AddIssue(const Issue& issue) override; | 101 void AddIssue(const Issue& issue) override; |
| 101 void ClearIssue(const Issue::Id& issue_id) override; | 102 void ClearIssue(const Issue::Id& issue_id) override; |
| 102 void OnUserGesture() override; | 103 void OnUserGesture() override; |
| 104 void SearchSinksAndCreateRoute( |
| 105 const MediaSink::Id& sink_id, |
| 106 const MediaSource::Id& source_id, |
| 107 const std::string& search_input, |
| 108 const std::string& domain, |
| 109 const GURL& origin, |
| 110 content::WebContents* web_contents, |
| 111 const std::vector<MediaRouteResponseCallback>& route_callbacks, |
| 112 const MediaSinkSearchResponseCallback& sink_callback, |
| 113 base::TimeDelta timeout, |
| 114 bool off_the_record) override; |
| 103 | 115 |
| 104 const std::string& media_route_provider_extension_id() const { | 116 const std::string& media_route_provider_extension_id() const { |
| 105 return media_route_provider_extension_id_; | 117 return media_route_provider_extension_id_; |
| 106 } | 118 } |
| 107 | 119 |
| 108 void set_instance_id_for_test(const std::string& instance_id) { | 120 void set_instance_id_for_test(const std::string& instance_id) { |
| 109 instance_id_ = instance_id; | 121 instance_id_ = instance_id; |
| 110 } | 122 } |
| 111 | 123 |
| 112 private: | 124 private: |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 const SendRouteMessageCallback& callback); | 258 const SendRouteMessageCallback& callback); |
| 247 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, | 259 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, |
| 248 std::unique_ptr<std::vector<uint8_t>> data, | 260 std::unique_ptr<std::vector<uint8_t>> data, |
| 249 const SendRouteMessageCallback& callback); | 261 const SendRouteMessageCallback& callback); |
| 250 void DoListenForRouteMessages(const MediaRoute::Id& route_id); | 262 void DoListenForRouteMessages(const MediaRoute::Id& route_id); |
| 251 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); | 263 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); |
| 252 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); | 264 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); |
| 253 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); | 265 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); |
| 254 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id); | 266 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id); |
| 255 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id); | 267 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id); |
| 268 void DoSearchSinksAndCreateRoute( |
| 269 const MediaSink::Id& sink_id, |
| 270 const MediaSource::Id& source_id, |
| 271 const std::string& search_input, |
| 272 const std::string& domain, |
| 273 const std::string& origin, |
| 274 int tab_id, |
| 275 const std::vector<MediaRouteResponseCallback>& route_callbacks, |
| 276 const MediaSinkSearchResponseCallback& sink_callback, |
| 277 base::TimeDelta timeout, |
| 278 bool off_the_record); |
| 256 | 279 |
| 257 // Invoked when the next batch of messages arrives. | 280 // Invoked when the next batch of messages arrives. |
| 258 // |route_id|: ID of route of the messages. | 281 // |route_id|: ID of route of the messages. |
| 259 // |messages|: A list of messages received. | 282 // |messages|: A list of messages received. |
| 260 // |error|: true if an error occurred. | 283 // |error|: true if an error occurred. |
| 261 void OnRouteMessagesReceived( | 284 void OnRouteMessagesReceived( |
| 262 const MediaRoute::Id& route_id, | 285 const MediaRoute::Id& route_id, |
| 263 mojo::Array<interfaces::RouteMessagePtr> messages, | 286 mojo::Array<interfaces::RouteMessagePtr> messages, |
| 264 bool error); | 287 bool error); |
| 265 | 288 |
| 266 // Error handler callback for |binding_| and |media_route_provider_|. | 289 // Error handler callback for |binding_| and |media_route_provider_|. |
| 267 void OnConnectionError(); | 290 void OnConnectionError(); |
| 268 | 291 |
| 269 // interfaces::MediaRouter implementation. | 292 // interfaces::MediaRouter implementation. |
| 270 void RegisterMediaRouteProvider( | 293 void RegisterMediaRouteProvider( |
| 271 interfaces::MediaRouteProviderPtr media_route_provider_ptr, | 294 interfaces::MediaRouteProviderPtr media_route_provider_ptr, |
| 272 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& | 295 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& |
| 273 callback) override; | 296 callback) override; |
| 274 void OnIssue(interfaces::IssuePtr issue) override; | 297 void OnIssue(interfaces::IssuePtr issue) override; |
| 275 void OnSinksReceived(const mojo::String& media_source, | 298 void OnSinksReceived(const mojo::String& media_source, |
| 276 mojo::Array<interfaces::MediaSinkPtr> sinks, | 299 mojo::Array<interfaces::MediaSinkPtr> sinks, |
| 277 mojo::Array<mojo::String> origins) override; | 300 mojo::Array<mojo::String> origins) override; |
| 301 void OnSearchSinkIdReceived(const mojo::String& pseudo_sink_id, |
| 302 const mojo::String& sink_id) override; |
| 278 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes, | 303 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes, |
| 279 const mojo::String& media_source, | 304 const mojo::String& media_source, |
| 280 mojo::Array<mojo::String> joinable_route_ids) override; | 305 mojo::Array<mojo::String> joinable_route_ids) override; |
| 281 void OnSinkAvailabilityUpdated( | 306 void OnSinkAvailabilityUpdated( |
| 282 interfaces::MediaRouter::SinkAvailability availability) override; | 307 interfaces::MediaRouter::SinkAvailability availability) override; |
| 283 void OnPresentationConnectionStateChanged( | 308 void OnPresentationConnectionStateChanged( |
| 284 const mojo::String& route_id, | 309 const mojo::String& route_id, |
| 285 interfaces::MediaRouter::PresentationConnectionState state) override; | 310 interfaces::MediaRouter::PresentationConnectionState state) override; |
| 286 void OnPresentationConnectionClosed( | 311 void OnPresentationConnectionClosed( |
| 287 const mojo::String& route_id, | 312 const mojo::String& route_id, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 void UpdateMediaSinks(const MediaSource::Id& source_id); | 366 void UpdateMediaSinks(const MediaSource::Id& source_id); |
| 342 void DoUpdateMediaSinks(const MediaSource::Id& source_id); | 367 void DoUpdateMediaSinks(const MediaSource::Id& source_id); |
| 343 | 368 |
| 344 // Pending requests queued to be executed once component extension | 369 // Pending requests queued to be executed once component extension |
| 345 // becomes ready. | 370 // becomes ready. |
| 346 std::deque<base::Closure> pending_requests_; | 371 std::deque<base::Closure> pending_requests_; |
| 347 | 372 |
| 348 base::ScopedPtrHashMap<MediaSource::Id, std::unique_ptr<MediaSinksQuery>> | 373 base::ScopedPtrHashMap<MediaSource::Id, std::unique_ptr<MediaSinksQuery>> |
| 349 sinks_queries_; | 374 sinks_queries_; |
| 350 | 375 |
| 351 base::ScopedPtrHashMap<MediaSource::Id, std::unique_ptr<MediaRoutesQuery>> | 376 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaRoutesQuery>> |
| 352 routes_queries_; | 377 routes_queries_; |
| 353 | 378 |
| 379 std::unordered_map<std::string, std::vector<MediaSinkSearchResponseCallback>> |
| 380 search_callbacks_; |
| 381 |
| 354 using PresentationSessionMessagesObserverList = | 382 using PresentationSessionMessagesObserverList = |
| 355 base::ObserverList<PresentationSessionMessagesObserver>; | 383 base::ObserverList<PresentationSessionMessagesObserver>; |
| 356 base::ScopedPtrHashMap< | 384 base::ScopedPtrHashMap< |
| 357 MediaRoute::Id, | 385 MediaRoute::Id, |
| 358 std::unique_ptr<PresentationSessionMessagesObserverList>> | 386 std::unique_ptr<PresentationSessionMessagesObserverList>> |
| 359 messages_observers_; | 387 messages_observers_; |
| 360 | 388 |
| 361 // IDs of MediaRoutes being listened for messages. Note that this is | 389 // IDs of MediaRoutes being listened for messages. Note that this is |
| 362 // different from |message_observers_| because we might be waiting for | 390 // different from |message_observers_| because we might be waiting for |
| 363 // |OnRouteMessagesReceived()| to be invoked after all observers for that | 391 // |OnRouteMessagesReceived()| to be invoked after all observers for that |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 #endif | 443 #endif |
| 416 | 444 |
| 417 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 445 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 418 | 446 |
| 419 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 447 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 420 }; | 448 }; |
| 421 | 449 |
| 422 } // namespace media_router | 450 } // namespace media_router |
| 423 | 451 |
| 424 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 452 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |