| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/android/java/gin_java_method_invocation_helper.h" | 5 #include "content/browser/android/java/gin_java_method_invocation_helper.h" |
| 6 | 6 |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 | |
| 9 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/android/event_log.h" | 11 #include "base/android/event_log.h" |
| 12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
| 13 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
| 14 #include "content/browser/android/java/gin_java_script_to_java_types_coercion.h" | 14 #include "content/browser/android/java/gin_java_script_to_java_types_coercion.h" |
| 15 #include "content/browser/android/java/java_method.h" | 15 #include "content/browser/android/java/java_method.h" |
| 16 #include "content/browser/android/java/jni_helper.h" | 16 #include "content/browser/android/java/jni_helper.h" |
| 17 #include "content/common/android/gin_java_bridge_value.h" | 17 #include "content/common/android/gin_java_bridge_value.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 | 19 |
| 20 using base::android::AttachCurrentThread; | 20 using base::android::AttachCurrentThread; |
| 21 using base::android::ScopedJavaLocalRef; | 21 using base::android::ScopedJavaLocalRef; |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // See frameworks/base/core/java/android/webkit/EventLogTags.logtags | 27 // See frameworks/base/core/java/android/webkit/EventLogTags.logtags |
| 28 const int kObjectGetClassInvocationAttemptLogTag = 70151; | 28 const int kObjectGetClassInvocationAttemptLogTag = 70151; |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 GinJavaMethodInvocationHelper::GinJavaMethodInvocationHelper( | 32 GinJavaMethodInvocationHelper::GinJavaMethodInvocationHelper( |
| 33 scoped_ptr<ObjectDelegate> object, | 33 scoped_ptr<ObjectDelegate> object, |
| 34 const std::string& method_name, | 34 const std::string& method_name, |
| 35 const base::ListValue& arguments) | 35 const base::ListValue& arguments) |
| 36 : object_(object.Pass()), | 36 : object_(std::move(object)), |
| 37 method_name_(method_name), | 37 method_name_(method_name), |
| 38 arguments_(arguments.DeepCopy()), | 38 arguments_(arguments.DeepCopy()), |
| 39 invocation_error_(kGinJavaBridgeNoError) { | 39 invocation_error_(kGinJavaBridgeNoError) {} |
| 40 } | |
| 41 | 40 |
| 42 GinJavaMethodInvocationHelper::~GinJavaMethodInvocationHelper() {} | 41 GinJavaMethodInvocationHelper::~GinJavaMethodInvocationHelper() {} |
| 43 | 42 |
| 44 void GinJavaMethodInvocationHelper::Init(DispatcherDelegate* dispatcher) { | 43 void GinJavaMethodInvocationHelper::Init(DispatcherDelegate* dispatcher) { |
| 45 // Build on the UI thread a map of object_id -> WeakRef for Java objects from | 44 // Build on the UI thread a map of object_id -> WeakRef for Java objects from |
| 46 // |arguments_|. Then we can use this map on the background thread without | 45 // |arguments_|. Then we can use this map on the background thread without |
| 47 // accessing |dispatcher|. | 46 // accessing |dispatcher|. |
| 48 BuildObjectRefsFromListValue(dispatcher, arguments_.get()); | 47 BuildObjectRefsFromListValue(dispatcher, arguments_.get()); |
| 49 } | 48 } |
| 50 | 49 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 336 } |
| 338 // This is for all cases except JavaType::TypeObject. | 337 // This is for all cases except JavaType::TypeObject. |
| 339 if (!base::android::ClearException(env)) { | 338 if (!base::android::ClearException(env)) { |
| 340 SetPrimitiveResult(result_wrapper); | 339 SetPrimitiveResult(result_wrapper); |
| 341 } else { | 340 } else { |
| 342 SetInvocationError(kGinJavaBridgeJavaExceptionRaised); | 341 SetInvocationError(kGinJavaBridgeJavaExceptionRaised); |
| 343 } | 342 } |
| 344 } | 343 } |
| 345 | 344 |
| 346 } // namespace content | 345 } // namespace content |
| OLD | NEW |