| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLERS_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLERS_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLERS_MANAGER_H_ | 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLERS_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "content/public/browser/web_contents_observer.h" // For MediaPlayerId. | 14 #include "content/public/browser/web_contents_observer.h" // For MediaPlayerId. |
| 15 | 15 |
| 16 namespace media { |
| 17 |
| 18 enum class MediaContentType; |
| 19 |
| 20 } |
| 21 |
| 16 namespace content { | 22 namespace content { |
| 17 | 23 |
| 18 class MediaSessionController; | 24 class MediaSessionController; |
| 19 class MediaWebContentsObserver; | 25 class MediaWebContentsObserver; |
| 20 class RenderFrameHost; | 26 class RenderFrameHost; |
| 21 | 27 |
| 22 // MediaSessionControllersManager is a delegate of MediaWebContentsObserver that | 28 // MediaSessionControllersManager is a delegate of MediaWebContentsObserver that |
| 23 // handles MediaSessionController instances. | 29 // handles MediaSessionController instances. |
| 24 class MediaSessionControllersManager { | 30 class MediaSessionControllersManager { |
| 25 public: | 31 public: |
| 26 using MediaPlayerId = WebContentsObserver::MediaPlayerId; | 32 using MediaPlayerId = WebContentsObserver::MediaPlayerId; |
| 27 | 33 |
| 28 explicit MediaSessionControllersManager( | 34 explicit MediaSessionControllersManager( |
| 29 MediaWebContentsObserver* media_web_contents_observer); | 35 MediaWebContentsObserver* media_web_contents_observer); |
| 30 ~MediaSessionControllersManager(); | 36 ~MediaSessionControllersManager(); |
| 31 | 37 |
| 32 // Clear all the MediaSessionController associated with the given | 38 // Clear all the MediaSessionController associated with the given |
| 33 // |render_frame_host|. | 39 // |render_frame_host|. |
| 34 void RenderFrameDeleted(RenderFrameHost* render_frame_host); | 40 void RenderFrameDeleted(RenderFrameHost* render_frame_host); |
| 35 | 41 |
| 36 // Called before a player starts playing. It will be added to the media | 42 // Called before a player starts playing. It will be added to the media |
| 37 // session and will have a controller associated with it. | 43 // session and will have a controller associated with it. |
| 38 // Returns whether the player was added to the session and can start playing. | 44 // Returns whether the player was added to the session and can start playing. |
| 39 bool RequestPlay(const MediaPlayerId& id, | 45 bool RequestPlay(const MediaPlayerId& id, |
| 40 bool has_audio, | 46 bool has_audio, |
| 41 bool is_remote, | 47 bool is_remote, |
| 42 base::TimeDelta duration); | 48 media::MediaContentType media_content_type); |
| 43 | 49 |
| 44 // Called when the given player |id| has paused. | 50 // Called when the given player |id| has paused. |
| 45 void OnPause(const MediaPlayerId& id); | 51 void OnPause(const MediaPlayerId& id); |
| 46 | 52 |
| 47 // Called when the given player |id| has ended. | 53 // Called when the given player |id| has ended. |
| 48 void OnEnd(const MediaPlayerId& id); | 54 void OnEnd(const MediaPlayerId& id); |
| 49 | 55 |
| 50 private: | 56 private: |
| 51 // Weak pointer because |this| is owned by |media_web_contents_observer_|. | 57 // Weak pointer because |this| is owned by |media_web_contents_observer_|. |
| 52 MediaWebContentsObserver* const media_web_contents_observer_; | 58 MediaWebContentsObserver* const media_web_contents_observer_; |
| 53 | 59 |
| 54 using ControllersMap = | 60 using ControllersMap = |
| 55 std::map<MediaPlayerId, std::unique_ptr<MediaSessionController>>; | 61 std::map<MediaPlayerId, std::unique_ptr<MediaSessionController>>; |
| 56 ControllersMap controllers_map_; | 62 ControllersMap controllers_map_; |
| 57 | 63 |
| 58 DISALLOW_COPY_AND_ASSIGN(MediaSessionControllersManager); | 64 DISALLOW_COPY_AND_ASSIGN(MediaSessionControllersManager); |
| 59 }; | 65 }; |
| 60 | 66 |
| 61 } // namespace content | 67 } // namespace content |
| 62 | 68 |
| 63 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLERS_MANAGER_H_ | 69 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLERS_MANAGER_H_ |
| OLD | NEW |