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

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

Issue 2731043002: [Media Router] Add a presentation id to MediaRoute mapping in the MR (Closed)
Patch Set: resolve code review comments from Mark Created 3 years, 9 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_base.h" 5 #include "chrome/browser/media/router/media_router_base.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/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 20 matching lines...) Expand all
31 incognito_route_ids.clear(); 31 incognito_route_ids.clear();
32 // TODO(crbug.com/611486): Have the MRPM pass a list of joinable route ids 32 // TODO(crbug.com/611486): Have the MRPM pass a list of joinable route ids
33 // via |joinable_route_ids|, and check here if it is non-empty. 33 // via |joinable_route_ids|, and check here if it is non-empty.
34 has_route = !routes.empty(); 34 has_route = !routes.empty();
35 for (const auto& route : routes) { 35 for (const auto& route : routes) {
36 if (route.is_incognito()) 36 if (route.is_incognito())
37 incognito_route_ids.push_back(route.media_route_id()); 37 incognito_route_ids.push_back(route.media_route_id());
38 } 38 }
39 } 39 }
40 40
41 const MediaRoute* GetPresentationRoute(
42 const std::string& presentation_id) const {
43 for (const auto& route : current_routes) {
44 if (route.presentation_id().value() == presentation_id)
45 return &route;
46 }
47
48 return nullptr;
49 }
50
41 bool has_route; 51 bool has_route;
42 std::vector<MediaRoute> current_routes; 52 std::vector<MediaRoute> current_routes;
43 std::vector<MediaRoute::Id> incognito_route_ids; 53 std::vector<MediaRoute::Id> incognito_route_ids;
44 54
45 private: 55 private:
46 DISALLOW_COPY_AND_ASSIGN(InternalMediaRoutesObserver); 56 DISALLOW_COPY_AND_ASSIGN(InternalMediaRoutesObserver);
47 }; 57 };
48 58
49 MediaRouterBase::~MediaRouterBase() { 59 MediaRouterBase::~MediaRouterBase() {
50 CHECK(!internal_routes_observer_); 60 CHECK(!internal_routes_observer_);
(...skipping 18 matching lines...) Expand all
69 79
70 void MediaRouterBase::OnIncognitoProfileShutdown() { 80 void MediaRouterBase::OnIncognitoProfileShutdown() {
71 for (const auto& route_id : internal_routes_observer_->incognito_route_ids) 81 for (const auto& route_id : internal_routes_observer_->incognito_route_ids)
72 TerminateRoute(route_id); 82 TerminateRoute(route_id);
73 } 83 }
74 84
75 std::vector<MediaRoute> MediaRouterBase::GetCurrentRoutes() const { 85 std::vector<MediaRoute> MediaRouterBase::GetCurrentRoutes() const {
76 return internal_routes_observer_->current_routes; 86 return internal_routes_observer_->current_routes;
77 } 87 }
78 88
89 const MediaRoute* MediaRouterBase::GetPresentationRoute(
90 const std::string& presentation_id) const {
91 DCHECK(internal_routes_observer_);
92 return internal_routes_observer_->GetPresentationRoute(presentation_id);
93 }
94
79 MediaRouterBase::MediaRouterBase() : initialized_(false) {} 95 MediaRouterBase::MediaRouterBase() : initialized_(false) {}
80 96
81 // static 97 // static
82 std::string MediaRouterBase::CreatePresentationId() { 98 std::string MediaRouterBase::CreatePresentationId() {
83 return "mr_" + base::GenerateGUID(); 99 return "mr_" + base::GenerateGUID();
84 } 100 }
85 101
86 void MediaRouterBase::NotifyPresentationConnectionStateChange( 102 void MediaRouterBase::NotifyPresentationConnectionStateChange(
87 const MediaRoute::Id& route_id, 103 const MediaRoute::Id& route_id,
88 content::PresentationConnectionState state) { 104 content::PresentationConnectionState state) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 148 }
133 } 149 }
134 150
135 void MediaRouterBase::Shutdown() { 151 void MediaRouterBase::Shutdown() {
136 // The observer calls virtual methods on MediaRouter; it must be destroyed 152 // The observer calls virtual methods on MediaRouter; it must be destroyed
137 // outside of the dtor 153 // outside of the dtor
138 internal_routes_observer_.reset(); 154 internal_routes_observer_.reset();
139 } 155 }
140 156
141 } // namespace media_router 157 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698