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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "gin/array_buffer.h" | 8 #include "gin/array_buffer.h" |
9 #include "gin/per_isolate_data.h" | 9 #include "gin/per_isolate_data.h" |
10 | 10 |
11 namespace gin { | 11 namespace gin { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 gin::WrapperInfo g_array_buffer_wrapper_info = {gin::kEmbedderNativeGin}; | 15 gin::WrapperInfo g_array_buffer_wrapper_info = {gin::kEmbedderNativeGin}; |
16 | 16 |
17 } // namespace | 17 } // namespace |
18 | 18 |
19 COMPILE_ASSERT(V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT == 2, | 19 static_assert(V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT == 2, |
20 array_buffers_must_have_two_internal_fields); | 20 "array buffers must have two internal fields"); |
21 | 21 |
22 // ArrayBufferAllocator ------------------------------------------------------- | 22 // ArrayBufferAllocator ------------------------------------------------------- |
23 | 23 |
24 void* ArrayBufferAllocator::Allocate(size_t length) { | 24 void* ArrayBufferAllocator::Allocate(size_t length) { |
25 return calloc(1, length); | 25 return calloc(1, length); |
26 } | 26 } |
27 | 27 |
28 void* ArrayBufferAllocator::AllocateUninitialized(size_t length) { | 28 void* ArrayBufferAllocator::AllocateUninitialized(size_t length) { |
29 return malloc(length); | 29 return malloc(length); |
30 } | 30 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 bool Converter<ArrayBufferView>::FromV8(v8::Isolate* isolate, | 188 bool Converter<ArrayBufferView>::FromV8(v8::Isolate* isolate, |
189 v8::Handle<v8::Value> val, | 189 v8::Handle<v8::Value> val, |
190 ArrayBufferView* out) { | 190 ArrayBufferView* out) { |
191 if (!val->IsArrayBufferView()) | 191 if (!val->IsArrayBufferView()) |
192 return false; | 192 return false; |
193 *out = ArrayBufferView(isolate, v8::Handle<v8::ArrayBufferView>::Cast(val)); | 193 *out = ArrayBufferView(isolate, v8::Handle<v8::ArrayBufferView>::Cast(val)); |
194 return true; | 194 return true; |
195 } | 195 } |
196 | 196 |
197 } // namespace gin | 197 } // namespace gin |
OLD | NEW |