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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 for (AvailabilityCallbacksMap::iterator iter(&availability_callbacks_); | 348 for (AvailabilityCallbacksMap::iterator iter(&availability_callbacks_); |
349 !iter.IsAtEnd(); iter.Advance()) { | 349 !iter.IsAtEnd(); iter.Advance()) { |
350 bool* result = new bool(available); | 350 bool* result = new bool(available); |
351 iter.GetCurrentValue()->onSuccess(result); | 351 iter.GetCurrentValue()->onSuccess(result); |
352 } | 352 } |
353 availability_callbacks_.Clear(); | 353 availability_callbacks_.Clear(); |
354 | 354 |
355 UpdateListeningState(); | 355 UpdateListeningState(); |
356 } | 356 } |
357 | 357 |
| 358 void PresentationDispatcher::OnScreenAvailabilityNotSupported() { |
| 359 DCHECK(listening_state_ == ListeningState::Waiting); |
| 360 |
| 361 for (AvailabilityCallbacksMap::iterator iter(&availability_callbacks_); |
| 362 !iter.IsAtEnd(); iter.Advance()) { |
| 363 iter.GetCurrentValue()->onError(new blink::WebPresentationError( |
| 364 blink::WebPresentationError::ErrorTypeAvailabilityNotSupported, |
| 365 blink::WebString::fromUTF8( |
| 366 "getAvailability() isn't supported at the moment. It can be due to" |
| 367 "a permanent or temporary system limitation. It is recommended to" |
| 368 "try to blindly start a session in that case."))); |
| 369 } |
| 370 availability_callbacks_.Clear(); |
| 371 |
| 372 UpdateListeningState(); |
| 373 } |
| 374 |
358 void PresentationDispatcher::OnDefaultSessionStarted( | 375 void PresentationDispatcher::OnDefaultSessionStarted( |
359 presentation::PresentationSessionInfoPtr session_info) { | 376 presentation::PresentationSessionInfoPtr session_info) { |
360 if (!controller_) | 377 if (!controller_) |
361 return; | 378 return; |
362 | 379 |
363 // Reset the callback to get the next event. | 380 // Reset the callback to get the next event. |
364 presentation_service_->ListenForDefaultSessionStart(base::Bind( | 381 presentation_service_->ListenForDefaultSessionStart(base::Bind( |
365 &PresentationDispatcher::OnDefaultSessionStarted, | 382 &PresentationDispatcher::OnDefaultSessionStarted, |
366 base::Unretained(this))); | 383 base::Unretained(this))); |
367 | 384 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 if (should_listen) { | 480 if (should_listen) { |
464 listening_state_ = ListeningState::Waiting; | 481 listening_state_ = ListeningState::Waiting; |
465 presentation_service_->ListenForScreenAvailability(); | 482 presentation_service_->ListenForScreenAvailability(); |
466 } else { | 483 } else { |
467 listening_state_ = ListeningState::Inactive; | 484 listening_state_ = ListeningState::Inactive; |
468 presentation_service_->StopListeningForScreenAvailability(); | 485 presentation_service_->StopListeningForScreenAvailability(); |
469 } | 486 } |
470 } | 487 } |
471 | 488 |
472 } // namespace content | 489 } // namespace content |
OLD | NEW |