| Index: content/browser/renderer_host/java/java_method.cc
|
| diff --git a/content/browser/renderer_host/java/java_method.cc b/content/browser/renderer_host/java/java_method.cc
|
| index c236940aa9615a65d40f163093d12f4466a9e7fe..f61f1774995508223f15dd11469d2df264e67ecd 100644
|
| --- a/content/browser/renderer_host/java/java_method.cc
|
| +++ b/content/browser/renderer_host/java/java_method.cc
|
| @@ -11,7 +11,7 @@
|
|
|
| using base::android::AttachCurrentThread;
|
| using base::android::ConvertJavaStringToUTF8;
|
| -using base::android::MethodID;
|
| +using base::android::GetMethodIDFromClassName;
|
| using base::android::ScopedJavaLocalRef;
|
|
|
| namespace {
|
| @@ -50,75 +50,45 @@ std::string BinaryNameToJNIName(const std::string& binary_name,
|
| }
|
| }
|
|
|
| -class MethodGetParameterTypesID : public MethodID {
|
| - public:
|
| - static MethodGetParameterTypesID* GetInstance() {
|
| - return Singleton<MethodGetParameterTypesID>::get();
|
| - }
|
| - private:
|
| - friend struct DefaultSingletonTraits<MethodGetParameterTypesID>;
|
| - MethodGetParameterTypesID()
|
| - : MethodID(AttachCurrentThread(), "java/lang/reflect/Method",
|
| - "getParameterTypes", "()[Ljava/lang/Class;") {
|
| - }
|
| - DISALLOW_COPY_AND_ASSIGN(MethodGetParameterTypesID);
|
| -};
|
| +jmethodID GetMethodGetParameterTypesID() {
|
| + static jmethodID id = GetMethodIDFromClassName(AttachCurrentThread(),
|
| + "java/lang/reflect/Method",
|
| + "getParameterTypes",
|
| + "()[Ljava/lang/Class;");
|
| + return id;
|
| +}
|
|
|
| -class MethodGetNameID : public MethodID {
|
| - public:
|
| - static MethodGetNameID* GetInstance() {
|
| - return Singleton<MethodGetNameID>::get();
|
| - }
|
| - private:
|
| - friend struct DefaultSingletonTraits<MethodGetNameID>;
|
| - MethodGetNameID()
|
| - : MethodID(AttachCurrentThread(), "java/lang/reflect/Method",
|
| - "getName", "()Ljava/lang/String;") {
|
| - }
|
| - DISALLOW_COPY_AND_ASSIGN(MethodGetNameID);
|
| -};
|
| +jmethodID GetMethodGetNameID() {
|
| + static jmethodID id = GetMethodIDFromClassName(AttachCurrentThread(),
|
| + "java/lang/reflect/Method",
|
| + "getName",
|
| + "()Ljava/lang/String;");
|
| + return id;
|
| +}
|
|
|
| -class MethodGetReturnTypeID : public MethodID {
|
| - public:
|
| - static MethodGetReturnTypeID* GetInstance() {
|
| - return Singleton<MethodGetReturnTypeID>::get();
|
| - }
|
| - private:
|
| - friend struct DefaultSingletonTraits<MethodGetReturnTypeID>;
|
| - MethodGetReturnTypeID()
|
| - : MethodID(AttachCurrentThread(), "java/lang/reflect/Method",
|
| - "getReturnType", "()Ljava/lang/Class;") {
|
| - }
|
| - DISALLOW_COPY_AND_ASSIGN(MethodGetReturnTypeID);
|
| -};
|
| +jmethodID GetMethodGetReturnTypeID() {
|
| + static jmethodID id = GetMethodIDFromClassName(AttachCurrentThread(),
|
| + "java/lang/reflect/Method",
|
| + "getReturnType",
|
| + "()Ljava/lang/Class;");
|
| + return id;
|
| +}
|
|
|
| -class MethodGetDeclaringClassID : public MethodID {
|
| - public:
|
| - static MethodGetDeclaringClassID* GetInstance() {
|
| - return Singleton<MethodGetDeclaringClassID>::get();
|
| - }
|
| - private:
|
| - friend struct DefaultSingletonTraits<MethodGetDeclaringClassID>;
|
| - MethodGetDeclaringClassID()
|
| - : MethodID(AttachCurrentThread(), "java/lang/reflect/Method",
|
| - "getDeclaringClass", "()Ljava/lang/Class;") {
|
| - }
|
| - DISALLOW_COPY_AND_ASSIGN(MethodGetDeclaringClassID);
|
| -};
|
| +jmethodID GetMethodGetDeclaringClassID() {
|
| + static jmethodID id = GetMethodIDFromClassName(AttachCurrentThread(),
|
| + "java/lang/reflect/Method",
|
| + "getDeclaringClass",
|
| + "()Ljava/lang/Class;");
|
| + return id;
|
| +}
|
|
|
| -class ClassGetNameID : public MethodID {
|
| - public:
|
| - static ClassGetNameID* GetInstance() {
|
| - return Singleton<ClassGetNameID>::get();
|
| - }
|
| - private:
|
| - friend struct DefaultSingletonTraits<ClassGetNameID>;
|
| - ClassGetNameID()
|
| - : MethodID(AttachCurrentThread(), "java/lang/Class", "getName",
|
| - "()Ljava/lang/String;") {
|
| - }
|
| - DISALLOW_COPY_AND_ASSIGN(ClassGetNameID);
|
| -};
|
| +jmethodID GetClassGetNameID() {
|
| + static jmethodID id = GetMethodIDFromClassName(AttachCurrentThread(),
|
| + "java/lang/Class",
|
| + "getName",
|
| + "()Ljava/lang/String;");
|
| + return id;
|
| +}
|
|
|
| } // namespace
|
|
|
| @@ -130,8 +100,7 @@ JavaMethod::JavaMethod(const base::android::JavaRef<jobject>& method)
|
| // On construction, we do nothing except get the name. Everything else is
|
| // done lazily.
|
| ScopedJavaLocalRef<jstring> name(env, static_cast<jstring>(
|
| - env->CallObjectMethod(java_method_.obj(),
|
| - MethodGetNameID::GetInstance()->id())));
|
| + env->CallObjectMethod(java_method_.obj(), GetMethodGetNameID())));
|
| name_ = ConvertJavaStringToUTF8(env, name.obj());
|
| }
|
|
|
| @@ -170,7 +139,7 @@ void JavaMethod::EnsureNumParametersIsSetUp() const {
|
| JNIEnv* env = java_method_.env();
|
| ScopedJavaLocalRef<jarray> parameters(env, static_cast<jarray>(
|
| env->CallObjectMethod(java_method_.obj(),
|
| - MethodGetParameterTypesID::GetInstance()->id())));
|
| + GetMethodGetParameterTypesID())));
|
| num_parameters_ = env->GetArrayLength(parameters.obj());
|
| }
|
|
|
| @@ -183,7 +152,7 @@ void JavaMethod::EnsureTypesAndIDAreSetUp() const {
|
| JNIEnv* env = java_method_.env();
|
| ScopedJavaLocalRef<jobjectArray> parameters(env, static_cast<jobjectArray>(
|
| env->CallObjectMethod(java_method_.obj(),
|
| - MethodGetParameterTypesID::GetInstance()->id())));
|
| + GetMethodGetParameterTypesID())));
|
| // Usually, this will already have been called.
|
| EnsureNumParametersIsSetUp();
|
| DCHECK_EQ(num_parameters_,
|
| @@ -202,8 +171,7 @@ void JavaMethod::EnsureTypesAndIDAreSetUp() const {
|
| ScopedJavaLocalRef<jobject> parameter(env, env->GetObjectArrayElement(
|
| parameters.obj(), i));
|
| ScopedJavaLocalRef<jstring> name(env, static_cast<jstring>(
|
| - env->CallObjectMethod(parameter.obj(),
|
| - ClassGetNameID::GetInstance()->id())));
|
| + env->CallObjectMethod(parameter.obj(), GetClassGetNameID())));
|
| std::string name_utf8 = ConvertJavaStringToUTF8(env, name.obj());
|
| signature += BinaryNameToJNIName(name_utf8, ¶meter_types_[i]);
|
| }
|
| @@ -211,17 +179,16 @@ void JavaMethod::EnsureTypesAndIDAreSetUp() const {
|
|
|
| // Get the return type
|
| ScopedJavaLocalRef<jclass> clazz(env, static_cast<jclass>(
|
| - env->CallObjectMethod(java_method_.obj(),
|
| - MethodGetReturnTypeID::GetInstance()->id())));
|
| + env->CallObjectMethod(java_method_.obj(), GetMethodGetReturnTypeID())));
|
| ScopedJavaLocalRef<jstring> name(env, static_cast<jstring>(
|
| - env->CallObjectMethod(clazz.obj(), ClassGetNameID::GetInstance()->id())));
|
| + env->CallObjectMethod(clazz.obj(), GetClassGetNameID())));
|
| signature += BinaryNameToJNIName(ConvertJavaStringToUTF8(env, name.obj()),
|
| &return_type_);
|
|
|
| // Get the ID for this method.
|
| ScopedJavaLocalRef<jclass> declaring_class(env, static_cast<jclass>(
|
| env->CallObjectMethod(java_method_.obj(),
|
| - MethodGetDeclaringClassID::GetInstance()->id())));
|
| + GetMethodGetDeclaringClassID())));
|
| id_ = base::android::GetMethodID(env, declaring_class.obj(), name_.c_str(),
|
| signature.c_str());
|
|
|
|
|