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

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

Issue 2714783002: [Presentation API] (browser side) Implement reconnect() for 1-UA mode (Closed)
Patch Set: resolve code review comments from Mark 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/offscreen_presentation_manager.h" 5 #include "chrome/browser/media/router/offscreen_presentation_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/public/browser/render_frame_host.h" 10 #include "content/public/browser/render_frame_host.h"
(...skipping 21 matching lines...) Expand all
32 .first; 32 .first;
33 } 33 }
34 return it->second.get(); 34 return it->second.get();
35 } 35 }
36 36
37 void OffscreenPresentationManager::RegisterOffscreenPresentationController( 37 void OffscreenPresentationManager::RegisterOffscreenPresentationController(
38 const std::string& presentation_id, 38 const std::string& presentation_id,
39 const GURL& presentation_url, 39 const GURL& presentation_url,
40 const RenderFrameHostId& render_frame_host_id, 40 const RenderFrameHostId& render_frame_host_id,
41 content::PresentationConnectionPtr controller_connection_ptr, 41 content::PresentationConnectionPtr controller_connection_ptr,
42 content::PresentationConnectionRequest receiver_connection_request) { 42 content::PresentationConnectionRequest receiver_connection_request,
43 const MediaRoute& route) {
43 DVLOG(2) << __FUNCTION__ << " [presentation_id]: " << presentation_id 44 DVLOG(2) << __FUNCTION__ << " [presentation_id]: " << presentation_id
44 << ", [render_frame_host_id]: " << render_frame_host_id.second; 45 << ", [render_frame_host_id]: " << render_frame_host_id.second;
45 DCHECK(thread_checker_.CalledOnValidThread()); 46 DCHECK(thread_checker_.CalledOnValidThread());
46 47
47 auto* presentation = 48 auto* presentation =
48 GetOrCreateOffscreenPresentation(presentation_id, presentation_url); 49 GetOrCreateOffscreenPresentation(presentation_id, presentation_url);
49 presentation->RegisterController(render_frame_host_id, 50 presentation->RegisterController(
50 std::move(controller_connection_ptr), 51 render_frame_host_id, std::move(controller_connection_ptr),
51 std::move(receiver_connection_request)); 52 std::move(receiver_connection_request), route);
52 } 53 }
53 54
54 void OffscreenPresentationManager::UnregisterOffscreenPresentationController( 55 void OffscreenPresentationManager::UnregisterOffscreenPresentationController(
55 const std::string& presentation_id, 56 const std::string& presentation_id,
56 const RenderFrameHostId& render_frame_host_id) { 57 const RenderFrameHostId& render_frame_host_id) {
57 DVLOG(2) << __FUNCTION__ << " [presentation_id]: " << presentation_id 58 DVLOG(2) << __FUNCTION__ << " [presentation_id]: " << presentation_id
58 << ", [render_frame_host_id]: " << render_frame_host_id.second; 59 << ", [render_frame_host_id]: " << render_frame_host_id.second;
59 DCHECK(thread_checker_.CalledOnValidThread()); 60 DCHECK(thread_checker_.CalledOnValidThread());
60 61
61 auto it = offscreen_presentations_.find(presentation_id); 62 auto it = offscreen_presentations_.find(presentation_id);
(...skipping 21 matching lines...) Expand all
83 } 84 }
84 85
85 void OffscreenPresentationManager::OnOffscreenPresentationReceiverTerminated( 86 void OffscreenPresentationManager::OnOffscreenPresentationReceiverTerminated(
86 const std::string& presentation_id) { 87 const std::string& presentation_id) {
87 DVLOG(2) << __FUNCTION__ << " [presentation_id]: " << presentation_id; 88 DVLOG(2) << __FUNCTION__ << " [presentation_id]: " << presentation_id;
88 DCHECK(thread_checker_.CalledOnValidThread()); 89 DCHECK(thread_checker_.CalledOnValidThread());
89 90
90 offscreen_presentations_.erase(presentation_id); 91 offscreen_presentations_.erase(presentation_id);
91 } 92 }
92 93
94 bool OffscreenPresentationManager::IsOffscreenPresentation(
95 const std::string& presentation_id) {
96 return base::ContainsKey(offscreen_presentations_, presentation_id);
97 }
98
99 const MediaRoute* OffscreenPresentationManager::GetRoute(
100 const std::string& presentation_id) {
101 auto it = offscreen_presentations_.find(presentation_id);
102 return (it != offscreen_presentations_.end() &&
103 it->second->route_.has_value())
104 ? &(it->second->route_.value())
105 : nullptr;
106 }
107
93 // OffscreenPresentation implementation. 108 // OffscreenPresentation implementation.
94 OffscreenPresentationManager::OffscreenPresentation::OffscreenPresentation( 109 OffscreenPresentationManager::OffscreenPresentation::OffscreenPresentation(
95 const std::string& presentation_id, 110 const std::string& presentation_id,
96 const GURL& presentation_url) 111 const GURL& presentation_url)
97 : presentation_id_(presentation_id), presentation_url_(presentation_url) {} 112 : presentation_id_(presentation_id), presentation_url_(presentation_url) {}
98 113
99 OffscreenPresentationManager::OffscreenPresentation::~OffscreenPresentation() {} 114 OffscreenPresentationManager::OffscreenPresentation::~OffscreenPresentation() {}
100 115
101 void OffscreenPresentationManager::OffscreenPresentation::RegisterController( 116 void OffscreenPresentationManager::OffscreenPresentation::RegisterController(
102 const RenderFrameHostId& render_frame_host_id, 117 const RenderFrameHostId& render_frame_host_id,
103 content::PresentationConnectionPtr controller_connection_ptr, 118 content::PresentationConnectionPtr controller_connection_ptr,
104 content::PresentationConnectionRequest receiver_connection_request) { 119 content::PresentationConnectionRequest receiver_connection_request,
120 const MediaRoute& route) {
105 if (!receiver_callback_.is_null()) { 121 if (!receiver_callback_.is_null()) {
106 receiver_callback_.Run( 122 receiver_callback_.Run(
107 content::PresentationSessionInfo(presentation_url_, presentation_id_), 123 content::PresentationSessionInfo(presentation_url_, presentation_id_),
108 std::move(controller_connection_ptr), 124 std::move(controller_connection_ptr),
109 std::move(receiver_connection_request)); 125 std::move(receiver_connection_request));
110 } else { 126 } else {
111 pending_controllers_.insert(std::make_pair( 127 pending_controllers_.insert(std::make_pair(
112 render_frame_host_id, base::MakeUnique<ControllerConnection>( 128 render_frame_host_id, base::MakeUnique<ControllerConnection>(
113 std::move(controller_connection_ptr), 129 std::move(controller_connection_ptr),
114 std::move(receiver_connection_request)))); 130 std::move(receiver_connection_request))));
115 } 131 }
132
133 route_ = route;
116 } 134 }
117 135
118 void OffscreenPresentationManager::OffscreenPresentation::UnregisterController( 136 void OffscreenPresentationManager::OffscreenPresentation::UnregisterController(
119 const RenderFrameHostId& render_frame_host_id) { 137 const RenderFrameHostId& render_frame_host_id) {
120 pending_controllers_.erase(render_frame_host_id); 138 pending_controllers_.erase(render_frame_host_id);
121 } 139 }
122 140
123 void OffscreenPresentationManager::OffscreenPresentation::RegisterReceiver( 141 void OffscreenPresentationManager::OffscreenPresentation::RegisterReceiver(
124 const content::ReceiverConnectionAvailableCallback& receiver_callback) { 142 const content::ReceiverConnectionAvailableCallback& receiver_callback) {
125 DCHECK(receiver_callback_.is_null()); 143 DCHECK(receiver_callback_.is_null());
(...skipping 16 matching lines...) Expand all
142 ControllerConnection( 160 ControllerConnection(
143 content::PresentationConnectionPtr controller_connection_ptr, 161 content::PresentationConnectionPtr controller_connection_ptr,
144 content::PresentationConnectionRequest receiver_connection_request) 162 content::PresentationConnectionRequest receiver_connection_request)
145 : controller_connection_ptr(std::move(controller_connection_ptr)), 163 : controller_connection_ptr(std::move(controller_connection_ptr)),
146 receiver_connection_request(std::move(receiver_connection_request)) {} 164 receiver_connection_request(std::move(receiver_connection_request)) {}
147 165
148 OffscreenPresentationManager::OffscreenPresentation::ControllerConnection:: 166 OffscreenPresentationManager::OffscreenPresentation::ControllerConnection::
149 ~ControllerConnection() {} 167 ~ControllerConnection() {}
150 168
151 } // namespace media_router 169 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698