| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/renderer/java/gin_java_function_invocation_helper.h" | 5 #include "content/renderer/java/gin_java_function_invocation_helper.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
| 7 #include "content/common/android/gin_java_bridge_errors.h" | 8 #include "content/common/android/gin_java_bridge_errors.h" |
| 8 #include "content/common/android/gin_java_bridge_value.h" | 9 #include "content/common/android/gin_java_bridge_value.h" |
| 9 #include "content/public/child/v8_value_converter.h" | 10 #include "content/public/child/v8_value_converter.h" |
| 10 #include "content/renderer/java/gin_java_bridge_object.h" | 11 #include "content/renderer/java/gin_java_bridge_object.h" |
| 11 #include "content/renderer/java/gin_java_bridge_value_converter.h" | 12 #include "content/renderer/java/gin_java_bridge_value_converter.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 base::ListValue arguments; | 59 base::ListValue arguments; |
| 59 { | 60 { |
| 60 v8::HandleScope handle_scope(args->isolate()); | 61 v8::HandleScope handle_scope(args->isolate()); |
| 61 v8::Local<v8::Context> context = args->isolate()->GetCurrentContext(); | 62 v8::Local<v8::Context> context = args->isolate()->GetCurrentContext(); |
| 62 v8::Local<v8::Value> val; | 63 v8::Local<v8::Value> val; |
| 63 while (args->GetNext(&val)) { | 64 while (args->GetNext(&val)) { |
| 64 std::unique_ptr<base::Value> arg(converter_->FromV8Value(val, context)); | 65 std::unique_ptr<base::Value> arg(converter_->FromV8Value(val, context)); |
| 65 if (arg.get()) { | 66 if (arg.get()) { |
| 66 arguments.Append(arg.release()); | 67 arguments.Append(arg.release()); |
| 67 } else { | 68 } else { |
| 68 arguments.Append(base::Value::CreateNullValue()); | 69 arguments.Append(base::MakeUnique<base::Value>()); |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 } | 72 } |
| 72 | 73 |
| 73 GinJavaBridgeError error; | 74 GinJavaBridgeError error; |
| 74 std::unique_ptr<base::Value> result = dispatcher_->InvokeJavaMethod( | 75 std::unique_ptr<base::Value> result = dispatcher_->InvokeJavaMethod( |
| 75 object->object_id(), method_name_, arguments, &error); | 76 object->object_id(), method_name_, arguments, &error); |
| 76 if (!result.get()) { | 77 if (!result.get()) { |
| 77 args->isolate()->ThrowException(v8::Exception::Error(gin::StringToV8( | 78 args->isolate()->ThrowException(v8::Exception::Error(gin::StringToV8( |
| 78 args->isolate(), GinJavaBridgeErrorToString(error)))); | 79 args->isolate(), GinJavaBridgeErrorToString(error)))); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 100 } | 101 } |
| 101 } else if (gin_value->IsType(GinJavaBridgeValue::TYPE_NONFINITE)) { | 102 } else if (gin_value->IsType(GinJavaBridgeValue::TYPE_NONFINITE)) { |
| 102 float float_value; | 103 float float_value; |
| 103 gin_value->GetAsNonFinite(&float_value); | 104 gin_value->GetAsNonFinite(&float_value); |
| 104 return v8::Number::New(args->isolate(), float_value); | 105 return v8::Number::New(args->isolate(), float_value); |
| 105 } | 106 } |
| 106 return v8::Undefined(args->isolate()); | 107 return v8::Undefined(args->isolate()); |
| 107 } | 108 } |
| 108 | 109 |
| 109 } // namespace content | 110 } // namespace content |
| OLD | NEW |