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 11 matching lines...) Expand all Loading... | |
22 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
23 #include "base/optional.h" | 23 #include "base/optional.h" |
24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "chrome/browser/media/router/issue_manager.h" | 26 #include "chrome/browser/media/router/issue_manager.h" |
27 #include "chrome/browser/media/router/media_router_base.h" | 27 #include "chrome/browser/media/router/media_router_base.h" |
28 #include "chrome/browser/media/router/media_routes_observer.h" | 28 #include "chrome/browser/media/router/media_routes_observer.h" |
29 #include "chrome/common/media_router/issue.h" | 29 #include "chrome/common/media_router/issue.h" |
30 #include "chrome/common/media_router/mojo/media_router.mojom.h" | 30 #include "chrome/common/media_router/mojo/media_router.mojom.h" |
31 #include "chrome/common/media_router/route_request_result.h" | 31 #include "chrome/common/media_router/route_request_result.h" |
32 #include "content/public/browser/browser_thread.h" | |
32 #include "mojo/public/cpp/bindings/binding.h" | 33 #include "mojo/public/cpp/bindings/binding.h" |
33 | 34 |
34 namespace content { | 35 namespace content { |
35 class BrowserContext; | 36 class BrowserContext; |
36 } | 37 } |
37 | 38 |
38 namespace extensions { | 39 namespace extensions { |
39 class EventPageTracker; | 40 class EventPageTracker; |
40 class Extension; | 41 class Extension; |
41 } | 42 } |
42 | 43 |
43 namespace media_router { | 44 namespace media_router { |
44 | 45 |
45 enum class MediaRouteProviderWakeReason; | 46 enum class MediaRouteProviderWakeReason; |
47 class DialMediaSinkService; | |
46 | 48 |
47 // MediaRouter implementation that delegates calls to the component extension. | 49 // MediaRouter implementation that delegates calls to the component extension. |
48 // Also handles the suspension and wakeup of the component extension. | 50 // Also handles the suspension and wakeup of the component extension. |
49 // Lives on the UI thread. | 51 // Lives on the UI thread. |
50 class MediaRouterMojoImpl : public MediaRouterBase, | 52 class MediaRouterMojoImpl : public MediaRouterBase, |
51 public mojom::MediaRouter { | 53 public mojom::MediaRouter { |
52 public: | 54 public: |
53 ~MediaRouterMojoImpl() override; | 55 ~MediaRouterMojoImpl() override; |
54 | 56 |
55 // Sets up the MediaRouterMojoImpl instance owned by |context| to handle | 57 // Sets up the MediaRouterMojoImpl instance owned by |context| to handle |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 std::vector<std::string> joinable_route_ids; | 209 std::vector<std::string> joinable_route_ids; |
208 | 210 |
209 base::ObserverList<MediaRoutesObserver> observers; | 211 base::ObserverList<MediaRoutesObserver> observers; |
210 | 212 |
211 private: | 213 private: |
212 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery); | 214 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery); |
213 }; | 215 }; |
214 | 216 |
215 // Standard constructor, used by | 217 // Standard constructor, used by |
216 // MediaRouterMojoImplFactory::GetApiForBrowserContext. | 218 // MediaRouterMojoImplFactory::GetApiForBrowserContext. |
217 explicit MediaRouterMojoImpl( | 219 explicit MediaRouterMojoImpl(extensions::EventPageTracker* event_page_tracker, |
Kevin M
2017/05/03 21:07:28
Remove "explicit" (>1 arg ctor)
zhaobin
2017/05/04 23:52:36
Done.
| |
218 extensions::EventPageTracker* event_page_tracker); | 220 content::BrowserContext* context); |
219 | 221 |
220 // Binds |this| to a Mojo interface request, so that clients can acquire a | 222 // Binds |this| to a Mojo interface request, so that clients can acquire a |
221 // handle to a MediaRouterMojoImpl instance via the Mojo service connector. | 223 // handle to a MediaRouterMojoImpl instance via the Mojo service connector. |
222 // Stores the ID of |extension| in |media_route_provider_extension_id_|. | 224 // Stores the ID of |extension| in |media_route_provider_extension_id_|. |
223 void BindToMojoRequest( | 225 void BindToMojoRequest( |
224 mojo::InterfaceRequest<mojom::MediaRouter> request, | 226 mojo::InterfaceRequest<mojom::MediaRouter> request, |
225 const extensions::Extension& extension); | 227 const extensions::Extension& extension); |
226 | 228 |
227 // Enqueues a closure for later execution by ExecutePendingRequests(). | 229 // Enqueues a closure for later execution by ExecutePendingRequests(). |
228 void EnqueueTask(base::OnceClosure closure); | 230 void EnqueueTask(base::OnceClosure closure); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 // period. | 384 // period. |
383 void EnsureMdnsDiscoveryEnabled(); | 385 void EnsureMdnsDiscoveryEnabled(); |
384 void DoEnsureMdnsDiscoveryEnabled(); | 386 void DoEnsureMdnsDiscoveryEnabled(); |
385 | 387 |
386 // Callback used to enabled mDNS in the MRPM if a firewall prompt will not be | 388 // Callback used to enabled mDNS in the MRPM if a firewall prompt will not be |
387 // triggered. If a firewall prompt would be triggered, enabling mDNS won't | 389 // triggered. If a firewall prompt would be triggered, enabling mDNS won't |
388 // happen until the user is clearly interacting with MR. | 390 // happen until the user is clearly interacting with MR. |
389 void OnFirewallCheckComplete(bool firewall_can_use_local_ports); | 391 void OnFirewallCheckComplete(bool firewall_can_use_local_ports); |
390 #endif | 392 #endif |
391 | 393 |
394 // Start browser side sink discovery. | |
395 void StartDiscovery(); | |
396 | |
392 // Requests MRPM to update media sinks. This allows MRPs that only do | 397 // Requests MRPM to update media sinks. This allows MRPs that only do |
393 // discovery on sink queries an opportunity to update discovery results | 398 // discovery on sink queries an opportunity to update discovery results |
394 // even if the MRP SinkAvailability is marked UNAVAILABLE. | 399 // even if the MRP SinkAvailability is marked UNAVAILABLE. |
395 void UpdateMediaSinks(const MediaSource::Id& source_id); | 400 void UpdateMediaSinks(const MediaSource::Id& source_id); |
396 void DoUpdateMediaSinks(const MediaSource::Id& source_id); | 401 void DoUpdateMediaSinks(const MediaSource::Id& source_id); |
397 | 402 |
398 // Invalidates and removes controllers from |route_controllers_| whose media | 403 // Invalidates and removes controllers from |route_controllers_| whose media |
399 // routes do not appear in |routes|. | 404 // routes do not appear in |routes|. |
400 void RemoveInvalidRouteControllers(const std::vector<MediaRoute>& routes); | 405 void RemoveInvalidRouteControllers(const std::vector<MediaRoute>& routes); |
401 | 406 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 MediaRouteProviderWakeReason current_wake_reason_; | 457 MediaRouteProviderWakeReason current_wake_reason_; |
453 | 458 |
454 // A flag to ensure that we record the provider version once, during the | 459 // A flag to ensure that we record the provider version once, during the |
455 // initial event page wakeup attempt. | 460 // initial event page wakeup attempt. |
456 bool provider_version_was_recorded_ = false; | 461 bool provider_version_was_recorded_ = false; |
457 | 462 |
458 // Stores route controllers that can be used to send media commands to the | 463 // Stores route controllers that can be used to send media commands to the |
459 // extension. | 464 // extension. |
460 std::unordered_map<MediaRoute::Id, MediaRouteController*> route_controllers_; | 465 std::unordered_map<MediaRoute::Id, MediaRouteController*> route_controllers_; |
461 | 466 |
467 // Media sink service for DIAL devices. | |
468 scoped_refptr<DialMediaSinkService> dial_media_sink_service_; | |
469 | |
470 content::BrowserContext* context_; | |
471 | |
462 #if defined(OS_WIN) | 472 #if defined(OS_WIN) |
463 // A pair of flags to ensure that mDNS discovery is only enabled on Windows | 473 // A pair of flags to ensure that mDNS discovery is only enabled on Windows |
464 // when there will be appropriate context for the user to associate a firewall | 474 // when there will be appropriate context for the user to associate a firewall |
465 // prompt with Media Router. |should_enable_mdns_discovery_| can only go from | 475 // prompt with Media Router. |should_enable_mdns_discovery_| can only go from |
466 // |false| to |true|. On Windows, |is_mdns_enabled_| is set to |false| in | 476 // |false| to |true|. On Windows, |is_mdns_enabled_| is set to |false| in |
467 // RegisterMediaRouteProvider and only set to |true| when we successfully call | 477 // RegisterMediaRouteProvider and only set to |true| when we successfully call |
468 // the extension to enable mDNS. | 478 // the extension to enable mDNS. |
469 bool is_mdns_enabled_ = false; | 479 bool is_mdns_enabled_ = false; |
470 bool should_enable_mdns_discovery_ = false; | 480 bool should_enable_mdns_discovery_ = false; |
471 #endif | 481 #endif |
472 | 482 |
473 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 483 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
474 | 484 |
475 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 485 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
476 }; | 486 }; |
477 | 487 |
478 } // namespace media_router | 488 } // namespace media_router |
479 | 489 |
480 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 490 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
OLD | NEW |