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

Unified Diff: services/native_viewport/platform_viewport_android.cc

Issue 1081443005: Make the C++ PlatformViewportAndroid's dtor call the Java PVA's destroy() method. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: use a weak ref instead Created 5 years, 8 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
« no previous file with comments | « services/native_viewport/platform_viewport_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/native_viewport/platform_viewport_android.cc
diff --git a/services/native_viewport/platform_viewport_android.cc b/services/native_viewport/platform_viewport_android.cc
index 31b7ea22cd6ee7220bb6da1cda2d5624b253f83a..3a7a1bf349c0348cd68ffb2ba509f319d06e3469 100644
--- a/services/native_viewport/platform_viewport_android.cc
+++ b/services/native_viewport/platform_viewport_android.cc
@@ -61,6 +61,11 @@ PlatformViewportAndroid::PlatformViewportAndroid(Delegate* delegate)
PlatformViewportAndroid::~PlatformViewportAndroid() {
if (window_)
ReleaseWindow();
+ if (!java_platform_viewport_android_.is_empty()) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_PlatformViewportAndroid_detach(
+ env, java_platform_viewport_android_.get(env).obj());
+ }
}
void PlatformViewportAndroid::Destroy(JNIEnv* env, jobject obj) {
@@ -161,10 +166,10 @@ bool PlatformViewportAndroid::KeyEvent(JNIEnv* env,
void PlatformViewportAndroid::Init(const gfx::Rect& bounds) {
JNIEnv* env = base::android::AttachCurrentThread();
- Java_PlatformViewportAndroid_createForActivity(
- env,
- base::android::GetApplicationContext(),
- reinterpret_cast<jlong>(this));
+ java_platform_viewport_android_ = JavaObjectWeakGlobalRef(
+ env, Java_PlatformViewportAndroid_createForActivity(
+ env, base::android::GetApplicationContext(),
+ reinterpret_cast<jlong>(this)).obj());
}
void PlatformViewportAndroid::Show() {
« no previous file with comments | « services/native_viewport/platform_viewport_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698