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

Side by Side Diff: chrome/browser/media/router/media_sinks_observer.h

Issue 2627463003: Convert MediaRouter mojom apis to intake url::Origin objects instead of strings (Closed)
Patch Set: Add missing dependency for extensions_renderer_resources target 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 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 #include "url/origin.h"
14 14
15 namespace media_router { 15 namespace media_router {
16 16
17 class MediaRouter; 17 class MediaRouter;
18 18
19 // Base class for observing when the collection of sinks compatible with 19 // Base class for observing when the collection of sinks compatible with
20 // a MediaSource has been updated. 20 // a MediaSource has been updated.
21 // A MediaSinksObserver implementation can be registered to MediaRouter to 21 // A MediaSinksObserver implementation can be registered to MediaRouter to
22 // receive results. It can then interpret / process the results accordingly. 22 // receive results. It can then interpret / process the results accordingly.
23 // More documentation can be found at 23 // More documentation can be found at
24 // docs.google.com/document/d/1RDXdzi2y7lRuL08HAe-qlSJG2DMz2iH3gBzMs0IRR78 24 // docs.google.com/document/d/1RDXdzi2y7lRuL08HAe-qlSJG2DMz2iH3gBzMs0IRR78
25 class MediaSinksObserver { 25 class MediaSinksObserver {
26 public: 26 public:
27 // Constructs an observer from |origin| that will observe for sinks compatible 27 // Constructs an observer from |origin| that will observe for sinks compatible
28 // with |source|. 28 // with |source|.
29 MediaSinksObserver(MediaRouter* router, 29 MediaSinksObserver(MediaRouter* router,
30 const MediaSource& source, 30 const MediaSource& source,
31 const GURL& origin); 31 const url::Origin& origin);
32 virtual ~MediaSinksObserver(); 32 virtual ~MediaSinksObserver();
33 33
34 // Registers with MediaRouter to start observing. Must be called before the 34 // Registers with MediaRouter to start observing. Must be called before the
35 // observer will start receiving updates. Returns |true| if the observer is 35 // observer will start receiving updates. Returns |true| if the observer is
36 // 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.
37 bool Init(); 37 bool Init();
38 38
39 // This function is invoked when the list of sinks compatible with |source_| 39 // This function is invoked when the list of sinks compatible with |source_|
40 // has been updated. The result also contains the list of valid origins. 40 // has been updated. The result also contains the list of valid origins.
41 // If |origins| is empty or contains |origin_|, then |OnSinksReceived(sinks)| 41 // If |origins| is empty or contains |origin_|, then |OnSinksReceived(sinks)|
42 // will be invoked with |sinks|. Otherwise, it will be invoked with an empty 42 // will be invoked with |sinks|. Otherwise, it will be invoked with an empty
43 // list. 43 // list.
44 void OnSinksUpdated(const std::vector<MediaSink>& sinks, 44 void OnSinksUpdated(const std::vector<MediaSink>& sinks,
45 const std::vector<GURL>& origins); 45 const std::vector<url::Origin>& origins);
46 46
47 const MediaSource& source() const { return source_; } 47 const MediaSource& source() const { return source_; }
48 48
49 protected: 49 protected:
50 // This function is invoked from |OnSinksUpdated(sinks, origins)|. 50 // This function is invoked from |OnSinksUpdated(sinks, origins)|.
51 // Implementations may not perform operations that modify the Media Router's 51 // Implementations may not perform operations that modify the Media Router's
52 // observer list. In particular, invoking this observer's destructor within 52 // observer list. In particular, invoking this observer's destructor within
53 // OnSinksReceived will result in undefined behavior. 53 // OnSinksReceived will result in undefined behavior.
54 virtual void OnSinksReceived(const std::vector<MediaSink>& sinks) = 0; 54 virtual void OnSinksReceived(const std::vector<MediaSink>& sinks) = 0;
55 55
56 private: 56 private:
57 const MediaSource source_; 57 const MediaSource source_;
58 const GURL origin_; 58 const url::Origin origin_;
59 MediaRouter* const router_; 59 MediaRouter* const router_;
60 bool initialized_; 60 bool initialized_;
61 61
62 #if DCHECK_IS_ON() 62 #if DCHECK_IS_ON()
63 bool in_on_sinks_updated_ = false; 63 bool in_on_sinks_updated_ = false;
64 #endif 64 #endif
65 65
66 DISALLOW_COPY_AND_ASSIGN(MediaSinksObserver); 66 DISALLOW_COPY_AND_ASSIGN(MediaSinksObserver);
67 }; 67 };
68 68
69 } // namespace media_router 69 } // namespace media_router
70 70
71 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_OBSERVER_H_ 71 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINKS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698