| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "gin/array_buffer.h" | 9 #include "gin/array_buffer.h" |
| 10 #include "gin/per_isolate_data.h" | 10 #include "gin/per_isolate_data.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 v8::Global<v8::ArrayBuffer> array_buffer_; | 80 v8::Global<v8::ArrayBuffer> array_buffer_; |
| 81 scoped_refptr<Private> self_reference_; | 81 scoped_refptr<Private> self_reference_; |
| 82 v8::Isolate* isolate_; | 82 v8::Isolate* isolate_; |
| 83 void* buffer_; | 83 void* buffer_; |
| 84 size_t length_; | 84 size_t length_; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 scoped_refptr<ArrayBuffer::Private> ArrayBuffer::Private::From( | 87 scoped_refptr<ArrayBuffer::Private> ArrayBuffer::Private::From( |
| 88 v8::Isolate* isolate, v8::Local<v8::ArrayBuffer> array) { | 88 v8::Isolate* isolate, v8::Local<v8::ArrayBuffer> array) { |
| 89 if (array->IsExternal()) { | 89 if (array->IsExternal()) { |
| 90 // Cannot mix blink and gin ArrayBuffers. |
| 90 CHECK_EQ(WrapperInfo::From(v8::Local<v8::Object>::Cast(array)), | 91 CHECK_EQ(WrapperInfo::From(v8::Local<v8::Object>::Cast(array)), |
| 91 &g_array_buffer_wrapper_info) | 92 &g_array_buffer_wrapper_info); |
| 92 << "Cannot mix blink and gin ArrayBuffers"; | |
| 93 return make_scoped_refptr(static_cast<Private*>( | 93 return make_scoped_refptr(static_cast<Private*>( |
| 94 array->GetAlignedPointerFromInternalField(kEncodedValueIndex))); | 94 array->GetAlignedPointerFromInternalField(kEncodedValueIndex))); |
| 95 } | 95 } |
| 96 return make_scoped_refptr(new Private(isolate, array)); | 96 return make_scoped_refptr(new Private(isolate, array)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 ArrayBuffer::Private::Private(v8::Isolate* isolate, | 99 ArrayBuffer::Private::Private(v8::Isolate* isolate, |
| 100 v8::Local<v8::ArrayBuffer> array) | 100 v8::Local<v8::ArrayBuffer> array) |
| 101 : array_buffer_(isolate, array), isolate_(isolate) { | 101 : array_buffer_(isolate, array), isolate_(isolate) { |
| 102 // Take ownership of the array buffer. | 102 // Take ownership of the array buffer. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 bool Converter<ArrayBufferView>::FromV8(v8::Isolate* isolate, | 196 bool Converter<ArrayBufferView>::FromV8(v8::Isolate* isolate, |
| 197 v8::Local<v8::Value> val, | 197 v8::Local<v8::Value> val, |
| 198 ArrayBufferView* out) { | 198 ArrayBufferView* out) { |
| 199 if (!val->IsArrayBufferView()) | 199 if (!val->IsArrayBufferView()) |
| 200 return false; | 200 return false; |
| 201 *out = ArrayBufferView(isolate, v8::Local<v8::ArrayBufferView>::Cast(val)); | 201 *out = ArrayBufferView(isolate, v8::Local<v8::ArrayBufferView>::Cast(val)); |
| 202 return true; | 202 return true; |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace gin | 205 } // namespace gin |
| OLD | NEW |