Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: content/renderer/presentation/presentation_dispatcher.cc

Issue 1314413005: [Presentation API] 1-UA presentation support + presenter APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments #18-21 Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 for (AvailabilityCallbacksMap::iterator iter(&status->availability_callbacks); 323 for (AvailabilityCallbacksMap::iterator iter(&status->availability_callbacks);
324 !iter.IsAtEnd(); iter.Advance()) { 324 !iter.IsAtEnd(); iter.Advance()) {
325 iter.GetCurrentValue()->onError(blink::WebPresentationError( 325 iter.GetCurrentValue()->onError(blink::WebPresentationError(
326 blink::WebPresentationError::ErrorTypeAvailabilityNotSupported, 326 blink::WebPresentationError::ErrorTypeAvailabilityNotSupported,
327 not_supported_error)); 327 not_supported_error));
328 } 328 }
329 status->availability_callbacks.Clear(); 329 status->availability_callbacks.Clear();
330 UpdateListeningState(status); 330 UpdateListeningState(status);
331 } 331 }
332 332
333 void PresentationDispatcher::OnDefaultSessionStarted( 333 void PresentationDispatcher::OnDefaultPresentationStarted(
334 presentation::PresentationSessionInfoPtr session_info) { 334 presentation::PresentationSessionInfoPtr session_info) {
335 if (!controller_) 335 if (!controller_)
336 return; 336 return;
337 337
338 // Reset the callback to get the next event.
339 presentation_service_->ListenForDefaultSessionStart(base::Bind(
340 &PresentationDispatcher::OnDefaultSessionStarted,
341 base::Unretained(this)));
342
343 if (!session_info.is_null()) { 338 if (!session_info.is_null()) {
344 controller_->didStartDefaultSession( 339 controller_->didStartDefaultSession(
345 new PresentationConnectionClient(session_info.Clone())); 340 new PresentationConnectionClient(session_info.Clone()));
346 presentation_service_->ListenForSessionStateChange(session_info.Clone()); 341 presentation_service_->ListenForSessionStateChange(session_info.Clone());
347 presentation_service_->ListenForSessionMessages(session_info.Pass()); 342 presentation_service_->ListenForSessionMessages(session_info.Pass());
348 } 343 }
349 } 344 }
350 345
351 void PresentationDispatcher::OnSessionCreated( 346 void PresentationDispatcher::OnSessionCreated(
352 blink::WebPresentationConnectionClientCallbacks* callback, 347 blink::WebPresentationConnectionClientCallbacks* callback,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 413
419 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { 414 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
420 if (presentation_service_.get()) 415 if (presentation_service_.get())
421 return; 416 return;
422 417
423 render_frame()->GetServiceRegistry()->ConnectToRemoteService( 418 render_frame()->GetServiceRegistry()->ConnectToRemoteService(
424 mojo::GetProxy(&presentation_service_)); 419 mojo::GetProxy(&presentation_service_));
425 presentation::PresentationServiceClientPtr client_ptr; 420 presentation::PresentationServiceClientPtr client_ptr;
426 binding_.Bind(GetProxy(&client_ptr), 16); 421 binding_.Bind(GetProxy(&client_ptr), 16);
427 presentation_service_->SetClient(client_ptr.Pass()); 422 presentation_service_->SetClient(client_ptr.Pass());
428
429 presentation_service_->ListenForDefaultSessionStart(base::Bind(
430 &PresentationDispatcher::OnDefaultSessionStarted,
431 base::Unretained(this)));
432 } 423 }
433 424
434 void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) { 425 void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) {
435 bool should_listen = !status->availability_callbacks.IsEmpty() || 426 bool should_listen = !status->availability_callbacks.IsEmpty() ||
436 !status->availability_observers.empty(); 427 !status->availability_observers.empty();
437 bool is_listening = status->listening_state != ListeningState::INACTIVE; 428 bool is_listening = status->listening_state != ListeningState::INACTIVE;
438 429
439 if (should_listen == is_listening) 430 if (should_listen == is_listening)
440 return; 431 return;
441 432
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( 490 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus(
500 const std::string& availability_url) 491 const std::string& availability_url)
501 : url(availability_url), 492 : url(availability_url),
502 last_known_availability(false), 493 last_known_availability(false),
503 listening_state(ListeningState::INACTIVE) {} 494 listening_state(ListeningState::INACTIVE) {}
504 495
505 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { 496 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() {
506 } 497 }
507 498
508 } // namespace content 499 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698