diff options
Diffstat (limited to 'Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp')
-rw-r--r-- | Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp b/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp index adbeacdf8..672c2ab9d 100644 --- a/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp @@ -29,15 +29,25 @@ */ #include "config.h" +#include "V8ArrayBufferCustom.h" + #include <wtf/ArrayBuffer.h> +#include <wtf/StdLibExtras.h> #include "ExceptionCode.h" -#include "V8Binding.h" #include "V8ArrayBuffer.h" +#include "V8Binding.h" #include "V8Proxy.h" namespace WebCore { +V8ArrayBufferDeallocationObserver* V8ArrayBufferDeallocationObserver::instance() +{ + DEFINE_STATIC_LOCAL(V8ArrayBufferDeallocationObserver, deallocationObserver, ()); + return &deallocationObserver; +} + + v8::Handle<v8::Value> V8ArrayBuffer::constructorCallback(const v8::Arguments& args) { INC_STATS("DOM.ArrayBuffer.Constructor"); @@ -71,6 +81,8 @@ v8::Handle<v8::Value> V8ArrayBuffer::constructorCallback(const v8::Arguments& ar buffer = ArrayBuffer::create(static_cast<unsigned>(length), 1); if (!buffer.get()) return throwError(RangeError, "ArrayBuffer size is not a small enough positive integer.", args.GetIsolate()); + buffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance()); + v8::V8::AdjustAmountOfExternalAllocatedMemory(buffer->byteLength()); // Transform the holder into a wrapper object for the array. v8::Handle<v8::Object> wrapper = args.Holder(); V8DOMWrapper::setDOMWrapper(wrapper, &info, buffer.get()); |