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

Unified Diff: Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.cpp

Issue 290333008: Oilpan: add [WillBeGarbageCollected] for Element. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased + remove WebNode FIXME Created 6 years, 7 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/V8TestInterfaceWillBeGarbageCollected.cpp
diff --git a/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.cpp b/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.cpp
index 59322aefa0b2f13d40ead64458694f37bb48b6aa..ffe3ae8a6c98d76fd40b4f3bce56ff87906e1dcb 100644
--- a/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.cpp
+++ b/Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.cpp
@@ -115,6 +115,58 @@ static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceWillBeGarbag
{"func", TestInterfaceWillBeGarbageCollectedV8Internal::funcMethodCallback, 0, 1},
};
+const WrapperTypeInfo V8TestInterfaceWillBeGarbageCollectedConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceWillBeGarbageCollectedConstructor::domTemplate, V8TestInterfaceWillBeGarbageCollected::derefObject, 0, V8TestInterfaceWillBeGarbageCollected::toEventTarget, 0, V8TestInterfaceWillBeGarbageCollected::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, WillBeGarbageCollectedObject };
+
+static void V8TestInterfaceWillBeGarbageCollectedConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ v8::Isolate* isolate = info.GetIsolate();
+ if (!info.IsConstructCall()) {
+ throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestInterface"), isolate);
+ return;
+ }
+
+ if (ConstructorMode::current(isolate) == ConstructorMode::WrapExistingObject) {
+ v8SetReturnValue(info, info.Holder());
+ return;
+ }
+
+ Document* document = currentDOMWindow(isolate)->document();
+ ASSERT(document);
+
+ // Make sure the document is added to the DOM Node map. Otherwise, the TestInterfaceWillBeGarbageCollected instance
+ // may end up being the only node in the map and get garbage-collected prematurely.
+ toV8(document, info.Holder(), isolate);
+
+ if (UNLIKELY(info.Length() < 1)) {
+ throwMinimumArityTypeErrorForConstructor("TestInterfaceWillBeGarbageCollected", 1, info.Length(), info.GetIsolate());
+ return;
+ }
+ TOSTRING_VOID(V8StringResource<>, str, info[0]);
+ RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> impl = TestInterfaceWillBeGarbageCollected::createForJSConstructor(*document, str);
+
+ v8::Handle<v8::Object> wrapper = info.Holder();
+ V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceWillBeGarbageCollected>(impl.release(), &V8TestInterfaceWillBeGarbageCollectedConstructor::wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
+ v8SetReturnValue(info, wrapper);
+}
+
+v8::Handle<v8::FunctionTemplate> V8TestInterfaceWillBeGarbageCollectedConstructor::domTemplate(v8::Isolate* isolate)
+{
+ static int domTemplateKey; // This address is used for a key to look up the dom template.
+ V8PerIsolateData* data = V8PerIsolateData::from(isolate);
+ v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTemplateKey);
+ if (!result.IsEmpty())
+ return result;
+
+ TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
+ result = v8::FunctionTemplate::New(isolate, V8TestInterfaceWillBeGarbageCollectedConstructorCallback);
+ v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
+ instanceTemplate->SetInternalFieldCount(V8TestInterfaceWillBeGarbageCollected::internalFieldCount);
+ result->SetClassName(v8AtomicString(isolate, "TestInterfaceWillBeGarbageCollected"));
+ result->Inherit(V8TestInterfaceWillBeGarbageCollected::domTemplate(isolate));
+ data->setDOMTemplate(&domTemplateKey, result);
+ return result;
+}
+
void V8TestInterfaceWillBeGarbageCollected::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
« no previous file with comments | « Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.h ('k') | Source/bindings/v8/CustomElementWrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698