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

Side by Side Diff: content/browser/media/session/media_session_android.h

Issue 2453623003: Decouple MediaSession messages from WebContents (full patch) (Closed)
Patch Set: nit 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_BROWSER_MEDIA_SESSION_MEDIA_SESSION_ANDROID_H_
6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_ANDROID_H_
7
8 #include <jni.h>
9 #include <memory>
10 #include <vector>
11
12 #include "base/android/jni_weak_ref.h"
13 #include "base/android/scoped_java_ref.h"
14 #include "content/public/browser/media_session_observer.h"
15
16 namespace content {
17
18 class MediaSessionImpl;
19 class WebContentsAndroid;
20
21 // This class is interlayer between native MediaSession and Java
22 // MediaSession. This class is owned by the native MediaSession and will
23 // teardown Java MediaSession when the native MediaSession is destroyed.
24 // Java MediaSessionObservers are also proxied via this class.
25 class MediaSessionAndroid final : public MediaSessionObserver {
26 public:
27 // Helper class for calling GetJavaObject() in a static method, in order to
28 // avoid leaking the Java object outside.
29 struct JavaObjectGetter;
30
31 static bool Register(JNIEnv* env);
32
33 explicit MediaSessionAndroid(MediaSessionImpl* session);
34 ~MediaSessionAndroid() override;
35
36 // MediaSessionObserver implementation.
37 void MediaSessionDestroyed() override;
38 void MediaSessionStateChanged(bool is_controllable,
39 bool is_suspended) override;
40 void MediaSessionMetadataChanged(
41 const base::Optional<MediaMetadata>& metadata) override;
42
43 // MediaSession method wrappers.
44 void Resume(JNIEnv* env, const base::android::JavaParamRef<jobject>& j_obj);
45 void Suspend(JNIEnv* env, const base::android::JavaParamRef<jobject>& j_obj);
46 void Stop(JNIEnv* env, const base::android::JavaParamRef<jobject>& j_obj);
47
48 private:
49 WebContentsAndroid* GetWebContentsAndroid();
50
51 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
52
53 // The linked Java object. The strong reference is hold by Java WebContensImpl
54 // to avoid introducing a new GC root.
55 JavaObjectWeakGlobalRef j_media_session_;
56
57 DISALLOW_COPY_AND_ASSIGN(MediaSessionAndroid);
58 };
59
60 } // namespace content
61
62 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_ANDROID_H_
OLDNEW
« no previous file with comments | « content/browser/media/session/media_session.cc ('k') | content/browser/media/session/media_session_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698