| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 void PresentationDispatcher::updateAvailableChangeWatched(bool watched) { | 106 void PresentationDispatcher::updateAvailableChangeWatched(bool watched) { |
| 107 ConnectToPresentationServiceIfNeeded(); | 107 ConnectToPresentationServiceIfNeeded(); |
| 108 if (watched) | 108 if (watched) |
| 109 presentation_service_->ListenForScreenAvailability(); | 109 presentation_service_->ListenForScreenAvailability(); |
| 110 else | 110 else |
| 111 presentation_service_->StopListeningForScreenAvailability(); | 111 presentation_service_->StopListeningForScreenAvailability(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void PresentationDispatcher::startSession( | 114 void PresentationDispatcher::startSession( |
| 115 const blink::WebString& presentationUrl, | 115 const blink::WebString& presentationUrl, |
| 116 const blink::WebString& presentationId, | |
| 117 blink::WebPresentationSessionClientCallbacks* callback) { | |
| 118 startSession(presentationUrl, callback); | |
| 119 } | |
| 120 | |
| 121 void PresentationDispatcher::startSession( | |
| 122 const blink::WebString& presentationUrl, | |
| 123 blink::WebPresentationSessionClientCallbacks* callback) { | 116 blink::WebPresentationSessionClientCallbacks* callback) { |
| 124 DCHECK(callback); | 117 DCHECK(callback); |
| 125 ConnectToPresentationServiceIfNeeded(); | 118 ConnectToPresentationServiceIfNeeded(); |
| 126 | 119 |
| 127 // The dispatcher owns the service so |this| will be valid when | 120 // The dispatcher owns the service so |this| will be valid when |
| 128 // OnSessionCreated() is called. |callback| needs to be alive and also needs | 121 // OnSessionCreated() is called. |callback| needs to be alive and also needs |
| 129 // to be destroyed so we transfer its ownership to the mojo callback. | 122 // to be destroyed so we transfer its ownership to the mojo callback. |
| 130 presentation_service_->StartSession( | 123 presentation_service_->StartSession( |
| 131 presentationUrl.utf8(), | 124 presentationUrl.utf8(), |
| 132 base::Bind(&PresentationDispatcher::OnSessionCreated, | 125 base::Bind(&PresentationDispatcher::OnSessionCreated, |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 345 |
| 353 if (listening_state_ == ListeningState::Waiting) | 346 if (listening_state_ == ListeningState::Waiting) |
| 354 listening_state_ = ListeningState::Active; | 347 listening_state_ = ListeningState::Active; |
| 355 | 348 |
| 356 for (auto observer : availability_observers_) | 349 for (auto observer : availability_observers_) |
| 357 observer->availabilityChanged(available); | 350 observer->availabilityChanged(available); |
| 358 | 351 |
| 359 for (auto observer : availability_observers_) | 352 for (auto observer : availability_observers_) |
| 360 observer->availabilityChanged(available); | 353 observer->availabilityChanged(available); |
| 361 | 354 |
| 355 for (auto observer : availability_observers_) |
| 356 observer->availabilityChanged(available); |
| 357 |
| 362 for (AvailabilityCallbacksMap::iterator iter(&availability_callbacks_); | 358 for (AvailabilityCallbacksMap::iterator iter(&availability_callbacks_); |
| 363 !iter.IsAtEnd(); iter.Advance()) { | 359 !iter.IsAtEnd(); iter.Advance()) { |
| 364 iter.GetCurrentValue()->onSuccess(new bool(available)); | 360 iter.GetCurrentValue()->onSuccess(new bool(available)); |
| 365 } | 361 } |
| 366 availability_callbacks_.Clear(); | 362 availability_callbacks_.Clear(); |
| 367 | 363 |
| 368 UpdateListeningState(); | 364 UpdateListeningState(); |
| 369 } | 365 } |
| 370 | 366 |
| 371 void PresentationDispatcher::OnScreenAvailabilityNotSupported() { | 367 void PresentationDispatcher::OnScreenAvailabilityNotSupported() { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 if (should_listen) { | 512 if (should_listen) { |
| 517 listening_state_ = ListeningState::Waiting; | 513 listening_state_ = ListeningState::Waiting; |
| 518 presentation_service_->ListenForScreenAvailability(); | 514 presentation_service_->ListenForScreenAvailability(); |
| 519 } else { | 515 } else { |
| 520 listening_state_ = ListeningState::Inactive; | 516 listening_state_ = ListeningState::Inactive; |
| 521 presentation_service_->StopListeningForScreenAvailability(); | 517 presentation_service_->StopListeningForScreenAvailability(); |
| 522 } | 518 } |
| 523 } | 519 } |
| 524 | 520 |
| 525 } // namespace content | 521 } // namespace content |
| OLD | NEW |