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

Side by Side Diff: chrome/browser/media/router/media_router_mojo_impl.cc

Issue 1507743005: [MediaRouter] Renames CloseRoute() to Terminate() and creates DetachRoute() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android build Created 5 years 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 "chrome/browser/media/router/media_router_mojo_impl.h" 5 #include "chrome/browser/media/router/media_router_mojo_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 307 }
308 308
309 SetWakeReason(MediaRouteProviderWakeReason::JOIN_ROUTE); 309 SetWakeReason(MediaRouteProviderWakeReason::JOIN_ROUTE);
310 int tab_id = SessionTabHelper::IdForTab(web_contents); 310 int tab_id = SessionTabHelper::IdForTab(web_contents);
311 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoJoinRoute, 311 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoJoinRoute,
312 base::Unretained(this), source_id, presentation_id, 312 base::Unretained(this), source_id, presentation_id,
313 origin.is_empty() ? "" : origin.spec(), tab_id, 313 origin.is_empty() ? "" : origin.spec(), tab_id,
314 callbacks)); 314 callbacks));
315 } 315 }
316 316
317 void MediaRouterMojoImpl::CloseRoute(const MediaRoute::Id& route_id) { 317 void MediaRouterMojoImpl::TerminateRoute(const MediaRoute::Id& route_id) {
318 DCHECK(thread_checker_.CalledOnValidThread()); 318 DCHECK(thread_checker_.CalledOnValidThread());
319 319
320 SetWakeReason(MediaRouteProviderWakeReason::CLOSE_ROUTE); 320 SetWakeReason(MediaRouteProviderWakeReason::TERMINATE_ROUTE);
321 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoCloseRoute, 321 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoTerminateRoute,
322 base::Unretained(this), route_id)); 322 base::Unretained(this), route_id));
323 } 323 }
324 324
325 void MediaRouterMojoImpl::DetachRoute(const MediaRoute::Id& route_id) {
326 DCHECK(thread_checker_.CalledOnValidThread());
327
328 SetWakeReason(MediaRouteProviderWakeReason::DETACH_ROUTE);
329 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoDetachRoute,
330 base::Unretained(this), route_id));
331 }
332
325 void MediaRouterMojoImpl::SendRouteMessage( 333 void MediaRouterMojoImpl::SendRouteMessage(
326 const MediaRoute::Id& route_id, 334 const MediaRoute::Id& route_id,
327 const std::string& message, 335 const std::string& message,
328 const SendRouteMessageCallback& callback) { 336 const SendRouteMessageCallback& callback) {
329 DCHECK(thread_checker_.CalledOnValidThread()); 337 DCHECK(thread_checker_.CalledOnValidThread());
330 338
331 SetWakeReason(MediaRouteProviderWakeReason::SEND_SESSION_MESSAGE); 339 SetWakeReason(MediaRouteProviderWakeReason::SEND_SESSION_MESSAGE);
332 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoSendSessionMessage, 340 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoSendSessionMessage,
333 base::Unretained(this), route_id, message, callback)); 341 base::Unretained(this), route_id, message, callback));
334 } 342 }
(...skipping 13 matching lines...) Expand all
348 void MediaRouterMojoImpl::AddIssue(const Issue& issue) { 356 void MediaRouterMojoImpl::AddIssue(const Issue& issue) {
349 DCHECK(thread_checker_.CalledOnValidThread()); 357 DCHECK(thread_checker_.CalledOnValidThread());
350 issue_manager_.AddIssue(issue); 358 issue_manager_.AddIssue(issue);
351 } 359 }
352 360
353 void MediaRouterMojoImpl::ClearIssue(const Issue::Id& issue_id) { 361 void MediaRouterMojoImpl::ClearIssue(const Issue::Id& issue_id) {
354 DCHECK(thread_checker_.CalledOnValidThread()); 362 DCHECK(thread_checker_.CalledOnValidThread());
355 issue_manager_.ClearIssue(issue_id); 363 issue_manager_.ClearIssue(issue_id);
356 } 364 }
357 365
358 void MediaRouterMojoImpl::OnPresentationSessionDetached(
359 const MediaRoute::Id& route_id) {
360 DCHECK(thread_checker_.CalledOnValidThread());
361 SetWakeReason(MediaRouteProviderWakeReason::PRESENTATION_SESSION_DETACHED);
362 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoOnPresentationSessionDetached,
363 base::Unretained(this), route_id));
364 }
365
366 bool MediaRouterMojoImpl::RegisterMediaSinksObserver( 366 bool MediaRouterMojoImpl::RegisterMediaSinksObserver(
367 MediaSinksObserver* observer) { 367 MediaSinksObserver* observer) {
368 DCHECK(thread_checker_.CalledOnValidThread()); 368 DCHECK(thread_checker_.CalledOnValidThread());
369 369
370 // Create an observer list for the media source and add |observer| 370 // Create an observer list for the media source and add |observer|
371 // to it. Fail if |observer| is already registered. 371 // to it. Fail if |observer| is already registered.
372 const std::string& source_id = observer->source().id(); 372 const std::string& source_id = observer->source().id();
373 auto* sinks_query = sinks_queries_.get(source_id); 373 auto* sinks_query = sinks_queries_.get(source_id);
374 if (!sinks_query) { 374 if (!sinks_query) {
375 sinks_query = new MediaSinksQuery; 375 sinks_query = new MediaSinksQuery;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 int tab_id, 544 int tab_id,
545 const std::vector<MediaRouteResponseCallback>& callbacks) { 545 const std::vector<MediaRouteResponseCallback>& callbacks) {
546 DVLOG_WITH_INSTANCE(1) << "DoJoinRoute " << source_id 546 DVLOG_WITH_INSTANCE(1) << "DoJoinRoute " << source_id
547 << ", presentation ID: " << presentation_id; 547 << ", presentation ID: " << presentation_id;
548 media_route_provider_->JoinRoute( 548 media_route_provider_->JoinRoute(
549 source_id, presentation_id, origin, tab_id, 549 source_id, presentation_id, origin, tab_id,
550 base::Bind(&MediaRouterMojoImpl::RouteResponseReceived, 550 base::Bind(&MediaRouterMojoImpl::RouteResponseReceived,
551 base::Unretained(this), presentation_id, callbacks)); 551 base::Unretained(this), presentation_id, callbacks));
552 } 552 }
553 553
554 void MediaRouterMojoImpl::DoCloseRoute(const MediaRoute::Id& route_id) { 554 void MediaRouterMojoImpl::DoTerminateRoute(const MediaRoute::Id& route_id) {
555 DVLOG_WITH_INSTANCE(1) << "DoCloseRoute " << route_id; 555 DVLOG_WITH_INSTANCE(1) << "DoTerminateRoute " << route_id;
556 media_route_provider_->CloseRoute(route_id); 556 media_route_provider_->TerminateRoute(route_id);
557 }
558
559 void MediaRouterMojoImpl::DoDetachRoute(const MediaRoute::Id& route_id) {
560 DVLOG_WITH_INSTANCE(1) << "DoDetachRoute " << route_id;
561 media_route_provider_->DetachRoute(route_id);
557 } 562 }
558 563
559 void MediaRouterMojoImpl::DoSendSessionMessage( 564 void MediaRouterMojoImpl::DoSendSessionMessage(
560 const MediaRoute::Id& route_id, 565 const MediaRoute::Id& route_id,
561 const std::string& message, 566 const std::string& message,
562 const SendRouteMessageCallback& callback) { 567 const SendRouteMessageCallback& callback) {
563 DVLOG_WITH_INSTANCE(1) << "SendRouteMessage " << route_id; 568 DVLOG_WITH_INSTANCE(1) << "SendRouteMessage " << route_id;
564 media_route_provider_->SendRouteMessage(route_id, message, callback); 569 media_route_provider_->SendRouteMessage(route_id, message, callback);
565 } 570 }
566 571
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 if (!interfaces::MediaRouter::PresentationConnectionState_IsValidValue( 677 if (!interfaces::MediaRouter::PresentationConnectionState_IsValidValue(
673 state)) { 678 state)) {
674 DLOG(WARNING) << "Unknown PresentationConnectionState value " << state; 679 DLOG(WARNING) << "Unknown PresentationConnectionState value " << state;
675 return; 680 return;
676 } 681 }
677 682
678 NotifyPresentationConnectionStateChange( 683 NotifyPresentationConnectionStateChange(
679 route_id, mojo::PresentationConnectionStateFromMojo(state)); 684 route_id, mojo::PresentationConnectionStateFromMojo(state));
680 } 685 }
681 686
682 void MediaRouterMojoImpl::DoOnPresentationSessionDetached(
683 const MediaRoute::Id& route_id) {
684 DVLOG_WITH_INSTANCE(1) << "DoOnPresentationSessionDetached " << route_id;
685 media_route_provider_->OnPresentationSessionDetached(route_id);
686 }
687
688 bool MediaRouterMojoImpl::HasLocalDisplayRoute() const { 687 bool MediaRouterMojoImpl::HasLocalDisplayRoute() const {
689 return has_local_display_route_; 688 return has_local_display_route_;
690 } 689 }
691 690
692 void MediaRouterMojoImpl::DoStartObservingMediaSinks( 691 void MediaRouterMojoImpl::DoStartObservingMediaSinks(
693 const MediaSource::Id& source_id) { 692 const MediaSource::Id& source_id) {
694 DVLOG_WITH_INSTANCE(1) << "DoStartObservingMediaSinks: " << source_id; 693 DVLOG_WITH_INSTANCE(1) << "DoStartObservingMediaSinks: " << source_id;
695 // No need to call MRPM if there are no sinks available. 694 // No need to call MRPM if there are no sinks available.
696 if (availability_ == interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE) 695 if (availability_ == interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE)
697 return; 696 return;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 if (current_wake_reason_ == MediaRouteProviderWakeReason::TOTAL_COUNT) 828 if (current_wake_reason_ == MediaRouteProviderWakeReason::TOTAL_COUNT)
830 current_wake_reason_ = reason; 829 current_wake_reason_ = reason;
831 } 830 }
832 831
833 void MediaRouterMojoImpl::ClearWakeReason() { 832 void MediaRouterMojoImpl::ClearWakeReason() {
834 DCHECK(current_wake_reason_ != MediaRouteProviderWakeReason::TOTAL_COUNT); 833 DCHECK(current_wake_reason_ != MediaRouteProviderWakeReason::TOTAL_COUNT);
835 current_wake_reason_ = MediaRouteProviderWakeReason::TOTAL_COUNT; 834 current_wake_reason_ = MediaRouteProviderWakeReason::TOTAL_COUNT;
836 } 835 }
837 836
838 } // namespace media_router 837 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_router_mojo_impl.h ('k') | chrome/browser/media/router/media_router_mojo_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698