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

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

Issue 2453623003: Decouple MediaSession messages from WebContents (full patch) (Closed)
Patch Set: Created 4 years, 1 month 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
(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_PUBLIC_BROWSER_MEDIA_SESSION_OBSERVER_H_
6 #define CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_OBSERVER_H_
7
8 #include "base/macros.h"
9 #include "base/optional.h"
10 #include "content/common/content_export.h"
11 #include "content/public/common/media_metadata.h"
12
13 namespace content {
14
15 class MediaSession;
16 class MediaSessionImpl;
17
18 // The observer for observing MediaSession events.
19 class CONTENT_EXPORT MediaSessionObserver {
20 public:
21 // Gets the observed MediaSession.
22 MediaSession* media_session() const;
jam 2016/10/26 17:30:59 this seems unnecessary, i.e. the two place that us
Zhiqiang Zhang (Slow) 2016/10/26 18:44:25 I slightly disagree here. We actually have three p
Zhiqiang Zhang (Slow) 2016/10/28 22:40:07 Removed all the MediaSession getter and StopObserv
23
24 // Called when the observed MediaSession is being destroyed. Gives subclass a
25 // chance to cleanup. After the whole loop over MediaSessionObservers has been
26 // finished, media_session() returns nullptr.
27 virtual void MediaSessionDestroyed() {}
28
29 // Called when the observed MediaSession has changed its state.
30 virtual void MediaSessionStateChanged(bool is_controllable,
31 bool is_suspended) {}
32
33 // Called when the observed MediaSession has changed metadata.
34 virtual void MediaSessionMetadataChanged(
35 const base::Optional<MediaMetadata>& metadata) {}
36
37 protected:
38 // Create a MediaSessionObserver and start observing |session|.
39 explicit MediaSessionObserver(MediaSession* session);
40
41 // Destructor of MediaSessionObserver. It will remove itself from |session| if
42 // the observer is still observing a MediaSession.
43 virtual ~MediaSessionObserver();
44
45 private:
46 friend class MediaSessionImpl;
47
48 void StopObserving();
49
50 // Weak pointer to MediaSession.
51 MediaSessionImpl* session_;
52
53 DISALLOW_COPY_AND_ASSIGN(MediaSessionObserver);
54 };
55
56 } // namespace content
57
58 #endif // CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698