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

Unified Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 85263006: Make IDL Callbacks non-refcounted by default (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing Created 7 years, 1 month 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
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestCallback.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/code_generator_v8.pm
diff --git a/Source/bindings/scripts/code_generator_v8.pm b/Source/bindings/scripts/code_generator_v8.pm
index 151e730274d243b735f395db05aca55246a943e6..2e0e42d492e2f753e5ed7c9421b4404ff88dc604 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -2557,10 +2557,11 @@ END
AddToImplIncludes("bindings/v8/ExceptionMessages.h");
AddToImplIncludes("bindings/v8/ExceptionState.h");
if (IsCallbackInterface($parameter->type)) {
+ my $ptrType = IsLegacyRefCountedCallback($parameter->type) ? "Ref" : "Own";
my $v8ClassName = "V8" . $parameter->type;
AddToImplIncludes("$v8ClassName.h");
if ($parameter->isOptional) {
- $parameterCheckString .= " RefPtr<" . $parameter->type . "> $parameterName;\n";
+ $parameterCheckString .= " ${ptrType}Ptr<" . $parameter->type . "> $parameterName;\n";
$parameterCheckString .= " if (info.Length() > $paramIndex && !info[$paramIndex]->IsNull() && !info[$paramIndex]->IsUndefined()) {\n";
$parameterCheckString .= " if (!info[$paramIndex]->IsFunction()) {\n";
$parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n";
@@ -2579,8 +2580,8 @@ END
$parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n";
$parameterCheckString .= " return;\n";
$parameterCheckString .= " }\n";
- $parameterCheckString .= " RefPtr<" . $parameter->type . "> $parameterName = ";
- $parameterCheckString .= "info[$paramIndex]->IsNull() ? 0 : " if $parameter->isNullable;
+ $parameterCheckString .= " ${ptrType}Ptr<" . $parameter->type . "> $parameterName = ";
+ $parameterCheckString .= "info[$paramIndex]->IsNull() ? nullptr : " if $parameter->isNullable;
$parameterCheckString .= "${v8ClassName}::create(info[$paramIndex], getExecutionContext());\n";
}
} elsif ($parameter->extendedAttributes->{"Clamp"}) {
@@ -4782,6 +4783,9 @@ sub GenerateCallbackHeader
my $interfaceName = $interface->name;
my $implClassName = GetImplName($interface);
my $v8ClassName = GetV8ClassName($interface);
+ my $refCounted = IsLegacyRefCountedCallback($interfaceName);
+ my $ptrType = $refCounted ? "Ref" : "Own";
+ my $adoptType = $refCounted ? "Ref" : "Ptr";
my @includes = ();
push(@includes, "bindings/v8/ActiveDOMCallback.h");
@@ -4796,11 +4800,11 @@ sub GenerateCallbackHeader
$header{class}->addFooter("};\n");
$header{classPublic}->add(<<END);
- static PassRefPtr<${v8ClassName}> create(v8::Handle<v8::Value> jsValue, ExecutionContext* context)
+ static Pass${ptrType}Ptr<${v8ClassName}> create(v8::Handle<v8::Value> jsValue, ExecutionContext* context)
{
ASSERT(jsValue->IsObject());
ASSERT(context);
- return adoptRef(new ${v8ClassName}(v8::Handle<v8::Object>::Cast(jsValue), context));
+ return adopt${adoptType}(new ${v8ClassName}(v8::Handle<v8::Object>::Cast(jsValue), context));
}
virtual ~${v8ClassName}();
@@ -6356,4 +6360,30 @@ sub NeedsSpecialWrap
return 0;
}
+# FIXME: This list should go away entirely, see http://crbug.com/323681
+sub IsLegacyRefCountedCallback
+{
+ my $name = shift;
+ # WebSQL
+ return 1 if $name eq "DatabaseCallback";
+ return 1 if $name eq "SQLTransactionCallback";
+ return 1 if $name eq "SQLTransactionErrorCallback";
+ return 1 if $name eq "SQLTransactionSyncCallback";
+ return 1 if $name eq "SQLStatementCallback";
+ return 1 if $name eq "SQLStatementErrorCallback";
+ # Filesystem
+ return 1 if $name eq "EntryCallback";
+ return 1 if $name eq "EntriesCallback";
+ return 1 if $name eq "ErrorCallback";
+ return 1 if $name eq "FileCallback";
+ return 1 if $name eq "FileSystemCallback";
+ return 1 if $name eq "FileWriterCallback";
+ return 1 if $name eq "MetadataCallback";
+ # requestAnimationFrame
+ return 1 if $name eq "RequestAnimationFrameCallback";
+ # Used everywhere
+ return 1 if $name eq "VoidCallback";
+ return 0;
+}
+
1;
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestCallback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698