| 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 | 8 |
| 9 #include "base/containers/scoped_ptr_hash_map.h" | 9 #include "base/containers/scoped_ptr_hash_map.h" |
| 10 #include "base/containers/small_map.h" | 10 #include "base/containers/small_map.h" |
| 11 #include "base/guid.h" | 11 #include "base/guid.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "chrome/browser/media/router/create_presentation_connection_request.h" | 14 #include "chrome/browser/media/router/create_presentation_connection_request.h" |
| 15 #include "chrome/browser/media/router/media_route.h" | 15 #include "chrome/browser/media/router/media_route.h" |
| 16 #include "chrome/browser/media/router/media_router.h" | 16 #include "chrome/browser/media/router/media_router.h" |
| 17 #include "chrome/browser/media/router/media_router_dialog_controller.h" | 17 #include "chrome/browser/media/router/media_router_dialog_controller.h" |
| 18 #include "chrome/browser/media/router/media_router_factory.h" | 18 #include "chrome/browser/media/router/media_router_factory.h" |
| 19 #include "chrome/browser/media/router/media_sink.h" | 19 #include "chrome/browser/media/router/media_sink.h" |
| 20 #include "chrome/browser/media/router/media_source_helper.h" | 20 #include "chrome/browser/media/router/media_source_helper.h" |
| 21 #include "chrome/browser/media/router/presentation_connection_state_observer.h" |
| 21 #include "chrome/browser/media/router/presentation_media_sinks_observer.h" | 22 #include "chrome/browser/media/router/presentation_media_sinks_observer.h" |
| 22 #include "chrome/browser/media/router/presentation_session_messages_observer.h" | 23 #include "chrome/browser/media/router/presentation_session_messages_observer.h" |
| 23 #include "chrome/browser/media/router/presentation_session_state_observer.h" | |
| 24 #include "chrome/browser/sessions/session_tab_helper.h" | 24 #include "chrome/browser/sessions/session_tab_helper.h" |
| 25 #include "content/public/browser/presentation_screen_availability_listener.h" | 25 #include "content/public/browser/presentation_screen_availability_listener.h" |
| 26 #include "content/public/browser/presentation_session.h" | 26 #include "content/public/browser/presentation_session.h" |
| 27 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
| 28 #include "content/public/browser/render_process_host.h" | 28 #include "content/public/browser/render_process_host.h" |
| 29 | 29 |
| 30 DEFINE_WEB_CONTENTS_USER_DATA_KEY( | 30 DEFINE_WEB_CONTENTS_USER_DATA_KEY( |
| 31 media_router::PresentationServiceDelegateImpl); | 31 media_router::PresentationServiceDelegateImpl); |
| 32 | 32 |
| 33 using content::RenderFrameHost; | 33 using content::RenderFrameHost; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 ~PresentationFrame(); | 68 ~PresentationFrame(); |
| 69 | 69 |
| 70 // Mirror corresponding APIs in PresentationServiceDelegateImpl. | 70 // Mirror corresponding APIs in PresentationServiceDelegateImpl. |
| 71 bool SetScreenAvailabilityListener( | 71 bool SetScreenAvailabilityListener( |
| 72 content::PresentationScreenAvailabilityListener* listener); | 72 content::PresentationScreenAvailabilityListener* listener); |
| 73 bool RemoveScreenAvailabilityListener( | 73 bool RemoveScreenAvailabilityListener( |
| 74 content::PresentationScreenAvailabilityListener* listener); | 74 content::PresentationScreenAvailabilityListener* listener); |
| 75 bool HasScreenAvailabilityListenerForTest( | 75 bool HasScreenAvailabilityListenerForTest( |
| 76 const MediaSource::Id& source_id) const; | 76 const MediaSource::Id& source_id) const; |
| 77 std::string GetDefaultPresentationId() const; | 77 std::string GetDefaultPresentationId() const; |
| 78 void ListenForSessionStateChange( | 78 void ListenForConnectionStateChange( |
| 79 const content::SessionStateChangedCallback& state_changed_cb); | 79 const content::PresentationSessionInfo& connection, |
| 80 const content::PresentationConnectionStateChangedCallback& |
| 81 state_changed_cb); |
| 80 void ListenForSessionMessages( | 82 void ListenForSessionMessages( |
| 81 const content::PresentationSessionInfo& session, | 83 const content::PresentationSessionInfo& session, |
| 82 const content::PresentationSessionMessageCallback& message_cb); | 84 const content::PresentationSessionMessageCallback& message_cb); |
| 83 | 85 |
| 84 void Reset(); | 86 void Reset(); |
| 85 | 87 |
| 86 const MediaRoute::Id GetRouteId(const std::string& presentation_id) const; | 88 const MediaRoute::Id GetRouteId(const std::string& presentation_id) const; |
| 87 const std::vector<MediaRoute::Id> GetRouteIds() const; | 89 const std::vector<MediaRoute::Id> GetRouteIds() const; |
| 88 void OnPresentationSessionClosed(const std::string& presentation_id); | |
| 89 | 90 |
| 90 void OnPresentationSessionStarted( | 91 void OnPresentationSessionStarted( |
| 91 const content::PresentationSessionInfo& session, | 92 const content::PresentationSessionInfo& session, |
| 92 const MediaRoute::Id& route_id); | 93 const MediaRoute::Id& route_id); |
| 93 void OnPresentationServiceDelegateDestroyed() const; | 94 void OnPresentationServiceDelegateDestroyed() const; |
| 94 | 95 |
| 95 void set_delegate_observer(DelegateObserver* observer) { | 96 void set_delegate_observer(DelegateObserver* observer) { |
| 96 delegate_observer_ = observer; | 97 delegate_observer_ = observer; |
| 97 } | 98 } |
| 98 | 99 |
| 99 private: | 100 private: |
| 100 MediaSource GetMediaSourceFromListener( | 101 MediaSource GetMediaSourceFromListener( |
| 101 content::PresentationScreenAvailabilityListener* listener) const; | 102 content::PresentationScreenAvailabilityListener* listener) const; |
| 102 MediaRouteIdToPresentationSessionMapping route_id_to_presentation_; | |
| 103 base::SmallMap<std::map<std::string, MediaRoute::Id>> | 103 base::SmallMap<std::map<std::string, MediaRoute::Id>> |
| 104 presentation_id_to_route_id_; | 104 presentation_id_to_route_id_; |
| 105 scoped_ptr<PresentationMediaSinksObserver> sinks_observer_; | 105 scoped_ptr<PresentationMediaSinksObserver> sinks_observer_; |
| 106 scoped_ptr<PresentationSessionStateObserver> session_state_observer_; | 106 ScopedVector<PresentationConnectionStateObserver> connection_state_observers_; |
| 107 ScopedVector<PresentationSessionMessagesObserver> session_messages_observers_; | 107 ScopedVector<PresentationSessionMessagesObserver> session_messages_observers_; |
| 108 | 108 |
| 109 // References to the owning WebContents, and the corresponding MediaRouter. | 109 // References to the owning WebContents, and the corresponding MediaRouter. |
| 110 const content::WebContents* web_contents_; | 110 const content::WebContents* web_contents_; |
| 111 MediaRouter* router_; | 111 MediaRouter* router_; |
| 112 | 112 |
| 113 DelegateObserver* delegate_observer_; | 113 DelegateObserver* delegate_observer_; |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 PresentationFrame::PresentationFrame(content::WebContents* web_contents, | 116 PresentationFrame::PresentationFrame(content::WebContents* web_contents, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 127 | 127 |
| 128 void PresentationFrame::OnPresentationServiceDelegateDestroyed() const { | 128 void PresentationFrame::OnPresentationServiceDelegateDestroyed() const { |
| 129 if (delegate_observer_) | 129 if (delegate_observer_) |
| 130 delegate_observer_->OnDelegateDestroyed(); | 130 delegate_observer_->OnDelegateDestroyed(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void PresentationFrame::OnPresentationSessionStarted( | 133 void PresentationFrame::OnPresentationSessionStarted( |
| 134 const content::PresentationSessionInfo& session, | 134 const content::PresentationSessionInfo& session, |
| 135 const MediaRoute::Id& route_id) { | 135 const MediaRoute::Id& route_id) { |
| 136 presentation_id_to_route_id_[session.presentation_id] = route_id; | 136 presentation_id_to_route_id_[session.presentation_id] = route_id; |
| 137 route_id_to_presentation_.Add(route_id, session); | |
| 138 if (session_state_observer_) | |
| 139 session_state_observer_->OnPresentationSessionConnected(route_id); | |
| 140 } | |
| 141 | |
| 142 void PresentationFrame::OnPresentationSessionClosed( | |
| 143 const std::string& presentation_id) { | |
| 144 auto it = presentation_id_to_route_id_.find(presentation_id); | |
| 145 if (it != presentation_id_to_route_id_.end()) { | |
| 146 route_id_to_presentation_.Remove(it->second); | |
| 147 presentation_id_to_route_id_.erase(it); | |
| 148 } | |
| 149 // TODO(imcheng): Notify |session_state_observer_|? | |
| 150 } | 137 } |
| 151 | 138 |
| 152 const MediaRoute::Id PresentationFrame::GetRouteId( | 139 const MediaRoute::Id PresentationFrame::GetRouteId( |
| 153 const std::string& presentation_id) const { | 140 const std::string& presentation_id) const { |
| 154 auto it = presentation_id_to_route_id_.find(presentation_id); | 141 auto it = presentation_id_to_route_id_.find(presentation_id); |
| 155 return it != presentation_id_to_route_id_.end() ? it->second : ""; | 142 return it != presentation_id_to_route_id_.end() ? it->second : ""; |
| 156 } | 143 } |
| 157 | 144 |
| 158 const std::vector<MediaRoute::Id> PresentationFrame::GetRouteIds() const { | 145 const std::vector<MediaRoute::Id> PresentationFrame::GetRouteIds() const { |
| 159 std::vector<MediaRoute::Id> route_ids; | 146 std::vector<MediaRoute::Id> route_ids; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 188 } | 175 } |
| 189 return false; | 176 return false; |
| 190 } | 177 } |
| 191 | 178 |
| 192 bool PresentationFrame::HasScreenAvailabilityListenerForTest( | 179 bool PresentationFrame::HasScreenAvailabilityListenerForTest( |
| 193 const MediaSource::Id& source_id) const { | 180 const MediaSource::Id& source_id) const { |
| 194 return sinks_observer_ && sinks_observer_->source().id() == source_id; | 181 return sinks_observer_ && sinks_observer_->source().id() == source_id; |
| 195 } | 182 } |
| 196 | 183 |
| 197 void PresentationFrame::Reset() { | 184 void PresentationFrame::Reset() { |
| 198 route_id_to_presentation_.Clear(); | |
| 199 | |
| 200 for (const auto& pid_route_id : presentation_id_to_route_id_) | 185 for (const auto& pid_route_id : presentation_id_to_route_id_) |
| 201 router_->OnPresentationSessionDetached(pid_route_id.second); | 186 router_->OnPresentationSessionDetached(pid_route_id.second); |
| 202 | 187 |
| 203 presentation_id_to_route_id_.clear(); | 188 presentation_id_to_route_id_.clear(); |
| 204 sinks_observer_.reset(); | 189 sinks_observer_.reset(); |
| 205 if (session_state_observer_) | 190 connection_state_observers_.clear(); |
| 206 session_state_observer_->Reset(); | |
| 207 | |
| 208 session_messages_observers_.clear(); | 191 session_messages_observers_.clear(); |
| 209 } | 192 } |
| 210 | 193 |
| 211 void PresentationFrame::ListenForSessionStateChange( | 194 void PresentationFrame::ListenForConnectionStateChange( |
| 212 const content::SessionStateChangedCallback& state_changed_cb) { | 195 const content::PresentationSessionInfo& connection, |
| 213 CHECK(!session_state_observer_.get()); | 196 const content::PresentationConnectionStateChangedCallback& |
| 214 session_state_observer_.reset(new PresentationSessionStateObserver( | 197 state_changed_cb) { |
| 215 state_changed_cb, &route_id_to_presentation_, router_)); | 198 auto it = presentation_id_to_route_id_.find(connection.presentation_id); |
| 199 if (it == presentation_id_to_route_id_.end()) { |
| 200 DLOG(ERROR) << __FUNCTION__ << "route id not found for presentation: " |
| 201 << connection.presentation_id; |
| 202 return; |
| 203 } |
| 204 |
| 205 connection_state_observers_.push_back(new PresentationConnectionStateObserver( |
| 206 state_changed_cb, connection, it->second, router_)); |
| 216 } | 207 } |
| 217 | 208 |
| 218 void PresentationFrame::ListenForSessionMessages( | 209 void PresentationFrame::ListenForSessionMessages( |
| 219 const content::PresentationSessionInfo& session, | 210 const content::PresentationSessionInfo& session, |
| 220 const content::PresentationSessionMessageCallback& message_cb) { | 211 const content::PresentationSessionMessageCallback& message_cb) { |
| 221 auto it = presentation_id_to_route_id_.find(session.presentation_id); | 212 auto it = presentation_id_to_route_id_.find(session.presentation_id); |
| 222 if (it == presentation_id_to_route_id_.end()) { | 213 if (it == presentation_id_to_route_id_.end()) { |
| 223 DVLOG(2) << "ListenForSessionMessages: no route for " | 214 DVLOG(2) << "ListenForSessionMessages: no route for " |
| 224 << session.presentation_id; | 215 << session.presentation_id; |
| 225 return; | 216 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 245 MediaRouter* router); | 236 MediaRouter* router); |
| 246 ~PresentationFrameManager(); | 237 ~PresentationFrameManager(); |
| 247 | 238 |
| 248 // Mirror corresponding APIs in PresentationServiceDelegateImpl. | 239 // Mirror corresponding APIs in PresentationServiceDelegateImpl. |
| 249 bool SetScreenAvailabilityListener( | 240 bool SetScreenAvailabilityListener( |
| 250 const RenderFrameHostId& render_frame_host_id, | 241 const RenderFrameHostId& render_frame_host_id, |
| 251 content::PresentationScreenAvailabilityListener* listener); | 242 content::PresentationScreenAvailabilityListener* listener); |
| 252 bool RemoveScreenAvailabilityListener( | 243 bool RemoveScreenAvailabilityListener( |
| 253 const RenderFrameHostId& render_frame_host_id, | 244 const RenderFrameHostId& render_frame_host_id, |
| 254 content::PresentationScreenAvailabilityListener* listener); | 245 content::PresentationScreenAvailabilityListener* listener); |
| 255 void ListenForSessionStateChange( | 246 void ListenForConnectionStateChange( |
| 256 const RenderFrameHostId& render_frame_host_id, | 247 const RenderFrameHostId& render_frame_host_id, |
| 257 const content::SessionStateChangedCallback& state_changed_cb); | 248 const content::PresentationSessionInfo& connection, |
| 249 const content::PresentationConnectionStateChangedCallback& |
| 250 state_changed_cb); |
| 258 void ListenForSessionMessages( | 251 void ListenForSessionMessages( |
| 259 const RenderFrameHostId& render_frame_host_id, | 252 const RenderFrameHostId& render_frame_host_id, |
| 260 const content::PresentationSessionInfo& session, | 253 const content::PresentationSessionInfo& session, |
| 261 const content::PresentationSessionMessageCallback& message_cb); | 254 const content::PresentationSessionMessageCallback& message_cb); |
| 262 | 255 |
| 263 // Sets or clears the default presentation request and callback for the given | 256 // Sets or clears the default presentation request and callback for the given |
| 264 // frame. Also sets / clears the default presentation requests for the owning | 257 // frame. Also sets / clears the default presentation requests for the owning |
| 265 // tab WebContents. | 258 // tab WebContents. |
| 266 void SetDefaultPresentationUrl( | 259 void SetDefaultPresentationUrl( |
| 267 const RenderFrameHostId& render_frame_host_id, | 260 const RenderFrameHostId& render_frame_host_id, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 284 | 277 |
| 285 void OnPresentationSessionStarted( | 278 void OnPresentationSessionStarted( |
| 286 const RenderFrameHostId& render_frame_host_id, | 279 const RenderFrameHostId& render_frame_host_id, |
| 287 const content::PresentationSessionInfo& session, | 280 const content::PresentationSessionInfo& session, |
| 288 const MediaRoute::Id& route_id); | 281 const MediaRoute::Id& route_id); |
| 289 void OnDefaultPresentationSessionStarted( | 282 void OnDefaultPresentationSessionStarted( |
| 290 const PresentationRequest& request, | 283 const PresentationRequest& request, |
| 291 const content::PresentationSessionInfo& session, | 284 const content::PresentationSessionInfo& session, |
| 292 const MediaRoute::Id& route_id); | 285 const MediaRoute::Id& route_id); |
| 293 | 286 |
| 294 void OnPresentationSessionClosed( | |
| 295 const RenderFrameHostId& render_frame_host_id, | |
| 296 const std::string& presentation_id); | |
| 297 const MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id, | 287 const MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id, |
| 298 const std::string& presentation_id) const; | 288 const std::string& presentation_id) const; |
| 299 const std::vector<MediaRoute::Id> GetRouteIds( | 289 const std::vector<MediaRoute::Id> GetRouteIds( |
| 300 const RenderFrameHostId& render_frame_host_id) const; | 290 const RenderFrameHostId& render_frame_host_id) const; |
| 301 | 291 |
| 302 const PresentationRequest* default_presentation_request() const { | 292 const PresentationRequest* default_presentation_request() const { |
| 303 return default_presentation_request_.get(); | 293 return default_presentation_request_.get(); |
| 304 } | 294 } |
| 305 | 295 |
| 306 private: | 296 private: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 342 |
| 353 PresentationFrameManager::~PresentationFrameManager() { | 343 PresentationFrameManager::~PresentationFrameManager() { |
| 354 for (auto& frame : presentation_frames_) | 344 for (auto& frame : presentation_frames_) |
| 355 frame.second->OnPresentationServiceDelegateDestroyed(); | 345 frame.second->OnPresentationServiceDelegateDestroyed(); |
| 356 } | 346 } |
| 357 | 347 |
| 358 void PresentationFrameManager::OnPresentationSessionStarted( | 348 void PresentationFrameManager::OnPresentationSessionStarted( |
| 359 const RenderFrameHostId& render_frame_host_id, | 349 const RenderFrameHostId& render_frame_host_id, |
| 360 const content::PresentationSessionInfo& session, | 350 const content::PresentationSessionInfo& session, |
| 361 const MediaRoute::Id& route_id) { | 351 const MediaRoute::Id& route_id) { |
| 362 auto presentation_frame = presentation_frames_.get(render_frame_host_id); | 352 auto presentation_frame = GetOrAddPresentationFrame(render_frame_host_id); |
| 363 if (presentation_frame) | 353 presentation_frame->OnPresentationSessionStarted(session, route_id); |
| 364 presentation_frame->OnPresentationSessionStarted(session, route_id); | |
| 365 } | 354 } |
| 366 | 355 |
| 367 void PresentationFrameManager::OnDefaultPresentationSessionStarted( | 356 void PresentationFrameManager::OnDefaultPresentationSessionStarted( |
| 368 const PresentationRequest& request, | 357 const PresentationRequest& request, |
| 369 const content::PresentationSessionInfo& session, | 358 const content::PresentationSessionInfo& session, |
| 370 const MediaRoute::Id& route_id) { | 359 const MediaRoute::Id& route_id) { |
| 371 auto presentation_frame = | 360 auto presentation_frame = |
| 372 presentation_frames_.get(request.render_frame_host_id()); | 361 presentation_frames_.get(request.render_frame_host_id()); |
| 373 if (presentation_frame) | 362 if (presentation_frame) |
| 374 presentation_frame->OnPresentationSessionStarted(session, route_id); | 363 presentation_frame->OnPresentationSessionStarted(session, route_id); |
| 375 | 364 |
| 376 if (default_presentation_request_ && | 365 if (default_presentation_request_ && |
| 377 default_presentation_request_->Equals(request)) { | 366 default_presentation_request_->Equals(request)) { |
| 378 default_presentation_started_callback_.Run(session); | 367 default_presentation_started_callback_.Run(session); |
| 379 } | 368 } |
| 380 } | 369 } |
| 381 | 370 |
| 382 void PresentationFrameManager::OnPresentationSessionClosed( | |
| 383 const RenderFrameHostId& render_frame_host_id, | |
| 384 const std::string& presentation_id) { | |
| 385 auto presentation_frame = presentation_frames_.get(render_frame_host_id); | |
| 386 if (presentation_frame) | |
| 387 presentation_frame->OnPresentationSessionClosed(presentation_id); | |
| 388 } | |
| 389 | |
| 390 const MediaRoute::Id PresentationFrameManager::GetRouteId( | 371 const MediaRoute::Id PresentationFrameManager::GetRouteId( |
| 391 const RenderFrameHostId& render_frame_host_id, | 372 const RenderFrameHostId& render_frame_host_id, |
| 392 const std::string& presentation_id) const { | 373 const std::string& presentation_id) const { |
| 393 auto presentation_frame = presentation_frames_.get(render_frame_host_id); | 374 auto presentation_frame = presentation_frames_.get(render_frame_host_id); |
| 394 return presentation_frame ? presentation_frame->GetRouteId(presentation_id) | 375 return presentation_frame ? presentation_frame->GetRouteId(presentation_id) |
| 395 : ""; | 376 : ""; |
| 396 } | 377 } |
| 397 | 378 |
| 398 const std::vector<MediaRoute::Id> PresentationFrameManager::GetRouteIds( | 379 const std::vector<MediaRoute::Id> PresentationFrameManager::GetRouteIds( |
| 399 const RenderFrameHostId& render_frame_host_id) const { | 380 const RenderFrameHostId& render_frame_host_id) const { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 420 } | 401 } |
| 421 | 402 |
| 422 bool PresentationFrameManager::HasScreenAvailabilityListenerForTest( | 403 bool PresentationFrameManager::HasScreenAvailabilityListenerForTest( |
| 423 const RenderFrameHostId& render_frame_host_id, | 404 const RenderFrameHostId& render_frame_host_id, |
| 424 const MediaSource::Id& source_id) const { | 405 const MediaSource::Id& source_id) const { |
| 425 auto presentation_frame = presentation_frames_.get(render_frame_host_id); | 406 auto presentation_frame = presentation_frames_.get(render_frame_host_id); |
| 426 return presentation_frame && | 407 return presentation_frame && |
| 427 presentation_frame->HasScreenAvailabilityListenerForTest(source_id); | 408 presentation_frame->HasScreenAvailabilityListenerForTest(source_id); |
| 428 } | 409 } |
| 429 | 410 |
| 430 void PresentationFrameManager::ListenForSessionStateChange( | 411 void PresentationFrameManager::ListenForConnectionStateChange( |
| 431 const RenderFrameHostId& render_frame_host_id, | 412 const RenderFrameHostId& render_frame_host_id, |
| 432 const content::SessionStateChangedCallback& state_changed_cb) { | 413 const content::PresentationSessionInfo& connection, |
| 433 PresentationFrame* presentation_frame = | 414 const content::PresentationConnectionStateChangedCallback& |
| 434 GetOrAddPresentationFrame(render_frame_host_id); | 415 state_changed_cb) { |
| 435 presentation_frame->ListenForSessionStateChange(state_changed_cb); | 416 auto presentation_frame = presentation_frames_.get(render_frame_host_id); |
| 417 if (presentation_frame) { |
| 418 presentation_frame->ListenForConnectionStateChange(connection, |
| 419 state_changed_cb); |
| 420 } |
| 436 } | 421 } |
| 437 | 422 |
| 438 void PresentationFrameManager::ListenForSessionMessages( | 423 void PresentationFrameManager::ListenForSessionMessages( |
| 439 const RenderFrameHostId& render_frame_host_id, | 424 const RenderFrameHostId& render_frame_host_id, |
| 440 const content::PresentationSessionInfo& session, | 425 const content::PresentationSessionInfo& session, |
| 441 const content::PresentationSessionMessageCallback& message_cb) { | 426 const content::PresentationSessionMessageCallback& message_cb) { |
| 442 PresentationFrame* presentation_frame = | 427 PresentationFrame* presentation_frame = |
| 443 presentation_frames_.get(render_frame_host_id); | 428 presentation_frames_.get(render_frame_host_id); |
| 444 if (!presentation_frame) { | 429 if (!presentation_frame) { |
| 445 DVLOG(2) << "ListenForSessionMessages: PresentationFrame does not exist " | 430 DVLOG(2) << "ListenForSessionMessages: PresentationFrame does not exist " |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 } | 744 } |
| 760 | 745 |
| 761 if (message->is_binary()) { | 746 if (message->is_binary()) { |
| 762 router_->SendRouteBinaryMessage(route_id, message->data.Pass(), | 747 router_->SendRouteBinaryMessage(route_id, message->data.Pass(), |
| 763 send_message_cb); | 748 send_message_cb); |
| 764 } else { | 749 } else { |
| 765 router_->SendRouteMessage(route_id, message->message, send_message_cb); | 750 router_->SendRouteMessage(route_id, message->message, send_message_cb); |
| 766 } | 751 } |
| 767 } | 752 } |
| 768 | 753 |
| 769 void PresentationServiceDelegateImpl::ListenForSessionStateChange( | 754 void PresentationServiceDelegateImpl::ListenForConnectionStateChange( |
| 770 int render_process_id, | 755 int render_process_id, |
| 771 int render_frame_id, | 756 int render_frame_id, |
| 772 const content::SessionStateChangedCallback& state_changed_cb) { | 757 const content::PresentationSessionInfo& connection, |
| 773 frame_manager_->ListenForSessionStateChange( | 758 const content::PresentationConnectionStateChangedCallback& |
| 774 RenderFrameHostId(render_process_id, render_frame_id), state_changed_cb); | 759 state_changed_cb) { |
| 760 frame_manager_->ListenForConnectionStateChange( |
| 761 RenderFrameHostId(render_process_id, render_frame_id), connection, |
| 762 state_changed_cb); |
| 775 } | 763 } |
| 776 | 764 |
| 777 void PresentationServiceDelegateImpl::OnRouteResponse( | 765 void PresentationServiceDelegateImpl::OnRouteResponse( |
| 778 const PresentationRequest& presentation_request, | 766 const PresentationRequest& presentation_request, |
| 779 const MediaRoute* route, | 767 const MediaRoute* route, |
| 780 const std::string& presentation_id, | 768 const std::string& presentation_id, |
| 781 const std::string& error) { | 769 const std::string& error) { |
| 782 if (!route) | 770 if (!route) |
| 783 return; | 771 return; |
| 784 | 772 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( | 810 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( |
| 823 int render_process_id, | 811 int render_process_id, |
| 824 int render_frame_id, | 812 int render_frame_id, |
| 825 const MediaSource::Id& source_id) const { | 813 const MediaSource::Id& source_id) const { |
| 826 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); | 814 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); |
| 827 return frame_manager_->HasScreenAvailabilityListenerForTest( | 815 return frame_manager_->HasScreenAvailabilityListenerForTest( |
| 828 render_frame_host_id, source_id); | 816 render_frame_host_id, source_id); |
| 829 } | 817 } |
| 830 | 818 |
| 831 } // namespace media_router | 819 } // namespace media_router |
| OLD | NEW |