Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: gin/array_buffer.h

Issue 67763002: Add gin, a lightweight bindings system for V8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Aaron's comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gin/README ('k') | gin/array_buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/array_buffer.h
diff --git a/gin/array_buffer.h b/gin/array_buffer.h
new file mode 100644
index 0000000000000000000000000000000000000000..b48a687eeb3d6702a637f46733db76fc18df5944
--- /dev/null
+++ b/gin/array_buffer.h
@@ -0,0 +1,45 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GIN_ARRAY_BUFFER_H_
+#define GIN_ARRAY_BUFFER_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h" // For scoped_refptr only!
+#include "v8/include/v8.h"
+
+namespace gin {
+
+class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
+ public:
+ virtual void* Allocate(size_t length) OVERRIDE;
+ virtual void* AllocateUninitialized(size_t length) OVERRIDE;
+ virtual void Free(void* data, size_t length) OVERRIDE;
+
+ static ArrayBufferAllocator* SharedInstance();
+};
+
+class BufferView {
+ public:
+ BufferView(v8::Isolate* isolate, v8::Handle<v8::ArrayBufferView> view);
+ BufferView(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> buffer);
+ ~BufferView();
+
+ void* bytes() const { return bytes_; }
+ size_t num_bytes() const { return num_bytes_; }
+
+ private:
+ class Private;
+
+ void Initialize(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> buffer);
+
+ scoped_refptr<Private> private_;
+ void* bytes_;
+ size_t num_bytes_;
+};
+
+} // namespace gin
+
+#endif // GIN_ARRAY_BUFFER_H_
« no previous file with comments | « gin/README ('k') | gin/array_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698