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

Unified Diff: gin/array_buffer.cc

Issue 172133002: gin: Make it possible to use gin array buffers when running on top of blink (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months 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 | « no previous file | gin/isolate_holder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/array_buffer.cc
diff --git a/gin/array_buffer.cc b/gin/array_buffer.cc
index ee9f2a5867b21a970daec17881ba4411a2631762..42948a7882580ff87982b708659dead5e83d1420 100644
--- a/gin/array_buffer.cc
+++ b/gin/array_buffer.cc
@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "gin/array_buffer.h"
-
#include <stdlib.h>
+#include "gin/array_buffer.h"
+#include "gin/per_isolate_data.h"
+
namespace gin {
COMPILE_ASSERT(V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT == 2,
@@ -72,6 +73,7 @@ class ArrayBuffer::Private : public base::RefCounted<ArrayBuffer::Private> {
v8::Persistent<v8::ArrayBuffer> array_buffer_;
scoped_refptr<Private> self_reference_;
+ v8::Isolate* isolate_;
void* buffer_;
size_t length_;
};
@@ -87,8 +89,9 @@ scoped_refptr<ArrayBuffer::Private> ArrayBuffer::Private::From(
ArrayBuffer::Private::Private(v8::Isolate* isolate,
v8::Handle<v8::ArrayBuffer> array)
- : array_buffer_(isolate, array) {
+ : array_buffer_(isolate, array), isolate_(isolate) {
// Take ownership of the array buffer.
+ CHECK(!array->IsExternal());
v8::ArrayBuffer::Contents contents = array->Externalize();
buffer_ = contents.Data();
length_ = contents.ByteLength();
@@ -100,7 +103,7 @@ ArrayBuffer::Private::Private(v8::Isolate* isolate,
}
ArrayBuffer::Private::~Private() {
- ArrayBufferAllocator::SharedInstance()->Free(buffer_, length_);
+ PerIsolateData::From(isolate_)->allocator()->Free(buffer_, length_);
}
void ArrayBuffer::Private::WeakCallback(
« no previous file with comments | « no previous file | gin/isolate_holder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698