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

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

Issue 2874283002: [Media Router] Notify MRUI of a media status update when it starts observing (Closed)
Patch Set: Created 3 years, 7 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_ROUTE_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 26 matching lines...) Expand all
37 // Observes MediaRouteController for MediaStatus updates. The ownership of a 37 // Observes MediaRouteController for MediaStatus updates. The ownership of a
38 // MediaRouteController is shared by its observers. 38 // MediaRouteController is shared by its observers.
39 class Observer { 39 class Observer {
40 public: 40 public:
41 // Adds itself as an observer to |controller|. 41 // Adds itself as an observer to |controller|.
42 explicit Observer(scoped_refptr<MediaRouteController> controller); 42 explicit Observer(scoped_refptr<MediaRouteController> controller);
43 43
44 // Removes itself as an observer if |controller_| is still valid. 44 // Removes itself as an observer if |controller_| is still valid.
45 virtual ~Observer(); 45 virtual ~Observer();
46 46
47 // Notifies itself with the latest media status that the controller has
48 // received.
49 void CheckForMediaStatusUpdates();
mark a. foltz 2017/05/12 21:00:58 Is this necessary?
takumif 2017/05/12 22:20:58 Removed.
50
47 virtual void OnMediaStatusUpdated(const MediaStatus& status) = 0; 51 virtual void OnMediaStatusUpdated(const MediaStatus& status) = 0;
48 52
49 // Returns a reference to the observed MediaRouteController. The reference 53 // Returns a reference to the observed MediaRouteController. The reference
50 // should not be stored by any object that does not subclass ::Observer. 54 // should not be stored by any object that does not subclass ::Observer.
51 scoped_refptr<MediaRouteController> controller() const { 55 scoped_refptr<MediaRouteController> controller() const {
52 return controller_; 56 return controller_;
53 } 57 }
54 58
55 private: 59 private:
56 friend class MediaRouteController; 60 friend class MediaRouteController;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 102
99 protected: 103 protected:
100 ~MediaRouteController() override; 104 ~MediaRouteController() override;
101 105
102 private: 106 private:
103 friend class base::RefCounted<MediaRouteController>; 107 friend class base::RefCounted<MediaRouteController>;
104 108
105 void AddObserver(Observer* observer); 109 void AddObserver(Observer* observer);
106 void RemoveObserver(Observer* observer); 110 void RemoveObserver(Observer* observer);
107 111
112 const base::Optional<MediaStatus>& current_media_status() const {
113 return current_media_status_;
114 }
115
108 // Called when the connection between |this| and the MediaControllerPtr or 116 // Called when the connection between |this| and the MediaControllerPtr or
109 // the MediaStatusObserver binding is no longer valid. Notifies 117 // the MediaStatusObserver binding is no longer valid. Notifies
110 // |media_router_| and |observers_| to dispose their references to |this|. 118 // |media_router_| and |observers_| to dispose their references to |this|.
111 void OnMojoConnectionError(); 119 void OnMojoConnectionError();
112 120
113 // The ID of the Media Route that |this| controls. 121 // The ID of the Media Route that |this| controls.
114 const MediaRoute::Id route_id_; 122 const MediaRoute::Id route_id_;
115 123
116 // Handle to the mojom::MediaController that receives media commands. 124 // Handle to the mojom::MediaController that receives media commands.
117 mojom::MediaControllerPtr mojo_media_controller_; 125 mojom::MediaControllerPtr mojo_media_controller_;
118 126
119 // |media_router_| will be notified when the controller is destroyed. 127 // |media_router_| will be notified when the controller is destroyed.
120 MediaRouter* const media_router_; 128 MediaRouter* const media_router_;
121 129
122 // The binding to observe the out-of-process provider of status updates. 130 // The binding to observe the out-of-process provider of status updates.
123 mojo::Binding<mojom::MediaStatusObserver> binding_; 131 mojo::Binding<mojom::MediaStatusObserver> binding_;
124 132
125 // Observers that are notified of status updates. The observers share the 133 // Observers that are notified of status updates. The observers share the
126 // ownership of the controller through scoped_refptr. 134 // ownership of the controller through scoped_refptr.
127 base::ObserverList<Observer> observers_; 135 base::ObserverList<Observer> observers_;
128 136
129 // This becomes false when the controller is invalidated. 137 // This becomes false when the controller is invalidated.
130 bool is_valid_ = true; 138 bool is_valid_ = true;
131 139
140 // The latest media status that the controller has been notified with.
141 base::Optional<MediaStatus> current_media_status_;
142
132 DISALLOW_COPY_AND_ASSIGN(MediaRouteController); 143 DISALLOW_COPY_AND_ASSIGN(MediaRouteController);
133 }; 144 };
134 145
135 } // namespace media_router 146 } // namespace media_router
136 147
137 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_ 148 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698