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

Unified Diff: gin/array_buffer.h

Issue 59153005: Begin implementing V8 bindings for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix skipped comment 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
« gin/arguments.cc ('K') | « gin/arguments.cc ('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
index b48a687eeb3d6702a637f46733db76fc18df5944..a645431a60f9c4e3baca44126d7a8ebf5a53a18d 100644
--- a/gin/array_buffer.h
+++ b/gin/array_buffer.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h" // For scoped_refptr only!
+#include "gin/converter.h"
#include "v8/include/v8.h"
namespace gin {
@@ -21,25 +22,57 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
static ArrayBufferAllocator* SharedInstance();
};
-class BufferView {
+class ArrayBuffer {
public:
- BufferView(v8::Isolate* isolate, v8::Handle<v8::ArrayBufferView> view);
- BufferView(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> buffer);
- ~BufferView();
+ explicit ArrayBuffer(v8::Isolate* isolate);
+ ArrayBuffer(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> buffer);
+ ~ArrayBuffer();
void* bytes() const { return bytes_; }
size_t num_bytes() const { return num_bytes_; }
+ v8::Isolate* isolate() const { return isolate_; }
+
private:
class Private;
- void Initialize(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> buffer);
-
+ v8::Isolate* isolate_;
scoped_refptr<Private> private_;
void* bytes_;
size_t num_bytes_;
};
+template<>
+struct Converter<ArrayBuffer> {
+ static bool FromV8(v8::Handle<v8::Value> val,
+ ArrayBuffer* out);
+};
+
+class ArrayBufferView {
+ public:
+ explicit ArrayBufferView(v8::Isolate* isolate);
+ ArrayBufferView(v8::Isolate* isolate, v8::Handle<v8::ArrayBufferView> view);
+ ~ArrayBufferView();
+
+ void* bytes() const {
+ return static_cast<uint8_t*>(array_buffer_.bytes()) + offset_;
+ }
+ size_t num_bytes() const { return num_bytes_; }
+
+ v8::Isolate* isolate() const { return array_buffer_.isolate(); }
+
+ private:
+ ArrayBuffer array_buffer_;
+ size_t offset_;
+ size_t num_bytes_;
+};
+
+template<>
+struct Converter<ArrayBufferView> {
+ static bool FromV8(v8::Handle<v8::Value> val,
+ ArrayBufferView* out);
+};
+
} // namespace gin
#endif // GIN_ARRAY_BUFFER_H_
« gin/arguments.cc ('K') | « gin/arguments.cc ('k') | gin/array_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698