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/renderer/java/gin_java_bridge_value_converter.h" | 5 #include "content/renderer/java/gin_java_bridge_value_converter.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 void serializeTo(char* data, | 80 void serializeTo(char* data, |
81 size_t data_length, | 81 size_t data_length, |
82 base::ListValue* out) override { | 82 base::ListValue* out) override { |
83 DCHECK_EQ(data_length, typed_array_->Length() * sizeof(ElementType)); | 83 DCHECK_EQ(data_length, typed_array_->Length() * sizeof(ElementType)); |
84 for (ElementType *element = reinterpret_cast<ElementType*>(data), | 84 for (ElementType *element = reinterpret_cast<ElementType*>(data), |
85 *end = element + typed_array_->Length(); | 85 *end = element + typed_array_->Length(); |
86 element != end; | 86 element != end; |
87 ++element) { | 87 ++element) { |
88 const ListType list_value = *element; | 88 out->Append(base::MakeUnique<base::Value>(ListType(*element))); |
89 out->Append(new base::Value(list_value)); | |
90 } | 89 } |
91 } | 90 } |
92 | 91 |
93 private: | 92 private: |
94 explicit TypedArraySerializerImpl(v8::Local<v8::TypedArray> typed_array) | 93 explicit TypedArraySerializerImpl(v8::Local<v8::TypedArray> typed_array) |
95 : typed_array_(typed_array) {} | 94 : typed_array_(typed_array) {} |
96 | 95 |
97 v8::Local<v8::TypedArray> typed_array_; | 96 v8::Local<v8::TypedArray> typed_array_; |
98 | 97 |
99 DISALLOW_COPY_AND_ASSIGN(TypedArraySerializerImpl); | 98 DISALLOW_COPY_AND_ASSIGN(TypedArraySerializerImpl); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 return true; | 159 return true; |
161 } | 160 } |
162 | 161 |
163 bool GinJavaBridgeValueConverter::FromV8Undefined( | 162 bool GinJavaBridgeValueConverter::FromV8Undefined( |
164 std::unique_ptr<base::Value>* out) const { | 163 std::unique_ptr<base::Value>* out) const { |
165 *out = GinJavaBridgeValue::CreateUndefinedValue(); | 164 *out = GinJavaBridgeValue::CreateUndefinedValue(); |
166 return true; | 165 return true; |
167 } | 166 } |
168 | 167 |
169 } // namespace content | 168 } // namespace content |
OLD | NEW |