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

Side by Side Diff: chrome/browser/ui/ash/cast_config_delegate_media_router.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: Fixing ChromeOS System Tray Test 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/ui/ash/cast_config_delegate_media_router.h" 5 #include "chrome/browser/ui/ash/cast_config_delegate_media_router.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/media/router/media_router.h" 10 #include "chrome/browser/media/router/media_router.h"
(...skipping 30 matching lines...) Expand all
41 } // namespace 41 } // namespace
42 42
43 // This class caches the values that the observers give us so we can query them 43 // This class caches the values that the observers give us so we can query them
44 // at any point in time. It also emits a device refresh event when new data is 44 // at any point in time. It also emits a device refresh event when new data is
45 // available. 45 // available.
46 class CastDeviceCache : public media_router::MediaRoutesObserver, 46 class CastDeviceCache : public media_router::MediaRoutesObserver,
47 public media_router::MediaSinksObserver { 47 public media_router::MediaSinksObserver {
48 public: 48 public:
49 using MediaSinks = std::vector<media_router::MediaSink>; 49 using MediaSinks = std::vector<media_router::MediaSink>;
50 using MediaRoutes = std::vector<media_router::MediaRoute>; 50 using MediaRoutes = std::vector<media_router::MediaRoute>;
51 using MediaRouteIds = std::vector<media_router::MediaRoute::Id>;
51 52
52 explicit CastDeviceCache(ash::CastConfigDelegate* cast_config_delegate); 53 explicit CastDeviceCache(ash::CastConfigDelegate* cast_config_delegate);
53 ~CastDeviceCache() override; 54 ~CastDeviceCache() override;
54 55
55 // This may call cast_config_delegate->RequestDeviceRefresh() before 56 // This may call cast_config_delegate->RequestDeviceRefresh() before
56 // returning. 57 // returning.
57 void Init(); 58 void Init();
58 59
59 const MediaSinks& sinks() const { return sinks_; } 60 const MediaSinks& sinks() const { return sinks_; }
60 const MediaRoutes& routes() const { return routes_; } 61 const MediaRoutes& routes() const { return routes_; }
61 62
62 private: 63 private:
63 // media_router::MediaSinksObserver: 64 // media_router::MediaSinksObserver:
64 void OnSinksReceived(const MediaSinks& sinks) override; 65 void OnSinksReceived(const MediaSinks& sinks) override;
65 66
66 // media_router::MediaRoutesObserver: 67 // media_router::MediaRoutesObserver:
67 void OnRoutesUpdated(const MediaRoutes& routes) override; 68 void OnRoutesUpdated(const MediaRoutes& routes,
69 const MediaRouteIds& unused_joinable_route_ids) override;
68 70
69 MediaSinks sinks_; 71 MediaSinks sinks_;
70 MediaRoutes routes_; 72 MediaRoutes routes_;
71 73
72 // Not owned. 74 // Not owned.
73 ash::CastConfigDelegate* cast_config_delegate_; 75 ash::CastConfigDelegate* cast_config_delegate_;
74 76
75 DISALLOW_COPY_AND_ASSIGN(CastDeviceCache); 77 DISALLOW_COPY_AND_ASSIGN(CastDeviceCache);
76 }; 78 };
77 79
78 CastDeviceCache::CastDeviceCache(ash::CastConfigDelegate* cast_config_delegate) 80 CastDeviceCache::CastDeviceCache(ash::CastConfigDelegate* cast_config_delegate)
79 : MediaRoutesObserver(GetMediaRouter()), 81 : MediaRoutesObserver(GetMediaRouter()),
80 MediaSinksObserver(GetMediaRouter(), 82 MediaSinksObserver(GetMediaRouter(),
81 media_router::MediaSourceForDesktop()), 83 media_router::MediaSourceForDesktop()),
82 cast_config_delegate_(cast_config_delegate) { 84 cast_config_delegate_(cast_config_delegate) {
83 } 85 }
84 86
85 CastDeviceCache::~CastDeviceCache() {} 87 CastDeviceCache::~CastDeviceCache() {}
86 88
87 void CastDeviceCache::Init() { 89 void CastDeviceCache::Init() {
88 CHECK(MediaSinksObserver::Init()); 90 CHECK(MediaSinksObserver::Init());
89 } 91 }
90 92
91 void CastDeviceCache::OnSinksReceived(const MediaSinks& sinks) { 93 void CastDeviceCache::OnSinksReceived(const MediaSinks& sinks) {
92 sinks_ = sinks; 94 sinks_ = sinks;
93 cast_config_delegate_->RequestDeviceRefresh(); 95 cast_config_delegate_->RequestDeviceRefresh();
94 } 96 }
95 97
96 void CastDeviceCache::OnRoutesUpdated(const MediaRoutes& routes) { 98 void CastDeviceCache::OnRoutesUpdated(
99 const MediaRoutes& routes,
100 const MediaRouteIds& unused_joinable_route_ids) {
97 routes_ = routes; 101 routes_ = routes;
98 cast_config_delegate_->RequestDeviceRefresh(); 102 cast_config_delegate_->RequestDeviceRefresh();
99 } 103 }
100 104
101 //////////////////////////////////////////////////////////////////////////////// 105 ////////////////////////////////////////////////////////////////////////////////
102 // CastConfigDelegateMediaRouter: 106 // CastConfigDelegateMediaRouter:
103 107
104 // static 108 // static
105 bool CastConfigDelegateMediaRouter::IsEnabled() { 109 bool CastConfigDelegateMediaRouter::IsEnabled() {
106 return media_router::MediaRouterEnabled( 110 return media_router::MediaRouterEnabled(
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void CastConfigDelegateMediaRouter::StopCasting(const std::string& route_id) { 206 void CastConfigDelegateMediaRouter::StopCasting(const std::string& route_id) {
203 GetMediaRouter()->TerminateRoute(route_id); 207 GetMediaRouter()->TerminateRoute(route_id);
204 } 208 }
205 209
206 bool CastConfigDelegateMediaRouter::HasOptions() const { 210 bool CastConfigDelegateMediaRouter::HasOptions() const {
207 // There are no plans to have an options page for the MediaRouter. 211 // There are no plans to have an options page for the MediaRouter.
208 return false; 212 return false;
209 } 213 }
210 214
211 void CastConfigDelegateMediaRouter::LaunchCastOptions() {} 215 void CastConfigDelegateMediaRouter::LaunchCastOptions() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698