| 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 "content/renderer/presentation/presentation_dispatcher.h" | 5 #include "content/renderer/presentation/presentation_dispatcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 } | 330 } |
| 331 status->availability_callbacks.Clear(); | 331 status->availability_callbacks.Clear(); |
| 332 UpdateListeningState(status); | 332 UpdateListeningState(status); |
| 333 } | 333 } |
| 334 | 334 |
| 335 void PresentationDispatcher::OnDefaultSessionStarted( | 335 void PresentationDispatcher::OnDefaultSessionStarted( |
| 336 presentation::PresentationSessionInfoPtr session_info) { | 336 presentation::PresentationSessionInfoPtr session_info) { |
| 337 if (!controller_) | 337 if (!controller_) |
| 338 return; | 338 return; |
| 339 | 339 |
| 340 // Reset the callback to get the next event. |
| 341 presentation_service_->ListenForDefaultSessionStart(base::Bind( |
| 342 &PresentationDispatcher::OnDefaultSessionStarted, |
| 343 base::Unretained(this))); |
| 344 |
| 340 if (!session_info.is_null()) { | 345 if (!session_info.is_null()) { |
| 341 controller_->didStartDefaultSession( | 346 controller_->didStartDefaultSession( |
| 342 new PresentationConnectionClient(session_info.Clone())); | 347 new PresentationConnectionClient(session_info.Clone())); |
| 343 presentation_service_->ListenForSessionMessages(session_info.Pass()); | 348 presentation_service_->ListenForSessionMessages(session_info.Pass()); |
| 344 } | 349 } |
| 345 } | 350 } |
| 346 | 351 |
| 347 void PresentationDispatcher::OnSessionCreated( | 352 void PresentationDispatcher::OnSessionCreated( |
| 348 blink::WebPresentationConnectionClientCallbacks* callback, | 353 blink::WebPresentationConnectionClientCallbacks* callback, |
| 349 presentation::PresentationSessionInfoPtr session_info, | 354 presentation::PresentationSessionInfoPtr session_info, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { | 419 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { |
| 415 if (presentation_service_.get()) | 420 if (presentation_service_.get()) |
| 416 return; | 421 return; |
| 417 | 422 |
| 418 render_frame()->GetServiceRegistry()->ConnectToRemoteService( | 423 render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
| 419 mojo::GetProxy(&presentation_service_)); | 424 mojo::GetProxy(&presentation_service_)); |
| 420 presentation::PresentationServiceClientPtr client_ptr; | 425 presentation::PresentationServiceClientPtr client_ptr; |
| 421 binding_.Bind(GetProxy(&client_ptr)); | 426 binding_.Bind(GetProxy(&client_ptr)); |
| 422 presentation_service_->SetClient(client_ptr.Pass()); | 427 presentation_service_->SetClient(client_ptr.Pass()); |
| 423 | 428 |
| 429 presentation_service_->ListenForDefaultSessionStart(base::Bind( |
| 430 &PresentationDispatcher::OnDefaultSessionStarted, |
| 431 base::Unretained(this))); |
| 424 presentation_service_->ListenForSessionStateChange(); | 432 presentation_service_->ListenForSessionStateChange(); |
| 425 } | 433 } |
| 426 | 434 |
| 427 void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) { | 435 void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) { |
| 428 bool should_listen = !status->availability_callbacks.IsEmpty() || | 436 bool should_listen = !status->availability_callbacks.IsEmpty() || |
| 429 !status->availability_observers.empty(); | 437 !status->availability_observers.empty(); |
| 430 bool is_listening = status->listening_state != ListeningState::INACTIVE; | 438 bool is_listening = status->listening_state != ListeningState::INACTIVE; |
| 431 | 439 |
| 432 if (should_listen == is_listening) | 440 if (should_listen == is_listening) |
| 433 return; | 441 return; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( | 500 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( |
| 493 const std::string& availability_url) | 501 const std::string& availability_url) |
| 494 : url(availability_url), | 502 : url(availability_url), |
| 495 last_known_availability(false), | 503 last_known_availability(false), |
| 496 listening_state(ListeningState::INACTIVE) {} | 504 listening_state(ListeningState::INACTIVE) {} |
| 497 | 505 |
| 498 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { | 506 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { |
| 499 } | 507 } |
| 500 | 508 |
| 501 } // namespace content | 509 } // namespace content |
| OLD | NEW |