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 | 8 |
| 9 #include <cmath> |
| 10 |
9 #include "base/android/event_log.h" | 11 #include "base/android/event_log.h" |
10 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
11 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
12 #include "base/float_util.h" | |
13 #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" |
14 #include "content/browser/android/java/java_method.h" | 15 #include "content/browser/android/java/java_method.h" |
15 #include "content/browser/android/java/jni_helper.h" | 16 #include "content/browser/android/java/jni_helper.h" |
16 #include "content/common/android/gin_java_bridge_value.h" | 17 #include "content/common/android/gin_java_bridge_value.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 | 19 |
19 using base::android::AttachCurrentThread; | 20 using base::android::AttachCurrentThread; |
20 using base::android::ScopedJavaLocalRef; | 21 using base::android::ScopedJavaLocalRef; |
21 | 22 |
22 namespace content { | 23 namespace content { |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 break; | 250 break; |
250 case JavaType::TypeLong: | 251 case JavaType::TypeLong: |
251 result_wrapper.AppendDouble( | 252 result_wrapper.AppendDouble( |
252 object ? env->CallLongMethodA(object, id, parameters) | 253 object ? env->CallLongMethodA(object, id, parameters) |
253 : env->CallStaticLongMethodA(clazz, id, parameters)); | 254 : env->CallStaticLongMethodA(clazz, id, parameters)); |
254 break; | 255 break; |
255 case JavaType::TypeFloat: { | 256 case JavaType::TypeFloat: { |
256 float result = object | 257 float result = object |
257 ? env->CallFloatMethodA(object, id, parameters) | 258 ? env->CallFloatMethodA(object, id, parameters) |
258 : env->CallStaticFloatMethodA(clazz, id, parameters); | 259 : env->CallStaticFloatMethodA(clazz, id, parameters); |
259 if (base::IsFinite(result)) { | 260 if (std::isfinite(result)) { |
260 result_wrapper.AppendDouble(result); | 261 result_wrapper.AppendDouble(result); |
261 } else { | 262 } else { |
262 result_wrapper.Append( | 263 result_wrapper.Append( |
263 GinJavaBridgeValue::CreateNonFiniteValue(result).release()); | 264 GinJavaBridgeValue::CreateNonFiniteValue(result).release()); |
264 } | 265 } |
265 break; | 266 break; |
266 } | 267 } |
267 case JavaType::TypeDouble: { | 268 case JavaType::TypeDouble: { |
268 double result = object | 269 double result = object |
269 ? env->CallDoubleMethodA(object, id, parameters) | 270 ? env->CallDoubleMethodA(object, id, parameters) |
270 : env->CallStaticDoubleMethodA(clazz, id, parameters); | 271 : env->CallStaticDoubleMethodA(clazz, id, parameters); |
271 if (base::IsFinite(result)) { | 272 if (std::isfinite(result)) { |
272 result_wrapper.AppendDouble(result); | 273 result_wrapper.AppendDouble(result); |
273 } else { | 274 } else { |
274 result_wrapper.Append( | 275 result_wrapper.Append( |
275 GinJavaBridgeValue::CreateNonFiniteValue(result).release()); | 276 GinJavaBridgeValue::CreateNonFiniteValue(result).release()); |
276 } | 277 } |
277 break; | 278 break; |
278 } | 279 } |
279 case JavaType::TypeVoid: | 280 case JavaType::TypeVoid: |
280 if (object) | 281 if (object) |
281 env->CallVoidMethodA(object, id, parameters); | 282 env->CallVoidMethodA(object, id, parameters); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } | 337 } |
337 // This is for all cases except JavaType::TypeObject. | 338 // This is for all cases except JavaType::TypeObject. |
338 if (!base::android::ClearException(env)) { | 339 if (!base::android::ClearException(env)) { |
339 SetPrimitiveResult(result_wrapper); | 340 SetPrimitiveResult(result_wrapper); |
340 } else { | 341 } else { |
341 SetInvocationError(kGinJavaBridgeJavaExceptionRaised); | 342 SetInvocationError(kGinJavaBridgeJavaExceptionRaised); |
342 } | 343 } |
343 } | 344 } |
344 | 345 |
345 } // namespace content | 346 } // namespace content |
OLD | NEW |