Bug 340960 - Provide proper profile locking and notification. r=bsmedberg. XULRunner only.
This commit is contained in:
@@ -70,6 +70,7 @@ JNI_OnUnload(JavaVM* vm, void* reserved)
|
||||
#define JXM_NATIVE(func) Java_org_mozilla_xpcom_internal_JavaXPCOMMethods_##func
|
||||
|
||||
enum {
|
||||
kFunc_Initialize,
|
||||
kFunc_InitEmbedding,
|
||||
kFunc_TermEmbedding,
|
||||
kFunc_LockProfileDirectory,
|
||||
@@ -82,10 +83,11 @@ enum {
|
||||
kFunc_NewLocalFile,
|
||||
kFunc_CallXPCOMMethod,
|
||||
kFunc_FinalizeProxy,
|
||||
kFunc_IsSameXPCOMObject
|
||||
kFunc_IsSameXPCOMObject,
|
||||
kFunc_ReleaseProfileLock
|
||||
};
|
||||
|
||||
#define JX_NUM_FUNCS 13
|
||||
#define JX_NUM_FUNCS 15
|
||||
|
||||
|
||||
// Get path string from java.io.File object.
|
||||
@@ -129,6 +131,8 @@ LoadXULMethods(JNIEnv* env, jobject aXPCOMPath, void** aFunctions)
|
||||
return rv;
|
||||
|
||||
nsDynamicFunctionLoad funcs[] = {
|
||||
{ "Java_org_mozilla_xpcom_internal_MozillaImpl_initialize",
|
||||
(NSFuncPtr*) &aFunctions[kFunc_Initialize] },
|
||||
{ "Java_org_mozilla_xpcom_internal_GREImpl_initEmbedding",
|
||||
(NSFuncPtr*) &aFunctions[kFunc_InitEmbedding] },
|
||||
{ "Java_org_mozilla_xpcom_internal_GREImpl_termEmbedding",
|
||||
@@ -155,6 +159,8 @@ LoadXULMethods(JNIEnv* env, jobject aXPCOMPath, void** aFunctions)
|
||||
(NSFuncPtr*) &aFunctions[kFunc_FinalizeProxy] },
|
||||
{ "Java_org_mozilla_xpcom_internal_XPCOMJavaProxy_isSameXPCOMObject",
|
||||
(NSFuncPtr*) &aFunctions[kFunc_IsSameXPCOMObject] },
|
||||
{ "Java_org_mozilla_xpcom_ProfileLock_release",
|
||||
(NSFuncPtr*) &aFunctions[kFunc_ReleaseProfileLock] },
|
||||
{ nsnull, nsnull }
|
||||
};
|
||||
|
||||
@@ -210,13 +216,18 @@ ThrowException(JNIEnv* env, const nsresult aErrorCode, const char* aMessage)
|
||||
nsresult
|
||||
RegisterNativeMethods(JNIEnv* env, void** aFunctions)
|
||||
{
|
||||
JNINativeMethod mozilla_methods[] = {
|
||||
{ "initializeNative", "()V",
|
||||
(void*) aFunctions[kFunc_Initialize] },
|
||||
};
|
||||
|
||||
JNINativeMethod gre_methods[] = {
|
||||
{ "initEmbeddingNative",
|
||||
"(Ljava/io/File;Ljava/io/File;Lorg/mozilla/xpcom/IAppFileLocProvider;)V",
|
||||
(void*) aFunctions[kFunc_InitEmbedding] },
|
||||
{ "termEmbedding", "()V",
|
||||
(void*) aFunctions[kFunc_TermEmbedding] },
|
||||
{ "lockProfileDirectory", "(Ljava/io/File;)Lorg/mozilla/xpcom/nsISupports;",
|
||||
{ "lockProfileDirectory", "(Ljava/io/File;)Lorg/mozilla/xpcom/ProfileLock;",
|
||||
(void*) aFunctions[kFunc_LockProfileDirectory] },
|
||||
{ "notifyProfile", "()V",
|
||||
(void*) aFunctions[kFunc_NotifyProfile] },
|
||||
@@ -248,8 +259,21 @@ RegisterNativeMethods(JNIEnv* env, void** aFunctions)
|
||||
(void*) aFunctions[kFunc_IsSameXPCOMObject] }
|
||||
};
|
||||
|
||||
JNINativeMethod lockProxy_methods[] = {
|
||||
{ "releaseNative", "(J)V",
|
||||
(void*) aFunctions[kFunc_ReleaseProfileLock] }
|
||||
};
|
||||
|
||||
jint rc = -1;
|
||||
jclass clazz = env->FindClass("org/mozilla/xpcom/internal/GREImpl");
|
||||
jclass clazz = env->FindClass("org/mozilla/xpcom/internal/MozillaImpl");
|
||||
if (clazz) {
|
||||
rc = env->RegisterNatives(clazz, mozilla_methods,
|
||||
sizeof(mozilla_methods) / sizeof(mozilla_methods[0]));
|
||||
}
|
||||
NS_ENSURE_TRUE(rc == 0, NS_ERROR_FAILURE);
|
||||
|
||||
rc = -1;
|
||||
clazz = env->FindClass("org/mozilla/xpcom/internal/GREImpl");
|
||||
if (clazz) {
|
||||
rc = env->RegisterNatives(clazz, gre_methods,
|
||||
sizeof(gre_methods) / sizeof(gre_methods[0]));
|
||||
@@ -272,6 +296,14 @@ RegisterNativeMethods(JNIEnv* env, void** aFunctions)
|
||||
}
|
||||
NS_ENSURE_TRUE(rc == 0, NS_ERROR_FAILURE);
|
||||
|
||||
rc = -1;
|
||||
clazz = env->FindClass("org/mozilla/xpcom/ProfileLock");
|
||||
if (clazz) {
|
||||
rc = env->RegisterNatives(clazz, lockProxy_methods,
|
||||
sizeof(lockProxy_methods) / sizeof(lockProxy_methods[0]));
|
||||
}
|
||||
NS_ENSURE_TRUE(rc == 0, NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user