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/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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 std::unique_ptr<PresentationConnectionStateSubscription>> | 167 std::unique_ptr<PresentationConnectionStateSubscription>> |
168 connection_state_subscriptions_; | 168 connection_state_subscriptions_; |
169 std::unordered_map< | 169 std::unordered_map< |
170 MediaRoute::Id, | 170 MediaRoute::Id, |
171 std::unique_ptr<PresentationSessionMessagesObserver>> | 171 std::unique_ptr<PresentationSessionMessagesObserver>> |
172 session_messages_observers_; | 172 session_messages_observers_; |
173 | 173 |
174 RenderFrameHostId render_frame_host_id_; | 174 RenderFrameHostId render_frame_host_id_; |
175 | 175 |
176 // References to the owning WebContents, and the corresponding MediaRouter. | 176 // References to the owning WebContents, and the corresponding MediaRouter. |
177 const content::WebContents* web_contents_; | 177 content::WebContents* web_contents_; |
178 MediaRouter* router_; | 178 MediaRouter* router_; |
179 | 179 |
180 DelegateObserver* delegate_observer_; | 180 DelegateObserver* delegate_observer_; |
181 }; | 181 }; |
182 | 182 |
183 PresentationFrame::PresentationFrame( | 183 PresentationFrame::PresentationFrame( |
184 const RenderFrameHostId& render_frame_host_id, | 184 const RenderFrameHostId& render_frame_host_id, |
185 content::WebContents* web_contents, | 185 content::WebContents* web_contents, |
186 MediaRouter* router) | 186 MediaRouter* router) |
187 : render_frame_host_id_(render_frame_host_id), | 187 : render_frame_host_id_(render_frame_host_id), |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 250 } |
251 return false; | 251 return false; |
252 } | 252 } |
253 | 253 |
254 bool PresentationFrame::HasScreenAvailabilityListenerForTest( | 254 bool PresentationFrame::HasScreenAvailabilityListenerForTest( |
255 const MediaSource::Id& source_id) const { | 255 const MediaSource::Id& source_id) const { |
256 return url_to_sinks_observer_.find(source_id) != url_to_sinks_observer_.end(); | 256 return url_to_sinks_observer_.find(source_id) != url_to_sinks_observer_.end(); |
257 } | 257 } |
258 | 258 |
259 void PresentationFrame::Reset() { | 259 void PresentationFrame::Reset() { |
260 for (const auto& pid_route_id : presentation_id_to_route_id_) | 260 auto offscreen_presentation_manager = OffscreenPresentationManagerFactory:: |
| 261 GetOrCreateForControllerBrowserContext(web_contents_); |
| 262 |
| 263 for (const auto& pid_route_id : presentation_id_to_route_id_) { |
| 264 offscreen_presentation_manager->UnregisterOffscreenPresentationController( |
| 265 pid_route_id.first, render_frame_host_id_); |
261 router_->DetachRoute(pid_route_id.second); | 266 router_->DetachRoute(pid_route_id.second); |
| 267 } |
262 | 268 |
263 presentation_id_to_route_id_.clear(); | 269 presentation_id_to_route_id_.clear(); |
264 url_to_sinks_observer_.clear(); | 270 url_to_sinks_observer_.clear(); |
265 connection_state_subscriptions_.clear(); | 271 connection_state_subscriptions_.clear(); |
266 session_messages_observers_.clear(); | 272 session_messages_observers_.clear(); |
267 } | 273 } |
268 | 274 |
269 void PresentationFrame::RemoveConnection(const std::string& presentation_id, | 275 void PresentationFrame::RemoveConnection(const std::string& presentation_id, |
270 const MediaRoute::Id& route_id) { | 276 const MediaRoute::Id& route_id) { |
271 // Remove the presentation id mapping so a later call to Reset is a no-op. | 277 // Remove the presentation id mapping so a later call to Reset is a no-op. |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( | 985 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( |
980 int render_process_id, | 986 int render_process_id, |
981 int render_frame_id, | 987 int render_frame_id, |
982 const MediaSource::Id& source_id) const { | 988 const MediaSource::Id& source_id) const { |
983 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); | 989 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); |
984 return frame_manager_->HasScreenAvailabilityListenerForTest( | 990 return frame_manager_->HasScreenAvailabilityListenerForTest( |
985 render_frame_host_id, source_id); | 991 render_frame_host_id, source_id); |
986 } | 992 } |
987 | 993 |
988 } // namespace media_router | 994 } // namespace media_router |
OLD | NEW |