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 #ifndef GIN_ARRAY_BUFFER_H_ | 5 #ifndef GIN_ARRAY_BUFFER_H_ |
6 #define GIN_ARRAY_BUFFER_H_ | 6 #define GIN_ARRAY_BUFFER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "gin/converter.h" | 11 #include "gin/converter.h" |
12 #include "gin/gin_export.h" | 12 #include "gin/gin_export.h" |
13 #include "v8/include/v8.h" | 13 #include "v8/include/v8.h" |
14 | 14 |
15 namespace gin { | 15 namespace gin { |
16 | 16 |
17 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 17 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
18 public: | 18 public: |
19 virtual void* Allocate(size_t length) OVERRIDE; | 19 virtual void* Allocate(size_t length) OVERRIDE; |
20 virtual void* AllocateUninitialized(size_t length) OVERRIDE; | 20 virtual void* AllocateUninitialized(size_t length) OVERRIDE; |
21 virtual void Free(void* data, size_t length) OVERRIDE; | 21 virtual void Free(void* data, size_t length) OVERRIDE; |
22 | 22 |
23 static ArrayBufferAllocator* SharedInstance(); | 23 GIN_EXPORT static ArrayBufferAllocator* SharedInstance(); |
24 }; | 24 }; |
25 | 25 |
26 class GIN_EXPORT ArrayBuffer { | 26 class GIN_EXPORT ArrayBuffer { |
27 public: | 27 public: |
28 ArrayBuffer(); | 28 ArrayBuffer(); |
29 ArrayBuffer(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> buffer); | 29 ArrayBuffer(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> buffer); |
30 ~ArrayBuffer(); | 30 ~ArrayBuffer(); |
31 ArrayBuffer& operator=(const ArrayBuffer& other); | 31 ArrayBuffer& operator=(const ArrayBuffer& other); |
32 | 32 |
33 void* bytes() const { return bytes_; } | 33 void* bytes() const { return bytes_; } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 template<> | 72 template<> |
73 struct GIN_EXPORT Converter<ArrayBufferView> { | 73 struct GIN_EXPORT Converter<ArrayBufferView> { |
74 static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val, | 74 static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val, |
75 ArrayBufferView* out); | 75 ArrayBufferView* out); |
76 }; | 76 }; |
77 | 77 |
78 } // namespace gin | 78 } // namespace gin |
79 | 79 |
80 #endif // GIN_ARRAY_BUFFER_H_ | 80 #endif // GIN_ARRAY_BUFFER_H_ |
OLD | NEW |