summaryrefslogtreecommitdiffstats
path: root/content/common/android
diff options
context:
space:
mode:
authorbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-16 18:35:10 +0000
committerbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-16 18:35:10 +0000
commitc410a2cb9f7120b5c1e6a83ff54b53b19cae79d3 (patch)
treeea2a3871c5bae617dd9ceb8e8418f84cd60e74bd /content/common/android
parent784ba78a56c2e541bff04fdc54e8ea8a235c14f0 (diff)
downloadchromium_src-c410a2cb9f7120b5c1e6a83ff54b53b19cae79d3.zip
chromium_src-c410a2cb9f7120b5c1e6a83ff54b53b19cae79d3.tar.gz
chromium_src-c410a2cb9f7120b5c1e6a83ff54b53b19cae79d3.tar.bz2
Android: lazy initialization for method id.
Rather than requiring early registration for all method id, we can initialize them lazily as required. This solves the problem of building against SDK X but running against X - 1. Also adds a microbenchmark to ensure there are no considerable regressions. Results are a bit variable, but it hovers over: [ERROR:jni_android_unittest.cc(125)] JNI LazyMethodIDCall (us) 1983 [ERROR:jni_android_unittest.cc(127)] JNI MethodIDCall (us) 1862 BUG=152987 TEST=JNIAndroidMicrobenchmark.MethodId TBR=akalin Review URL: https://chromiumcodereview.appspot.com/11038015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162186 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common/android')
-rw-r--r--content/common/android/surface_callback.cc13
-rw-r--r--content/common/android/surface_texture_bridge.cc1
2 files changed, 5 insertions, 9 deletions
diff --git a/content/common/android/surface_callback.cc b/content/common/android/surface_callback.cc
index 77757e9..7bfd033 100644
--- a/content/common/android/surface_callback.cc
+++ b/content/common/android/surface_callback.cc
@@ -19,7 +19,8 @@
using base::android::AttachCurrentThread;
using base::android::CheckException;
-using base::android::GetMethodID;
+using base::android::GetClass;
+using base::android::MethodID;
using base::WaitableEvent;
using content::SurfaceTexturePeer;
@@ -76,16 +77,12 @@ void ReleaseSurface(jobject surface) {
JNIEnv* env = AttachCurrentThread();
CHECK(env);
- jclass cls = env->FindClass("android/view/Surface");
- DCHECK(cls);
+ ScopedJavaLocalRef<jclass> cls(GetClass(env, "android/view/Surface"));
- jmethodID method = env->GetMethodID(cls, "release", "()V");
- DCHECK(method);
+ jmethodID method = MethodID::Get<MethodID::TYPE_INSTANCE>(
+ env, cls.obj(), "release", "()V");
env->CallVoidMethod(surface, method);
- DCHECK(env);
-
- env->DeleteLocalRef(cls);
}
void SetSurfaceAsync(JNIEnv* env,
diff --git a/content/common/android/surface_texture_bridge.cc b/content/common/android/surface_texture_bridge.cc
index bc17c13..8f640f8 100644
--- a/content/common/android/surface_texture_bridge.cc
+++ b/content/common/android/surface_texture_bridge.cc
@@ -12,7 +12,6 @@
using base::android::AttachCurrentThread;
using base::android::CheckException;
using base::android::GetClass;
-using base::android::GetMethodID;
using base::android::ScopedJavaLocalRef;
namespace {