Index: content/browser/media/session/media_session_android.h |
diff --git a/content/browser/media/session/media_session_android.h b/content/browser/media/session/media_session_android.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cd15e017aa0d6039c37b7b2b4c6765a4640eedaf |
--- /dev/null |
+++ b/content/browser/media/session/media_session_android.h |
@@ -0,0 +1,53 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_ANDROID_H_ |
+#define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_ANDROID_H_ |
+ |
+#include <memory> |
+#include <vector> |
+ |
+#include "base/android/scoped_java_ref.h" |
+#include "content/browser/media/session/media_session.h" |
+#include "content/browser/media/session/media_session_observer.h" |
+ |
+namespace content { |
+ |
+class MediaSession; |
+ |
+// This class is interlayer between native MediaSession and Java |
+// ChromeMediaSession. This class is owned by the native MediaSession and will |
+// teardown Java ChromeMediaSession when the native MediaSession is destroyed. |
+// Java MediaSessionObservers are also proxied via this class. |
+class MediaSessionAndroid final : public MediaSessionObserver { |
+ public: |
+ MediaSessionAndroid(MediaSession* session); |
+ ~MediaSessionAndroid() override; |
+ |
+ static bool Register(JNIEnv* env); |
+ |
+ base::android::ScopedJavaLocalRef<jobject> GetJavaSession(); |
+ |
+ // MediaSessionObserver implementation. |
+ void MediaSessionDestroyed() override; |
+ void MediaSessionStateChanged(bool is_controllable, |
+ bool is_suspended) override; |
+ void MediaSessionMetadataChanged( |
+ const base::Optional<MediaMetadata>& metadata) override; |
+ |
+ // MediaSession method wrappers. |
+ void Resume(JNIEnv* env, const base::android::JavaParamRef<jobject>& j_obj); |
+ void Suspend(JNIEnv* env, const base::android::JavaParamRef<jobject>& j_obj); |
+ void Stop(JNIEnv* env, const base::android::JavaParamRef<jobject>& j_obj); |
+ |
+ private: |
+ // The linked Java object |
+ base::android::ScopedJavaGlobalRef<jobject> j_media_session_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MediaSessionAndroid); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_ANDROID_H_ |