OLD | NEW |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 // Constructs a MediaRouteController that forwards media commands to | 70 // Constructs a MediaRouteController that forwards media commands to |
71 // |mojo_media_controller|. |media_router| will be notified when the | 71 // |mojo_media_controller|. |media_router| will be notified when the |
72 // MediaRouteController is destroyed via DetachRouteController(). | 72 // MediaRouteController is destroyed via DetachRouteController(). |
73 MediaRouteController(const MediaRoute::Id& route_id, | 73 MediaRouteController(const MediaRoute::Id& route_id, |
74 mojom::MediaControllerPtr mojo_media_controller, | 74 mojom::MediaControllerPtr mojo_media_controller, |
75 MediaRouter* media_router); | 75 MediaRouter* media_router); |
76 | 76 |
77 // Media controller methods for forwarding commands to a | 77 // Media controller methods for forwarding commands to a |
78 // mojom::MediaControllerPtr held in |mojo_media_controller_|. | 78 // mojom::MediaControllerPtr held in |mojo_media_controller_|. |
79 void Play(); | 79 virtual void Play() const; |
80 void Pause(); | 80 virtual void Pause() const; |
81 void Seek(base::TimeDelta time); | 81 virtual void Seek(base::TimeDelta time) const; |
82 void SetMute(bool mute); | 82 virtual void SetMute(bool mute) const; |
83 void SetVolume(float volume); | 83 virtual void SetVolume(float volume) const; |
84 | 84 |
85 // mojom::MediaStatusObserver: | 85 // mojom::MediaStatusObserver: |
86 // Notifies |observers_| of a status update. | 86 // Notifies |observers_| of a status update. |
87 void OnMediaStatusUpdated(const MediaStatus& status) override; | 87 void OnMediaStatusUpdated(const MediaStatus& status) override; |
88 | 88 |
89 // Notifies |observers_| to dispose their references to the controller. The | 89 // Notifies |observers_| to dispose their references to the controller. The |
90 // controller gets destroyed when all the references are disposed. | 90 // controller gets destroyed when all the references are disposed. |
91 void Invalidate(); | 91 void Invalidate(); |
92 | 92 |
93 // Returns a mojo pointer bound to |this| by |binding_|. This must only be | 93 // Returns a mojo pointer bound to |this| by |binding_|. This must only be |
94 // called at most once in the lifetime of the controller. | 94 // called at most once in the lifetime of the controller. |
95 mojom::MediaStatusObserverPtr BindObserverPtr(); | 95 mojom::MediaStatusObserverPtr BindObserverPtr(); |
96 | 96 |
97 MediaRoute::Id route_id() const { return route_id_; } | 97 MediaRoute::Id route_id() const { return route_id_; } |
98 | 98 |
| 99 protected: |
| 100 ~MediaRouteController() override; |
| 101 |
99 private: | 102 private: |
100 friend class base::RefCounted<MediaRouteController>; | 103 friend class base::RefCounted<MediaRouteController>; |
101 | 104 |
102 ~MediaRouteController() override; | |
103 | |
104 void AddObserver(Observer* observer); | 105 void AddObserver(Observer* observer); |
105 void RemoveObserver(Observer* observer); | 106 void RemoveObserver(Observer* observer); |
106 | 107 |
107 // Called when the connection between |this| and the MediaControllerPtr or | 108 // Called when the connection between |this| and the MediaControllerPtr or |
108 // the MediaStatusObserver binding is no longer valid. Notifies | 109 // the MediaStatusObserver binding is no longer valid. Notifies |
109 // |media_router_| and |observers_| to dispose their references to |this|. | 110 // |media_router_| and |observers_| to dispose their references to |this|. |
110 void OnMojoConnectionError(); | 111 void OnMojoConnectionError(); |
111 | 112 |
112 // The ID of the Media Route that |this| controls. | 113 // The ID of the Media Route that |this| controls. |
113 const MediaRoute::Id route_id_; | 114 const MediaRoute::Id route_id_; |
(...skipping 13 matching lines...) Expand all Loading... |
127 | 128 |
128 // This becomes false when the controller is invalidated. | 129 // This becomes false when the controller is invalidated. |
129 bool is_valid_ = true; | 130 bool is_valid_ = true; |
130 | 131 |
131 DISALLOW_COPY_AND_ASSIGN(MediaRouteController); | 132 DISALLOW_COPY_AND_ASSIGN(MediaRouteController); |
132 }; | 133 }; |
133 | 134 |
134 } // namespace media_router | 135 } // namespace media_router |
135 | 136 |
136 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_ | 137 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTE_CONTROLLER_H_ |
OLD | NEW |