| OLD | NEW |
| (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. Will return null when the session is |
| 22 // destroyed. |
| 23 MediaSession* media_session() const; |
| 24 |
| 25 // Called when the observed MediaSession is being destroyed. Give subclass a |
| 26 // chance to clean up. media_session() will return nullptr after this method |
| 27 // is called. |
| 28 virtual void MediaSessionDestroyed() {} |
| 29 |
| 30 // Called when the observed MediaSession has changed its state. |
| 31 virtual void MediaSessionStateChanged(bool is_controllable, |
| 32 bool is_suspended) {} |
| 33 |
| 34 // Called when the observed MediaSession has changed metadata. |
| 35 virtual void MediaSessionMetadataChanged( |
| 36 const base::Optional<MediaMetadata>& metadata) {} |
| 37 |
| 38 protected: |
| 39 // Create a MediaSessionObserver and start observing a session. |
| 40 MediaSessionObserver(MediaSession* media_session); |
| 41 // Destruct a MediaSessionObserver and remove it from the session if it's |
| 42 // still observing. |
| 43 virtual ~MediaSessionObserver(); |
| 44 |
| 45 private: |
| 46 friend class MediaSessionImpl; |
| 47 |
| 48 void StopObserving(); |
| 49 |
| 50 // Weak pointer to MediaSession |
| 51 MediaSessionImpl* media_session_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(MediaSessionObserver); |
| 54 }; |
| 55 |
| 56 } // namespace content |
| 57 |
| 58 #endif // CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_OBSERVER_H_ |
| OLD | NEW |