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

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

Issue 13799007: Support for selective DOM activity logging, based on IDL attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed bindings tests output, temporarily, to work around diff difficulty. Created 7 years, 8 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
« no previous file with comments | « no previous file | Source/bindings/scripts/IDLAttributes.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/CodeGeneratorV8.pm
diff --git a/Source/bindings/scripts/CodeGeneratorV8.pm b/Source/bindings/scripts/CodeGeneratorV8.pm
index 1bbf3af35708283cbfc60e91d2d742b667354555..d5c0c3ade437766adfff6adad502395ab52c51bc 100644
--- a/Source/bindings/scripts/CodeGeneratorV8.pm
+++ b/Source/bindings/scripts/CodeGeneratorV8.pm
@@ -798,6 +798,26 @@ sub GenerateHeaderCustomCall
}
}
+sub HasActivityLogging
+{
+ my $forMainWorldSuffix = shift;
+ my $attrExt = shift;
+ my $access = shift;
+
+ if (!$attrExt->{"ActivityLog"}) {
+ return 0;
+ }
+ my $logAllAccess = ($attrExt->{"ActivityLog"} =~ /^Access/);
+ my $logGetter = ($attrExt->{"ActivityLog"} =~ /^Getter/);
+ my $logSetter = ($attrExt->{"ActivityLog"} =~ /^Setter/);
+ my $logOnlyIsolatedWorlds = ($attrExt->{"ActivityLog"} =~ /ForIsolatedWorlds$/);
+
+ if ($logOnlyIsolatedWorlds && $forMainWorldSuffix eq "ForMainWorld") {
+ return 0;
+ }
+ return $logAllAccess || ($logGetter && $access eq "Getter") || ($logSetter && $access eq "Setter");
+}
+
sub IsConstructable
{
my $interface = shift;
@@ -943,6 +963,48 @@ sub GenerateFeatureObservation
return "";
}
+sub GenerateActivityLogging
+{
+ my $accessType = shift;
+ my $interface = shift;
+ my $propertyName = shift;
+
+ my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface);
+
+ AddToImplIncludes("V8Binding.h");
+ AddToImplIncludes("V8DOMActivityLogger.h");
+ AddToImplIncludes("wtf/Vector.h");
+
+ my $code = "";
+ if ($accessType eq "Method") {
+ $code .= <<END;
+ V8PerContextData* contextData = V8PerContextData::from(args.GetIsolate()->GetCurrentContext());
+ if (contextData && contextData->activityLogger()) {
+ Vector<v8::Handle<v8::Value> > loggerArgs = toVectorOfArguments(args);
+ contextData->activityLogger()->log("${visibleInterfaceName}.${propertyName}", args.Length(), loggerArgs.data(), "${accessType}");
+ }
+END
+ } elsif ($accessType eq "Setter") {
+ $code .= <<END;
+ V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->GetCurrentContext());
+ if (contextData && contextData->activityLogger()) {
+ v8::Handle<v8::Value> loggerArg[] = { value };
+ contextData->activityLogger()->log("${visibleInterfaceName}.${propertyName}", 1, &loggerArg[0], "${accessType}");
+ }
+END
+ } elsif ($accessType eq "Getter") {
+ $code .= <<END;
+ V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->GetCurrentContext());
+ if (contextData && contextData->activityLogger())
+ contextData->activityLogger()->log("${visibleInterfaceName}.${propertyName}", 0, 0, "${accessType}");
+END
+ } else {
+ die "Unrecognized activity logging access type";
+ }
+
+ return $code;
+}
+
sub GenerateNormalAttrGetterCallback
{
my $attribute = shift;
@@ -961,6 +1023,9 @@ sub GenerateNormalAttrGetterCallback
$code .= "static v8::Handle<v8::Value> ${attrName}AttrGetterCallback${forMainWorldSuffix}(v8::Local<v8::String> name, const v8::AccessorInfo& info)\n";
$code .= "{\n";
$code .= GenerateFeatureObservation($attrExt->{"MeasureAs"});
+ if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Getter")) {
+ $code .= GenerateActivityLogging("Getter", $interface, "${attrName}");
+ }
if (HasCustomGetter($attrExt)) {
$code .= " return ${v8InterfaceName}::${attrName}AttrGetterCustom(name, info);\n";
} else {
@@ -1265,6 +1330,9 @@ sub GenerateReplaceableAttrSetterCallback
$code .= "static void ${interfaceName}ReplaceableAttrSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n";
$code .= "{\n";
$code .= GenerateFeatureObservation($interface->extendedAttributes->{"MeasureAs"});
+ if (HasActivityLogging("", $interface->extendedAttributes, "Setter")) {
+ die "IDL error: ActivityLog attribute cannot exist on a ReplacableAttrSetterCallback";
+ }
$code .= " return ${interfaceName}V8Internal::${interfaceName}ReplaceableAttrSetter(name, value, info);\n";
$code .= "}\n\n";
AddToImplContentInternals($code);
@@ -1335,6 +1403,9 @@ sub GenerateNormalAttrSetterCallback
$code .= "static void ${attrName}AttrSetterCallback${forMainWorldSuffix}(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n";
$code .= "{\n";
$code .= GenerateFeatureObservation($attrExt->{"MeasureAs"});
+ if (HasActivityLogging($forMainWorldSuffix, $attrExt, "Setter")) {
+ $code .= GenerateActivityLogging("Setter", $interface, "${attrName}");
+ }
if (HasCustomSetter($attrExt)) {
$code .= " ${v8InterfaceName}::${attrName}AttrSetterCustom(name, value, info);\n";
} else {
@@ -1684,6 +1755,9 @@ static v8::Handle<v8::Value> ${name}MethodCallback${forMainWorldSuffix}(const v8
{
END
$code .= GenerateFeatureObservation($function->signature->extendedAttributes->{"MeasureAs"});
+ if (HasActivityLogging($forMainWorldSuffix, $function->signature->extendedAttributes, "Access")) {
+ $code .= GenerateActivityLogging("Method", $interface, "${name}");
+ }
if (HasCustomMethod($function->signature->extendedAttributes)) {
$code .= " return ${v8InterfaceName}::${name}MethodCustom(args);\n";
} else {
« no previous file with comments | « no previous file | Source/bindings/scripts/IDLAttributes.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698