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

Unified Diff: chrome/browser/media/router/media_sinks_observer.h

Issue 1784533004: [Media Router] Add origins to sink query results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/media_sinks_observer.h
diff --git a/chrome/browser/media/router/media_sinks_observer.h b/chrome/browser/media/router/media_sinks_observer.h
index da9f517967fce9f322c9569b61bb961212ccfeb8..5a87f27321f890801f695c3e6378cec1a4d3459d 100644
--- a/chrome/browser/media/router/media_sinks_observer.h
+++ b/chrome/browser/media/router/media_sinks_observer.h
@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "chrome/browser/media/router/media_sink.h"
#include "chrome/browser/media/router/media_source.h"
+#include "url/gurl.h"
namespace media_router {
@@ -23,9 +24,11 @@ class MediaRouter;
// docs.google.com/document/d/1RDXdzi2y7lRuL08HAe-qlSJG2DMz2iH3gBzMs0IRR78
class MediaSinksObserver {
public:
- // Constructs an observer that will observe for sinks compatible
+ // Constructs an observer from |origin| that will observe for sinks compatible
// with |source|.
- MediaSinksObserver(MediaRouter* router, const MediaSource& source);
+ MediaSinksObserver(MediaRouter* router,
+ const MediaSource& source,
+ const GURL& origin);
virtual ~MediaSinksObserver();
// Registers with MediaRouter to start observing. Must be called before the
@@ -33,20 +36,33 @@ class MediaSinksObserver {
// initialized. This method is no-op if the observer is already initialized.
bool Init();
- // This function is invoked when the list of sinks compatible
- // with |source_| has been updated.
+ // This function is invoked when the list of sinks compatible with |source_|
+ // has been updated. The result also contains the list of valid origins.
+ // If |origins| is empty or contains |origin_|, then |OnSinksReceived(sinks)|
+ // will be invoked with |sinks|. Otherwise, it will be invoked with an empty
+ // list.
+ void OnSinksUpdated(const std::vector<MediaSink>& sinks,
+ const std::vector<GURL>& origins);
+
+ const MediaSource& source() const { return source_; }
+
+ protected:
+ // This function is invoked from |OnSinksUpdated(sinks, origins)|.
// Implementations may not perform operations that modify the Media Router's
// observer list. In particular, invoking this observer's destructor within
// OnSinksReceived will result in undefined behavior.
- virtual void OnSinksReceived(const std::vector<MediaSink>& sinks) {}
-
- const MediaSource& source() const { return source_; }
+ virtual void OnSinksReceived(const std::vector<MediaSink>& sinks) = 0;
private:
const MediaSource source_;
- MediaRouter* router_;
+ const GURL origin_;
+ MediaRouter* const router_;
bool initialized_;
+#if DCHECK_IS_ON()
+ bool in_on_sinks_updated_ = false;
+#endif
+
DISALLOW_COPY_AND_ASSIGN(MediaSinksObserver);
};
« no previous file with comments | « chrome/browser/media/router/media_router_mojo_impl_unittest.cc ('k') | chrome/browser/media/router/media_sinks_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698