Chromium Code Reviews| Index: content/browser/media/session/media_session_controllers_manager.h |
| diff --git a/content/browser/media/session/media_session_controllers_manager.h b/content/browser/media/session/media_session_controllers_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dddc64bf7f887c0b305cfbf14cba76f5d8195a62 |
| --- /dev/null |
| +++ b/content/browser/media/session/media_session_controllers_manager.h |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLERS_MANAGER_H_ |
| +#define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLERS_MANAGER_H_ |
| + |
| +#include <map> |
| +#include <utility> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/time/time.h" |
| + |
| +namespace content { |
| + |
| +class MediaSessionController; |
| +class MediaWebContentsObserver; |
| +class RenderFrameHost; |
| + |
| +using MediaPlayerId = std::pair<RenderFrameHost*, int>; |
|
DaleCurtis
2016/02/26 03:22:50
Why not include web_contents_observer.h to get thi
mlamouri (slow - plz ping)
2016/02/26 12:26:17
I don't really like the idea of including a file l
|
| + |
| +// MediaSessionControllersManager is a delegate of MediaWebContentsObserver that |
| +// handles MediaSessionController instances. |
| +class MediaSessionControllersManager { |
|
DaleCurtis
2016/02/26 03:22:50
You'll want CONTENT_EXPORT if you're planning to w
mlamouri (slow - plz ping)
2016/02/26 12:26:17
There are no tests for this. I don't think adding
|
| + public: |
| + explicit MediaSessionControllersManager( |
| + MediaWebContentsObserver* media_web_contents_observer); |
| + ~MediaSessionControllersManager(); |
| + |
| + // Clear all the MediaSessionController associated with the given |
| + // |render_frame_host|. |
| + void Clear(RenderFrameHost* render_frame_host); |
| + |
| + // Called before a player starts playing. It will be added to the media |
| + // session and will have a controller associated with it. |
| + // Returns whether the player was added to the session and can start playing. |
| + bool RequestPlay(const MediaPlayerId& id, bool has_audio, bool is_remote, |
| + base::TimeDelta duration); |
| + |
| + // Called when the given player |id| has paused. |
| + void OnPause(const MediaPlayerId& id); |
| + |
| + // Called when the given player |id| has ended. |
| + void OnEnd(const MediaPlayerId& id); |
| + |
| + private: |
| + static bool IsDefaultMediaSessionEnabled(); |
|
DaleCurtis
2016/02/26 03:22:50
Keep as a .cc local method?
mlamouri (slow - plz ping)
2016/02/26 12:26:17
Done.
|
| + |
| + // Weak pointer because |this| is owned by |media_web_contents_observer_|. |
| + MediaWebContentsObserver* const media_web_contents_observer_; |
| + |
| + using ControllersMap = |
| + std::map<MediaPlayerId, scoped_ptr<MediaSessionController>>; |
| + ControllersMap controllers_map_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MediaSessionControllersManager); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLERS_MANAGER_H_ |