Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: chrome/browser/media/router/mojo/media_router_mojo_impl.cc

Issue 2973983002: Revert of [Media Router] Add CastMediaSinkService (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/media/router/mojo/media_router_mojo_impl.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/media/router/mojo/media_router_mojo_impl.h" 5 #include "chrome/browser/media/router/mojo/media_router_mojo_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/guid.h" 12 #include "base/guid.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "chrome/browser/media/router/discovery/dial/dial_media_sink_service_pro xy.h" 18 #include "chrome/browser/media/router/discovery/dial/dial_media_sink_service_pro xy.h"
19 #include "chrome/browser/media/router/discovery/mdns/cast_media_sink_service.h"
20 #include "chrome/browser/media/router/event_page_request_manager.h" 19 #include "chrome/browser/media/router/event_page_request_manager.h"
21 #include "chrome/browser/media/router/event_page_request_manager_factory.h" 20 #include "chrome/browser/media/router/event_page_request_manager_factory.h"
22 #include "chrome/browser/media/router/issues_observer.h" 21 #include "chrome/browser/media/router/issues_observer.h"
23 #include "chrome/browser/media/router/media_router_factory.h" 22 #include "chrome/browser/media/router/media_router_factory.h"
24 #include "chrome/browser/media/router/media_router_feature.h" 23 #include "chrome/browser/media/router/media_router_feature.h"
25 #include "chrome/browser/media/router/media_routes_observer.h" 24 #include "chrome/browser/media/router/media_routes_observer.h"
26 #include "chrome/browser/media/router/media_sinks_observer.h" 25 #include "chrome/browser/media/router/media_sinks_observer.h"
27 #include "chrome/browser/media/router/mojo/media_route_controller.h" 26 #include "chrome/browser/media/router/mojo/media_route_controller.h"
28 #include "chrome/browser/media/router/mojo/media_route_provider_util_win.h" 27 #include "chrome/browser/media/router/mojo/media_route_provider_util_win.h"
29 #include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h" 28 #include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 std::move(mojo_media_controller_request), 422 std::move(mojo_media_controller_request),
424 route_controller->BindObserverPtr()), 423 route_controller->BindObserverPtr()),
425 MediaRouteProviderWakeReason::CREATE_MEDIA_ROUTE_CONTROLLER); 424 MediaRouteProviderWakeReason::CREATE_MEDIA_ROUTE_CONTROLLER);
426 route_controllers_.emplace(route_id, route_controller.get()); 425 route_controllers_.emplace(route_id, route_controller.get());
427 return route_controller; 426 return route_controller;
428 } 427 }
429 428
430 void MediaRouterMojoImpl::ProvideSinks(const std::string& provider_name, 429 void MediaRouterMojoImpl::ProvideSinks(const std::string& provider_name,
431 std::vector<MediaSinkInternal> sinks) { 430 std::vector<MediaSinkInternal> sinks) {
432 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 431 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
433 DVLOG_WITH_INSTANCE(1) << "Provider [" << provider_name << "] found " 432 DVLOG_WITH_INSTANCE(1) << "OnDialMediaSinkDiscovered found " << sinks.size()
434 << sinks.size() << " devices..."; 433 << " devices...";
435 434
436 event_page_request_manager_->RunOrDefer( 435 event_page_request_manager_->RunOrDefer(
437 base::Bind(&MediaRouterMojoImpl::DoProvideSinks, 436 base::Bind(&MediaRouterMojoImpl::DoProvideSinks,
438 weak_factory_.GetWeakPtr(), provider_name, std::move(sinks)), 437 weak_factory_.GetWeakPtr(), provider_name, std::move(sinks)),
439 MediaRouteProviderWakeReason::PROVIDE_SINKS); 438 MediaRouteProviderWakeReason::PROVIDE_SINKS);
440 } 439 }
441 440
442 bool MediaRouterMojoImpl::RegisterMediaSinksObserver( 441 bool MediaRouterMojoImpl::RegisterMediaSinksObserver(
443 MediaSinksObserver* observer) { 442 MediaSinksObserver* observer) {
444 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 443 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 // The MRPM extension already turns on mDNS discovery for platforms other than 934 // The MRPM extension already turns on mDNS discovery for platforms other than
936 // Windows. It only relies on this signalling from MR on Windows to avoid 935 // Windows. It only relies on this signalling from MR on Windows to avoid
937 // triggering a firewall prompt out of the context of MR from the user's 936 // triggering a firewall prompt out of the context of MR from the user's
938 // perspective. This particular call reminds the extension to enable mDNS 937 // perspective. This particular call reminds the extension to enable mDNS
939 // discovery when it wakes up, has been upgraded, etc. 938 // discovery when it wakes up, has been upgraded, etc.
940 if (should_enable_mdns_discovery_) { 939 if (should_enable_mdns_discovery_) {
941 DoEnsureMdnsDiscoveryEnabled(); 940 DoEnsureMdnsDiscoveryEnabled();
942 } 941 }
943 #endif 942 #endif
944 943
945 StartDiscovery(); 944 if (media_router::DialLocalDiscoveryEnabled())
945 StartDiscovery();
946 } 946 }
947 947
948 #if defined(OS_WIN) 948 #if defined(OS_WIN)
949 void MediaRouterMojoImpl::EnsureMdnsDiscoveryEnabled() { 949 void MediaRouterMojoImpl::EnsureMdnsDiscoveryEnabled() {
950 if (is_mdns_enabled_) 950 if (is_mdns_enabled_)
951 return; 951 return;
952 952
953 event_page_request_manager_->RunOrDefer( 953 event_page_request_manager_->RunOrDefer(
954 base::BindOnce(&MediaRouterMojoImpl::DoEnsureMdnsDiscoveryEnabled, 954 base::BindOnce(&MediaRouterMojoImpl::DoEnsureMdnsDiscoveryEnabled,
955 weak_factory_.GetWeakPtr()), 955 weak_factory_.GetWeakPtr()),
(...skipping 13 matching lines...) Expand all
969 bool firewall_can_use_local_ports) { 969 bool firewall_can_use_local_ports) {
970 if (firewall_can_use_local_ports) 970 if (firewall_can_use_local_ports)
971 EnsureMdnsDiscoveryEnabled(); 971 EnsureMdnsDiscoveryEnabled();
972 } 972 }
973 #endif 973 #endif
974 974
975 void MediaRouterMojoImpl::StartDiscovery() { 975 void MediaRouterMojoImpl::StartDiscovery() {
976 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 976 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
977 DVLOG_WITH_INSTANCE(1) << "StartDiscovery"; 977 DVLOG_WITH_INSTANCE(1) << "StartDiscovery";
978 978
979 if (media_router::DialLocalDiscoveryEnabled()) { 979 if (!dial_media_sink_service_proxy_) {
980 if (!dial_media_sink_service_proxy_) { 980 dial_media_sink_service_proxy_ = new DialMediaSinkServiceProxy(
981 dial_media_sink_service_proxy_ = new DialMediaSinkServiceProxy( 981 base::Bind(&MediaRouterMojoImpl::ProvideSinks,
982 base::Bind(&MediaRouterMojoImpl::ProvideSinks, 982 weak_factory_.GetWeakPtr(), "dial"),
983 weak_factory_.GetWeakPtr(), "dial"), 983 context_);
984 context_);
985 }
986 dial_media_sink_service_proxy_->Start();
987 } 984 }
988 985
989 if (media_router::CastDiscoveryEnabled()) { 986 dial_media_sink_service_proxy_->Start();
990 if (!cast_media_sink_service_) {
991 cast_media_sink_service_ = new CastMediaSinkService(
992 base::Bind(&MediaRouterMojoImpl::ProvideSinks,
993 weak_factory_.GetWeakPtr(), "cast"),
994 context_);
995 }
996 cast_media_sink_service_->Start();
997 }
998 } 987 }
999 988
1000 void MediaRouterMojoImpl::UpdateMediaSinks( 989 void MediaRouterMojoImpl::UpdateMediaSinks(
1001 const MediaSource::Id& source_id) { 990 const MediaSource::Id& source_id) {
1002 event_page_request_manager_->RunOrDefer( 991 event_page_request_manager_->RunOrDefer(
1003 base::BindOnce(&MediaRouterMojoImpl::DoUpdateMediaSinks, 992 base::BindOnce(&MediaRouterMojoImpl::DoUpdateMediaSinks,
1004 weak_factory_.GetWeakPtr(), source_id), 993 weak_factory_.GetWeakPtr(), source_id),
1005 MediaRouteProviderWakeReason::UPDATE_MEDIA_SINKS); 994 MediaRouteProviderWakeReason::UPDATE_MEDIA_SINKS);
1006 } 995 }
1007 996
(...skipping 18 matching lines...) Expand all
1026 1015
1027 void MediaRouterMojoImpl::OnMediaControllerCreated( 1016 void MediaRouterMojoImpl::OnMediaControllerCreated(
1028 const MediaRoute::Id& route_id, 1017 const MediaRoute::Id& route_id,
1029 bool success) { 1018 bool success) {
1030 DVLOG_WITH_INSTANCE(1) << "OnMediaControllerCreated: " << route_id 1019 DVLOG_WITH_INSTANCE(1) << "OnMediaControllerCreated: " << route_id
1031 << (success ? " was successful." : " failed."); 1020 << (success ? " was successful." : " failed.");
1032 MediaRouterMojoMetrics::RecordMediaRouteControllerCreationResult(success); 1021 MediaRouterMojoMetrics::RecordMediaRouteControllerCreationResult(success);
1033 } 1022 }
1034 1023
1035 } // namespace media_router 1024 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/media/router/mojo/media_router_mojo_impl.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698