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

Side by Side 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: 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 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_MEDIA_SINKS_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_OBSERVER_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_OBSERVER_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_OBSERVER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "chrome/browser/media/router/media_sink.h" 11 #include "chrome/browser/media/router/media_sink.h"
12 #include "chrome/browser/media/router/media_source.h" 12 #include "chrome/browser/media/router/media_source.h"
13 #include "url/gurl.h"
13 14
14 namespace media_router { 15 namespace media_router {
15 16
16 class MediaRouter; 17 class MediaRouter;
17 18
18 // Base class for observing when the collection of sinks compatible with 19 // Base class for observing when the collection of sinks compatible with
19 // a MediaSource has been updated. 20 // a MediaSource has been updated.
20 // A MediaSinksObserver implementation can be registered to MediaRouter to 21 // A MediaSinksObserver implementation can be registered to MediaRouter to
21 // receive results. It can then interpret / process the results accordingly. 22 // receive results. It can then interpret / process the results accordingly.
22 // More documentation can be found at 23 // More documentation can be found at
23 // docs.google.com/document/d/1RDXdzi2y7lRuL08HAe-qlSJG2DMz2iH3gBzMs0IRR78 24 // docs.google.com/document/d/1RDXdzi2y7lRuL08HAe-qlSJG2DMz2iH3gBzMs0IRR78
24 class MediaSinksObserver { 25 class MediaSinksObserver {
25 public: 26 public:
26 // Constructs an observer that will observe for sinks compatible 27 // Constructs an observer that will observe for sinks compatible
27 // with |source|. 28 // with |source|.
mark a. foltz 2016/03/11 01:20:23 Document meaning of |origin|.
imcheng 2016/03/14 21:30:20 Done.
28 MediaSinksObserver(MediaRouter* router, const MediaSource& source); 29 MediaSinksObserver(MediaRouter* router,
30 const MediaSource& source,
31 const GURL& origin);
29 virtual ~MediaSinksObserver(); 32 virtual ~MediaSinksObserver();
30 33
31 // Registers with MediaRouter to start observing. Must be called before the 34 // Registers with MediaRouter to start observing. Must be called before the
32 // observer will start receiving updates. Returns |true| if the observer is 35 // observer will start receiving updates. Returns |true| if the observer is
33 // initialized. This method is no-op if the observer is already initialized. 36 // initialized. This method is no-op if the observer is already initialized.
34 bool Init(); 37 bool Init();
35 38
36 // This function is invoked when the list of sinks compatible 39 // This function is invoked when the list of sinks compatible with |source_|
37 // with |source_| has been updated. 40 // has been updated. The result also contains the list of valid origins.
38 // Implementations may not perform operations that modify the Media Router's 41 // If |origins| is empty or contains |origin_|, then |OnSinksReceived(sinks)|
39 // observer list. In particular, invoking this observer's destructor within 42 // will be invoked with |sinks|. Otherwise, it will be invoked with an empty
40 // OnSinksReceived will result in undefined behavior. 43 // list.
41 virtual void OnSinksReceived(const std::vector<MediaSink>& sinks) {} 44 void OnSinksUpdated(const std::vector<MediaSink>& sinks,
45 const std::vector<GURL>& origins);
42 46
43 const MediaSource& source() const { return source_; } 47 const MediaSource& source() const { return source_; }
44 48
45 private: 49 private:
50 // This function is invoked from |OnSinksUpdated(sinks, origins)|.
51 // Implementations may not perform operations that modify the Media Router's
52 // observer list. In particular, invoking this observer's destructor within
53 // OnSinksReceived will result in undefined behavior.
mark a. foltz 2016/03/11 01:20:23 This seems like common sense, but maybe it could b
imcheng 2016/03/14 21:30:20 Done.
54 virtual void OnSinksReceived(const std::vector<MediaSink>& sinks) = 0;
mark a. foltz 2016/03/11 01:20:23 Usually virtual methods that are to be implemented
imcheng 2016/03/14 21:30:20 Done. Moved back to public
55
46 const MediaSource source_; 56 const MediaSource source_;
47 MediaRouter* router_; 57 const GURL origin_;
58 MediaRouter* const router_;
48 bool initialized_; 59 bool initialized_;
49 60
50 DISALLOW_COPY_AND_ASSIGN(MediaSinksObserver); 61 DISALLOW_COPY_AND_ASSIGN(MediaSinksObserver);
51 }; 62 };
52 63
53 } // namespace media_router 64 } // namespace media_router
54 65
55 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_OBSERVER_H_ 66 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698