| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // |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 |
| 46 // accessing |dispatcher|. | 46 // accessing |dispatcher|. |
| 47 BuildObjectRefsFromListValue(dispatcher, *arguments_); | 47 BuildObjectRefsFromListValue(dispatcher, *arguments_); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // As V8ValueConverter has finite recursion depth when serializing | 50 // As V8ValueConverter has finite recursion depth when serializing |
| 51 // JavaScript values, we don't bother about having a recursion threshold here. | 51 // JavaScript values, we don't bother about having a recursion threshold here. |
| 52 void GinJavaMethodInvocationHelper::BuildObjectRefsFromListValue( | 52 void GinJavaMethodInvocationHelper::BuildObjectRefsFromListValue( |
| 53 DispatcherDelegate* dispatcher, | 53 DispatcherDelegate* dispatcher, |
| 54 const base::Value& list_value) { | 54 const base::Value& list_value) { |
| 55 DCHECK(list_value.IsType(base::Value::TYPE_LIST)); | 55 DCHECK(list_value.IsType(base::Value::Type::LIST)); |
| 56 const base::ListValue* list; | 56 const base::ListValue* list; |
| 57 list_value.GetAsList(&list); | 57 list_value.GetAsList(&list); |
| 58 for (const auto& entry : *list) { | 58 for (const auto& entry : *list) { |
| 59 if (AppendObjectRef(dispatcher, *entry)) | 59 if (AppendObjectRef(dispatcher, *entry)) |
| 60 continue; | 60 continue; |
| 61 if (entry->IsType(base::Value::TYPE_LIST)) { | 61 if (entry->IsType(base::Value::Type::LIST)) { |
| 62 BuildObjectRefsFromListValue(dispatcher, *entry); | 62 BuildObjectRefsFromListValue(dispatcher, *entry); |
| 63 } else if (entry->IsType(base::Value::TYPE_DICTIONARY)) { | 63 } else if (entry->IsType(base::Value::Type::DICTIONARY)) { |
| 64 BuildObjectRefsFromDictionaryValue(dispatcher, *entry); | 64 BuildObjectRefsFromDictionaryValue(dispatcher, *entry); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 void GinJavaMethodInvocationHelper::BuildObjectRefsFromDictionaryValue( | 69 void GinJavaMethodInvocationHelper::BuildObjectRefsFromDictionaryValue( |
| 70 DispatcherDelegate* dispatcher, | 70 DispatcherDelegate* dispatcher, |
| 71 const base::Value& dict_value) { | 71 const base::Value& dict_value) { |
| 72 DCHECK(dict_value.IsType(base::Value::TYPE_DICTIONARY)); | 72 DCHECK(dict_value.IsType(base::Value::Type::DICTIONARY)); |
| 73 const base::DictionaryValue* dict; | 73 const base::DictionaryValue* dict; |
| 74 dict_value.GetAsDictionary(&dict); | 74 dict_value.GetAsDictionary(&dict); |
| 75 for (base::DictionaryValue::Iterator iter(*dict); | 75 for (base::DictionaryValue::Iterator iter(*dict); |
| 76 !iter.IsAtEnd(); | 76 !iter.IsAtEnd(); |
| 77 iter.Advance()) { | 77 iter.Advance()) { |
| 78 if (AppendObjectRef(dispatcher, iter.value())) | 78 if (AppendObjectRef(dispatcher, iter.value())) |
| 79 continue; | 79 continue; |
| 80 if (iter.value().IsType(base::Value::TYPE_LIST)) { | 80 if (iter.value().IsType(base::Value::Type::LIST)) { |
| 81 BuildObjectRefsFromListValue(dispatcher, iter.value()); | 81 BuildObjectRefsFromListValue(dispatcher, iter.value()); |
| 82 } else if (iter.value().IsType(base::Value::TYPE_DICTIONARY)) { | 82 } else if (iter.value().IsType(base::Value::Type::DICTIONARY)) { |
| 83 BuildObjectRefsFromDictionaryValue(dispatcher, iter.value()); | 83 BuildObjectRefsFromDictionaryValue(dispatcher, iter.value()); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool GinJavaMethodInvocationHelper::AppendObjectRef( | 88 bool GinJavaMethodInvocationHelper::AppendObjectRef( |
| 89 DispatcherDelegate* dispatcher, | 89 DispatcherDelegate* dispatcher, |
| 90 const base::Value& raw_value) { | 90 const base::Value& raw_value) { |
| 91 if (!GinJavaBridgeValue::ContainsGinJavaBridgeValue(&raw_value)) | 91 if (!GinJavaBridgeValue::ContainsGinJavaBridgeValue(&raw_value)) |
| 92 return false; | 92 return false; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 334 } |
| 335 // This is for all cases except JavaType::TypeObject. | 335 // This is for all cases except JavaType::TypeObject. |
| 336 if (!base::android::ClearException(env)) { | 336 if (!base::android::ClearException(env)) { |
| 337 SetPrimitiveResult(result_wrapper); | 337 SetPrimitiveResult(result_wrapper); |
| 338 } else { | 338 } else { |
| 339 SetInvocationError(kGinJavaBridgeJavaExceptionRaised); | 339 SetInvocationError(kGinJavaBridgeJavaExceptionRaised); |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 | 342 |
| 343 } // namespace content | 343 } // namespace content |
| OLD | NEW |