Index: chrome/browser/media/router/media_router_mojo_impl.cc |
diff --git a/chrome/browser/media/router/media_router_mojo_impl.cc b/chrome/browser/media/router/media_router_mojo_impl.cc |
index 54c50ee20c89b837ddffe385d4c6fe37d90b0fdd..4ecddc4e21a0ddc98030f0d5a9d404bc3cdd9564 100644 |
--- a/chrome/browser/media/router/media_router_mojo_impl.cc |
+++ b/chrome/browser/media/router/media_router_mojo_impl.cc |
@@ -15,6 +15,7 @@ |
#include "base/stl_util.h" |
#include "base/strings/stringprintf.h" |
#include "chrome/browser/media/router/issues_observer.h" |
+#include "chrome/browser/media/router/media_route_provider_util_win.h" |
#include "chrome/browser/media/router/media_router_factory.h" |
#include "chrome/browser/media/router/media_router_metrics.h" |
#include "chrome/browser/media/router/media_router_type_converters.h" |
@@ -81,6 +82,11 @@ MediaRouterMojoImpl::MediaRouterMojoImpl( |
current_wake_reason_(MediaRouteProviderWakeReason::TOTAL_COUNT), |
weak_factory_(this) { |
DCHECK(event_page_tracker_); |
+#if defined(OS_WIN) |
mark a. foltz
2016/03/25 23:14:16
Prefer to check initial vale of should_ here inste
btolsch
2016/03/26 10:53:59
There is nothing for this function call to link to
|
+ CanFirewallUseLocalPorts( |
+ base::Bind(&MediaRouterMojoImpl::EnableMdnsFromFirewallCheck, |
+ base::Unretained(this))); |
mark a. foltz
2016/03/25 23:14:16
There's two design issues here (first is mandatory
btolsch
2016/03/26 10:53:59
MediaRouterMojoImpl already has a WeakPtrFactory f
|
+#endif |
} |
MediaRouterMojoImpl::~MediaRouterMojoImpl() { |
@@ -157,6 +163,11 @@ void MediaRouterMojoImpl::RegisterMediaRouteProvider( |
callback.Run(instance_id_); |
ExecutePendingRequests(); |
wakeup_attempt_count_ = 0; |
+#if defined(OS_WIN) |
mark a. foltz
2016/03/25 23:14:16
Why only for Windows? Are we assuming that the MRP
btolsch
2016/03/26 10:53:59
Yes, the extension is also aware of whether it's o
|
+ if (should_enable_mdns_discovery_) { |
+ media_route_provider_->EnableMdnsDiscovery(); |
mark a. foltz
2016/03/25 23:14:16
There's a code path L149-158 where the event page
btolsch
2016/03/26 10:53:59
Doesn't this path get retried once the extension w
|
+ } |
+#endif |
} |
void MediaRouterMojoImpl::OnIssue(const interfaces::IssuePtr issue) { |
@@ -402,6 +413,17 @@ void MediaRouterMojoImpl::ClearIssue(const Issue::Id& issue_id) { |
issue_manager_.ClearIssue(issue_id); |
} |
+bool MediaRouterMojoImpl::should_enable_mdns_discovery() const { |
+ return should_enable_mdns_discovery_; |
+} |
+ |
+void MediaRouterMojoImpl::EnsureMdnsDiscoveryEnabled() { |
+ SetWakeReason(MediaRouteProviderWakeReason::ENABLE_MDNS_DISCOVERY); |
mark a. foltz
2016/03/25 23:14:16
I'm not sure what this method should do when shoul
btolsch
2016/03/26 10:53:58
I'm not preventing it from being called multiple t
|
+ RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoEnsureMdnsDiscoveryEnabled, |
+ base::Unretained(this))); |
+ should_enable_mdns_discovery_ = true; |
+} |
+ |
bool MediaRouterMojoImpl::RegisterMediaSinksObserver( |
MediaSinksObserver* observer) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
@@ -823,6 +845,11 @@ void MediaRouterMojoImpl::DoStopObservingMediaRoutes( |
routes_queries_.erase(source_id); |
} |
+void MediaRouterMojoImpl::DoEnsureMdnsDiscoveryEnabled() { |
+ DVLOG_WITH_INSTANCE(1) << "DoEnsureMdnsDiscoveryEnabled"; |
+ media_route_provider_->EnableMdnsDiscovery(); |
mark a. foltz
2016/03/25 23:14:16
Another task could have already called this.
btolsch
2016/03/26 10:53:59
See the comment above.
|
+} |
+ |
void MediaRouterMojoImpl::EnqueueTask(const base::Closure& closure) { |
pending_requests_.push_back(closure); |
if (pending_requests_.size() > kMaxPendingRequests) { |
@@ -930,4 +957,11 @@ void MediaRouterMojoImpl::ClearWakeReason() { |
current_wake_reason_ = MediaRouteProviderWakeReason::TOTAL_COUNT; |
} |
+void MediaRouterMojoImpl::EnableMdnsFromFirewallCheck( |
+ bool firewall_can_use_local_ports) { |
+ if (firewall_can_use_local_ports) { |
mark a. foltz
2016/03/25 23:14:16
Nit: Remove { }
btolsch
2016/03/26 10:53:58
Done.
|
+ EnsureMdnsDiscoveryEnabled(); |
+ } |
+} |
+ |
} // namespace media_router |