| 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> | |
| 12 #include <memory> | 11 #include <memory> |
| 13 #include <set> | 12 #include <set> |
| 14 #include <string> | 13 #include <string> |
| 15 #include <unordered_map> | 14 #include <unordered_map> |
| 16 #include <vector> | 15 #include <vector> |
| 17 | 16 |
| 18 #include "base/containers/hash_tables.h" | 17 #include "base/containers/hash_tables.h" |
| 19 #include "base/containers/scoped_ptr_hash_map.h" | 18 #include "base/containers/scoped_ptr_hash_map.h" |
| 20 #include "base/gtest_prod_util.h" | 19 #include "base/gtest_prod_util.h" |
| 21 #include "base/macros.h" | 20 #include "base/macros.h" |
| 22 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 23 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
| 24 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
| 25 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 26 #include "chrome/browser/media/router/issue.h" | 25 #include "chrome/browser/media/router/issue.h" |
| 27 #include "chrome/browser/media/router/issue_manager.h" | 26 #include "chrome/browser/media/router/issue_manager.h" |
| 28 #include "chrome/browser/media/router/media_router_base.h" | 27 #include "chrome/browser/media/router/media_router_base.h" |
| 29 #include "chrome/browser/media/router/media_routes_observer.h" | 28 #include "chrome/browser/media/router/media_routes_observer.h" |
| 29 #include "chrome/browser/media/router/mojo/media_remoter.mojom.h" |
| 30 #include "chrome/browser/media/router/mojo/media_router.mojom.h" | 30 #include "chrome/browser/media/router/mojo/media_router.mojom.h" |
| 31 #include "mojo/public/cpp/bindings/binding.h" | 31 #include "mojo/public/cpp/bindings/binding.h" |
| 32 | 32 |
| 33 namespace content { | 33 namespace content { |
| 34 class BrowserContext; | 34 class BrowserContext; |
| 35 } | 35 } |
| 36 | 36 |
| 37 namespace extensions { | 37 namespace extensions { |
| 38 class EventPageTracker; | 38 class EventPageTracker; |
| 39 class Extension; | 39 class Extension; |
| 40 } | 40 } |
| 41 | 41 |
| 42 namespace media_router { | 42 namespace media_router { |
| 43 | 43 |
| 44 class MediaRemotingSessionImpl; |
| 44 enum class MediaRouteProviderWakeReason; | 45 enum class MediaRouteProviderWakeReason; |
| 45 | 46 |
| 46 // MediaRouter implementation that delegates calls to the component extension. | 47 // MediaRouter implementation that delegates calls to the component extension. |
| 47 // Also handles the suspension and wakeup of the component extension. | 48 // Also handles the suspension and wakeup of the component extension. |
| 48 // Lives on the UI thread. | 49 // Lives on the UI thread. |
| 49 class MediaRouterMojoImpl : public MediaRouterBase, | 50 class MediaRouterMojoImpl : public MediaRouterBase, |
| 50 public interfaces::MediaRouter { | 51 public interfaces::MediaRouter { |
| 51 public: | 52 public: |
| 52 ~MediaRouterMojoImpl() override; | 53 ~MediaRouterMojoImpl() override; |
| 53 | 54 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 void OnPresentationConnectionStateChanged( | 299 void OnPresentationConnectionStateChanged( |
| 299 const mojo::String& route_id, | 300 const mojo::String& route_id, |
| 300 interfaces::MediaRouter::PresentationConnectionState state) override; | 301 interfaces::MediaRouter::PresentationConnectionState state) override; |
| 301 void OnPresentationConnectionClosed( | 302 void OnPresentationConnectionClosed( |
| 302 const mojo::String& route_id, | 303 const mojo::String& route_id, |
| 303 interfaces::MediaRouter::PresentationConnectionCloseReason reason, | 304 interfaces::MediaRouter::PresentationConnectionCloseReason reason, |
| 304 const mojo::String& message) override; | 305 const mojo::String& message) override; |
| 305 void OnRouteMessagesReceived( | 306 void OnRouteMessagesReceived( |
| 306 const mojo::String& route_id, | 307 const mojo::String& route_id, |
| 307 mojo::Array<interfaces::RouteMessagePtr> messages) override; | 308 mojo::Array<interfaces::RouteMessagePtr> messages) override; |
| 309 void CreateRemotingSession( |
| 310 const mojo::String& media_source, |
| 311 interfaces::MediaRemotingProviderPtr provider, |
| 312 const CreateRemotingSessionCallback& callback) override; |
| 313 |
| 314 void OnRemotingSessionTerminated(const MediaSource::Id& media_source); |
| 315 void TerminateAllRemotingSessions(const std::string& error_reason); |
| 308 | 316 |
| 309 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() | 317 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() |
| 310 // into a local callback. | 318 // into a local callback. |
| 311 void RouteResponseReceived( | 319 void RouteResponseReceived( |
| 312 const std::string& presentation_id, | 320 const std::string& presentation_id, |
| 313 bool off_the_record, | 321 bool off_the_record, |
| 314 const std::vector<MediaRouteResponseCallback>& callbacks, | 322 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 315 interfaces::MediaRoutePtr media_route, | 323 interfaces::MediaRoutePtr media_route, |
| 316 mojo::String error_text, | 324 mojo::String error_text, |
| 317 interfaces::RouteRequestResultCode result_code); | 325 interfaces::RouteRequestResultCode result_code); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 // A pair of flags to ensure that mDNS discovery is only enabled on Windows | 427 // A pair of flags to ensure that mDNS discovery is only enabled on Windows |
| 420 // when there will be appropriate context for the user to associate a firewall | 428 // when there will be appropriate context for the user to associate a firewall |
| 421 // prompt with Media Router. |should_enable_mdns_discovery_| can only go from | 429 // prompt with Media Router. |should_enable_mdns_discovery_| can only go from |
| 422 // |false| to |true|. On Windows, |is_mdns_enabled_| is set to |false| in | 430 // |false| to |true|. On Windows, |is_mdns_enabled_| is set to |false| in |
| 423 // RegisterMediaRouteProvider and only set to |true| when we successfully call | 431 // RegisterMediaRouteProvider and only set to |true| when we successfully call |
| 424 // the extension to enable mDNS. | 432 // the extension to enable mDNS. |
| 425 bool is_mdns_enabled_ = false; | 433 bool is_mdns_enabled_ = false; |
| 426 bool should_enable_mdns_discovery_ = false; | 434 bool should_enable_mdns_discovery_ = false; |
| 427 #endif | 435 #endif |
| 428 | 436 |
| 437 // Owned set of currently-active media remoting sessions. |
| 438 std::unordered_map<MediaSource::Id, std::unique_ptr<MediaRemotingSessionImpl>> |
| 439 remoting_sessions_; |
| 440 |
| 429 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 441 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 430 | 442 |
| 431 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 443 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 432 }; | 444 }; |
| 433 | 445 |
| 434 } // namespace media_router | 446 } // namespace media_router |
| 435 | 447 |
| 436 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 448 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |