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

Side by Side Diff: chrome/browser/media/router/presentation_service_delegate_impl.cc

Issue 2731043002: [Media Router] Add a presentation id to MediaRoute mapping in the MR (Closed)
Patch Set: Created 3 years, 9 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
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/presentation_service_delegate_impl.h" 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <unordered_map> 8 #include <unordered_map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 206 }
207 207
208 PresentationFrame::~PresentationFrame() { 208 PresentationFrame::~PresentationFrame() {
209 } 209 }
210 210
211 void PresentationFrame::OnPresentationSessionStarted( 211 void PresentationFrame::OnPresentationSessionStarted(
212 const content::PresentationSessionInfo& session, 212 const content::PresentationSessionInfo& session,
213 const MediaRoute& route) { 213 const MediaRoute& route) {
214 presentation_id_to_route_.insert( 214 presentation_id_to_route_.insert(
215 std::make_pair(session.presentation_id, route)); 215 std::make_pair(session.presentation_id, route));
216 router_->RegisterPresentationRoute(session.presentation_id, route);
216 } 217 }
217 218
218 const MediaRoute::Id PresentationFrame::GetRouteId( 219 const MediaRoute::Id PresentationFrame::GetRouteId(
219 const std::string& presentation_id) const { 220 const std::string& presentation_id) const {
220 auto it = presentation_id_to_route_.find(presentation_id); 221 auto it = presentation_id_to_route_.find(presentation_id);
221 return it != presentation_id_to_route_.end() ? it->second.media_route_id() 222 return it != presentation_id_to_route_.end() ? it->second.media_route_id()
222 : ""; 223 : "";
223 } 224 }
224 225
225 bool PresentationFrame::SetScreenAvailabilityListener( 226 bool PresentationFrame::SetScreenAvailabilityListener(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 auto* offscreen_presentation_manager = 264 auto* offscreen_presentation_manager =
264 OffscreenPresentationManagerFactory::GetOrCreateForWebContents( 265 OffscreenPresentationManagerFactory::GetOrCreateForWebContents(
265 web_contents_); 266 web_contents_);
266 267
267 for (const auto& pid_route : presentation_id_to_route_) { 268 for (const auto& pid_route : presentation_id_to_route_) {
268 if (IsOffscreenPresentation(pid_route.first)) { 269 if (IsOffscreenPresentation(pid_route.first)) {
269 offscreen_presentation_manager->UnregisterOffscreenPresentationController( 270 offscreen_presentation_manager->UnregisterOffscreenPresentationController(
270 pid_route.first, render_frame_host_id_); 271 pid_route.first, render_frame_host_id_);
271 } 272 }
272 router_->DetachRoute(pid_route.second.media_route_id()); 273 router_->DetachRoute(pid_route.second.media_route_id());
274 router_->UnregisterPresentationRoute(pid_route.first);
273 } 275 }
274 276
275 presentation_id_to_route_.clear(); 277 presentation_id_to_route_.clear();
276 url_to_sinks_observer_.clear(); 278 url_to_sinks_observer_.clear();
277 connection_state_subscriptions_.clear(); 279 connection_state_subscriptions_.clear();
278 session_messages_observers_.clear(); 280 session_messages_observers_.clear();
279 browser_connection_proxies_.clear(); 281 browser_connection_proxies_.clear();
280 } 282 }
281 283
282 void PresentationFrame::RemoveConnection(const std::string& presentation_id, 284 void PresentationFrame::RemoveConnection(const std::string& presentation_id,
283 const MediaRoute::Id& route_id) { 285 const MediaRoute::Id& route_id) {
284 // Remove the presentation id mapping so a later call to Reset is a no-op. 286 // Remove the presentation id mapping so a later call to Reset is a no-op.
285 presentation_id_to_route_.erase(presentation_id); 287 presentation_id_to_route_.erase(presentation_id);
286 288
289 router_->UnregisterPresentationRoute(presentation_id);
290
287 // We no longer need to observe route messages. 291 // We no longer need to observe route messages.
288 session_messages_observers_.erase(route_id); 292 session_messages_observers_.erase(route_id);
289 293
290 browser_connection_proxies_.erase(route_id); 294 browser_connection_proxies_.erase(route_id);
291 // We keep the PresentationConnectionStateChangedCallback registered with MR 295 // We keep the PresentationConnectionStateChangedCallback registered with MR
292 // so the MRP can tell us when terminate() completed. 296 // so the MRP can tell us when terminate() completed.
293 } 297 }
294 298
295 void PresentationFrame::ListenForConnectionStateChange( 299 void PresentationFrame::ListenForConnectionStateChange(
296 const content::PresentationSessionInfo& connection, 300 const content::PresentationSessionInfo& connection,
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 const base::ListValue* origins = 1058 const base::ListValue* origins =
1055 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) 1059 Profile::FromBrowserContext(web_contents_->GetBrowserContext())
1056 ->GetPrefs() 1060 ->GetPrefs()
1057 ->GetList(prefs::kMediaRouterTabMirroringSources); 1061 ->GetList(prefs::kMediaRouterTabMirroringSources);
1058 return origins && 1062 return origins &&
1059 origins->Find(base::StringValue(origin.Serialize())) != origins->end(); 1063 origins->Find(base::StringValue(origin.Serialize())) != origins->end();
1060 } 1064 }
1061 #endif // !defined(OS_ANDROID) 1065 #endif // !defined(OS_ANDROID)
1062 1066
1063 } // namespace media_router 1067 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698