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

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

Issue 1430413003: [Media Router] Connection state change listening redesign part 2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « content/renderer/presentation/presentation_dispatcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 blink::WebString::fromUTF8(error->message))); 356 blink::WebString::fromUTF8(error->message)));
357 return; 357 return;
358 } 358 }
359 359
360 DCHECK(!session_info.is_null()); 360 DCHECK(!session_info.is_null());
361 callback->onSuccess(blink::adoptWebPtr( 361 callback->onSuccess(blink::adoptWebPtr(
362 new PresentationConnectionClient(session_info.Clone()))); 362 new PresentationConnectionClient(session_info.Clone())));
363 presentation_service_->ListenForSessionMessages(session_info.Pass()); 363 presentation_service_->ListenForSessionMessages(session_info.Pass());
364 } 364 }
365 365
366 void PresentationDispatcher::OnSessionStateChanged( 366 void PresentationDispatcher::OnConnectionStateChanged(
367 presentation::PresentationSessionInfoPtr session_info, 367 presentation::PresentationSessionInfoPtr connection,
368 presentation::PresentationConnectionState session_state) { 368 presentation::PresentationConnectionState state) {
369 if (!controller_) 369 if (!controller_)
370 return; 370 return;
371 371
372 DCHECK(!session_info.is_null()); 372 DCHECK(!connection.is_null());
373 controller_->didChangeSessionState( 373 controller_->didChangeSessionState(
374 new PresentationConnectionClient(session_info.Pass()), 374 new PresentationConnectionClient(connection.Pass()),
375 GetWebPresentationConnectionStateFromMojo(session_state)); 375 GetWebPresentationConnectionStateFromMojo(state));
376 } 376 }
377 377
378 void PresentationDispatcher::OnSessionMessagesReceived( 378 void PresentationDispatcher::OnSessionMessagesReceived(
379 presentation::PresentationSessionInfoPtr session_info, 379 presentation::PresentationSessionInfoPtr session_info,
380 mojo::Array<presentation::SessionMessagePtr> messages) { 380 mojo::Array<presentation::SessionMessagePtr> messages) {
381 if (!controller_) 381 if (!controller_)
382 return; 382 return;
383 383
384 for (size_t i = 0; i < messages.size(); ++i) { 384 for (size_t i = 0; i < messages.size(); ++i) {
385 // Note: Passing batches of messages to the Blink layer would be more 385 // Note: Passing batches of messages to the Blink layer would be more
(...skipping 27 matching lines...) Expand all
413 413
414 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { 414 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
415 if (presentation_service_.get()) 415 if (presentation_service_.get())
416 return; 416 return;
417 417
418 render_frame()->GetServiceRegistry()->ConnectToRemoteService( 418 render_frame()->GetServiceRegistry()->ConnectToRemoteService(
419 mojo::GetProxy(&presentation_service_)); 419 mojo::GetProxy(&presentation_service_));
420 presentation::PresentationServiceClientPtr client_ptr; 420 presentation::PresentationServiceClientPtr client_ptr;
421 binding_.Bind(GetProxy(&client_ptr)); 421 binding_.Bind(GetProxy(&client_ptr));
422 presentation_service_->SetClient(client_ptr.Pass()); 422 presentation_service_->SetClient(client_ptr.Pass());
423
424 presentation_service_->ListenForSessionStateChange();
425 } 423 }
426 424
427 void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) { 425 void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) {
428 bool should_listen = !status->availability_callbacks.IsEmpty() || 426 bool should_listen = !status->availability_callbacks.IsEmpty() ||
429 !status->availability_observers.empty(); 427 !status->availability_observers.empty();
430 bool is_listening = status->listening_state != ListeningState::INACTIVE; 428 bool is_listening = status->listening_state != ListeningState::INACTIVE;
431 429
432 if (should_listen == is_listening) 430 if (should_listen == is_listening)
433 return; 431 return;
434 432
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( 490 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus(
493 const std::string& availability_url) 491 const std::string& availability_url)
494 : url(availability_url), 492 : url(availability_url),
495 last_known_availability(false), 493 last_known_availability(false),
496 listening_state(ListeningState::INACTIVE) {} 494 listening_state(ListeningState::INACTIVE) {}
497 495
498 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { 496 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() {
499 } 497 }
500 498
501 } // namespace content 499 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/presentation/presentation_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698