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

Unified Diff: content/browser/renderer_host/java/gin_java_method_invocation_helper.cc

Issue 345753003: [Android] Java Bridge with Gin: implement Java Bridge dispatcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use an enum for passing error codes Created 6 years, 6 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
Index: content/browser/renderer_host/java/gin_java_method_invocation_helper.cc
diff --git a/content/browser/renderer_host/java/gin_java_method_invocation_helper.cc b/content/browser/renderer_host/java/gin_java_method_invocation_helper.cc
index d3fb138654424771076277aa52edf517c2dbf8f1..5c60ecfb9eaf41f344b890c1a488f083a0103516 100644
--- a/content/browser/renderer_host/java/gin_java_method_invocation_helper.cc
+++ b/content/browser/renderer_host/java/gin_java_method_invocation_helper.cc
@@ -23,13 +23,6 @@ namespace content {
namespace {
-const char kObjectIsGone[] = "Java object is gone";
-const char kMethodNotFound[] = "Method not found";
-const char kAccessToObjectGetClassIsBlocked[] =
- "Access to java.lang.Object.getClass is blocked";
-const char kJavaExceptionRaised[] =
- "Java exception has been raised during method invocation";
-
// See frameworks/base/core/java/android/webkit/EventLogTags.logtags
const int kObjectGetClassInvocationAttemptLogTag = 70151;
@@ -41,7 +34,8 @@ GinJavaMethodInvocationHelper::GinJavaMethodInvocationHelper(
const base::ListValue& arguments)
: object_(object.Pass()),
method_name_(method_name),
- arguments_(arguments.DeepCopy()) {
+ arguments_(arguments.DeepCopy()),
+ invocation_error_(kGinJavaBridgeNoError) {
}
GinJavaMethodInvocationHelper::~GinJavaMethodInvocationHelper() {}
@@ -121,14 +115,14 @@ void GinJavaMethodInvocationHelper::Invoke() {
const JavaMethod* method =
object_->FindMethod(method_name_, arguments_->GetSize());
if (!method) {
- SetInvocationFailure(kMethodNotFound);
+ SetInvocationError(kGinJavaBridgeMethodNotFound);
return;
}
if (object_->IsObjectGetClassMethod(method)) {
base::android::EventLogWriteInt(kObjectGetClassInvocationAttemptLogTag,
getuid());
- SetInvocationFailure(kAccessToObjectGetClassIsBlocked);
+ SetInvocationError(kGinJavaBridgeAccessToObjectGetClassIsBlocked);
return;
}
@@ -140,7 +134,7 @@ void GinJavaMethodInvocationHelper::Invoke() {
obj = object_->GetLocalRef(env);
}
if (obj.is_null() && cls.is_null()) {
- SetInvocationFailure(kObjectIsGone);
+ SetInvocationError(kGinJavaBridgeObjectIsGone);
return;
}
@@ -166,11 +160,11 @@ void GinJavaMethodInvocationHelper::Invoke() {
}
}
-void GinJavaMethodInvocationHelper::SetInvocationFailure(
- const char* error_message) {
+void GinJavaMethodInvocationHelper::SetInvocationError(
+ GinJavaBridgeError error) {
holds_primitive_result_ = true;
primitive_result_.reset(new base::ListValue());
- error_message_ = error_message;
+ invocation_error_ = error;
}
void GinJavaMethodInvocationHelper::SetPrimitiveResult(
@@ -205,8 +199,8 @@ GinJavaMethodInvocationHelper::GetSafeAnnotationClass() {
return safe_annotation_clazz_;
}
-const std::string& GinJavaMethodInvocationHelper::GetErrorMessage() {
- return error_message_;
+const GinJavaBridgeError GinJavaMethodInvocationHelper::GetInvocationError() {
+ return invocation_error_;
}
void GinJavaMethodInvocationHelper::InvokeMethod(jobject object,
@@ -295,7 +289,7 @@ void GinJavaMethodInvocationHelper::InvokeMethod(jobject object,
// methods. ScopedJavaLocalRef is liable to make such calls, so we test
// first.
if (base::android::ClearException(env)) {
- SetInvocationFailure(kJavaExceptionRaised);
+ SetInvocationError(kGinJavaBridgeJavaExceptionRaised);
return;
}
ScopedJavaLocalRef<jstring> scoped_java_string(env, java_string);
@@ -318,7 +312,7 @@ void GinJavaMethodInvocationHelper::InvokeMethod(jobject object,
object ? env->CallObjectMethodA(object, id, parameters)
: env->CallStaticObjectMethodA(clazz, id, parameters);
if (base::android::ClearException(env)) {
- SetInvocationFailure(kJavaExceptionRaised);
+ SetInvocationError(kGinJavaBridgeJavaExceptionRaised);
return;
}
ScopedJavaLocalRef<jobject> scoped_java_object(env, java_object);
@@ -334,7 +328,7 @@ void GinJavaMethodInvocationHelper::InvokeMethod(jobject object,
if (!base::android::ClearException(env)) {
SetPrimitiveResult(result_wrapper);
} else {
- SetInvocationFailure(kJavaExceptionRaised);
+ SetInvocationError(kGinJavaBridgeJavaExceptionRaised);
}
}

Powered by Google App Engine
This is Rietveld 408576698