| 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_MEDIA_ROUTER_MOJO_IMPL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_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 <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
| 17 #include "base/containers/scoped_ptr_hash_map.h" | 17 #include "base/containers/scoped_ptr_hash_map.h" |
| 18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
| 23 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 24 #include "build/build_config.h" |
| 24 #include "chrome/browser/media/router/issue.h" | 25 #include "chrome/browser/media/router/issue.h" |
| 25 #include "chrome/browser/media/router/issue_manager.h" | 26 #include "chrome/browser/media/router/issue_manager.h" |
| 26 #include "chrome/browser/media/router/media_router.mojom.h" | 27 #include "chrome/browser/media/router/media_router.mojom.h" |
| 27 #include "chrome/browser/media/router/media_router_base.h" | 28 #include "chrome/browser/media/router/media_router_base.h" |
| 28 #include "chrome/browser/media/router/media_routes_observer.h" | 29 #include "chrome/browser/media/router/media_routes_observer.h" |
| 29 #include "mojo/public/cpp/bindings/binding.h" | 30 #include "mojo/public/cpp/bindings/binding.h" |
| 30 | 31 |
| 31 namespace content { | 32 namespace content { |
| 32 class BrowserContext; | 33 class BrowserContext; |
| 33 } | 34 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 void DetachRoute(const MediaRoute::Id& route_id) override; | 90 void DetachRoute(const MediaRoute::Id& route_id) override; |
| 90 void SendRouteMessage(const MediaRoute::Id& route_id, | 91 void SendRouteMessage(const MediaRoute::Id& route_id, |
| 91 const std::string& message, | 92 const std::string& message, |
| 92 const SendRouteMessageCallback& callback) override; | 93 const SendRouteMessageCallback& callback) override; |
| 93 void SendRouteBinaryMessage( | 94 void SendRouteBinaryMessage( |
| 94 const MediaRoute::Id& route_id, | 95 const MediaRoute::Id& route_id, |
| 95 scoped_ptr<std::vector<uint8_t>> data, | 96 scoped_ptr<std::vector<uint8_t>> data, |
| 96 const SendRouteMessageCallback& callback) override; | 97 const SendRouteMessageCallback& callback) override; |
| 97 void AddIssue(const Issue& issue) override; | 98 void AddIssue(const Issue& issue) override; |
| 98 void ClearIssue(const Issue::Id& issue_id) override; | 99 void ClearIssue(const Issue::Id& issue_id) override; |
| 100 void OnUserGesture() override; |
| 99 | 101 |
| 100 const std::string& media_route_provider_extension_id() const { | 102 const std::string& media_route_provider_extension_id() const { |
| 101 return media_route_provider_extension_id_; | 103 return media_route_provider_extension_id_; |
| 102 } | 104 } |
| 103 | 105 |
| 104 void set_instance_id_for_test(const std::string& instance_id) { | 106 void set_instance_id_for_test(const std::string& instance_id) { |
| 105 instance_id_ = instance_id; | 107 instance_id_ = instance_id; |
| 106 } | 108 } |
| 107 | 109 |
| 108 private: | 110 private: |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 void AttemptWakeEventPage(); | 311 void AttemptWakeEventPage(); |
| 310 | 312 |
| 311 // Sets the reason why we are attempting to wake the extension. Since | 313 // Sets the reason why we are attempting to wake the extension. Since |
| 312 // multiple tasks may be enqueued for execution each time the extension runs, | 314 // multiple tasks may be enqueued for execution each time the extension runs, |
| 313 // we record the first such reason. | 315 // we record the first such reason. |
| 314 void SetWakeReason(MediaRouteProviderWakeReason reason); | 316 void SetWakeReason(MediaRouteProviderWakeReason reason); |
| 315 | 317 |
| 316 // Clears the wake reason after the extension has been awoken. | 318 // Clears the wake reason after the extension has been awoken. |
| 317 void ClearWakeReason(); | 319 void ClearWakeReason(); |
| 318 | 320 |
| 321 #if defined(OS_WIN) |
| 322 // Ensures that mDNS discovery is enabled in the MRPM extension. This can be |
| 323 // called many times but the MRPM will only be called once per registration |
| 324 // period. |
| 325 void EnsureMdnsDiscoveryEnabled(); |
| 326 void DoEnsureMdnsDiscoveryEnabled(); |
| 327 |
| 328 // Callback used to enabled mDNS in the MRPM if a firewall prompt will not be |
| 329 // triggered. If a firewall prompt would be triggered, enabling mDNS won't |
| 330 // happen until the user is clearly interacting with MR. |
| 331 void OnFirewallCheckComplete(bool firewall_can_use_local_ports); |
| 332 #endif |
| 333 |
| 319 // Pending requests queued to be executed once component extension | 334 // Pending requests queued to be executed once component extension |
| 320 // becomes ready. | 335 // becomes ready. |
| 321 std::deque<base::Closure> pending_requests_; | 336 std::deque<base::Closure> pending_requests_; |
| 322 | 337 |
| 323 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaSinksQuery>> | 338 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaSinksQuery>> |
| 324 sinks_queries_; | 339 sinks_queries_; |
| 325 | 340 |
| 326 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaRoutesQuery>> | 341 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaRoutesQuery>> |
| 327 routes_queries_; | 342 routes_queries_; |
| 328 | 343 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 381 |
| 367 // The last reported sink availability from the media route provider manager. | 382 // The last reported sink availability from the media route provider manager. |
| 368 interfaces::MediaRouter::SinkAvailability availability_; | 383 interfaces::MediaRouter::SinkAvailability availability_; |
| 369 | 384 |
| 370 int wakeup_attempt_count_; | 385 int wakeup_attempt_count_; |
| 371 | 386 |
| 372 // Records the current reason the extension is being woken up. Is set to | 387 // Records the current reason the extension is being woken up. Is set to |
| 373 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason. | 388 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason. |
| 374 MediaRouteProviderWakeReason current_wake_reason_; | 389 MediaRouteProviderWakeReason current_wake_reason_; |
| 375 | 390 |
| 391 #if defined(OS_WIN) |
| 392 // A pair of flags to ensure that mDNS discovery is only enabled on Windows |
| 393 // when there will be appropriate context for the user to associate a firewall |
| 394 // prompt with Media Router. |should_enable_mdns_discovery_| can only go from |
| 395 // |false| to |true|. On Windows, |is_mdns_enabled_| is set to |false| in |
| 396 // RegisterMediaRouteProvider and only set to |true| when we successfully call |
| 397 // the extension to enable mDNS. |
| 398 bool is_mdns_enabled_ = false; |
| 399 bool should_enable_mdns_discovery_ = false; |
| 400 #endif |
| 401 |
| 376 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 402 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 377 | 403 |
| 378 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 404 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 379 }; | 405 }; |
| 380 | 406 |
| 381 } // namespace media_router | 407 } // namespace media_router |
| 382 | 408 |
| 383 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 409 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |