OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! |
| 6 |
| 7 #include "config.h" |
| 8 #include "V8ArrayBuffer.h" |
| 9 |
| 10 #include "bindings/core/v8/ExceptionState.h" |
| 11 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 12 #include "bindings/core/v8/V8DOMConfiguration.h" |
| 13 #include "bindings/core/v8/V8HiddenValue.h" |
| 14 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 15 #include "core/dom/ContextFeatures.h" |
| 16 #include "core/dom/DOMArrayBufferDeallocationObserver.h" |
| 17 #include "core/dom/Document.h" |
| 18 #include "platform/RuntimeEnabledFeatures.h" |
| 19 #include "platform/TraceEvent.h" |
| 20 #include "wtf/GetPtr.h" |
| 21 #include "wtf/RefPtr.h" |
| 22 |
| 23 namespace blink { |
| 24 |
| 25 const WrapperTypeInfo V8ArrayBuffer::wrapperTypeInfo = { gin::kEmbedderBlink, 0,
V8ArrayBuffer::refObject, V8ArrayBuffer::derefObject, V8ArrayBuffer::trace, 0,
0, 0, V8ArrayBuffer::installConditionallyEnabledMethods, V8ArrayBuffer::installC
onditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, W
rapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::Re
fCountedObject }; |
| 26 |
| 27 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestArrayBuf
fer.h. |
| 28 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in |
| 29 // bindings/core/v8/ScriptWrappable.h. |
| 30 const WrapperTypeInfo& TestArrayBuffer::s_wrapperTypeInfo = V8ArrayBuffer::wrapp
erTypeInfo; |
| 31 |
| 32 bool V8ArrayBuffer::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isol
ate) |
| 33 { |
| 34 return v8Value->IsArrayBuffer(); |
| 35 } |
| 36 |
| 37 TestArrayBuffer* V8ArrayBuffer::toImpl(v8::Handle<v8::Object> object) |
| 38 { |
| 39 ASSERT(object->IsArrayBuffer()); |
| 40 v8::Local<v8::ArrayBuffer> v8buffer = object.As<v8::ArrayBuffer>(); |
| 41 if (v8buffer->IsExternal()) { |
| 42 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); |
| 43 RELEASE_ASSERT(wrapperTypeInfo); |
| 44 RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink); |
| 45 return blink::toScriptWrappableBase(object)->toImpl<TestArrayBuffer>(); |
| 46 } |
| 47 |
| 48 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize(); |
| 49 // This special way to create ArrayBuffer via ArrayBufferContents makes the |
| 50 // underlying ArrayBufferContents not call ArrayBufferDeallocationObserver:: |
| 51 // blinkAllocatedMemory. The array buffer created by V8 already called it, |
| 52 // so we shouldn't call it. |
| 53 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength()
, DOMArrayBufferDeallocationObserver::instance()); |
| 54 RefPtr<TestArrayBuffer> buffer = TestArrayBuffer::create(contents); |
| 55 buffer->associateWithWrapper(buffer->wrapperTypeInfo(), object, v8::Isolate:
:GetCurrent()); |
| 56 |
| 57 return blink::toScriptWrappableBase(object)->toImpl<TestArrayBuffer>(); |
| 58 } |
| 59 |
| 60 TestArrayBuffer* V8ArrayBuffer::toImplWithTypeCheck(v8::Isolate* isolate, v8::Ha
ndle<v8::Value> value) |
| 61 { |
| 62 return hasInstance(value, isolate) ? toImpl(v8::Handle<v8::Object>::Cast(val
ue)) : 0; |
| 63 } |
| 64 |
| 65 void V8ArrayBuffer::refObject(ScriptWrappableBase* internalPointer) |
| 66 { |
| 67 internalPointer->toImpl<TestArrayBuffer>()->ref(); |
| 68 } |
| 69 |
| 70 void V8ArrayBuffer::derefObject(ScriptWrappableBase* internalPointer) |
| 71 { |
| 72 internalPointer->toImpl<TestArrayBuffer>()->deref(); |
| 73 } |
| 74 |
| 75 template<> |
| 76 v8::Handle<v8::Value> toV8NoInline(TestArrayBuffer* impl, v8::Handle<v8::Object>
creationContext, v8::Isolate* isolate) |
| 77 { |
| 78 return toV8(impl, creationContext, isolate); |
| 79 } |
| 80 |
| 81 } // namespace blink |
OLD | NEW |