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 #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 |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "chrome/browser/media/router/media_router_feature.h" | 21 #include "chrome/browser/media/router/media_router_feature.h" |
22 #include "chrome/browser/media/router/media_routes_observer.h" | 22 #include "chrome/browser/media/router/media_routes_observer.h" |
23 #include "chrome/browser/media/router/media_sinks_observer.h" | 23 #include "chrome/browser/media/router/media_sinks_observer.h" |
24 #include "chrome/browser/media/router/mojo/media_route_controller.h" | 24 #include "chrome/browser/media/router/mojo/media_route_controller.h" |
25 #include "chrome/browser/media/router/mojo/media_route_provider_util_win.h" | 25 #include "chrome/browser/media/router/mojo/media_route_provider_util_win.h" |
26 #include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h" | 26 #include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h" |
27 #include "chrome/browser/media/router/route_message_observer.h" | 27 #include "chrome/browser/media/router/route_message_observer.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/sessions/session_tab_helper.h" | 29 #include "chrome/browser/sessions/session_tab_helper.h" |
30 #include "chrome/common/media_router/media_source_helper.h" | 30 #include "chrome/common/media_router/media_source_helper.h" |
31 #include "chrome/common/media_router/mojo/media_router.mojom.h" | |
31 #include "chrome/common/media_router/route_message.h" | 32 #include "chrome/common/media_router/route_message.h" |
32 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
33 #include "extensions/browser/process_manager.h" | 34 #include "extensions/browser/process_manager.h" |
34 | 35 |
35 #define DVLOG_WITH_INSTANCE(level) \ | 36 #define DVLOG_WITH_INSTANCE(level) \ |
36 DVLOG(level) << "MR #" << instance_id_ << ": " | 37 DVLOG(level) << "MR #" << instance_id_ << ": " |
37 | 38 |
38 #define DLOG_WITH_INSTANCE(level) DLOG(level) << "MR #" << instance_id_ << ": " | 39 #define DLOG_WITH_INSTANCE(level) DLOG(level) << "MR #" << instance_id_ << ": " |
39 | 40 |
40 namespace media_router { | 41 namespace media_router { |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1123 } | 1124 } |
1124 | 1125 |
1125 void MediaRouterMojoImpl::OnMediaControllerCreated( | 1126 void MediaRouterMojoImpl::OnMediaControllerCreated( |
1126 const MediaRoute::Id& route_id, | 1127 const MediaRoute::Id& route_id, |
1127 bool success) { | 1128 bool success) { |
1128 DVLOG_WITH_INSTANCE(1) << "OnMediaControllerCreated: " << route_id | 1129 DVLOG_WITH_INSTANCE(1) << "OnMediaControllerCreated: " << route_id |
1129 << (success ? " was successful." : " failed."); | 1130 << (success ? " was successful." : " failed."); |
1130 MediaRouterMojoMetrics::RecordMediaRouteControllerCreationResult(success); | 1131 MediaRouterMojoMetrics::RecordMediaRouteControllerCreationResult(success); |
1131 } | 1132 } |
1132 | 1133 |
1134 void MediaRouterMojoImpl::RegisterRemotingSource( | |
imcheng
2017/06/22 01:13:27
It seems this logic could actually go into MediaRo
xjz
2017/06/23 19:02:41
Done.
| |
1135 int32_t tab_id, | |
1136 CastRemotingConnector* remoting_source) { | |
1137 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
1138 DVLOG_WITH_INSTANCE(1) << "RegisterRemotingSource " << tab_id; | |
1139 | |
1140 auto it = remoting_sources_.find(tab_id); | |
1141 if (it != remoting_sources_.end()) { | |
1142 DCHECK(remoting_source == it->second); | |
1143 return; | |
1144 } | |
1145 remoting_sources_.emplace(tab_id, std::move(remoting_source)); | |
1146 } | |
1147 | |
1148 void MediaRouterMojoImpl::UnRegisterRemotingSource( | |
1149 int32_t tab_id, | |
1150 CastRemotingConnector* remoting_source) { | |
imcheng
2017/06/22 01:13:27
I'm not sure if you need to pass in remoting_sourc
xjz
2017/06/23 19:02:41
Removed.
| |
1151 auto it = remoting_sources_.find(tab_id); | |
1152 DCHECK(it != remoting_sources_.end()); | |
1153 DCHECK(it->second == remoting_source); | |
1154 remoting_sources_.erase(it); | |
1155 } | |
1156 | |
1157 void MediaRouterMojoImpl::OnMediaRemoterCreated( | |
1158 int32_t tab_id, | |
1159 media::mojom::MirrorServiceRemoterPtr remoter, | |
1160 media::mojom::MirrorServiceRemotingSourceRequest source_request) { | |
1161 DVLOG_WITH_INSTANCE(1) << __func__ << ": tab_id = " << tab_id; | |
1162 | |
1163 auto it = remoting_sources_.find(tab_id); | |
1164 if (it == remoting_sources_.end()) { | |
1165 LOG(WARNING) << __func__ | |
1166 << ": No registered remoting source for tab_id = " << tab_id; | |
1167 return; | |
1168 } | |
1169 | |
1170 CastRemotingConnector* connector = it->second; | |
1171 connector->ConnectToService(std::move(source_request), std::move(remoter)); | |
1172 } | |
1173 | |
1133 } // namespace media_router | 1174 } // namespace media_router |
OLD | NEW |