Chromium Code Reviews| 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_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/scoped_java_ref.h" | |
| 13 #include "content/public/browser/media_session_observer.h" | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 class MediaSessionImpl; | |
| 18 | |
| 19 bool RegisterMediaSessionNatives(JNIEnv* env); | |
|
boliu
2016/10/29 01:11:28
remove
Zhiqiang Zhang (Slow)
2016/10/31 11:57:34
Done.
| |
| 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 static bool Register(JNIEnv* env); | |
| 28 | |
| 29 explicit MediaSessionAndroid(MediaSession* session); | |
| 30 ~MediaSessionAndroid() override; | |
| 31 | |
| 32 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); | |
|
boliu
2016/10/29 01:11:28
Leaking the java object outside of class is genera
Zhiqiang Zhang (Slow)
2016/10/31 11:57:34
Ugh, I tried but failed. The problem is that the j
boliu
2016/10/31 18:58:55
Oh, static :/
You could declare another function,
Zhiqiang Zhang (Slow)
2016/10/31 22:22:26
Done. But actually I found other files including t
boliu
2016/10/31 22:44:02
Really? I'd expect a link error. Perhaps a runtime
Zhiqiang Zhang (Slow)
2016/10/31 23:30:28
Maybe...
| |
| 33 | |
| 34 // MediaSessionObserver implementation. | |
| 35 void MediaSessionDestroyed() override; | |
| 36 void MediaSessionStateChanged(bool is_controllable, | |
| 37 bool is_suspended) override; | |
| 38 void MediaSessionMetadataChanged( | |
| 39 const base::Optional<MediaMetadata>& metadata) override; | |
| 40 | |
| 41 // MediaSession method wrappers. | |
| 42 void Resume(JNIEnv* env, const base::android::JavaParamRef<jobject>& j_obj); | |
| 43 void Suspend(JNIEnv* env, const base::android::JavaParamRef<jobject>& j_obj); | |
| 44 void Stop(JNIEnv* env, const base::android::JavaParamRef<jobject>& j_obj); | |
| 45 | |
| 46 private: | |
| 47 // The linked Java object | |
| 48 base::android::ScopedJavaGlobalRef<jobject> j_media_session_; | |
|
boliu
2016/10/29 01:11:28
I raised the point about strong reference from nat
Zhiqiang Zhang (Slow)
2016/10/31 11:57:34
I don't know about how GC on WebContentsImpl.java
boliu
2016/10/31 18:58:55
Yes in webview, where native WebContentsImpl destr
Zhiqiang Zhang (Slow)
2016/10/31 19:50:03
I think the problem lies in the client side.
If w
boliu
2016/10/31 20:13:19
Meaning outside of content?
Zhiqiang Zhang (Slow)
2016/10/31 22:22:26
Yes.
boliu
2016/10/31 22:44:02
That's a good point. Yes it will still be referenc
Zhiqiang Zhang (Slow)
2016/10/31 23:30:28
Acknowledged.
| |
| 49 // The native MediaSession object | |
| 50 MediaSessionImpl* media_session_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(MediaSessionAndroid); | |
| 53 }; | |
| 54 | |
| 55 } // namespace content | |
| 56 | |
| 57 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_ANDROID_H_ | |
| OLD | NEW |