Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ | 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 | 46 |
| 47 enum class SuspendType { | 47 enum class SuspendType { |
| 48 // Suspended by the system because a transient sound needs to be played. | 48 // Suspended by the system because a transient sound needs to be played. |
| 49 SYSTEM, | 49 SYSTEM, |
| 50 // Suspended by the UI. | 50 // Suspended by the UI. |
| 51 UI, | 51 UI, |
| 52 // Suspended by the page via script or user interaction. | 52 // Suspended by the page via script or user interaction. |
| 53 CONTENT, | 53 CONTENT, |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 enum class State { | |
| 57 ACTIVE, | |
| 58 SUSPENDED, | |
| 59 INACTIVE | |
| 60 }; | |
| 61 | |
| 56 // Returns the MediaSession associated to this WebContents. Creates one if | 62 // Returns the MediaSession associated to this WebContents. Creates one if |
| 57 // none is currently available. | 63 // none is currently available. |
| 58 CONTENT_EXPORT static MediaSession* Get(WebContents* web_contents); | 64 CONTENT_EXPORT static MediaSession* Get(WebContents* web_contents); |
| 59 | 65 |
| 60 ~MediaSession() override; | 66 ~MediaSession() override; |
| 61 | 67 |
| 62 void setMetadata(const MediaMetadata& metadata) { | 68 void setMetadata(const MediaMetadata& metadata) { |
| 63 metadata_ = metadata; | 69 metadata_ = metadata; |
| 64 } | 70 } |
| 65 const MediaMetadata& metadata() const { return metadata_; } | 71 const MediaMetadata& metadata() const { return metadata_; } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 // Returns if the session is currently suspended. | 119 // Returns if the session is currently suspended. |
| 114 // TODO(mlamouri): IsSuspended() below checks if the state is not ACTIVE | 120 // TODO(mlamouri): IsSuspended() below checks if the state is not ACTIVE |
| 115 // instead of checking if the state is SUSPENDED. In order to not have to | 121 // instead of checking if the state is SUSPENDED. In order to not have to |
| 116 // change all the callers and make the current refactoring ridiculously huge, | 122 // change all the callers and make the current refactoring ridiculously huge, |
| 117 // this method is introduced temporarily and will be removed later. | 123 // this method is introduced temporarily and will be removed later. |
| 118 bool IsReallySuspended() const; | 124 bool IsReallySuspended() const; |
| 119 | 125 |
| 120 // Returns if the session is currently suspended or inactive. | 126 // Returns if the session is currently suspended or inactive. |
| 121 CONTENT_EXPORT bool IsSuspended() const; | 127 CONTENT_EXPORT bool IsSuspended() const; |
| 122 | 128 |
| 129 CONTENT_EXPORT State audio_focus_state_for_test() const; | |
|
mlamouri (slow - plz ping)
2016/03/23 15:10:15
Could you make MediaSessionIntegrationBrowserTestB
Zhiqiang Zhang (Slow)
2016/03/24 18:16:49
Done.
| |
| 130 | |
| 123 private: | 131 private: |
| 124 friend class content::WebContentsUserData<MediaSession>; | 132 friend class content::WebContentsUserData<MediaSession>; |
| 125 friend class ::MediaSessionBrowserTest; | 133 friend class ::MediaSessionBrowserTest; |
| 126 | 134 |
| 127 CONTENT_EXPORT void SetDelegateForTests( | 135 CONTENT_EXPORT void SetDelegateForTests( |
| 128 scoped_ptr<MediaSessionDelegate> delegate); | 136 scoped_ptr<MediaSessionDelegate> delegate); |
| 129 CONTENT_EXPORT bool IsActiveForTest() const; | 137 CONTENT_EXPORT bool IsActiveForTest() const; |
| 130 CONTENT_EXPORT Type audio_focus_type_for_test() const; | 138 CONTENT_EXPORT Type audio_focus_type_for_test() const; |
| 131 CONTENT_EXPORT void RemoveAllPlayersForTest(); | 139 CONTENT_EXPORT void RemoveAllPlayersForTest(); |
| 132 CONTENT_EXPORT MediaSessionUmaHelper* uma_helper_for_test(); | 140 CONTENT_EXPORT MediaSessionUmaHelper* uma_helper_for_test(); |
| 133 | 141 |
| 134 enum class State { | |
| 135 ACTIVE, | |
| 136 SUSPENDED, | |
| 137 INACTIVE | |
| 138 }; | |
| 139 | |
| 140 // Representation of a player for the MediaSession. | 142 // Representation of a player for the MediaSession. |
| 141 struct PlayerIdentifier { | 143 struct PlayerIdentifier { |
| 142 PlayerIdentifier(MediaSessionObserver* observer, int player_id); | 144 PlayerIdentifier(MediaSessionObserver* observer, int player_id); |
| 143 PlayerIdentifier(const PlayerIdentifier&) = default; | 145 PlayerIdentifier(const PlayerIdentifier&) = default; |
| 144 | 146 |
| 145 void operator=(const PlayerIdentifier&) = delete; | 147 void operator=(const PlayerIdentifier&) = delete; |
| 146 bool operator==(const PlayerIdentifier& player_identifier) const; | 148 bool operator==(const PlayerIdentifier& player_identifier) const; |
| 147 | 149 |
| 148 // Hash operator for base::hash_map<>. | 150 // Hash operator for base::hash_map<>. |
| 149 struct Hash { | 151 struct Hash { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 double volume_multiplier_; | 193 double volume_multiplier_; |
| 192 | 194 |
| 193 MediaMetadata metadata_; | 195 MediaMetadata metadata_; |
| 194 | 196 |
| 195 DISALLOW_COPY_AND_ASSIGN(MediaSession); | 197 DISALLOW_COPY_AND_ASSIGN(MediaSession); |
| 196 }; | 198 }; |
| 197 | 199 |
| 198 } // namespace content | 200 } // namespace content |
| 199 | 201 |
| 200 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ | 202 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ |
| OLD | NEW |