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 #include <cmath> | 8 #include <cmath> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
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 std::unique_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_(std::move(object)), | 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 | 40 |
41 GinJavaMethodInvocationHelper::~GinJavaMethodInvocationHelper() {} | 41 GinJavaMethodInvocationHelper::~GinJavaMethodInvocationHelper() {} |
42 | 42 |
43 void GinJavaMethodInvocationHelper::Init(DispatcherDelegate* dispatcher) { | 43 void GinJavaMethodInvocationHelper::Init(DispatcherDelegate* dispatcher) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 BuildObjectRefsFromDictionaryValue(dispatcher, &iter.value()); | 85 BuildObjectRefsFromDictionaryValue(dispatcher, &iter.value()); |
86 } | 86 } |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 bool GinJavaMethodInvocationHelper::AppendObjectRef( | 90 bool GinJavaMethodInvocationHelper::AppendObjectRef( |
91 DispatcherDelegate* dispatcher, | 91 DispatcherDelegate* dispatcher, |
92 const base::Value* raw_value) { | 92 const base::Value* raw_value) { |
93 if (!GinJavaBridgeValue::ContainsGinJavaBridgeValue(raw_value)) | 93 if (!GinJavaBridgeValue::ContainsGinJavaBridgeValue(raw_value)) |
94 return false; | 94 return false; |
95 scoped_ptr<const GinJavaBridgeValue> value( | 95 std::unique_ptr<const GinJavaBridgeValue> value( |
96 GinJavaBridgeValue::FromValue(raw_value)); | 96 GinJavaBridgeValue::FromValue(raw_value)); |
97 if (!value->IsType(GinJavaBridgeValue::TYPE_OBJECT_ID)) | 97 if (!value->IsType(GinJavaBridgeValue::TYPE_OBJECT_ID)) |
98 return false; | 98 return false; |
99 GinJavaBoundObject::ObjectID object_id; | 99 GinJavaBoundObject::ObjectID object_id; |
100 if (value->GetAsObjectID(&object_id)) { | 100 if (value->GetAsObjectID(&object_id)) { |
101 ObjectRefs::iterator iter = object_refs_.find(object_id); | 101 ObjectRefs::iterator iter = object_refs_.find(object_id); |
102 if (iter == object_refs_.end()) { | 102 if (iter == object_refs_.end()) { |
103 JavaObjectWeakGlobalRef object_ref( | 103 JavaObjectWeakGlobalRef object_ref( |
104 dispatcher->GetObjectWeakRef(object_id)); | 104 dispatcher->GetObjectWeakRef(object_id)); |
105 if (!object_ref.is_empty()) { | 105 if (!object_ref.is_empty()) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } | 336 } |
337 // This is for all cases except JavaType::TypeObject. | 337 // This is for all cases except JavaType::TypeObject. |
338 if (!base::android::ClearException(env)) { | 338 if (!base::android::ClearException(env)) { |
339 SetPrimitiveResult(result_wrapper); | 339 SetPrimitiveResult(result_wrapper); |
340 } else { | 340 } else { |
341 SetInvocationError(kGinJavaBridgeJavaExceptionRaised); | 341 SetInvocationError(kGinJavaBridgeJavaExceptionRaised); |
342 } | 342 } |
343 } | 343 } |
344 | 344 |
345 } // namespace content | 345 } // namespace content |
OLD | NEW |