OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef GIN_ARRAY_BUFFER_H_ |
| 6 #define GIN_ARRAY_BUFFER_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" // For scoped_refptr only! |
| 11 #include "v8/include/v8.h" |
| 12 |
| 13 namespace gin { |
| 14 |
| 15 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
| 16 public: |
| 17 virtual void* Allocate(size_t length) OVERRIDE; |
| 18 virtual void* AllocateUninitialized(size_t length) OVERRIDE; |
| 19 virtual void Free(void* data, size_t length) OVERRIDE; |
| 20 |
| 21 static ArrayBufferAllocator* SharedInstance(); |
| 22 }; |
| 23 |
| 24 class BufferView { |
| 25 public: |
| 26 BufferView(v8::Isolate* isolate, v8::Handle<v8::ArrayBufferView> view); |
| 27 BufferView(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> buffer); |
| 28 ~BufferView(); |
| 29 |
| 30 void* bytes() const { return bytes_; } |
| 31 size_t num_bytes() const { return num_bytes_; } |
| 32 |
| 33 private: |
| 34 class Private; |
| 35 |
| 36 void Initialize(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> buffer); |
| 37 |
| 38 scoped_refptr<Private> private_; |
| 39 void* bytes_; |
| 40 size_t num_bytes_; |
| 41 }; |
| 42 |
| 43 } // namespace gin |
| 44 |
| 45 #endif // GIN_ARRAY_BUFFER_H_ |
OLD | NEW |