Chromium Code Reviews| 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_media_sinks_observer.h" | 21 #include "chrome/browser/media/router/presentation_media_sinks_observer.h" |
| 22 #include "chrome/browser/media/router/presentation_session_messages_observer.h" | 22 #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" | 23 #include "chrome/browser/sessions/session_tab_helper.h" |
| 25 #include "content/public/browser/presentation_screen_availability_listener.h" | 24 #include "content/public/browser/presentation_screen_availability_listener.h" |
| 26 #include "content/public/browser/presentation_session.h" | 25 #include "content/public/browser/presentation_session.h" |
| 27 #include "content/public/browser/render_frame_host.h" | 26 #include "content/public/browser/render_frame_host.h" |
| 28 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
| 29 | 28 |
| 30 DEFINE_WEB_CONTENTS_USER_DATA_KEY( | 29 DEFINE_WEB_CONTENTS_USER_DATA_KEY( |
| 31 media_router::PresentationServiceDelegateImpl); | 30 media_router::PresentationServiceDelegateImpl); |
| 32 | 31 |
| 33 using content::RenderFrameHost; | 32 using content::RenderFrameHost; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 ~PresentationFrame(); | 67 ~PresentationFrame(); |
| 69 | 68 |
| 70 // Mirror corresponding APIs in PresentationServiceDelegateImpl. | 69 // Mirror corresponding APIs in PresentationServiceDelegateImpl. |
| 71 bool SetScreenAvailabilityListener( | 70 bool SetScreenAvailabilityListener( |
| 72 content::PresentationScreenAvailabilityListener* listener); | 71 content::PresentationScreenAvailabilityListener* listener); |
| 73 bool RemoveScreenAvailabilityListener( | 72 bool RemoveScreenAvailabilityListener( |
| 74 content::PresentationScreenAvailabilityListener* listener); | 73 content::PresentationScreenAvailabilityListener* listener); |
| 75 bool HasScreenAvailabilityListenerForTest( | 74 bool HasScreenAvailabilityListenerForTest( |
| 76 const MediaSource::Id& source_id) const; | 75 const MediaSource::Id& source_id) const; |
| 77 std::string GetDefaultPresentationId() const; | 76 std::string GetDefaultPresentationId() const; |
| 78 void ListenForSessionStateChange( | 77 void ListenForConnectionStateChange( |
| 79 const content::SessionStateChangedCallback& state_changed_cb); | 78 const content::PresentationSessionInfo& connection, |
| 79 const content::PresentationConnectionStateChangedCallback& | |
| 80 state_changed_cb); | |
| 80 void ListenForSessionMessages( | 81 void ListenForSessionMessages( |
| 81 const content::PresentationSessionInfo& session, | 82 const content::PresentationSessionInfo& session, |
| 82 const content::PresentationSessionMessageCallback& message_cb); | 83 const content::PresentationSessionMessageCallback& message_cb); |
| 83 | 84 |
| 84 void Reset(); | 85 void Reset(); |
| 85 | 86 |
| 86 const MediaRoute::Id GetRouteId(const std::string& presentation_id) const; | 87 const MediaRoute::Id GetRouteId(const std::string& presentation_id) const; |
| 87 const std::vector<MediaRoute::Id> GetRouteIds() const; | 88 const std::vector<MediaRoute::Id> GetRouteIds() const; |
| 88 void OnPresentationSessionClosed(const std::string& presentation_id); | |
| 89 | 89 |
| 90 void OnPresentationSessionStarted( | 90 void OnPresentationSessionStarted( |
| 91 const content::PresentationSessionInfo& session, | 91 const content::PresentationSessionInfo& session, |
| 92 const MediaRoute::Id& route_id); | 92 const MediaRoute::Id& route_id); |
| 93 void OnPresentationServiceDelegateDestroyed() const; | 93 void OnPresentationServiceDelegateDestroyed() const; |
| 94 | 94 |
| 95 void set_delegate_observer(DelegateObserver* observer) { | 95 void set_delegate_observer(DelegateObserver* observer) { |
| 96 delegate_observer_ = observer; | 96 delegate_observer_ = observer; |
| 97 } | 97 } |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 MediaSource GetMediaSourceFromListener( | 100 MediaSource GetMediaSourceFromListener( |
| 101 content::PresentationScreenAvailabilityListener* listener) const; | 101 content::PresentationScreenAvailabilityListener* listener) const; |
| 102 MediaRouteIdToPresentationSessionMapping route_id_to_presentation_; | |
| 103 base::SmallMap<std::map<std::string, MediaRoute::Id>> | 102 base::SmallMap<std::map<std::string, MediaRoute::Id>> |
| 104 presentation_id_to_route_id_; | 103 presentation_id_to_route_id_; |
| 105 scoped_ptr<PresentationMediaSinksObserver> sinks_observer_; | 104 scoped_ptr<PresentationMediaSinksObserver> sinks_observer_; |
| 106 scoped_ptr<PresentationSessionStateObserver> session_state_observer_; | 105 std::vector<scoped_ptr<PresentationConnectionStateSubscription>> |
| 106 connection_state_subscriptions_; | |
| 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_subscriptions_.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( |
|
mark a. foltz
2015/11/18 00:39:38
Can this be called more than once per |connection|
imcheng
2015/11/19 23:39:53
Yes. Although it should only be called once by Pre
| |
| 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_subscriptions_.push_back( | |
|
mark a. foltz
2015/11/18 00:39:38
It seems like we only want to add at most one Subs
imcheng
2015/11/19 23:39:53
We could do that, by keeping a map from route id t
| |
| 206 router_->AddPresentationConnectionStateChangedCallback(it->second, | |
| 207 state_changed_cb)); | |
| 216 } | 208 } |
| 217 | 209 |
| 218 void PresentationFrame::ListenForSessionMessages( | 210 void PresentationFrame::ListenForSessionMessages( |
| 219 const content::PresentationSessionInfo& session, | 211 const content::PresentationSessionInfo& session, |
| 220 const content::PresentationSessionMessageCallback& message_cb) { | 212 const content::PresentationSessionMessageCallback& message_cb) { |
| 221 auto it = presentation_id_to_route_id_.find(session.presentation_id); | 213 auto it = presentation_id_to_route_id_.find(session.presentation_id); |
| 222 if (it == presentation_id_to_route_id_.end()) { | 214 if (it == presentation_id_to_route_id_.end()) { |
| 223 DVLOG(2) << "ListenForSessionMessages: no route for " | 215 DVLOG(2) << "ListenForSessionMessages: no route for " |
| 224 << session.presentation_id; | 216 << session.presentation_id; |
| 225 return; | 217 return; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 245 MediaRouter* router); | 237 MediaRouter* router); |
| 246 ~PresentationFrameManager(); | 238 ~PresentationFrameManager(); |
| 247 | 239 |
| 248 // Mirror corresponding APIs in PresentationServiceDelegateImpl. | 240 // Mirror corresponding APIs in PresentationServiceDelegateImpl. |
| 249 bool SetScreenAvailabilityListener( | 241 bool SetScreenAvailabilityListener( |
| 250 const RenderFrameHostId& render_frame_host_id, | 242 const RenderFrameHostId& render_frame_host_id, |
| 251 content::PresentationScreenAvailabilityListener* listener); | 243 content::PresentationScreenAvailabilityListener* listener); |
| 252 bool RemoveScreenAvailabilityListener( | 244 bool RemoveScreenAvailabilityListener( |
| 253 const RenderFrameHostId& render_frame_host_id, | 245 const RenderFrameHostId& render_frame_host_id, |
| 254 content::PresentationScreenAvailabilityListener* listener); | 246 content::PresentationScreenAvailabilityListener* listener); |
| 255 void ListenForSessionStateChange( | 247 void ListenForConnectionStateChange( |
| 256 const RenderFrameHostId& render_frame_host_id, | 248 const RenderFrameHostId& render_frame_host_id, |
| 257 const content::SessionStateChangedCallback& state_changed_cb); | 249 const content::PresentationSessionInfo& connection, |
| 250 const content::PresentationConnectionStateChangedCallback& | |
| 251 state_changed_cb); | |
| 258 void ListenForSessionMessages( | 252 void ListenForSessionMessages( |
| 259 const RenderFrameHostId& render_frame_host_id, | 253 const RenderFrameHostId& render_frame_host_id, |
| 260 const content::PresentationSessionInfo& session, | 254 const content::PresentationSessionInfo& session, |
| 261 const content::PresentationSessionMessageCallback& message_cb); | 255 const content::PresentationSessionMessageCallback& message_cb); |
| 262 | 256 |
| 263 // Sets or clears the default presentation request and callback for the given | 257 // Sets or clears the default presentation request and callback for the given |
| 264 // frame. Also sets / clears the default presentation requests for the owning | 258 // frame. Also sets / clears the default presentation requests for the owning |
| 265 // tab WebContents. | 259 // tab WebContents. |
| 266 void SetDefaultPresentationUrl( | 260 void SetDefaultPresentationUrl( |
| 267 const RenderFrameHostId& render_frame_host_id, | 261 const RenderFrameHostId& render_frame_host_id, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 284 | 278 |
| 285 void OnPresentationSessionStarted( | 279 void OnPresentationSessionStarted( |
| 286 const RenderFrameHostId& render_frame_host_id, | 280 const RenderFrameHostId& render_frame_host_id, |
| 287 const content::PresentationSessionInfo& session, | 281 const content::PresentationSessionInfo& session, |
| 288 const MediaRoute::Id& route_id); | 282 const MediaRoute::Id& route_id); |
| 289 void OnDefaultPresentationSessionStarted( | 283 void OnDefaultPresentationSessionStarted( |
| 290 const PresentationRequest& request, | 284 const PresentationRequest& request, |
| 291 const content::PresentationSessionInfo& session, | 285 const content::PresentationSessionInfo& session, |
| 292 const MediaRoute::Id& route_id); | 286 const MediaRoute::Id& route_id); |
| 293 | 287 |
| 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, | 288 const MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id, |
| 298 const std::string& presentation_id) const; | 289 const std::string& presentation_id) const; |
| 299 const std::vector<MediaRoute::Id> GetRouteIds( | 290 const std::vector<MediaRoute::Id> GetRouteIds( |
| 300 const RenderFrameHostId& render_frame_host_id) const; | 291 const RenderFrameHostId& render_frame_host_id) const; |
| 301 | 292 |
| 302 const PresentationRequest* default_presentation_request() const { | 293 const PresentationRequest* default_presentation_request() const { |
| 303 return default_presentation_request_.get(); | 294 return default_presentation_request_.get(); |
| 304 } | 295 } |
| 305 | 296 |
| 306 private: | 297 private: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 | 343 |
| 353 PresentationFrameManager::~PresentationFrameManager() { | 344 PresentationFrameManager::~PresentationFrameManager() { |
| 354 for (auto& frame : presentation_frames_) | 345 for (auto& frame : presentation_frames_) |
| 355 frame.second->OnPresentationServiceDelegateDestroyed(); | 346 frame.second->OnPresentationServiceDelegateDestroyed(); |
| 356 } | 347 } |
| 357 | 348 |
| 358 void PresentationFrameManager::OnPresentationSessionStarted( | 349 void PresentationFrameManager::OnPresentationSessionStarted( |
| 359 const RenderFrameHostId& render_frame_host_id, | 350 const RenderFrameHostId& render_frame_host_id, |
| 360 const content::PresentationSessionInfo& session, | 351 const content::PresentationSessionInfo& session, |
| 361 const MediaRoute::Id& route_id) { | 352 const MediaRoute::Id& route_id) { |
| 362 auto presentation_frame = presentation_frames_.get(render_frame_host_id); | 353 auto presentation_frame = GetOrAddPresentationFrame(render_frame_host_id); |
| 363 if (presentation_frame) | 354 presentation_frame->OnPresentationSessionStarted(session, route_id); |
| 364 presentation_frame->OnPresentationSessionStarted(session, route_id); | |
| 365 } | 355 } |
| 366 | 356 |
| 367 void PresentationFrameManager::OnDefaultPresentationSessionStarted( | 357 void PresentationFrameManager::OnDefaultPresentationSessionStarted( |
| 368 const PresentationRequest& request, | 358 const PresentationRequest& request, |
| 369 const content::PresentationSessionInfo& session, | 359 const content::PresentationSessionInfo& session, |
| 370 const MediaRoute::Id& route_id) { | 360 const MediaRoute::Id& route_id) { |
| 371 auto presentation_frame = | 361 auto presentation_frame = |
| 372 presentation_frames_.get(request.render_frame_host_id()); | 362 presentation_frames_.get(request.render_frame_host_id()); |
| 373 if (presentation_frame) | 363 if (presentation_frame) |
| 374 presentation_frame->OnPresentationSessionStarted(session, route_id); | 364 presentation_frame->OnPresentationSessionStarted(session, route_id); |
| 375 | 365 |
| 376 if (default_presentation_request_ && | 366 if (default_presentation_request_ && |
| 377 default_presentation_request_->Equals(request)) { | 367 default_presentation_request_->Equals(request)) { |
| 378 default_presentation_started_callback_.Run(session); | 368 default_presentation_started_callback_.Run(session); |
| 379 } | 369 } |
| 380 } | 370 } |
| 381 | 371 |
| 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( | 372 const MediaRoute::Id PresentationFrameManager::GetRouteId( |
| 391 const RenderFrameHostId& render_frame_host_id, | 373 const RenderFrameHostId& render_frame_host_id, |
| 392 const std::string& presentation_id) const { | 374 const std::string& presentation_id) const { |
| 393 auto presentation_frame = presentation_frames_.get(render_frame_host_id); | 375 auto presentation_frame = presentation_frames_.get(render_frame_host_id); |
| 394 return presentation_frame ? presentation_frame->GetRouteId(presentation_id) | 376 return presentation_frame ? presentation_frame->GetRouteId(presentation_id) |
| 395 : ""; | 377 : ""; |
| 396 } | 378 } |
| 397 | 379 |
| 398 const std::vector<MediaRoute::Id> PresentationFrameManager::GetRouteIds( | 380 const std::vector<MediaRoute::Id> PresentationFrameManager::GetRouteIds( |
| 399 const RenderFrameHostId& render_frame_host_id) const { | 381 const RenderFrameHostId& render_frame_host_id) const { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 420 } | 402 } |
| 421 | 403 |
| 422 bool PresentationFrameManager::HasScreenAvailabilityListenerForTest( | 404 bool PresentationFrameManager::HasScreenAvailabilityListenerForTest( |
| 423 const RenderFrameHostId& render_frame_host_id, | 405 const RenderFrameHostId& render_frame_host_id, |
| 424 const MediaSource::Id& source_id) const { | 406 const MediaSource::Id& source_id) const { |
| 425 auto presentation_frame = presentation_frames_.get(render_frame_host_id); | 407 auto presentation_frame = presentation_frames_.get(render_frame_host_id); |
| 426 return presentation_frame && | 408 return presentation_frame && |
| 427 presentation_frame->HasScreenAvailabilityListenerForTest(source_id); | 409 presentation_frame->HasScreenAvailabilityListenerForTest(source_id); |
| 428 } | 410 } |
| 429 | 411 |
| 430 void PresentationFrameManager::ListenForSessionStateChange( | 412 void PresentationFrameManager::ListenForConnectionStateChange( |
| 431 const RenderFrameHostId& render_frame_host_id, | 413 const RenderFrameHostId& render_frame_host_id, |
| 432 const content::SessionStateChangedCallback& state_changed_cb) { | 414 const content::PresentationSessionInfo& connection, |
| 433 PresentationFrame* presentation_frame = | 415 const content::PresentationConnectionStateChangedCallback& |
| 434 GetOrAddPresentationFrame(render_frame_host_id); | 416 state_changed_cb) { |
| 435 presentation_frame->ListenForSessionStateChange(state_changed_cb); | 417 auto presentation_frame = presentation_frames_.get(render_frame_host_id); |
| 418 if (presentation_frame) { | |
| 419 presentation_frame->ListenForConnectionStateChange(connection, | |
| 420 state_changed_cb); | |
| 421 } | |
| 436 } | 422 } |
| 437 | 423 |
| 438 void PresentationFrameManager::ListenForSessionMessages( | 424 void PresentationFrameManager::ListenForSessionMessages( |
| 439 const RenderFrameHostId& render_frame_host_id, | 425 const RenderFrameHostId& render_frame_host_id, |
| 440 const content::PresentationSessionInfo& session, | 426 const content::PresentationSessionInfo& session, |
| 441 const content::PresentationSessionMessageCallback& message_cb) { | 427 const content::PresentationSessionMessageCallback& message_cb) { |
| 442 PresentationFrame* presentation_frame = | 428 PresentationFrame* presentation_frame = |
| 443 presentation_frames_.get(render_frame_host_id); | 429 presentation_frames_.get(render_frame_host_id); |
| 444 if (!presentation_frame) { | 430 if (!presentation_frame) { |
| 445 DVLOG(2) << "ListenForSessionMessages: PresentationFrame does not exist " | 431 DVLOG(2) << "ListenForSessionMessages: PresentationFrame does not exist " |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 759 } | 745 } |
| 760 | 746 |
| 761 if (message->is_binary()) { | 747 if (message->is_binary()) { |
| 762 router_->SendRouteBinaryMessage(route_id, message->data.Pass(), | 748 router_->SendRouteBinaryMessage(route_id, message->data.Pass(), |
| 763 send_message_cb); | 749 send_message_cb); |
| 764 } else { | 750 } else { |
| 765 router_->SendRouteMessage(route_id, message->message, send_message_cb); | 751 router_->SendRouteMessage(route_id, message->message, send_message_cb); |
| 766 } | 752 } |
| 767 } | 753 } |
| 768 | 754 |
| 769 void PresentationServiceDelegateImpl::ListenForSessionStateChange( | 755 void PresentationServiceDelegateImpl::ListenForConnectionStateChange( |
| 770 int render_process_id, | 756 int render_process_id, |
| 771 int render_frame_id, | 757 int render_frame_id, |
| 772 const content::SessionStateChangedCallback& state_changed_cb) { | 758 const content::PresentationSessionInfo& connection, |
| 773 frame_manager_->ListenForSessionStateChange( | 759 const content::PresentationConnectionStateChangedCallback& |
| 774 RenderFrameHostId(render_process_id, render_frame_id), state_changed_cb); | 760 state_changed_cb) { |
| 761 frame_manager_->ListenForConnectionStateChange( | |
| 762 RenderFrameHostId(render_process_id, render_frame_id), connection, | |
| 763 state_changed_cb); | |
| 775 } | 764 } |
| 776 | 765 |
| 777 void PresentationServiceDelegateImpl::OnRouteResponse( | 766 void PresentationServiceDelegateImpl::OnRouteResponse( |
| 778 const PresentationRequest& presentation_request, | 767 const PresentationRequest& presentation_request, |
| 779 const MediaRoute* route, | 768 const MediaRoute* route, |
| 780 const std::string& presentation_id, | 769 const std::string& presentation_id, |
| 781 const std::string& error) { | 770 const std::string& error) { |
| 782 if (!route) | 771 if (!route) |
| 783 return; | 772 return; |
| 784 | 773 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( | 811 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( |
| 823 int render_process_id, | 812 int render_process_id, |
| 824 int render_frame_id, | 813 int render_frame_id, |
| 825 const MediaSource::Id& source_id) const { | 814 const MediaSource::Id& source_id) const { |
| 826 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); | 815 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); |
| 827 return frame_manager_->HasScreenAvailabilityListenerForTest( | 816 return frame_manager_->HasScreenAvailabilityListenerForTest( |
| 828 render_frame_host_id, source_id); | 817 render_frame_host_id, source_id); |
| 829 } | 818 } |
| 830 | 819 |
| 831 } // namespace media_router | 820 } // namespace media_router |
| OLD | NEW |