diff options
Diffstat (limited to 'chromium/gin/array_buffer.cc')
-rw-r--r-- | chromium/gin/array_buffer.cc | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/chromium/gin/array_buffer.cc b/chromium/gin/array_buffer.cc index f84934bfd71..a02797e94f6 100644 --- a/chromium/gin/array_buffer.cc +++ b/chromium/gin/array_buffer.cc @@ -83,6 +83,7 @@ class ArrayBuffer::Private : public base::RefCounted<ArrayBuffer::Private> { private: friend class base::RefCounted<Private>; + using DataDeleter = void (*)(void* data, size_t length, void* info); Private(v8::Isolate* isolate, v8::Local<v8::ArrayBuffer> array); ~Private(); @@ -95,9 +96,8 @@ class ArrayBuffer::Private : public base::RefCounted<ArrayBuffer::Private> { v8::Isolate* isolate_; void* buffer_; size_t length_; - void* allocation_base_; - size_t allocation_length_; - v8::ArrayBuffer::Allocator::AllocationMode allocation_mode_; + DataDeleter deleter_; + void* deleter_data_; }; scoped_refptr<ArrayBuffer::Private> ArrayBuffer::Private::From( @@ -118,18 +118,10 @@ ArrayBuffer::Private::Private(v8::Isolate* isolate, // Take ownership of the array buffer. CHECK(!array->IsExternal()); v8::ArrayBuffer::Contents contents = array->Externalize(); - // We shouldn't receive large page-allocated array buffers. - CHECK_NE(v8::ArrayBuffer::Allocator::AllocationMode::kReservation, - contents.AllocationMode()); buffer_ = contents.Data(); length_ = contents.ByteLength(); - allocation_base_ = contents.AllocationBase(); - allocation_length_ = contents.AllocationLength(); - - DCHECK(reinterpret_cast<uintptr_t>(allocation_base_) <= - reinterpret_cast<uintptr_t>(buffer_)); - DCHECK(reinterpret_cast<uintptr_t>(buffer_) + length_ <= - reinterpret_cast<uintptr_t>(allocation_base_) + allocation_length_); + deleter_ = contents.Deleter(); + deleter_data_ = contents.DeleterData(); array->SetAlignedPointerInInternalField(kWrapperInfoIndex, &g_array_buffer_wrapper_info); @@ -141,8 +133,7 @@ ArrayBuffer::Private::Private(v8::Isolate* isolate, } ArrayBuffer::Private::~Private() { - PerIsolateData::From(isolate_)->allocator()->Free(allocation_base_, - allocation_length_); + deleter_(buffer_, length_, deleter_data_); } void ArrayBuffer::Private::FirstWeakCallback( |