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

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: Add optional presentation_id field to MediaRoute 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().has_value() &&
mark a. foltz 2017/03/10 00:56:28 I think .has_value() is optional here.
zhaobin 2017/03/10 01:51:11 Done.
45 (*route.presentation_id()) == presentation_id) {
mark a. foltz 2017/03/10 00:56:28 In other code I have used .value() explicitly to r
zhaobin 2017/03/10 01:51:11 Done.
46 return &route;
47 }
48 }
49
50 return nullptr;
51 }
52
41 bool has_route; 53 bool has_route;
42 std::vector<MediaRoute> current_routes; 54 std::vector<MediaRoute> current_routes;
43 std::vector<MediaRoute::Id> incognito_route_ids; 55 std::vector<MediaRoute::Id> incognito_route_ids;
44 56
45 private: 57 private:
46 DISALLOW_COPY_AND_ASSIGN(InternalMediaRoutesObserver); 58 DISALLOW_COPY_AND_ASSIGN(InternalMediaRoutesObserver);
47 }; 59 };
48 60
49 MediaRouterBase::~MediaRouterBase() { 61 MediaRouterBase::~MediaRouterBase() {
50 CHECK(!internal_routes_observer_); 62 CHECK(!internal_routes_observer_);
(...skipping 18 matching lines...) Expand all
69 81
70 void MediaRouterBase::OnIncognitoProfileShutdown() { 82 void MediaRouterBase::OnIncognitoProfileShutdown() {
71 for (const auto& route_id : internal_routes_observer_->incognito_route_ids) 83 for (const auto& route_id : internal_routes_observer_->incognito_route_ids)
72 TerminateRoute(route_id); 84 TerminateRoute(route_id);
73 } 85 }
74 86
75 std::vector<MediaRoute> MediaRouterBase::GetCurrentRoutes() const { 87 std::vector<MediaRoute> MediaRouterBase::GetCurrentRoutes() const {
76 return internal_routes_observer_->current_routes; 88 return internal_routes_observer_->current_routes;
77 } 89 }
78 90
91 const MediaRoute* MediaRouterBase::GetPresentationRoute(
92 const std::string& presentation_id) const {
93 DCHECK(internal_routes_observer_);
94 return internal_routes_observer_->GetPresentationRoute(presentation_id);
95 }
96
79 MediaRouterBase::MediaRouterBase() : initialized_(false) {} 97 MediaRouterBase::MediaRouterBase() : initialized_(false) {}
80 98
81 // static 99 // static
82 std::string MediaRouterBase::CreatePresentationId() { 100 std::string MediaRouterBase::CreatePresentationId() {
83 return "mr_" + base::GenerateGUID(); 101 return "mr_" + base::GenerateGUID();
84 } 102 }
85 103
86 void MediaRouterBase::NotifyPresentationConnectionStateChange( 104 void MediaRouterBase::NotifyPresentationConnectionStateChange(
87 const MediaRoute::Id& route_id, 105 const MediaRoute::Id& route_id,
88 content::PresentationConnectionState state) { 106 content::PresentationConnectionState state) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 150 }
133 } 151 }
134 152
135 void MediaRouterBase::Shutdown() { 153 void MediaRouterBase::Shutdown() {
136 // The observer calls virtual methods on MediaRouter; it must be destroyed 154 // The observer calls virtual methods on MediaRouter; it must be destroyed
137 // outside of the dtor 155 // outside of the dtor
138 internal_routes_observer_.reset(); 156 internal_routes_observer_.reset();
139 } 157 }
140 158
141 } // namespace media_router 159 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_router_base.h ('k') | chrome/browser/media/router/media_router_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698