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

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

Issue 1415103006: Non-Local Join for Media Router and Presentation API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Backwards Compatibility Created 4 years, 11 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 "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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 MediaRouterMediaRoutesObserver(MediaRouterMojoImpl* router) 67 MediaRouterMediaRoutesObserver(MediaRouterMojoImpl* router)
68 : MediaRoutesObserver(router), 68 : MediaRoutesObserver(router),
69 router_(router) { 69 router_(router) {
70 DCHECK(router); 70 DCHECK(router);
71 } 71 }
72 72
73 MediaRouterMojoImpl::MediaRouterMediaRoutesObserver:: 73 MediaRouterMojoImpl::MediaRouterMediaRoutesObserver::
74 ~MediaRouterMediaRoutesObserver() { 74 ~MediaRouterMediaRoutesObserver() {
75 } 75 }
76 76
77 MediaRouterMojoImpl::MediaRoutesQuery::MediaRoutesQuery() = default;
78
79 MediaRouterMojoImpl::MediaRoutesQuery::~MediaRoutesQuery() = default;
80
77 MediaRouterMojoImpl::MediaSinksQuery::MediaSinksQuery() = default; 81 MediaRouterMojoImpl::MediaSinksQuery::MediaSinksQuery() = default;
78 82
79 MediaRouterMojoImpl::MediaSinksQuery::~MediaSinksQuery() = default; 83 MediaRouterMojoImpl::MediaSinksQuery::~MediaSinksQuery() = default;
80 84
81 void MediaRouterMojoImpl::MediaRouterMediaRoutesObserver::OnRoutesUpdated( 85 void MediaRouterMojoImpl::MediaRouterMediaRoutesObserver::OnRoutesUpdated(
82 const std::vector<media_router::MediaRoute>& routes) { 86 const std::vector<media_router::MediaRoute>& routes,
87 const std::vector<media_router::MediaRoute::Id>& joinable_route_ids) {
83 bool has_local_display_route = 88 bool has_local_display_route =
84 std::find_if(routes.begin(), routes.end(), 89 std::find_if(routes.begin(), routes.end(),
85 [](const media_router::MediaRoute& route) { 90 [](const media_router::MediaRoute& route) {
86 return route.is_local() && route.for_display(); 91 return route.is_local() && route.for_display();
87 }) != routes.end(); 92 }) != routes.end();
88 93
89 // |this| will be deleted in UpdateHasLocalDisplayRoute() if 94 // |this| will be deleted in UpdateHasLocalDisplayRoute() if
90 // |has_local_display_route| is false. Note that ObserverList supports 95 // |has_local_display_route| is false. Note that ObserverList supports
91 // removing an observer while iterating through it. 96 // removing an observer while iterating through it.
92 router_->UpdateHasLocalDisplayRoute(has_local_display_route); 97 router_->UpdateHasLocalDisplayRoute(has_local_display_route);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 const Issue& issue_converted = issue.To<Issue>(); 190 const Issue& issue_converted = issue.To<Issue>();
186 issue_manager_.AddIssue(issue_converted); 191 issue_manager_.AddIssue(issue_converted);
187 } 192 }
188 193
189 void MediaRouterMojoImpl::OnSinksReceived( 194 void MediaRouterMojoImpl::OnSinksReceived(
190 const mojo::String& media_source, 195 const mojo::String& media_source,
191 mojo::Array<interfaces::MediaSinkPtr> sinks) { 196 mojo::Array<interfaces::MediaSinkPtr> sinks) {
192 DCHECK(thread_checker_.CalledOnValidThread()); 197 DCHECK(thread_checker_.CalledOnValidThread());
193 198
194 DVLOG_WITH_INSTANCE(1) << "OnSinksReceived"; 199 DVLOG_WITH_INSTANCE(1) << "OnSinksReceived";
200 if (!HasSinksObservers(media_source)) {
201 DVLOG_WITH_INSTANCE(1)
202 << "Received sink list without any active observers: " << media_source;
203 return;
204 }
205
195 std::vector<MediaSink> sinks_converted; 206 std::vector<MediaSink> sinks_converted;
196 sinks_converted.reserve(sinks.size()); 207 sinks_converted.reserve(sinks.size());
197 208
198 for (size_t i = 0; i < sinks.size(); ++i) { 209 for (size_t i = 0; i < sinks.size(); ++i) {
199 sinks_converted.push_back(sinks[i].To<MediaSink>()); 210 sinks_converted.push_back(sinks[i].To<MediaSink>());
200 } 211 }
201 212
202 auto it = sinks_queries_.find(media_source); 213 auto sinks_query = sinks_queries_.get(media_source);
203 if (it == sinks_queries_.end() || 214 FOR_EACH_OBSERVER(MediaSinksObserver, sinks_query->observers,
204 !(it->second->observers.might_have_observers())) { 215 OnSinksReceived(sinks_converted));
205 DVLOG_WITH_INSTANCE(1)
206 << "Received sink list without any active observers: " << media_source;
207 } else {
208 FOR_EACH_OBSERVER(MediaSinksObserver, it->second->observers,
209 OnSinksReceived(sinks_converted));
210 }
211 } 216 }
212 217
213 void MediaRouterMojoImpl::OnRoutesUpdated( 218 void MediaRouterMojoImpl::OnRoutesUpdated(
214 mojo::Array<interfaces::MediaRoutePtr> routes) { 219 mojo::Array<interfaces::MediaRoutePtr> routes,
220 const mojo::String& media_source,
221 mojo::Array<mojo::String> joinable_route_ids) {
215 DCHECK(thread_checker_.CalledOnValidThread()); 222 DCHECK(thread_checker_.CalledOnValidThread());
216 223
217 DVLOG_WITH_INSTANCE(1) << "OnRoutesUpdated"; 224 DVLOG_WITH_INSTANCE(1) << "OnRoutesUpdated";
225 auto it = routes_queries_.find(media_source);
226 if (it == routes_queries_.end() ||
227 !(it->second->observers.might_have_observers())) {
228 DVLOG_WITH_INSTANCE(1)
229 << "Received route list without any active observers: " << media_source;
230 return;
231 }
218 232
219 std::vector<MediaRoute> routes_converted; 233 std::vector<MediaRoute> routes_converted;
220 routes_converted.reserve(routes.size()); 234 routes_converted.reserve(routes.size());
221 235
222 for (size_t i = 0; i < routes.size(); ++i) { 236 for (size_t i = 0; i < routes.size(); ++i)
223 routes_converted.push_back(routes[i].To<MediaRoute>()); 237 routes_converted.push_back(routes[i].To<MediaRoute>());
224 }
225 238
226 FOR_EACH_OBSERVER(MediaRoutesObserver, routes_observers_, 239 std::vector<MediaRoute::Id> joinable_routes_converted =
227 OnRoutesUpdated(routes_converted)); 240 joinable_route_ids.To<std::vector<std::string>>();
apacible 2016/01/05 21:41:58 nit: indent 4 spaces rather than 2
matt.boetger 2016/01/06 22:49:07 Done.
241
242 FOR_EACH_OBSERVER(MediaRoutesObserver, it->second->observers,
243 OnRoutesUpdated(routes_converted,
244 joinable_routes_converted));
228 } 245 }
229 246
230 void MediaRouterMojoImpl::RouteResponseReceived( 247 void MediaRouterMojoImpl::RouteResponseReceived(
231 const std::string& presentation_id, 248 const std::string& presentation_id,
232 const std::vector<MediaRouteResponseCallback>& callbacks, 249 const std::vector<MediaRouteResponseCallback>& callbacks,
233 interfaces::MediaRoutePtr media_route, 250 interfaces::MediaRoutePtr media_route,
234 const mojo::String& error_text) { 251 const mojo::String& error_text) {
235 scoped_ptr<MediaRoute> route; 252 scoped_ptr<MediaRoute> route;
236 std::string actual_presentation_id; 253 std::string actual_presentation_id;
237 std::string error; 254 std::string error;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 324 }
308 325
309 SetWakeReason(MediaRouteProviderWakeReason::JOIN_ROUTE); 326 SetWakeReason(MediaRouteProviderWakeReason::JOIN_ROUTE);
310 int tab_id = SessionTabHelper::IdForTab(web_contents); 327 int tab_id = SessionTabHelper::IdForTab(web_contents);
311 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoJoinRoute, 328 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoJoinRoute,
312 base::Unretained(this), source_id, presentation_id, 329 base::Unretained(this), source_id, presentation_id,
313 origin.is_empty() ? "" : origin.spec(), tab_id, 330 origin.is_empty() ? "" : origin.spec(), tab_id,
314 callbacks)); 331 callbacks));
315 } 332 }
316 333
334 void MediaRouterMojoImpl::ConnectRouteByRouteId(
335 const MediaSource::Id& source_id,
336 const MediaRoute::Id& route_id,
337 const GURL& origin,
338 content::WebContents* web_contents,
339 const std::vector<MediaRouteResponseCallback>& callbacks) {
340 DCHECK(thread_checker_.CalledOnValidThread());
341
342 if (!origin.is_valid()) {
343 DVLOG_WITH_INSTANCE(1) << "Invalid origin: " << origin;
344 for (const MediaRouteResponseCallback& callback : callbacks)
345 callback.Run(nullptr, "", "Invalid origin");
346 return;
347 }
348
349 int tab_id = SessionTabHelper::IdForTab(web_contents);
350 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoConnectRouteByRouteId,
mark a. foltz 2016/01/05 18:39:40 You'll want to call SetWakeReason() so we update t
matt.boetger 2016/01/06 22:49:07 Done.
351 base::Unretained(this), source_id, route_id,
352 origin.is_empty() ? "" : origin.spec(), tab_id,
353 callbacks));
354 }
355
317 void MediaRouterMojoImpl::CloseRoute(const MediaRoute::Id& route_id) { 356 void MediaRouterMojoImpl::CloseRoute(const MediaRoute::Id& route_id) {
318 DCHECK(thread_checker_.CalledOnValidThread()); 357 DCHECK(thread_checker_.CalledOnValidThread());
319 358
320 SetWakeReason(MediaRouteProviderWakeReason::CLOSE_ROUTE); 359 SetWakeReason(MediaRouteProviderWakeReason::CLOSE_ROUTE);
321 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoCloseRoute, 360 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoCloseRoute,
322 base::Unretained(this), route_id)); 361 base::Unretained(this), route_id));
323 } 362 }
324 363
325 void MediaRouterMojoImpl::SendRouteMessage( 364 void MediaRouterMojoImpl::SendRouteMessage(
326 const MediaRoute::Id& route_id, 365 const MediaRoute::Id& route_id,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 base::Unretained(this), source_id)); 462 base::Unretained(this), source_id));
424 } else { 463 } else {
425 sinks_queries_.erase(source_id); 464 sinks_queries_.erase(source_id);
426 } 465 }
427 } 466 }
428 } 467 }
429 468
430 void MediaRouterMojoImpl::RegisterMediaRoutesObserver( 469 void MediaRouterMojoImpl::RegisterMediaRoutesObserver(
431 MediaRoutesObserver* observer) { 470 MediaRoutesObserver* observer) {
432 DCHECK(thread_checker_.CalledOnValidThread()); 471 DCHECK(thread_checker_.CalledOnValidThread());
433 DCHECK(!routes_observers_.HasObserver(observer)); 472 const MediaSource::Id source_id = observer->source_id();
473 auto* routes_query = routes_queries_.get(source_id);
474 if (!routes_query) {
475 routes_query = new MediaRoutesQuery;
476 routes_queries_.add(source_id, make_scoped_ptr(routes_query));
477 } else {
478 DCHECK(!routes_query->observers.HasObserver(observer));
479 }
434 480
481 routes_query->observers.AddObserver(observer);
435 SetWakeReason(MediaRouteProviderWakeReason::START_OBSERVING_MEDIA_ROUTES); 482 SetWakeReason(MediaRouteProviderWakeReason::START_OBSERVING_MEDIA_ROUTES);
436 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoStartObservingMediaRoutes, 483 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoStartObservingMediaRoutes,
437 base::Unretained(this))); 484 base::Unretained(this), source_id));
438 routes_observers_.AddObserver(observer);
439 } 485 }
440 486
441 void MediaRouterMojoImpl::UnregisterMediaRoutesObserver( 487 void MediaRouterMojoImpl::UnregisterMediaRoutesObserver(
442 MediaRoutesObserver* observer) { 488 MediaRoutesObserver* observer) {
443 if (!routes_observers_.HasObserver(observer)) 489 const MediaSource::Id source_id = observer->source_id();
490 auto* routes_query = routes_queries_.get(source_id);
491 if (!routes_query || !routes_query->observers.HasObserver(observer)) {
444 return; 492 return;
493 }
445 494
446 routes_observers_.RemoveObserver(observer); 495 // If we are removing the final observer for the source, then stop
447 if (!routes_observers_.might_have_observers()) { 496 // observing routes for it.
497 // might_have_observers() is reliable here on the assumption that this call
498 // is not inside the ObserverList iteration.
499 routes_query->observers.RemoveObserver(observer);
500 if (!routes_query->observers.might_have_observers()) {
448 SetWakeReason(MediaRouteProviderWakeReason::STOP_OBSERVING_MEDIA_ROUTES); 501 SetWakeReason(MediaRouteProviderWakeReason::STOP_OBSERVING_MEDIA_ROUTES);
449 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoStopObservingMediaRoutes, 502 RunOrDefer(base::Bind(&MediaRouterMojoImpl::DoStopObservingMediaRoutes,
450 base::Unretained(this))); 503 base::Unretained(this), source_id));
451 } 504 }
452 } 505 }
453 506
454 void MediaRouterMojoImpl::RegisterIssuesObserver(IssuesObserver* observer) { 507 void MediaRouterMojoImpl::RegisterIssuesObserver(IssuesObserver* observer) {
455 DCHECK(thread_checker_.CalledOnValidThread()); 508 DCHECK(thread_checker_.CalledOnValidThread());
456 issue_manager_.RegisterObserver(observer); 509 issue_manager_.RegisterObserver(observer);
457 } 510 }
458 511
459 void MediaRouterMojoImpl::UnregisterIssuesObserver(IssuesObserver* observer) { 512 void MediaRouterMojoImpl::UnregisterIssuesObserver(IssuesObserver* observer) {
460 DCHECK(thread_checker_.CalledOnValidThread()); 513 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 int tab_id, 597 int tab_id,
545 const std::vector<MediaRouteResponseCallback>& callbacks) { 598 const std::vector<MediaRouteResponseCallback>& callbacks) {
546 DVLOG_WITH_INSTANCE(1) << "DoJoinRoute " << source_id 599 DVLOG_WITH_INSTANCE(1) << "DoJoinRoute " << source_id
547 << ", presentation ID: " << presentation_id; 600 << ", presentation ID: " << presentation_id;
548 media_route_provider_->JoinRoute( 601 media_route_provider_->JoinRoute(
549 source_id, presentation_id, origin, tab_id, 602 source_id, presentation_id, origin, tab_id,
550 base::Bind(&MediaRouterMojoImpl::RouteResponseReceived, 603 base::Bind(&MediaRouterMojoImpl::RouteResponseReceived,
551 base::Unretained(this), presentation_id, callbacks)); 604 base::Unretained(this), presentation_id, callbacks));
552 } 605 }
553 606
607 void MediaRouterMojoImpl::DoConnectRouteByRouteId(
608 const MediaSource::Id& source_id,
609 const MediaRoute::Id& route_id,
610 const std::string& origin,
611 int tab_id,
612 const std::vector<MediaRouteResponseCallback>& callbacks) {
613 std::string presentation_id("mr_");
614 presentation_id += base::GenerateGUID();
615 DVLOG_WITH_INSTANCE(1) << "DoConnectRouteByRouteId " << source_id
616 << ", route ID: " << route_id
617 << ", presentation ID: " << presentation_id;
618 media_route_provider_->ConnectRouteByRouteId(
619 source_id, route_id, presentation_id, origin, tab_id,
620 base::Bind(&MediaRouterMojoImpl::RouteResponseReceived,
621 base::Unretained(this), presentation_id, callbacks));
622 }
623
554 void MediaRouterMojoImpl::DoCloseRoute(const MediaRoute::Id& route_id) { 624 void MediaRouterMojoImpl::DoCloseRoute(const MediaRoute::Id& route_id) {
555 DVLOG_WITH_INSTANCE(1) << "DoCloseRoute " << route_id; 625 DVLOG_WITH_INSTANCE(1) << "DoCloseRoute " << route_id;
556 media_route_provider_->CloseRoute(route_id); 626 media_route_provider_->CloseRoute(route_id);
557 } 627 }
558 628
559 void MediaRouterMojoImpl::DoSendSessionMessage( 629 void MediaRouterMojoImpl::DoSendSessionMessage(
560 const MediaRoute::Id& route_id, 630 const MediaRoute::Id& route_id,
561 const std::string& message, 631 const std::string& message,
562 const SendRouteMessageCallback& callback) { 632 const SendRouteMessageCallback& callback) {
563 DVLOG_WITH_INSTANCE(1) << "SendRouteMessage " << route_id; 633 DVLOG_WITH_INSTANCE(1) << "SendRouteMessage " << route_id;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 760 }
691 761
692 void MediaRouterMojoImpl::DoStartObservingMediaSinks( 762 void MediaRouterMojoImpl::DoStartObservingMediaSinks(
693 const MediaSource::Id& source_id) { 763 const MediaSource::Id& source_id) {
694 DVLOG_WITH_INSTANCE(1) << "DoStartObservingMediaSinks: " << source_id; 764 DVLOG_WITH_INSTANCE(1) << "DoStartObservingMediaSinks: " << source_id;
695 // No need to call MRPM if there are no sinks available. 765 // No need to call MRPM if there are no sinks available.
696 if (availability_ == interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE) 766 if (availability_ == interfaces::MediaRouter::SINK_AVAILABILITY_UNAVAILABLE)
697 return; 767 return;
698 768
699 // No need to call MRPM if all observers have been removed in the meantime. 769 // No need to call MRPM if all observers have been removed in the meantime.
700 auto* sinks_query = sinks_queries_.get(source_id); 770 if (!HasSinksObservers(source_id))
701 if (!sinks_query || !sinks_query->observers.might_have_observers()) {
702 return; 771 return;
703 }
704 772
705 DVLOG_WITH_INSTANCE(1) << "MRPM.StartObservingMediaSinks: " << source_id; 773 DVLOG_WITH_INSTANCE(1) << "MRPM.StartObservingMediaSinks: " << source_id;
706 media_route_provider_->StartObservingMediaSinks(source_id); 774 media_route_provider_->StartObservingMediaSinks(source_id);
775 auto* sinks_query = sinks_queries_.get(source_id);
707 sinks_query->is_active = true; 776 sinks_query->is_active = true;
708 } 777 }
709 778
710 void MediaRouterMojoImpl::DoStopObservingMediaSinks( 779 void MediaRouterMojoImpl::DoStopObservingMediaSinks(
711 const MediaSource::Id& source_id) { 780 const MediaSource::Id& source_id) {
712 DVLOG_WITH_INSTANCE(1) << "DoStopObservingMediaSinks: " << source_id; 781 DVLOG_WITH_INSTANCE(1) << "DoStopObservingMediaSinks: " << source_id;
713 782
714 auto* sinks_query = sinks_queries_.get(source_id); 783 auto* sinks_query = sinks_queries_.get(source_id);
715 // No need to call MRPM if observers have been added in the meantime, 784 // No need to call MRPM if observers have been added in the meantime,
716 // or StopObservingMediaSinks has already been called. 785 // or StopObservingMediaSinks has already been called.
717 if (!sinks_query || !sinks_query->is_active || 786 if (!sinks_query || !sinks_query->is_active ||
718 sinks_query->observers.might_have_observers()) { 787 sinks_query->observers.might_have_observers()) {
719 return; 788 return;
720 } 789 }
721 790
722 DVLOG_WITH_INSTANCE(1) << "MRPM.StopObservingMediaSinks: " << source_id; 791 DVLOG_WITH_INSTANCE(1) << "MRPM.StopObservingMediaSinks: " << source_id;
723 media_route_provider_->StopObservingMediaSinks(source_id); 792 media_route_provider_->StopObservingMediaSinks(source_id);
724 sinks_queries_.erase(source_id); 793 sinks_queries_.erase(source_id);
725 } 794 }
726 795
727 void MediaRouterMojoImpl::DoStartObservingMediaRoutes() { 796 void MediaRouterMojoImpl::DoStartObservingMediaRoutes(
797 const MediaSource::Id& source_id) {
728 DVLOG_WITH_INSTANCE(1) << "DoStartObservingMediaRoutes"; 798 DVLOG_WITH_INSTANCE(1) << "DoStartObservingMediaRoutes";
729 media_route_provider_->StartObservingMediaRoutes(); 799
800 // No need to call MRPM if all observers have been removed in the meantime.
801 if (!HasRoutesObservers(source_id))
802 return;
803
804 DVLOG_WITH_INSTANCE(1) << "MRPM.StartObservingMediaRoutes: " << source_id;
805 media_route_provider_->StartObservingMediaRoutes(source_id);
806 auto* routes_query = routes_queries_.get(source_id);
807 routes_query->is_active = true;
730 } 808 }
731 809
732 void MediaRouterMojoImpl::DoStopObservingMediaRoutes() { 810 void MediaRouterMojoImpl::DoStopObservingMediaRoutes(
811 const MediaSource::Id& source_id) {
733 DVLOG_WITH_INSTANCE(1) << "DoStopObservingMediaRoutes"; 812 DVLOG_WITH_INSTANCE(1) << "DoStopObservingMediaRoutes";
734 media_route_provider_->StopObservingMediaRoutes(); 813
814 // No need to call MRPM if observers have been added in the meantime,
815 // or StopObservingMediaRoutes has already been called.
816 auto* routes_query = routes_queries_.get(source_id);
817 if (!routes_query || !routes_query->is_active ||
818 routes_query->observers.might_have_observers()) {
819 return;
820 }
821
822 DVLOG_WITH_INSTANCE(1) << "MRPM.StopObservingMediaRoutes: " << source_id;
823 media_route_provider_->StopObservingMediaRoutes(source_id);
824 routes_queries_.erase(source_id);
735 } 825 }
736 826
737 void MediaRouterMojoImpl::EnqueueTask(const base::Closure& closure) { 827 void MediaRouterMojoImpl::EnqueueTask(const base::Closure& closure) {
738 pending_requests_.push_back(closure); 828 pending_requests_.push_back(closure);
739 if (pending_requests_.size() > kMaxPendingRequests) { 829 if (pending_requests_.size() > kMaxPendingRequests) {
740 DLOG_WITH_INSTANCE(ERROR) << "Reached max queue size. Dropping oldest " 830 DLOG_WITH_INSTANCE(ERROR) << "Reached max queue size. Dropping oldest "
741 << "request."; 831 << "request.";
742 pending_requests_.pop_front(); 832 pending_requests_.pop_front();
743 } 833 }
744 DVLOG_WITH_INSTANCE(2) << "EnqueueTask (queue-length=" 834 DVLOG_WITH_INSTANCE(2) << "EnqueueTask (queue-length="
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 DCHECK(reason != MediaRouteProviderWakeReason::TOTAL_COUNT); 918 DCHECK(reason != MediaRouteProviderWakeReason::TOTAL_COUNT);
829 if (current_wake_reason_ == MediaRouteProviderWakeReason::TOTAL_COUNT) 919 if (current_wake_reason_ == MediaRouteProviderWakeReason::TOTAL_COUNT)
830 current_wake_reason_ = reason; 920 current_wake_reason_ = reason;
831 } 921 }
832 922
833 void MediaRouterMojoImpl::ClearWakeReason() { 923 void MediaRouterMojoImpl::ClearWakeReason() {
834 DCHECK(current_wake_reason_ != MediaRouteProviderWakeReason::TOTAL_COUNT); 924 DCHECK(current_wake_reason_ != MediaRouteProviderWakeReason::TOTAL_COUNT);
835 current_wake_reason_ = MediaRouteProviderWakeReason::TOTAL_COUNT; 925 current_wake_reason_ = MediaRouteProviderWakeReason::TOTAL_COUNT;
836 } 926 }
837 927
928 bool MediaRouterMojoImpl::HasRoutesObservers(
929 const MediaSource::Id& source_id) const {
930 auto* routes_query = routes_queries_.get(source_id);
931 return routes_query && routes_query->observers.might_have_observers();
932 }
933
934 bool MediaRouterMojoImpl::HasSinksObservers(
935 const MediaSource::Id& source_id) const {
936 auto* sinks_query = sinks_queries_.get(source_id);
937 return sinks_query && sinks_query->observers.might_have_observers();
938 }
939
838 } // namespace media_router 940 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698