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

Side by Side Diff: chrome/browser/media/router/mojo/media_router_mojo_impl.h

Issue 2735493002: MediaRouter: Cache MediaRoutesObserver queries to prevent ext wake-ups (Closed)
Patch Set: 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 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // True if the query has been sent to the MRPM. 170 // True if the query has been sent to the MRPM.
171 bool is_active = false; 171 bool is_active = false;
172 172
173 // True if cached result is available. 173 // True if cached result is available.
174 bool has_cached_result = false; 174 bool has_cached_result = false;
175 175
176 // Cached list of sinks for the query, if |has_cached_result| is true. 176 // Cached list of sinks for the query, if |has_cached_result| is true.
177 // Empty otherwise. 177 // Empty otherwise.
178 std::vector<MediaSink> cached_sink_list; 178 std::vector<MediaSink> cached_sink_list;
179 std::vector<url::Origin> origins; 179 std::vector<url::Origin> origins;
180
180 base::ObserverList<MediaSinksObserver> observers; 181 base::ObserverList<MediaSinksObserver> observers;
181 182
182 private: 183 private:
183 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery); 184 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery);
184 }; 185 };
185 186
186 struct MediaRoutesQuery { 187 struct MediaRoutesQuery {
187 public: 188 public:
188 MediaRoutesQuery(); 189 MediaRoutesQuery();
189 ~MediaRoutesQuery(); 190 ~MediaRoutesQuery();
190 191
191 // True if the query has been sent to the MRPM. False otherwise. 192 // True if the query has been sent to the MRPM. False otherwise.
192 bool is_active = false; 193 bool is_active = false;
194
195 // True if cached result is available.
196 bool has_cached_result = false;
Wez 2017/03/04 02:07:32 nit: Since you have two cached-data fields below t
miu 2017/03/04 02:24:39 Done.
197
198 // Cached list of routes for the query, if |has_cached_result| is true.
199 // Empty otherwise.
200 std::vector<MediaRoute> cached_route_list;
201 std::vector<std::string> joinable_route_ids;
202
193 base::ObserverList<MediaRoutesObserver> observers; 203 base::ObserverList<MediaRoutesObserver> observers;
194 204
195 private: 205 private:
196 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery); 206 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery);
197 }; 207 };
198 208
199 // Standard constructor, used by 209 // Standard constructor, used by
200 // MediaRouterMojoImplFactory::GetApiForBrowserContext. 210 // MediaRouterMojoImplFactory::GetApiForBrowserContext.
201 explicit MediaRouterMojoImpl( 211 explicit MediaRouterMojoImpl(
202 extensions::EventPageTracker* event_page_tracker); 212 extensions::EventPageTracker* event_page_tracker);
(...skipping 22 matching lines...) Expand all
225 // MediaRouter implementation. 235 // MediaRouter implementation.
226 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override; 236 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override;
227 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override; 237 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override;
228 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; 238 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override;
229 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; 239 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override;
230 void RegisterIssuesObserver(IssuesObserver* observer) override; 240 void RegisterIssuesObserver(IssuesObserver* observer) override;
231 void UnregisterIssuesObserver(IssuesObserver* observer) override; 241 void UnregisterIssuesObserver(IssuesObserver* observer) override;
232 void RegisterRouteMessageObserver(RouteMessageObserver* observer) override; 242 void RegisterRouteMessageObserver(RouteMessageObserver* observer) override;
233 void UnregisterRouteMessageObserver(RouteMessageObserver* observer) override; 243 void UnregisterRouteMessageObserver(RouteMessageObserver* observer) override;
234 244
245 // Notifies |observer| of any existing cached routes, after registration.
246 void NotifyOfExistingRoutesAfterRegistration(
Wez 2017/03/04 02:07:32 This is a confusing name, IMO - I'd suggest either
miu 2017/03/04 02:24:39 Done.
247 const MediaSource::Id& source_id,
248 MediaRoutesObserver* observer) const;
249
235 // These calls invoke methods in the component extension via Mojo. 250 // These calls invoke methods in the component extension via Mojo.
236 void DoCreateRoute(const MediaSource::Id& source_id, 251 void DoCreateRoute(const MediaSource::Id& source_id,
237 const MediaSink::Id& sink_id, 252 const MediaSink::Id& sink_id,
238 const url::Origin& origin, 253 const url::Origin& origin,
239 int tab_id, 254 int tab_id,
240 const std::vector<MediaRouteResponseCallback>& callbacks, 255 const std::vector<MediaRouteResponseCallback>& callbacks,
241 base::TimeDelta timeout, 256 base::TimeDelta timeout,
242 bool incognito); 257 bool incognito);
243 void DoJoinRoute(const MediaSource::Id& source_id, 258 void DoJoinRoute(const MediaSource::Id& source_id,
244 const std::string& presentation_id, 259 const std::string& presentation_id,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 #endif 445 #endif
431 446
432 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; 447 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_;
433 448
434 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); 449 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl);
435 }; 450 };
436 451
437 } // namespace media_router 452 } // namespace media_router
438 453
439 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ 454 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698