Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: content/browser/media/session/media_session_impl.h

Issue 2758773003: Clean up MediaSessionImpl state interfaces (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_IMPL_H_ 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_
6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // TODO(thakis,mlamouri): MediaSessionImpl isn't CONTENT_EXPORT'd because it 62 // TODO(thakis,mlamouri): MediaSessionImpl isn't CONTENT_EXPORT'd because it
63 // creates complicated build issues with WebContentsUserData being a 63 // creates complicated build issues with WebContentsUserData being a
64 // non-exported template, see https://crbug.com/589840. As a result, the class 64 // non-exported template, see https://crbug.com/589840. As a result, the class
65 // uses CONTENT_EXPORT for methods that are being used from tests. 65 // uses CONTENT_EXPORT for methods that are being used from tests.
66 // CONTENT_EXPORT should be moved back to the class when the Windows build will 66 // CONTENT_EXPORT should be moved back to the class when the Windows build will
67 // work with it. 67 // work with it.
68 class MediaSessionImpl : public MediaSession, 68 class MediaSessionImpl : public MediaSession,
69 public WebContentsObserver, 69 public WebContentsObserver,
70 protected WebContentsUserData<MediaSessionImpl> { 70 protected WebContentsUserData<MediaSessionImpl> {
71 public: 71 public:
72 // Only visible to tests. 72 // Only visible to tests.
whywhat 2017/03/20 22:12:47 nit: this comment is not true? do we have a good c
Zhiqiang Zhang (Slow) 2017/03/22 13:52:51 Done.
73 enum class State { ACTIVE, SUSPENDED, INACTIVE }; 73 enum class State { ACTIVE, SUSPENDED, INACTIVE };
74 74
75 // Returns the MediaSessionImpl associated to this WebContents. Creates one if 75 // Returns the MediaSessionImpl associated to this WebContents. Creates one if
76 // none is currently available. 76 // none is currently available.
77 CONTENT_EXPORT static MediaSessionImpl* Get(WebContents* web_contents); 77 CONTENT_EXPORT static MediaSessionImpl* Get(WebContents* web_contents);
78 78
79 ~MediaSessionImpl() override; 79 ~MediaSessionImpl() override;
80 80
81 #if defined(OS_ANDROID) 81 #if defined(OS_ANDROID)
82 static MediaSession* FromJavaMediaSession( 82 static MediaSession* FromJavaMediaSession(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 void RemoveObserver(MediaSessionObserver* observer) override; 140 void RemoveObserver(MediaSessionObserver* observer) override;
141 141
142 // Returns if the session can be controlled by Resume() and Suspend calls 142 // Returns if the session can be controlled by Resume() and Suspend calls
143 // above. 143 // above.
144 CONTENT_EXPORT bool IsControllable() const; 144 CONTENT_EXPORT bool IsControllable() const;
145 145
146 // Returns if the session is currently active. 146 // Returns if the session is currently active.
147 CONTENT_EXPORT bool IsActive() const; 147 CONTENT_EXPORT bool IsActive() const;
148 148
149 // Returns if the session is currently suspended. 149 // Returns if the session is currently suspended.
150 // TODO(mlamouri): IsSuspended() below checks if the state is not ACTIVE 150 CONTENT_EXPORT bool IsSuspended() const;
151 // instead of checking if the state is SUSPENDED. In order to not have to
152 // change all the callers and make the current refactoring ridiculously huge,
153 // this method is introduced temporarily and will be removed later.
154 CONTENT_EXPORT bool IsReallySuspended() const;
155 151
156 // Returns if the session is currently suspended or inactive. 152 // Returns if the session is actually paused, which is the combined result of
157 CONTENT_EXPORT bool IsSuspended() const; 153 // |IsSuspended()| and the declared playback state of the routed service. This
154 // state should be used in the UI end
155 //
156 // TODO(zqzhang): Maybe also compute for IsControllable()? See
157 // https://crbug.com/674983.
158 CONTENT_EXPORT bool IsActuallyPaused() const;
158 159
159 // Returns the audio focus type. The type is updated everytime after the 160 // Returns the audio focus type. The type is updated everytime after the
160 // session requests audio focus. 161 // session requests audio focus.
161 CONTENT_EXPORT AudioFocusManager::AudioFocusType audio_focus_type() const { 162 CONTENT_EXPORT AudioFocusManager::AudioFocusType audio_focus_type() const {
162 return audio_focus_type_; 163 return audio_focus_type_;
163 } 164 }
164 165
165 // Returns whether the session has Pepper instances. 166 // Returns whether the session has Pepper instances.
166 bool HasPepper() const; 167 bool HasPepper() const;
167 168
(...skipping 30 matching lines...) Expand all
198 friend class content::WebContentsUserData<MediaSessionImpl>; 199 friend class content::WebContentsUserData<MediaSessionImpl>;
199 friend class ::MediaSessionImplBrowserTest; 200 friend class ::MediaSessionImplBrowserTest;
200 friend class content::MediaSessionImplVisibilityBrowserTest; 201 friend class content::MediaSessionImplVisibilityBrowserTest;
201 friend class content::AudioFocusManagerTest; 202 friend class content::AudioFocusManagerTest;
202 friend class content::MediaSessionImplServiceRoutingTest; 203 friend class content::MediaSessionImplServiceRoutingTest;
203 friend class content::MediaSessionImplStateObserver; 204 friend class content::MediaSessionImplStateObserver;
204 friend class content::MediaSessionServiceImplBrowserTest; 205 friend class content::MediaSessionServiceImplBrowserTest;
205 206
206 CONTENT_EXPORT void SetDelegateForTests( 207 CONTENT_EXPORT void SetDelegateForTests(
207 std::unique_ptr<AudioFocusDelegate> delegate); 208 std::unique_ptr<AudioFocusDelegate> delegate);
208 CONTENT_EXPORT bool IsActiveForTest() const;
209 CONTENT_EXPORT void RemoveAllPlayersForTest(); 209 CONTENT_EXPORT void RemoveAllPlayersForTest();
210 CONTENT_EXPORT MediaSessionUmaHelper* uma_helper_for_test(); 210 CONTENT_EXPORT MediaSessionUmaHelper* uma_helper_for_test();
211 211
212 // Representation of a player for the MediaSessionImpl. 212 // Representation of a player for the MediaSessionImpl.
213 struct PlayerIdentifier { 213 struct PlayerIdentifier {
214 PlayerIdentifier(MediaSessionPlayerObserver* observer, int player_id); 214 PlayerIdentifier(MediaSessionPlayerObserver* observer, int player_id);
215 PlayerIdentifier(const PlayerIdentifier&) = default; 215 PlayerIdentifier(const PlayerIdentifier&) = default;
216 216
217 void operator=(const PlayerIdentifier&) = delete; 217 void operator=(const PlayerIdentifier&) = delete;
218 bool operator==(const PlayerIdentifier& player_identifier) const; 218 bool operator==(const PlayerIdentifier& player_identifier) const;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 ServicesMap services_; 315 ServicesMap services_;
316 // The currently routed service (non-owned pointer). 316 // The currently routed service (non-owned pointer).
317 MediaSessionServiceImpl* routed_service_; 317 MediaSessionServiceImpl* routed_service_;
318 318
319 DISALLOW_COPY_AND_ASSIGN(MediaSessionImpl); 319 DISALLOW_COPY_AND_ASSIGN(MediaSessionImpl);
320 }; 320 };
321 321
322 } // namespace content 322 } // namespace content
323 323
324 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ 324 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698