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

Unified Diff: Source/bindings/tests/results/core/V8ArrayBuffer.cpp

Issue 606653006: bindings: Adds DOMArrayBuffer, etc. as thin wrappers for ArrayBuffer, etc. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. Created 6 years, 2 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
Index: Source/bindings/tests/results/core/V8ArrayBuffer.cpp
diff --git a/Source/bindings/tests/results/core/V8ArrayBuffer.cpp b/Source/bindings/tests/results/core/V8ArrayBuffer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3e857763462660d78b73c3f685b795e666d16e26
--- /dev/null
+++ b/Source/bindings/tests/results/core/V8ArrayBuffer.cpp
@@ -0,0 +1,81 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
+
+#include "config.h"
+#include "V8ArrayBuffer.h"
+
+#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/V8ArrayBuffer.h"
+#include "bindings/core/v8/V8DOMConfiguration.h"
+#include "bindings/core/v8/V8HiddenValue.h"
+#include "bindings/core/v8/V8ObjectConstructor.h"
+#include "core/dom/ContextFeatures.h"
+#include "core/dom/DOMArrayBufferDeallocationObserver.h"
+#include "core/dom/Document.h"
+#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/TraceEvent.h"
+#include "wtf/GetPtr.h"
+#include "wtf/RefPtr.h"
+
+namespace blink {
+
+const WrapperTypeInfo V8ArrayBuffer::wrapperTypeInfo = { gin::kEmbedderBlink, 0, V8ArrayBuffer::refObject, V8ArrayBuffer::derefObject, V8ArrayBuffer::trace, 0, 0, 0, V8ArrayBuffer::installConditionallyEnabledMethods, V8ArrayBuffer::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::RefCountedObject };
+
+// This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestArrayBuffer.h.
+// For details, see the comment of DEFINE_WRAPPERTYPEINFO in
+// bindings/core/v8/ScriptWrappable.h.
+const WrapperTypeInfo& TestArrayBuffer::s_wrapperTypeInfo = V8ArrayBuffer::wrapperTypeInfo;
+
+bool V8ArrayBuffer::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
+{
+ return v8Value->IsArrayBuffer();
+}
+
+TestArrayBuffer* V8ArrayBuffer::toImpl(v8::Handle<v8::Object> object)
+{
+ ASSERT(object->IsArrayBuffer());
+ v8::Local<v8::ArrayBuffer> v8buffer = object.As<v8::ArrayBuffer>();
+ if (v8buffer->IsExternal()) {
+ const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object);
+ RELEASE_ASSERT(wrapperTypeInfo);
+ RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink);
+ return blink::toScriptWrappableBase(object)->toImpl<TestArrayBuffer>();
+ }
+
+ v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize();
+ // This special way to create ArrayBuffer via ArrayBufferContents makes the
+ // underlying ArrayBufferContents not call ArrayBufferDeallocationObserver::
+ // blinkAllocatedMemory. The array buffer created by V8 already called it,
+ // so we shouldn't call it.
+ WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength(), DOMArrayBufferDeallocationObserver::instance());
+ RefPtr<TestArrayBuffer> buffer = TestArrayBuffer::create(contents);
+ buffer->associateWithWrapper(buffer->wrapperTypeInfo(), object, v8::Isolate::GetCurrent());
+
+ return blink::toScriptWrappableBase(object)->toImpl<TestArrayBuffer>();
+}
+
+TestArrayBuffer* V8ArrayBuffer::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
+{
+ return hasInstance(value, isolate) ? toImpl(v8::Handle<v8::Object>::Cast(value)) : 0;
+}
+
+void V8ArrayBuffer::refObject(ScriptWrappableBase* internalPointer)
+{
+ internalPointer->toImpl<TestArrayBuffer>()->ref();
+}
+
+void V8ArrayBuffer::derefObject(ScriptWrappableBase* internalPointer)
+{
+ internalPointer->toImpl<TestArrayBuffer>()->deref();
+}
+
+template<>
+v8::Handle<v8::Value> toV8NoInline(TestArrayBuffer* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+{
+ return toV8(impl, creationContext, isolate);
+}
+
+} // namespace blink
« no previous file with comments | « Source/bindings/tests/results/core/V8ArrayBuffer.h ('k') | Source/bindings/tests/results/core/V8ArrayBufferView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698