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

Side by Side Diff: content/public/browser/media_session.h

Issue 2623953002: [Chromecast] Fix media session blocking tests. (Closed)
Patch Set: Move MockMediaSession into chromecast/ only Created 3 years, 11 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 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_PUBLIC_BROWSER_MEDIA_SESSION_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_H_
6 #define CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_H_ 6 #define CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/observer_list.h"
9 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
10 11
11 namespace blink { 12 namespace blink {
12 namespace mojom { 13 namespace mojom {
13 enum class MediaSessionAction; 14 enum class MediaSessionAction;
14 } // namespace mojom 15 } // namespace mojom
15 } // namespace blink 16 } // namespace blink
16 17
17 namespace content { 18 namespace content {
18 19
20 class MediaSessionObserver;
19 class WebContents; 21 class WebContents;
20 22
21 // MediaSession manages the media session and audio focus for a given 23 // MediaSession manages the media session and audio focus for a given
22 // WebContents. There is only one MediaSession per WebContents. 24 // WebContents. There is only one MediaSession per WebContents.
23 // 25 //
24 // MediaSession allows clients to observe its changes via MediaSessionObserver, 26 // MediaSession allows clients to observe its changes via MediaSessionObserver,
25 // and allows clients to resume/suspend/stop the managed players. 27 // and allows clients to resume/suspend/stop the managed players.
26 class MediaSession { 28 class CONTENT_EXPORT MediaSession {
Zhiqiang Zhang (Slow) 2017/01/30 12:09:11 Revert this change as MediaSession is back to a pu
derekjchow1 2017/02/01 01:22:19 Done.
27 public: 29 public:
28 enum class SuspendType { 30 enum class SuspendType {
29 // Suspended by the system because a transient sound needs to be played. 31 // Suspended by the system because a transient sound needs to be played.
30 SYSTEM, 32 SYSTEM,
31 // Suspended by the UI. 33 // Suspended by the UI.
32 UI, 34 UI,
33 // Suspended by the page via script or user interaction. 35 // Suspended by the page via script or user interaction.
34 CONTENT, 36 CONTENT,
35 }; 37 };
36 38
37 // Returns the MediaSession associated to this WebContents. Creates one if 39 // Returns the MediaSession associated to this WebContents. Creates one if
38 // none is currently available. 40 // none is currently available.
39 CONTENT_EXPORT static MediaSession* Get(WebContents* contents); 41 CONTENT_EXPORT static MediaSession* Get(WebContents* contents);
40 42
41 virtual ~MediaSession() = default; 43 virtual ~MediaSession();
Zhiqiang Zhang (Slow) 2017/01/30 12:09:10 Revert this change as MediaSession is back to a pu
derekjchow1 2017/02/01 01:22:18 Done.
42 44
43 // Resume the media session. 45 // Resume the media session.
44 // |type| represents the origin of the request. 46 // |type| represents the origin of the request.
45 virtual void Resume(SuspendType suspend_type) = 0; 47 virtual void Resume(SuspendType suspend_type) = 0;
46 48
47 // Resume the media session. 49 // Resume the media session.
48 // |type| represents the origin of the request. 50 // |type| represents the origin of the request.
49 virtual void Suspend(SuspendType suspend_type) = 0; 51 virtual void Suspend(SuspendType suspend_type) = 0;
50 52
51 // Resume the media session. 53 // Resume the media session.
52 // |type| represents the origin of the request. 54 // |type| represents the origin of the request.
53 virtual void Stop(SuspendType suspend_type) = 0; 55 virtual void Stop(SuspendType suspend_type) = 0;
54 56
55 // Tell the media session a user action has performed. 57 // Tell the media session a user action has performed.
56 virtual void DidReceiveAction(blink::mojom::MediaSessionAction action) = 0; 58 virtual void DidReceiveAction(blink::mojom::MediaSessionAction action) = 0;
57 59
58 // Let the media session start ducking such that the volume multiplier is 60 // Let the media session start ducking such that the volume multiplier is
59 // reduced. 61 // reduced.
60 virtual void StartDucking() = 0; 62 virtual void StartDucking() = 0;
61 63
62 // Let the media session stop ducking such that the volume multiplier is 64 // Let the media session stop ducking such that the volume multiplier is
63 // recovered. 65 // recovered.
64 virtual void StopDucking() = 0; 66 virtual void StopDucking() = 0;
65 67
66 protected: 68 protected:
67 MediaSession() = default; 69 MediaSession();
Zhiqiang Zhang (Slow) 2017/01/30 12:09:11 Revert this change as MediaSession is back to a pu
derekjchow1 2017/02/01 01:22:18 Done.
70
71 base::ObserverList<MediaSessionObserver>& observers() { return observers_; }
mlamouri (slow - plz ping) 2017/01/28 02:01:40 Can you move the implementation to the .cc file?
Zhiqiang Zhang (Slow) 2017/01/30 12:09:10 I think you don't need this any more. Revert this
derekjchow1 2017/02/01 01:22:18 Removed (only in MediaSessionImpl now).
derekjchow1 2017/02/01 01:22:19 Done.
72
73 private:
74 friend class MediaSessionObserver;
75
76 void AddObserver(MediaSessionObserver* observer);
Zhiqiang Zhang (Slow) 2017/01/30 12:09:10 Make it pure-virtual. Keep it as private should be
derekjchow1 2017/02/01 01:22:19 Done.
77 void RemoveObserver(MediaSessionObserver* observer);
Zhiqiang Zhang (Slow) 2017/01/30 12:09:10 ditto
derekjchow1 2017/02/01 01:22:18 Done.
78
79 base::ObserverList<MediaSessionObserver> observers_;
Zhiqiang Zhang (Slow) 2017/01/30 12:09:10 ditto (same reason as `observers()`)
derekjchow1 2017/02/01 01:22:18 Done.
68 }; 80 };
69 81
70 } // namespace content 82 } // namespace content
71 83
72 #endif // CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_H_ 84 #endif // CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698