| 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 "base/float_util.h" | 7 #include "base/float_util.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "content/common/android/gin_java_bridge_value.h" | 9 #include "content/common/android/gin_java_bridge_value.h" |
| 10 #include "content/renderer/java/gin_java_bridge_object.h" | 10 #include "content/renderer/java/gin_java_bridge_object.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 base::ListValue* out) = 0; | 61 base::ListValue* out) = 0; |
| 62 protected: | 62 protected: |
| 63 TypedArraySerializer() {} | 63 TypedArraySerializer() {} |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 template <typename ElementType, typename ListType> | 66 template <typename ElementType, typename ListType> |
| 67 class TypedArraySerializerImpl : public TypedArraySerializer { | 67 class TypedArraySerializerImpl : public TypedArraySerializer { |
| 68 public: | 68 public: |
| 69 static scoped_ptr<TypedArraySerializer> Create( | 69 static scoped_ptr<TypedArraySerializer> Create( |
| 70 v8::Handle<v8::TypedArray> typed_array) { | 70 v8::Handle<v8::TypedArray> typed_array) { |
| 71 scoped_ptr<TypedArraySerializerImpl<ElementType, ListType> > result( | 71 return make_scoped_ptr( |
| 72 new TypedArraySerializerImpl<ElementType, ListType>(typed_array)); | 72 new TypedArraySerializerImpl<ElementType, ListType>(typed_array)); |
| 73 return result.template PassAs<TypedArraySerializer>(); | |
| 74 } | 73 } |
| 75 | 74 |
| 76 virtual void serializeTo(char* data, | 75 virtual void serializeTo(char* data, |
| 77 size_t data_length, | 76 size_t data_length, |
| 78 base::ListValue* out) override { | 77 base::ListValue* out) override { |
| 79 DCHECK_EQ(data_length, typed_array_->Length() * sizeof(ElementType)); | 78 DCHECK_EQ(data_length, typed_array_->Length() * sizeof(ElementType)); |
| 80 for (ElementType *element = reinterpret_cast<ElementType*>(data), | 79 for (ElementType *element = reinterpret_cast<ElementType*>(data), |
| 81 *end = element + typed_array_->Length(); | 80 *end = element + typed_array_->Length(); |
| 82 element != end; | 81 element != end; |
| 83 ++element) { | 82 ++element) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 *out = GinJavaBridgeValue::CreateNonFiniteValue(double_value).release(); | 153 *out = GinJavaBridgeValue::CreateNonFiniteValue(double_value).release(); |
| 155 return true; | 154 return true; |
| 156 } | 155 } |
| 157 | 156 |
| 158 bool GinJavaBridgeValueConverter::FromV8Undefined(base::Value** out) const { | 157 bool GinJavaBridgeValueConverter::FromV8Undefined(base::Value** out) const { |
| 159 *out = GinJavaBridgeValue::CreateUndefinedValue().release(); | 158 *out = GinJavaBridgeValue::CreateUndefinedValue().release(); |
| 160 return true; | 159 return true; |
| 161 } | 160 } |
| 162 | 161 |
| 163 } // namespace content | 162 } // namespace content |
| OLD | NEW |