summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-10-27 15:47:41 +0100
committerSteve Block <steveblock@google.com>2010-10-28 11:12:43 +0100
commitbf3f67c4fcfd68df256e5c001c67969997a63e28 (patch)
treee78cada468d14c9cd244f2f565b90918b7e0bc57 /WebKit/android/jni
parente59ed3e2c930c8eeed844aa0365e8285d956a8f2 (diff)
downloadexternal_webkit-bf3f67c4fcfd68df256e5c001c67969997a63e28.zip
external_webkit-bf3f67c4fcfd68df256e5c001c67969997a63e28.tar.gz
external_webkit-bf3f67c4fcfd68df256e5c001c67969997a63e28.tar.bz2
Make sure we delete local references to jclass objects
Change-Id: I1b398bd0a84ce366eb2e686e5f14335d7aa5ed31
Diffstat (limited to 'WebKit/android/jni')
-rw-r--r--WebKit/android/jni/CookieManager.cpp3
-rw-r--r--WebKit/android/jni/DeviceMotionAndOrientationManager.cpp9
-rw-r--r--WebKit/android/jni/DeviceMotionClientImpl.cpp1
-rw-r--r--WebKit/android/jni/DeviceOrientationClientImpl.cpp1
-rwxr-xr-xWebKit/android/jni/GeolocationPermissionsBridge.cpp4
-rw-r--r--WebKit/android/jni/JavaBridge.cpp2
-rwxr-xr-xWebKit/android/jni/MockGeolocation.cpp4
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp3
-rw-r--r--WebKit/android/jni/WebCoreResourceLoader.cpp6
-rw-r--r--WebKit/android/jni/WebHistory.cpp3
-rw-r--r--WebKit/android/jni/WebIconDatabase.cpp7
-rw-r--r--WebKit/android/jni/WebSettings.cpp17
-rw-r--r--WebKit/android/jni/WebStorage.cpp4
-rw-r--r--WebKit/android/jni/WebViewCore.cpp5
14 files changed, 57 insertions, 12 deletions
diff --git a/WebKit/android/jni/CookieManager.cpp b/WebKit/android/jni/CookieManager.cpp
index 154dc5d..9688851 100644
--- a/WebKit/android/jni/CookieManager.cpp
+++ b/WebKit/android/jni/CookieManager.cpp
@@ -120,8 +120,11 @@ static JNINativeMethod gCookieManagerMethods[] = {
int registerCookieManager(JNIEnv* env)
{
+#ifndef NDEBUG
jclass cookieManager = env->FindClass(javaCookieManagerClass);
LOG_ASSERT(cookieManager, "Unable to find class");
+ env->DeleteLocalRef(cookieManager);
+#endif
return jniRegisterNativeMethods(env, javaCookieManagerClass, gCookieManagerMethods, NELEM(gCookieManagerMethods));
}
diff --git a/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp b/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp
index ad96c6c..9db83a3 100644
--- a/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp
+++ b/WebKit/android/jni/DeviceMotionAndOrientationManager.cpp
@@ -121,6 +121,7 @@ static WebViewCore* getWebViewCore(JNIEnv* env, jobject webViewCoreObject)
{
jclass webViewCoreClass = env->FindClass("android/webkit/WebViewCore");
jfieldID nativeClassField = env->GetFieldID(webViewCoreClass, "mNativeClass", "I");
+ env->DeleteLocalRef(webViewCoreClass);
return reinterpret_cast<WebViewCore*>(env->GetIntField(webViewCoreObject, nativeClassField));
}
@@ -159,8 +160,12 @@ static JNINativeMethod gDeviceMotionAndOrientationManagerMethods[] = {
int registerDeviceMotionAndOrientationManager(JNIEnv* env)
{
- jclass deviceOrientationManager = env->FindClass(javaDeviceMotionAndOrientationManagerClass);
- LOG_ASSERT(deviceOrientationManager, "Unable to find class");
+#ifndef NDEBUG
+ jclass deviceMotionAndOrientationManager = env->FindClass(javaDeviceMotionAndOrientationManagerClass);
+ LOG_ASSERT(deviceMotionAndOrientationManager, "Unable to find class");
+ env->DeleteLocalRef(deviceMotionAndOrientationManager);
+#endif
+
return jniRegisterNativeMethods(env, javaDeviceMotionAndOrientationManagerClass, gDeviceMotionAndOrientationManagerMethods, NELEM(gDeviceMotionAndOrientationManagerMethods));
}
diff --git a/WebKit/android/jni/DeviceMotionClientImpl.cpp b/WebKit/android/jni/DeviceMotionClientImpl.cpp
index 1517a19..82f3c35 100644
--- a/WebKit/android/jni/DeviceMotionClientImpl.cpp
+++ b/WebKit/android/jni/DeviceMotionClientImpl.cpp
@@ -82,6 +82,7 @@ jobject DeviceMotionClientImpl::getJavaInstance()
env->GetMethodID(javaServiceClass, "suspend", "()V");
javaServiceClassMethodIDs[ServiceMethodResume] =
env->GetMethodID(javaServiceClass, "resume", "()V");
+ env->DeleteLocalRef(javaServiceClass);
m_javaServiceObject = getJNIEnv()->NewGlobalRef(object);
getJNIEnv()->DeleteLocalRef(object);
diff --git a/WebKit/android/jni/DeviceOrientationClientImpl.cpp b/WebKit/android/jni/DeviceOrientationClientImpl.cpp
index a295bf3..bf3b3c3 100644
--- a/WebKit/android/jni/DeviceOrientationClientImpl.cpp
+++ b/WebKit/android/jni/DeviceOrientationClientImpl.cpp
@@ -82,6 +82,7 @@ jobject DeviceOrientationClientImpl::getJavaInstance()
env->GetMethodID(javaDeviceOrientationServiceClass, "suspend", "()V");
javaDeviceOrientationServiceClassMethodIDs[DeviceOrientationServiceMethodResume] =
env->GetMethodID(javaDeviceOrientationServiceClass, "resume", "()V");
+ env->DeleteLocalRef(javaDeviceOrientationServiceClass);
m_javaDeviceOrientationServiceObject = getJNIEnv()->NewGlobalRef(object);
getJNIEnv()->DeleteLocalRef(object);
diff --git a/WebKit/android/jni/GeolocationPermissionsBridge.cpp b/WebKit/android/jni/GeolocationPermissionsBridge.cpp
index 5fea9a4..17628ab 100755
--- a/WebKit/android/jni/GeolocationPermissionsBridge.cpp
+++ b/WebKit/android/jni/GeolocationPermissionsBridge.cpp
@@ -47,6 +47,7 @@ static jobject getOrigins(JNIEnv* env, jobject obj)
jmethodID constructor = env->GetMethodID(setClass, "<init>", "()V");
jmethodID addMethod = env->GetMethodID(setClass, "add", "(Ljava/lang/Object;)Z");
jobject set = env->NewObject(setClass, constructor);
+ env->DeleteLocalRef(setClass);
GeolocationPermissions::OriginSet::const_iterator end = origins.end();
for (GeolocationPermissions::OriginSet::const_iterator iter = origins.begin(); iter != end; ++iter) {
@@ -99,8 +100,11 @@ static JNINativeMethod gGeolocationPermissionsMethods[] = {
int registerGeolocationPermissions(JNIEnv* env)
{
const char* kGeolocationPermissionsClass = "android/webkit/GeolocationPermissions";
+#ifndef NDEBUG
jclass geolocationPermissions = env->FindClass(kGeolocationPermissionsClass);
LOG_ASSERT(geolocationPermissions, "Unable to find class");
+ env->DeleteLocalRef(geolocationPermissions);
+#endif
return jniRegisterNativeMethods(env, kGeolocationPermissionsClass,
gGeolocationPermissionsMethods, NELEM(gGeolocationPermissionsMethods));
diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp
index 9574739..49fb1b1 100644
--- a/WebKit/android/jni/JavaBridge.cpp
+++ b/WebKit/android/jni/JavaBridge.cpp
@@ -143,6 +143,7 @@ JavaBridge::JavaBridge(JNIEnv* env, jobject obj)
mGetKeyStrengthList = env->GetMethodID(clazz, "getKeyStrengthList", "()[Ljava/lang/String;");
mGetSignedPublicKey = env->GetMethodID(clazz, "getSignedPublicKey", "(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
mResolveFilePathForContentUri = env->GetMethodID(clazz, "resolveFilePathForContentUri", "(Ljava/lang/String;)Ljava/lang/String;");
+ env->DeleteLocalRef(clazz);
LOG_ASSERT(mSetSharedTimer, "Could not find method setSharedTimer");
LOG_ASSERT(mStopSharedTimer, "Could not find method stopSharedTimer");
@@ -491,6 +492,7 @@ int registerJavaBridge(JNIEnv* env)
LOG_FATAL_IF(javaBridge == NULL, "Unable to find class android/webkit/JWebCoreJavaBridge");
gJavaBridge_ObjectID = env->GetFieldID(javaBridge, "mNativeBridge", "I");
LOG_FATAL_IF(gJavaBridge_ObjectID == NULL, "Unable to find android/webkit/JWebCoreJavaBridge.mNativeBridge");
+ env->DeleteLocalRef(javaBridge);
return jniRegisterNativeMethods(env, "android/webkit/JWebCoreJavaBridge",
gWebCoreJavaBridgeMethods, NELEM(gWebCoreJavaBridgeMethods));
diff --git a/WebKit/android/jni/MockGeolocation.cpp b/WebKit/android/jni/MockGeolocation.cpp
index d10ff83..1370715 100755
--- a/WebKit/android/jni/MockGeolocation.cpp
+++ b/WebKit/android/jni/MockGeolocation.cpp
@@ -72,8 +72,12 @@ static JNINativeMethod gMockGeolocationMethods[] = {
int registerMockGeolocation(JNIEnv* env)
{
+#ifndef NDEBUG
jclass mockGeolocation = env->FindClass(javaMockGeolocationClass);
LOG_ASSERT(mockGeolocation, "Unable to find class");
+ env->DeleteLocalRef(mockGeolocation);
+#endif
+
return jniRegisterNativeMethods(env, javaMockGeolocationClass, gMockGeolocationMethods, NELEM(gMockGeolocationMethods));
}
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index 42843e0..bc20c47 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -276,6 +276,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page*
"(ILjava/lang/String;Ljava/lang/String;Z)V");
mJavaFrame->mDownloadStart = env->GetMethodID(clazz, "downloadStart",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V");
+ env->DeleteLocalRef(clazz);
LOG_ASSERT(mJavaFrame->mInputStreamForAndroidResource, "Could not find method inputStreamForAndroidResource");
LOG_ASSERT(mJavaFrame->mStartLoadingResource, "Could not find method startLoadingResource");
@@ -1708,6 +1709,7 @@ static jobjectArray GetUsernamePassword(JNIEnv *env, jobject obj)
if (found) {
jclass stringClass = env->FindClass("java/lang/String");
strArray = env->NewObjectArray(2, stringClass, NULL);
+ env->DeleteLocalRef(stringClass);
env->SetObjectArrayElement(strArray, 0, env->NewString(username.characters(), username.length()));
env->SetObjectArrayElement(strArray, 1, env->NewString(password.characters(), password.length()));
}
@@ -1921,6 +1923,7 @@ int registerWebFrame(JNIEnv* env)
LOG_ASSERT(clazz, "Cannot find BrowserFrame");
gFrameField = env->GetFieldID(clazz, "mNativeFrame", "I");
LOG_ASSERT(gFrameField, "Cannot find mNativeFrame on BrowserFrame");
+ env->DeleteLocalRef(clazz);
return jniRegisterNativeMethods(env, "android/webkit/BrowserFrame",
gBrowserFrameNativeMethods, NELEM(gBrowserFrameNativeMethods));
diff --git a/WebKit/android/jni/WebCoreResourceLoader.cpp b/WebKit/android/jni/WebCoreResourceLoader.cpp
index 06f0021..301ccde 100644
--- a/WebKit/android/jni/WebCoreResourceLoader.cpp
+++ b/WebKit/android/jni/WebCoreResourceLoader.cpp
@@ -122,9 +122,9 @@ bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url, int64_t
WTF::String urlStr = url.string();
jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length());
jclass resourceLoader = env->FindClass("android/webkit/LoadListener");
- bool val = env->CallStaticBooleanMethod(resourceLoader,
- gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr, identifier);
+ bool val = env->CallStaticBooleanMethod(resourceLoader, gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr, identifier);
checkException(env);
+ env->DeleteLocalRef(resourceLoader);
env->DeleteLocalRef(jUrlStr);
return val;
@@ -347,6 +347,8 @@ int registerResourceLoader(JNIEnv* env)
LOG_FATAL_IF(gResourceLoader.mWillLoadFromCacheMethodID == NULL,
"Could not find static method willLoadFromCache on LoadListener");
+ env->DeleteLocalRef(resourceLoader);
+
return jniRegisterNativeMethods(env, "android/webkit/LoadListener",
gResourceloaderMethods, NELEM(gResourceloaderMethods));
}
diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp
index 474574e..deff687 100644
--- a/WebKit/android/jni/WebHistory.cpp
+++ b/WebKit/android/jni/WebHistory.cpp
@@ -329,6 +329,7 @@ void WebHistory::AddItem(const AutoJObject& list, WebCore::HistoryItem* item)
// Allocate a blank WebHistoryItem
jclass clazz = env->FindClass("android/webkit/WebHistoryItem");
jobject newItem = env->NewObject(clazz, gWebHistoryItem.mInit);
+ env->DeleteLocalRef(clazz);
// Create the bridge, make it active, and attach it to the item.
WebHistoryItem* bridge = new WebHistoryItem(env, newItem, item);
@@ -815,6 +816,7 @@ int registerWebHistory(JNIEnv* env)
LOG_ASSERT(gWebHistoryItem.mTitle, "Could not find field mTitle in WebHistoryItem");
gWebHistoryItem.mUrl = env->GetFieldID(clazz, "mUrl", "Ljava/lang/String;");
LOG_ASSERT(gWebHistoryItem.mUrl, "Could not find field mUrl in WebHistoryItem");
+ env->DeleteLocalRef(clazz);
// Find the WebBackForwardList object and method.
clazz = env->FindClass("android/webkit/WebBackForwardList");
@@ -827,6 +829,7 @@ int registerWebHistory(JNIEnv* env)
LOG_ASSERT(gWebBackForwardList.mRemoveHistoryItem, "Could not find method removeHistoryItem");
gWebBackForwardList.mSetCurrentIndex = env->GetMethodID(clazz, "setCurrentIndex", "(I)V");
LOG_ASSERT(gWebBackForwardList.mSetCurrentIndex, "Could not find method setCurrentIndex");
+ env->DeleteLocalRef(clazz);
int result = jniRegisterNativeMethods(env, "android/webkit/WebBackForwardList",
gWebBackForwardListMethods, NELEM(gWebBackForwardListMethods));
diff --git a/WebKit/android/jni/WebIconDatabase.cpp b/WebKit/android/jni/WebIconDatabase.cpp
index 8f5aa87..a9f6b05 100644
--- a/WebKit/android/jni/WebIconDatabase.cpp
+++ b/WebKit/android/jni/WebIconDatabase.cpp
@@ -206,8 +206,11 @@ static JNINativeMethod gWebIconDatabaseMethods[] = {
int registerWebIconDatabase(JNIEnv* env)
{
- jclass webIconDB = env->FindClass("android/webkit/WebIconDatabase");
- LOG_ASSERT(webIconDB, "Unable to find class android.webkit.WebIconDatabase");
+#ifndef NDEBUG
+ jclass webIconDatabase = env->FindClass("android/webkit/WebIconDatabase");
+ LOG_ASSERT(webIconDatabase, "Unable to find class android.webkit.WebIconDatabase");
+ env->DeleteLocalRef(webIconDatabase);
+#endif
return jniRegisterNativeMethods(env, "android/webkit/WebIconDatabase",
gWebIconDatabaseMethods, NELEM(gWebIconDatabaseMethods));
diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp
index 825476b..62594ff 100644
--- a/WebKit/android/jni/WebSettings.cpp
+++ b/WebKit/android/jni/WebSettings.cpp
@@ -140,6 +140,7 @@ struct FieldIds {
mAutoFillProfileZipCode = env->GetFieldID(autoFillProfileClass, "mZipCode", "Ljava/lang/String;");
mAutoFillProfileCountry = env->GetFieldID(autoFillProfileClass, "mCountry", "Ljava/lang/String;");
mAutoFillProfilePhoneNumber = env->GetFieldID(autoFillProfileClass, "mPhoneNumber", "Ljava/lang/String;");
+ env->DeleteLocalRef(autoFillProfileClass);
#endif
LOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm");
@@ -181,13 +182,16 @@ struct FieldIds {
LOG_ASSERT(mUseDoubleTree, "Could not find field mUseDoubleTree");
LOG_ASSERT(mPageCacheCapacity, "Could not find field mPageCacheCapacity");
- jclass c = env->FindClass("java/lang/Enum");
- LOG_ASSERT(c, "Could not find Enum class!");
- mOrdinal = env->GetMethodID(c, "ordinal", "()I");
+ jclass enumClass = env->FindClass("java/lang/Enum");
+ LOG_ASSERT(enumClass, "Could not find Enum class!");
+ mOrdinal = env->GetMethodID(enumClass, "ordinal", "()I");
LOG_ASSERT(mOrdinal, "Could not find method ordinal");
- c = env->FindClass("android/webkit/WebSettings$TextSize");
- LOG_ASSERT(c, "Could not find TextSize enum");
- mTextSizeValue = env->GetFieldID(c, "value", "I");
+ env->DeleteLocalRef(enumClass);
+
+ jclass textSizeClass = env->FindClass("android/webkit/WebSettings$TextSize");
+ LOG_ASSERT(textSizeClass, "Could not find TextSize enum");
+ mTextSizeValue = env->GetFieldID(textSizeClass, "value", "I");
+ env->DeleteLocalRef(textSizeClass);
}
// Field ids
@@ -534,6 +538,7 @@ int registerWebSettings(JNIEnv* env)
jclass clazz = env->FindClass("android/webkit/WebSettings");
LOG_ASSERT(clazz, "Unable to find class WebSettings!");
gFieldIds = new FieldIds(env, clazz);
+ env->DeleteLocalRef(clazz);
return jniRegisterNativeMethods(env, "android/webkit/WebSettings",
gWebSettingsMethods, NELEM(gWebSettingsMethods));
}
diff --git a/WebKit/android/jni/WebStorage.cpp b/WebKit/android/jni/WebStorage.cpp
index 10e0de0..23220f4 100644
--- a/WebKit/android/jni/WebStorage.cpp
+++ b/WebKit/android/jni/WebStorage.cpp
@@ -58,6 +58,7 @@ static jobject GetOrigins(JNIEnv* env, jobject obj)
jmethodID cid = env->GetMethodID(setClass, "<init>", "()V");
jmethodID mid = env->GetMethodID(setClass, "add", "(Ljava/lang/Object;)Z");
jobject set = env->NewObject(setClass, cid);
+ env->DeleteLocalRef(setClass);
for (unsigned i = 0; i < coreOrigins.size(); ++i) {
WebCore::SecurityOrigin* origin = coreOrigins[i].get();
@@ -165,8 +166,11 @@ static JNINativeMethod gWebStorageMethods[] = {
int registerWebStorage(JNIEnv* env)
{
+#ifndef NDEBUG
jclass webStorage = env->FindClass("android/webkit/WebStorage");
LOG_ASSERT(webStorage, "Unable to find class android.webkit.WebStorage");
+ env->DeleteLocalRef(webStorage);
+#endif
return jniRegisterNativeMethods(env, "android/webkit/WebStorage",
gWebStorageMethods, NELEM(gWebStorageMethods));
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 1c903f4..9edc1e2 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -195,6 +195,7 @@ jobject WebViewCore::getApplicationContext() {
JNIEnv* env = JSC::Bindings::getJNIEnv();
jclass contextClass = env->GetObjectClass(context);
jmethodID appContextMethod = env->GetMethodID(contextClass, "getApplicationContext", "()Landroid/content/Context;");
+ env->DeleteLocalRef(contextClass);
jobject result = env->CallObjectMethod(context, appContextMethod);
checkException(env);
return result;
@@ -213,6 +214,7 @@ bool WebViewCore::isSupportedMediaMimeType(const WTF::String& mimeType) {
bool val = env->CallStaticBooleanMethod(webViewCore,
gWebViewCoreStaticMethods.m_isSupportedMediaMimeType, jMimeType);
checkException(env);
+ env->DeleteLocalRef(webViewCore);
env->DeleteLocalRef(jMimeType);
return val;
@@ -378,6 +380,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_setScrollbarModes = GetJMethod(env, clazz, "setScrollbarModes", "(II)V");
m_javaGlue->m_setInstallableWebApp = GetJMethod(env, clazz, "setInstallableWebApp", "()V");
m_javaGlue->m_setWebTextViewAutoFillable = GetJMethod(env, clazz, "setWebTextViewAutoFillable", "(I)V");
+ env->DeleteLocalRef(clazz);
env->SetIntField(javaWebViewCore, gWebViewCoreFields.m_nativeClass, (jint)this);
@@ -4115,6 +4118,8 @@ int registerWebViewCore(JNIEnv* env)
LOG_FATAL_IF(gWebViewCoreStaticMethods.m_isSupportedMediaMimeType == NULL,
"Could not find static method isSupportedMediaMimeType from WebViewCore");
+ env->DeleteLocalRef(widget);
+
return jniRegisterNativeMethods(env, "android/webkit/WebViewCore",
gJavaWebViewCoreMethods, NELEM(gJavaWebViewCoreMethods));
}