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