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