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

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

Issue 1406013003: [Presentation API / Media Router] Clean up default pres URL logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Original patch 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
345 if (!session_info.is_null()) { 340 if (!session_info.is_null()) {
346 controller_->didStartDefaultSession( 341 controller_->didStartDefaultSession(
347 new PresentationConnectionClient(session_info.Clone())); 342 new PresentationConnectionClient(session_info.Clone()));
348 presentation_service_->ListenForSessionMessages(session_info.Pass()); 343 presentation_service_->ListenForSessionMessages(session_info.Pass());
349 } 344 }
350 } 345 }
351 346
352 void PresentationDispatcher::OnSessionCreated( 347 void PresentationDispatcher::OnSessionCreated(
353 blink::WebPresentationConnectionClientCallbacks* callback, 348 blink::WebPresentationConnectionClientCallbacks* callback,
354 presentation::PresentationSessionInfoPtr session_info, 349 presentation::PresentationSessionInfoPtr session_info,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)); 421 binding_.Bind(GetProxy(&client_ptr));
427 presentation_service_->SetClient(client_ptr.Pass()); 422 presentation_service_->SetClient(client_ptr.Pass());
428 423
429 presentation_service_->ListenForDefaultSessionStart(base::Bind(
430 &PresentationDispatcher::OnDefaultSessionStarted,
431 base::Unretained(this)));
432 presentation_service_->ListenForSessionStateChange(); 424 presentation_service_->ListenForSessionStateChange();
433 } 425 }
434 426
435 void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) { 427 void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) {
436 bool should_listen = !status->availability_callbacks.IsEmpty() || 428 bool should_listen = !status->availability_callbacks.IsEmpty() ||
437 !status->availability_observers.empty(); 429 !status->availability_observers.empty();
438 bool is_listening = status->listening_state != ListeningState::INACTIVE; 430 bool is_listening = status->listening_state != ListeningState::INACTIVE;
439 431
440 if (should_listen == is_listening) 432 if (should_listen == is_listening)
441 return; 433 return;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus( 492 PresentationDispatcher::AvailabilityStatus::AvailabilityStatus(
501 const std::string& availability_url) 493 const std::string& availability_url)
502 : url(availability_url), 494 : url(availability_url),
503 last_known_availability(false), 495 last_known_availability(false),
504 listening_state(ListeningState::INACTIVE) {} 496 listening_state(ListeningState::INACTIVE) {}
505 497
506 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() { 498 PresentationDispatcher::AvailabilityStatus::~AvailabilityStatus() {
507 } 499 }
508 500
509 } // namespace content 501 } // 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