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

Unified Diff: content/browser/media/session/media_session.h

Issue 2439483003: Link MediaSessionTabHelper with native MediaSession [CL is going to be split] (Closed)
Patch Set: Don't review, this CL is getting huge and needs to be split Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/media/session/media_session.h
diff --git a/content/browser/media/session/media_session.h b/content/browser/media/session/media_session.h
index 9239c7854a18b18326e2c2983451e49490922982..5641f0708be67c7164faf68e1dc89b5cbdde953d 100644
--- a/content/browser/media/session/media_session.h
+++ b/content/browser/media/session/media_session.h
@@ -7,9 +7,11 @@
#include <stddef.h>
+#include "base/android/scoped_java_ref.h"
#include "base/callback_list.h"
#include "base/id_map.h"
#include "base/macros.h"
+#include "base/observer_list.h"
#include "base/optional.h"
#include "content/browser/media/session/audio_focus_manager.h"
#include "content/browser/media/session/media_session_uma_helper.h"
@@ -29,9 +31,14 @@ namespace content {
class AudioFocusDelegate;
class AudioFocusManagerTest;
class MediaSessionPlayerObserver;
+class MediaSessionObserver;
class MediaSessionStateObserver;
class MediaSessionVisibilityBrowserTest;
+#if defined(OS_ANDROID)
+class MediaSessionAndroid;
+#endif // defined(OS_ANDROID)
+
// MediaSession manages the media session and audio focus for a given
// WebContents. It is requesting the audio focus, pausing when requested by the
// system and dropping it on demand.
@@ -71,6 +78,22 @@ class MediaSession : public WebContentsObserver,
~MediaSession() override;
+#if defined(OS_ANDROID)
+ static MediaSession* FromJavaMediaSession(
+ const base::android::JavaRef<jobject>& j_media_session);
+ MediaSessionAndroid* session_android() const {
+ return session_android_.get();
+ }
+#endif // defined(OS_ANDROID)
+
+ // Add and remove an observer for MediaSession messages. Clients must remove
+ // the observer before they go away, or pass the observer ownership to
+ // MediaSession via PassObserverOwnership (then the observer will go away when
+ // the session is destroyed. AddObserver() can only be called in
+ // MediaSessionObserver constructor, and cannot be called explicitly.
+ void AddObserver(MediaSessionObserver* observer);
+ void RemoveObserver(MediaSessionObserver* observer);
+
void SetMetadata(const base::Optional<MediaMetadata>& metadata);
const base::Optional<MediaMetadata>& metadata() const { return metadata_; }
@@ -237,6 +260,13 @@ class MediaSession : public WebContentsObserver,
base::Optional<MediaMetadata> metadata_;
base::CallbackList<void(State)> media_session_state_listeners_;
+ // The list of observers notified when the MediaSession changes.
+ base::ObserverList<MediaSessionObserver> observers_;
+
+#if defined(OS_ANDROID)
+ std::unique_ptr<MediaSessionAndroid> session_android_;
+#endif // defined(OS_ANDROID)
+
DISALLOW_COPY_AND_ASSIGN(MediaSession);
};
« no previous file with comments | « content/browser/android/web_contents_observer_proxy.cc ('k') | content/browser/media/session/media_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698