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

Unified 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: nits Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/media/router/mojo/media_router_mojo_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/router/mojo/media_router_mojo_impl.h
diff --git a/chrome/browser/media/router/mojo/media_router_mojo_impl.h b/chrome/browser/media/router/mojo/media_router_mojo_impl.h
index 73d7187e6f62bfb30c800eb0ea41bf29b462bd12..b5c0d7075d4cca497b7ff3c6d93a7a587690e622 100644
--- a/chrome/browser/media/router/mojo/media_router_mojo_impl.h
+++ b/chrome/browser/media/router/mojo/media_router_mojo_impl.h
@@ -20,6 +20,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
+#include "base/optional.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/media/router/issue.h"
@@ -170,13 +171,10 @@ class MediaRouterMojoImpl : public MediaRouterBase,
// True if the query has been sent to the MRPM.
bool is_active = false;
- // True if cached result is available.
- bool has_cached_result = false;
-
- // Cached list of sinks for the query, if |has_cached_result| is true.
- // Empty otherwise.
- std::vector<MediaSink> cached_sink_list;
+ // Cached list of sinks and origins for the query.
+ base::Optional<std::vector<MediaSink>> cached_sink_list;
std::vector<url::Origin> origins;
+
base::ObserverList<MediaSinksObserver> observers;
private:
@@ -190,6 +188,11 @@ class MediaRouterMojoImpl : public MediaRouterBase,
// True if the query has been sent to the MRPM. False otherwise.
bool is_active = false;
+
+ // Cached list of routes and joinable route IDs for the query.
+ base::Optional<std::vector<MediaRoute>> cached_route_list;
+ std::vector<std::string> joinable_route_ids;
+
base::ObserverList<MediaRoutesObserver> observers;
private:
@@ -232,6 +235,11 @@ class MediaRouterMojoImpl : public MediaRouterBase,
void RegisterRouteMessageObserver(RouteMessageObserver* observer) override;
void UnregisterRouteMessageObserver(RouteMessageObserver* observer) override;
+ // Notifies |observer| of any existing cached routes, if it is still
+ // registered.
+ void NotifyOfExistingRoutesIfRegistered(const MediaSource::Id& source_id,
+ MediaRoutesObserver* observer) const;
+
// These calls invoke methods in the component extension via Mojo.
void DoCreateRoute(const MediaSource::Id& source_id,
const MediaSink::Id& sink_id,
« no previous file with comments | « no previous file | chrome/browser/media/router/mojo/media_router_mojo_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698