| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 const SendRouteMessageCallback& callback) override; | 102 const SendRouteMessageCallback& callback) override; |
| 103 void AddIssue(const IssueInfo& issue_info) override; | 103 void AddIssue(const IssueInfo& issue_info) override; |
| 104 void ClearIssue(const Issue::Id& issue_id) override; | 104 void ClearIssue(const Issue::Id& issue_id) override; |
| 105 void OnUserGesture() override; | 105 void OnUserGesture() override; |
| 106 void SearchSinks( | 106 void SearchSinks( |
| 107 const MediaSink::Id& sink_id, | 107 const MediaSink::Id& sink_id, |
| 108 const MediaSource::Id& source_id, | 108 const MediaSource::Id& source_id, |
| 109 const std::string& search_input, | 109 const std::string& search_input, |
| 110 const std::string& domain, | 110 const std::string& domain, |
| 111 const MediaSinkSearchResponseCallback& sink_callback) override; | 111 const MediaSinkSearchResponseCallback& sink_callback) override; |
| 112 scoped_refptr<MediaRouteController> GetRouteController( |
| 113 const MediaRoute::Id& route_id) override; |
| 112 | 114 |
| 113 const std::string& media_route_provider_extension_id() const { | 115 const std::string& media_route_provider_extension_id() const { |
| 114 return media_route_provider_extension_id_; | 116 return media_route_provider_extension_id_; |
| 115 } | 117 } |
| 116 | 118 |
| 117 void set_instance_id_for_test(const std::string& instance_id) { | 119 void set_instance_id_for_test(const std::string& instance_id) { |
| 118 instance_id_ = instance_id; | 120 instance_id_ = instance_id; |
| 119 } | 121 } |
| 120 | 122 |
| 121 private: | 123 private: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 135 FRIEND_TEST_ALL_PREFIXES( | 137 FRIEND_TEST_ALL_PREFIXES( |
| 136 MediaRouterMojoImplTest, | 138 MediaRouterMojoImplTest, |
| 137 RegisterAndUnregisterMediaSinksObserverWithAvailabilityChange); | 139 RegisterAndUnregisterMediaSinksObserverWithAvailabilityChange); |
| 138 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 140 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 139 RegisterAndUnregisterMediaRoutesObserver); | 141 RegisterAndUnregisterMediaRoutesObserver); |
| 140 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 142 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 141 RouteMessagesSingleObserver); | 143 RouteMessagesSingleObserver); |
| 142 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 144 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 143 RouteMessagesMultipleObservers); | 145 RouteMessagesMultipleObservers); |
| 144 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, HandleIssue); | 146 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, HandleIssue); |
| 147 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 148 GetRouteControllerAfterRouteInvalidation); |
| 145 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 149 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 146 DeferredBindingAndSuspension); | 150 DeferredBindingAndSuspension); |
| 147 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 151 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 148 DrainPendingRequestQueue); | 152 DrainPendingRequestQueue); |
| 149 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 153 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 150 DropOldestPendingRequest); | 154 DropOldestPendingRequest); |
| 151 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 155 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 152 AttemptedWakeupTooManyTimes); | 156 AttemptedWakeupTooManyTimes); |
| 153 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 157 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 154 WakeupFailedDrainsQueue); | 158 WakeupFailedDrainsQueue); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 231 |
| 228 // MediaRouter implementation. | 232 // MediaRouter implementation. |
| 229 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override; | 233 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override; |
| 230 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override; | 234 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override; |
| 231 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | 235 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; |
| 232 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | 236 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; |
| 233 void RegisterIssuesObserver(IssuesObserver* observer) override; | 237 void RegisterIssuesObserver(IssuesObserver* observer) override; |
| 234 void UnregisterIssuesObserver(IssuesObserver* observer) override; | 238 void UnregisterIssuesObserver(IssuesObserver* observer) override; |
| 235 void RegisterRouteMessageObserver(RouteMessageObserver* observer) override; | 239 void RegisterRouteMessageObserver(RouteMessageObserver* observer) override; |
| 236 void UnregisterRouteMessageObserver(RouteMessageObserver* observer) override; | 240 void UnregisterRouteMessageObserver(RouteMessageObserver* observer) override; |
| 241 void DetachRouteController(const MediaRoute::Id& route_id, |
| 242 MediaRouteController* controller) override; |
| 237 | 243 |
| 238 // Notifies |observer| of any existing cached routes, if it is still | 244 // Notifies |observer| of any existing cached routes, if it is still |
| 239 // registered. | 245 // registered. |
| 240 void NotifyOfExistingRoutesIfRegistered(const MediaSource::Id& source_id, | 246 void NotifyOfExistingRoutesIfRegistered(const MediaSource::Id& source_id, |
| 241 MediaRoutesObserver* observer) const; | 247 MediaRoutesObserver* observer) const; |
| 242 | 248 |
| 243 // These calls invoke methods in the component extension via Mojo. | 249 // These calls invoke methods in the component extension via Mojo. |
| 244 void DoCreateRoute(const MediaSource::Id& source_id, | 250 void DoCreateRoute(const MediaSource::Id& source_id, |
| 245 const MediaSink::Id& sink_id, | 251 const MediaSink::Id& sink_id, |
| 246 const url::Origin& origin, | 252 const url::Origin& origin, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 // happen until the user is clearly interacting with MR. | 372 // happen until the user is clearly interacting with MR. |
| 367 void OnFirewallCheckComplete(bool firewall_can_use_local_ports); | 373 void OnFirewallCheckComplete(bool firewall_can_use_local_ports); |
| 368 #endif | 374 #endif |
| 369 | 375 |
| 370 // Requests MRPM to update media sinks. This allows MRPs that only do | 376 // Requests MRPM to update media sinks. This allows MRPs that only do |
| 371 // discovery on sink queries an opportunity to update discovery results | 377 // discovery on sink queries an opportunity to update discovery results |
| 372 // even if the MRP SinkAvailability is marked UNAVAILABLE. | 378 // even if the MRP SinkAvailability is marked UNAVAILABLE. |
| 373 void UpdateMediaSinks(const MediaSource::Id& source_id); | 379 void UpdateMediaSinks(const MediaSource::Id& source_id); |
| 374 void DoUpdateMediaSinks(const MediaSource::Id& source_id); | 380 void DoUpdateMediaSinks(const MediaSource::Id& source_id); |
| 375 | 381 |
| 382 // Invalidates and removes controllers from |route_controllers_| whose media |
| 383 // routes do not appear in |routes|. |
| 384 void RemoveInvalidRouteControllers(const std::vector<MediaRoute>& routes); |
| 385 |
| 386 // Callback called by MRP's CreateMediaRouteController(). |
| 387 void OnMediaControllerCreated(const MediaRoute::Id& route_id, bool success); |
| 388 |
| 376 // Pending requests queued to be executed once component extension | 389 // Pending requests queued to be executed once component extension |
| 377 // becomes ready. | 390 // becomes ready. |
| 378 std::deque<base::Closure> pending_requests_; | 391 std::deque<base::Closure> pending_requests_; |
| 379 | 392 |
| 380 std::unordered_map<MediaSource::Id, std::unique_ptr<MediaSinksQuery>> | 393 std::unordered_map<MediaSource::Id, std::unique_ptr<MediaSinksQuery>> |
| 381 sinks_queries_; | 394 sinks_queries_; |
| 382 | 395 |
| 383 std::unordered_map<MediaSource::Id, std::unique_ptr<MediaRoutesQuery>> | 396 std::unordered_map<MediaSource::Id, std::unique_ptr<MediaRoutesQuery>> |
| 384 routes_queries_; | 397 routes_queries_; |
| 385 | 398 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 int wakeup_attempt_count_ = 0; | 432 int wakeup_attempt_count_ = 0; |
| 420 | 433 |
| 421 // Records the current reason the extension is being woken up. Is set to | 434 // Records the current reason the extension is being woken up. Is set to |
| 422 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason. | 435 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason. |
| 423 MediaRouteProviderWakeReason current_wake_reason_; | 436 MediaRouteProviderWakeReason current_wake_reason_; |
| 424 | 437 |
| 425 // A flag to ensure that we record the provider version once, during the | 438 // A flag to ensure that we record the provider version once, during the |
| 426 // initial event page wakeup attempt. | 439 // initial event page wakeup attempt. |
| 427 bool provider_version_was_recorded_ = false; | 440 bool provider_version_was_recorded_ = false; |
| 428 | 441 |
| 442 // Stores route controllers that can be used to send media commands to the |
| 443 // extension. |
| 444 std::unordered_map<MediaRoute::Id, MediaRouteController*> route_controllers_; |
| 445 |
| 429 #if defined(OS_WIN) | 446 #if defined(OS_WIN) |
| 430 // A pair of flags to ensure that mDNS discovery is only enabled on Windows | 447 // A pair of flags to ensure that mDNS discovery is only enabled on Windows |
| 431 // when there will be appropriate context for the user to associate a firewall | 448 // when there will be appropriate context for the user to associate a firewall |
| 432 // prompt with Media Router. |should_enable_mdns_discovery_| can only go from | 449 // prompt with Media Router. |should_enable_mdns_discovery_| can only go from |
| 433 // |false| to |true|. On Windows, |is_mdns_enabled_| is set to |false| in | 450 // |false| to |true|. On Windows, |is_mdns_enabled_| is set to |false| in |
| 434 // RegisterMediaRouteProvider and only set to |true| when we successfully call | 451 // RegisterMediaRouteProvider and only set to |true| when we successfully call |
| 435 // the extension to enable mDNS. | 452 // the extension to enable mDNS. |
| 436 bool is_mdns_enabled_ = false; | 453 bool is_mdns_enabled_ = false; |
| 437 bool should_enable_mdns_discovery_ = false; | 454 bool should_enable_mdns_discovery_ = false; |
| 438 #endif | 455 #endif |
| 439 | 456 |
| 440 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 457 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 441 | 458 |
| 442 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 459 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 443 }; | 460 }; |
| 444 | 461 |
| 445 } // namespace media_router | 462 } // namespace media_router |
| 446 | 463 |
| 447 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 464 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |