Title: [128788] trunk/Source/WebCore
Revision
128788
Author
[email protected]
Date
2012-09-17 11:53:35 -0700 (Mon, 17 Sep 2012)

Log Message

We should make collecting metrics easier by adding an IDL attribute
https://bugs.webkit.org/show_bug.cgi?id=96837

Reviewed by Kentaro Hara.

Currently it is too hard to set up a good measurement experiment to see
whether we can safely remove a feature (including vendor-prefixed
features). This patch introduces the [V8MeasureAs] IDL attribute to make
that process easier.

When you add the [V8MeasureAs] IDL property to an API, we'll count what
fraction of Page objects used that API.

* Modules/notifications/DOMWindowNotifications.idl:
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateFeatureObservation):
(GenerateNormalAttrGetter):
(GenerateReplaceableAttrSetter):
(GenerateNormalAttrSetter):
(GenerateOverloadedFunctionCallback):
(GenerateFunctionCallback):
(GenerateConstructorCallback):
(GenerateNamedConstructorCallback):
* bindings/scripts/IDLAttributes.txt:
* bindings/scripts/test/TestObj.idl:
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjV8Internal::testObjAttrAttrGetter):
(WebCore::TestObjV8Internal::testObjAttrAttrSetter):
(WebCore::TestObjV8Internal::objMethodCallback):
(WebCore):
* page/Page.h:
(WebCore::Page::featureObserver):
(Page):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (128787 => 128788)


--- trunk/Source/WebCore/CMakeLists.txt	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/CMakeLists.txt	2012-09-17 18:53:35 UTC (rev 128788)
@@ -1685,6 +1685,7 @@
     page/DragController.cpp
     page/EventHandler.cpp
     page/EventSource.cpp
+    page/FeatureObserver.cpp
     page/FocusController.cpp
     page/Frame.cpp
     page/FrameActionScheduler.cpp

Modified: trunk/Source/WebCore/ChangeLog (128787 => 128788)


--- trunk/Source/WebCore/ChangeLog	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/ChangeLog	2012-09-17 18:53:35 UTC (rev 128788)
@@ -1,3 +1,39 @@
+2012-09-17  Adam Barth  <[email protected]>
+
+        We should make collecting metrics easier by adding an IDL attribute
+        https://bugs.webkit.org/show_bug.cgi?id=96837
+
+        Reviewed by Kentaro Hara.
+
+        Currently it is too hard to set up a good measurement experiment to see
+        whether we can safely remove a feature (including vendor-prefixed
+        features). This patch introduces the [V8MeasureAs] IDL attribute to make
+        that process easier.
+
+        When you add the [V8MeasureAs] IDL property to an API, we'll count what
+        fraction of Page objects used that API.
+
+        * Modules/notifications/DOMWindowNotifications.idl:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateFeatureObservation):
+        (GenerateNormalAttrGetter):
+        (GenerateReplaceableAttrSetter):
+        (GenerateNormalAttrSetter):
+        (GenerateOverloadedFunctionCallback):
+        (GenerateFunctionCallback):
+        (GenerateConstructorCallback):
+        (GenerateNamedConstructorCallback):
+        * bindings/scripts/IDLAttributes.txt:
+        * bindings/scripts/test/TestObj.idl:
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::TestObjV8Internal::testObjAttrAttrGetter):
+        (WebCore::TestObjV8Internal::testObjAttrAttrSetter):
+        (WebCore::TestObjV8Internal::objMethodCallback):
+        (WebCore):
+        * page/Page.h:
+        (WebCore::Page::featureObserver):
+        (Page):
+
 2012-09-17  Bear Travis  <[email protected]>
 
         [CSS Exclusions] Enable shape-inside for percentage lengths based on logical height

Modified: trunk/Source/WebCore/GNUmakefile.list.am (128787 => 128788)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-09-17 18:53:35 UTC (rev 128788)
@@ -3968,6 +3968,8 @@
 	Source/WebCore/page/EventHandler.h \
 	Source/WebCore/page/EventSource.cpp \
 	Source/WebCore/page/EventSource.h \
+	Source/WebCore/page/FeatureObserver.cpp \
+	Source/WebCore/page/FeatureObserver.h \
 	Source/WebCore/page/FocusController.cpp \
 	Source/WebCore/page/FocusController.h \
 	Source/WebCore/page/FocusDirection.h \

Modified: trunk/Source/WebCore/Modules/notifications/DOMWindowNotifications.idl (128787 => 128788)


--- trunk/Source/WebCore/Modules/notifications/DOMWindowNotifications.idl	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/Modules/notifications/DOMWindowNotifications.idl	2012-09-17 18:53:35 UTC (rev 128788)
@@ -31,7 +31,7 @@
         Supplemental=DOMWindow
     ] DOMWindowNotifications {
 #if defined(ENABLE_LEGACY_NOTIFICATIONS) && ENABLE_LEGACY_NOTIFICATIONS
-        readonly attribute [V8EnabledAtRuntime] NotificationCenter webkitNotifications;
+        readonly attribute [V8EnabledAtRuntime, V8MeasureAs=LegacyNotifications] NotificationCenter webkitNotifications;
 #endif
 #if defined(ENABLE_NOTIFICATIONS) && ENABLE_NOTIFICATIONS
         attribute NotificationConstructor Notification;

Modified: trunk/Source/WebCore/Target.pri (128787 => 128788)


--- trunk/Source/WebCore/Target.pri	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/Target.pri	2012-09-17 18:53:35 UTC (rev 128788)
@@ -865,6 +865,7 @@
     page/DragController.cpp \
     page/EventHandler.cpp \
     page/EventSource.cpp \
+    page/FeatureObserver.cpp \
     page/FocusController.cpp \
     page/Frame.cpp \
     page/FrameActionScheduler.cpp \

Modified: trunk/Source/WebCore/WebCore.gypi (128787 => 128788)


--- trunk/Source/WebCore/WebCore.gypi	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/WebCore.gypi	2012-09-17 18:53:35 UTC (rev 128788)
@@ -232,6 +232,7 @@
             'page/DragState.h',
             'page/EditorClient.h',
             'page/EventHandler.h',
+            'page/FeatureObserver.h',
             'page/FocusController.h',
             'page/FocusDirection.h',
             'page/Frame.h',
@@ -3113,6 +3114,7 @@
             'page/EventHandler.cpp',
             'page/EventSource.cpp',
             'page/EventSource.h',
+            'page/FeatureObserver.cpp',
             'page/FocusController.cpp',
             'page/Frame.cpp',
             'page/FrameActionScheduler.cpp',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (128787 => 128788)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-09-17 18:53:35 UTC (rev 128788)
@@ -27051,6 +27051,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\page\FeatureObserver.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\page\FeatureObserver.h"
+				>
+			</File>
+			<File
 				RelativePath="..\page\FocusController.cpp"
 				>
 			</File>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (128787 => 128788)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-09-17 18:53:35 UTC (rev 128788)
@@ -3690,6 +3690,8 @@
 		97C078501165D5BE003A32EF /* SuffixTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 97C0784F1165D5BE003A32EF /* SuffixTree.h */; };
 		97C471DB12F925BD0086354B /* ContentSecurityPolicy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97C471D912F925BC0086354B /* ContentSecurityPolicy.cpp */; };
 		97C471DC12F925BD0086354B /* ContentSecurityPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 97C471DA12F925BD0086354B /* ContentSecurityPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		97C740141603F7A10011FF2D /* FeatureObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97C740121603F7A10011FF2D /* FeatureObserver.cpp */; };
+		97C740151603F7A10011FF2D /* FeatureObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 97C740131603F7A10011FF2D /* FeatureObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		97D2AD0314B823A60093DF32 /* DOMWindowProperty.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97D2AD0114B823A60093DF32 /* DOMWindowProperty.cpp */; };
 		97D2AD0414B823A60093DF32 /* DOMWindowProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 97D2AD0214B823A60093DF32 /* DOMWindowProperty.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		97DCE20110807C750057D394 /* HistoryController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97DCE1FF10807C750057D394 /* HistoryController.cpp */; };
@@ -10915,6 +10917,8 @@
 		97C1F552122855CB00EDE616 /* HTMLToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLToken.h; path = parser/HTMLToken.h; sourceTree = "<group>"; };
 		97C471D912F925BC0086354B /* ContentSecurityPolicy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentSecurityPolicy.cpp; sourceTree = "<group>"; };
 		97C471DA12F925BD0086354B /* ContentSecurityPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentSecurityPolicy.h; sourceTree = "<group>"; };
+		97C740121603F7A10011FF2D /* FeatureObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FeatureObserver.cpp; sourceTree = "<group>"; };
+		97C740131603F7A10011FF2D /* FeatureObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FeatureObserver.h; sourceTree = "<group>"; };
 		97D2AD0114B823A60093DF32 /* DOMWindowProperty.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowProperty.cpp; sourceTree = "<group>"; };
 		97D2AD0214B823A60093DF32 /* DOMWindowProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWindowProperty.h; sourceTree = "<group>"; };
 		97DCE1FF10807C750057D394 /* HistoryController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HistoryController.cpp; sourceTree = "<group>"; };
@@ -15814,6 +15818,8 @@
 				E0FEF371B17C53EAC1C1FBEE /* EventSource.h */,
 				E0FEF371B07C53EAC1C1FBEE /* EventSource.idl */,
 				14993BE30B2F2B1C0050497F /* FocusController.cpp */,
+				97C740121603F7A10011FF2D /* FeatureObserver.cpp */,
+				97C740131603F7A10011FF2D /* FeatureObserver.h */,
 				14993BE40B2F2B1C0050497F /* FocusController.h */,
 				062287830B4DB322000C34DF /* FocusDirection.h */,
 				65BF02290974816300C43196 /* Frame.cpp */,
@@ -23406,6 +23412,7 @@
 				84730D8D1248F0B300D3A9C9 /* FETurbulence.h in Headers */,
 				FD31609512B026F700C1A359 /* FFTConvolver.h in Headers */,
 				FD31609712B026F700C1A359 /* FFTFrame.h in Headers */,
+				97C740151603F7A10011FF2D /* FeatureObserver.h in Headers */,
 				976D6C81122B8A3D001FD1F7 /* File.h in Headers */,
 				893C47A71238908B002B3D86 /* FileCallback.h in Headers */,
 				066C772B0AB603B700238CC4 /* FileChooser.h in Headers */,
@@ -26658,6 +26665,7 @@
 				FD31609412B026F700C1A359 /* FFTConvolver.cpp in Sources */,
 				FD31609612B026F700C1A359 /* FFTFrame.cpp in Sources */,
 				FD3160C012B0272A00C1A359 /* FFTFrameMac.cpp in Sources */,
+				97C740141603F7A10011FF2D /* FeatureObserver.cpp in Sources */,
 				976D6C80122B8A3D001FD1F7 /* File.cpp in Sources */,
 				934FE9E50B5CA539003E4A73 /* FileChooser.cpp in Sources */,
 				89878561122CA064003AABDA /* FileEntry.cpp in Sources */,

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (128787 => 128788)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-09-17 18:53:35 UTC (rev 128788)
@@ -813,6 +813,18 @@
 END
 }
 
+sub GenerateFeatureObservation
+{
+    my $measureAs = shift;
+
+    if ($measureAs) {
+        AddToImplIncludes("FeatureObserver.h");
+        return "    FeatureObserver::observe(activeDOMWindow(BindingState::instance()), FeatureObserver::${measureAs});\n";
+    }
+
+    return "";
+}
+
 sub GenerateNormalAttrGetter
 {
     my $attribute = shift;
@@ -836,8 +848,9 @@
     push(@implContentDecls, <<END);
 static v8::Handle<v8::Value> ${attrName}AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 {
-    INC_STATS(\"DOM.$implClassName.$attrName._get\");
+    INC_STATS("DOM.$implClassName.$attrName._get");
 END
+    push(@implContentDecls, GenerateFeatureObservation($attrExt->{"V8MeasureAs"}));
 
     if ($svgNativeType) {
         my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName);
@@ -1085,6 +1098,7 @@
 {
     INC_STATS("DOM.$implClassName.replaceable._set");
 END
+    push(@implContentDecls, GenerateFeatureObservation($dataNode->extendedAttributes->{"V8MeasureAs"}));
 
     if ($implClassName eq "DOMWindow" || $dataNode->extendedAttributes->{"CheckSecurity"}) {
         AddToImplIncludes("Frame.h");
@@ -1117,6 +1131,7 @@
 
     push(@implContentDecls, "static void ${attrName}AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n{\n");
     push(@implContentDecls, "    INC_STATS(\"DOM.$implClassName.$attrName._set\");\n");
+    push(@implContentDecls, GenerateFeatureObservation($attribute->signature->extendedAttributes->{"V8MeasureAs"}));
 
     # If the "StrictTypeChecking" extended attribute is present, and the attribute's type is an
     # interface type, then if the incoming value does not implement that interface, a TypeError is
@@ -1423,6 +1438,7 @@
 {
     INC_STATS(\"DOM.$implClassName.$name\");
 END
+    push(@implContentDecls, GenerateFeatureObservation($function->signature->extendedAttributes->{"V8MeasureAs"}));
 
     foreach my $overload (@{$function->{overloads}}) {
         my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersCheck($overload);
@@ -1473,6 +1489,7 @@
 {
     INC_STATS(\"DOM.$implClassName.$name\");
 END
+    push(@implContentDecls, GenerateFeatureObservation($function->signature->extendedAttributes->{"V8MeasureAs"}));
 
     push(@implContentDecls, GenerateArgumentsCountCheck($function, $dataNode));
 
@@ -1799,13 +1816,15 @@
         }
     }
 
+    my $maybeObserveFeature = GenerateFeatureObservation($function->signature->extendedAttributes->{"V8MeasureAs"});
+
     my @beforeArgumentList;
     my @afterArgumentList;
     push(@implContent, <<END);
 v8::Handle<v8::Value> V8${implClassName}::constructorCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.${implClassName}.Constructor");
-
+    ${maybeObserveFeature}
     if (!args.IsConstructCall())
         return throwTypeError("DOM object constructor cannot be called as a function.");
 
@@ -1976,6 +1995,8 @@
         }
     }
 
+    my $maybeObserveFeature = GenerateFeatureObservation($function->signature->extendedAttributes->{"V8MeasureAs"});
+
     my @beforeArgumentList;
     my @afterArgumentList;
 
@@ -1996,7 +2017,7 @@
 static v8::Handle<v8::Value> V8${implClassName}ConstructorCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.${implClassName}.Constructor");
-
+    ${maybeObserveFeature}
     if (!args.IsConstructCall())
         return throwTypeError("DOM object constructor cannot be called as a function.");
 

Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (128787 => 128788)


--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt	2012-09-17 18:53:35 UTC (rev 128788)
@@ -119,5 +119,6 @@
 V8EnabledAtRuntime=*
 V8EnabledPerContext=*
 V8GenerateIsReachable=ImplElementRoot|ImplOwnerRoot|ImplOwnerNodeRoot|ImplBaseRoot
+V8MeasureAs=*
 V8ReadOnly
 V8Unforgeable

Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (128787 => 128788)


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2012-09-17 18:53:35 UTC (rev 128788)
@@ -49,7 +49,7 @@
         attribute long long                longLongAttr;
         attribute unsigned long long       unsignedLongLongAttr;
         attribute DOMString                stringAttr;
-        attribute TestObj                  testObjAttr;
+        attribute [V8MeasureAs=TestFeature] TestObj testObjAttr;
 
         JS, V8
         // WK_ucfirst, WK_lcfirst exceptional cases.
@@ -75,7 +75,7 @@
         void    voidMethodWithArgs(in long longArg, in DOMString strArg, in TestObj objArg);
         long    longMethod();
         long    longMethodWithArgs(in long longArg, in DOMString strArg, in TestObj objArg);
-        TestObj objMethod();
+        [V8MeasureAs=TestFeature] TestObj objMethod();
         TestObj objMethodWithArgs(in long longArg, in DOMString strArg, in TestObj objArg);
 
         void methodWithSequenceArg(in sequence<ScriptProfile> sequenceArg);
@@ -97,7 +97,7 @@
 
         // 'Custom' extended attribute
         attribute [Custom] long            customAttr;
-        [Custom] void customMethod();
+        [Custom, V8MeasureAs=CustomTestFeature] void customMethod();
         [Custom] void customMethodWithArgs(in long longArg, in DOMString strArg, in TestObj objArg);
 
         void addEventListener(in DOMString type, 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp (128787 => 128788)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2012-09-17 18:53:35 UTC (rev 128788)
@@ -242,7 +242,7 @@
 v8::Handle<v8::Value> V8TestInterface::constructorCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.TestInterface.Constructor");
-
+    
     if (!args.IsConstructCall())
         return throwTypeError("DOM object constructor cannot be called as a function.");
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp (128787 => 128788)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp	2012-09-17 18:53:35 UTC (rev 128788)
@@ -45,7 +45,7 @@
 static v8::Handle<v8::Value> V8TestNamedConstructorConstructorCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.TestNamedConstructor.Constructor");
-
+    
     if (!args.IsConstructCall())
         return throwTypeError("DOM object constructor cannot be called as a function.");
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp (128787 => 128788)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp	2012-09-17 18:53:35 UTC (rev 128788)
@@ -43,7 +43,7 @@
 v8::Handle<v8::Value> V8TestNode::constructorCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.TestNode.Constructor");
-
+    
     if (!args.IsConstructCall())
         return throwTypeError("DOM object constructor cannot be called as a function.");
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (128787 => 128788)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-09-17 18:53:35 UTC (rev 128788)
@@ -26,6 +26,7 @@
 #include "DOMStringList.h"
 #include "Dictionary.h"
 #include "ExceptionCode.h"
+#include "FeatureObserver.h"
 #include "Frame.h"
 #include "HTMLNames.h"
 #include "IDBBindingUtilities.h"
@@ -227,6 +228,7 @@
 static v8::Handle<v8::Value> testObjAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 {
     INC_STATS("DOM.TestObj.testObjAttr._get");
+    FeatureObserver::observe(activeDOMWindow(BindingState::instance()), FeatureObserver::TestFeature);
     TestObj* imp = V8TestObj::toNative(info.Holder());
     return toV8(imp->testObjAttr(), info.Holder(), info.GetIsolate());
 }
@@ -234,6 +236,7 @@
 static void testObjAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 {
     INC_STATS("DOM.TestObj.testObjAttr._set");
+    FeatureObserver::observe(activeDOMWindow(BindingState::instance()), FeatureObserver::TestFeature);
     TestObj* imp = V8TestObj::toNative(info.Holder());
     TestObj* v = V8TestObj::HasInstance(value) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(value)) : 0;
     imp->setTestObjAttr(WTF::getPtr(v));
@@ -1094,6 +1097,7 @@
 static v8::Handle<v8::Value> objMethodCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.TestObj.objMethod");
+    FeatureObserver::observe(activeDOMWindow(BindingState::instance()), FeatureObserver::TestFeature);
     TestObj* imp = V8TestObj::toNative(args.Holder());
     return toV8(imp->objMethod(), args.Holder(), args.GetIsolate());
 }
@@ -1928,7 +1932,7 @@
     {"unsignedLongLongAttr", TestObjV8Internal::unsignedLongLongAttrAttrGetter, TestObjV8Internal::unsignedLongLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
     // Attribute 'stringAttr' (Type: 'attribute' ExtAttr: '')
     {"stringAttr", TestObjV8Internal::stringAttrAttrGetter, TestObjV8Internal::stringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
-    // Attribute 'testObjAttr' (Type: 'attribute' ExtAttr: '')
+    // Attribute 'testObjAttr' (Type: 'attribute' ExtAttr: 'V8MeasureAs')
     {"testObjAttr", TestObjV8Internal::testObjAttrAttrGetter, TestObjV8Internal::testObjAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
     // Attribute 'XMLObjAttr' (Type: 'attribute' ExtAttr: '')
     {"XMLObjAttr", TestObjV8Internal::XMLObjAttrAttrGetter, TestObjV8Internal::XMLObjAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
@@ -2122,7 +2126,7 @@
 v8::Handle<v8::Value> V8TestObj::constructorCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.TestObj.Constructor");
-
+    
     if (!args.IsConstructCall())
         return throwTypeError("DOM object constructor cannot be called as a function.");
 

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp (128787 => 128788)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp	2012-09-17 18:53:35 UTC (rev 128788)
@@ -210,7 +210,7 @@
 v8::Handle<v8::Value> V8TestSerializedScriptValueInterface::constructorCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.TestSerializedScriptValueInterface.Constructor");
-
+    
     if (!args.IsConstructCall())
         return throwTypeError("DOM object constructor cannot be called as a function.");
 

Copied: trunk/Source/WebCore/page/FeatureObserver.cpp (from rev 128787, trunk/Source/WebCore/Modules/notifications/DOMWindowNotifications.idl) (0 => 128788)


--- trunk/Source/WebCore/page/FeatureObserver.cpp	                        (rev 0)
+++ trunk/Source/WebCore/page/FeatureObserver.cpp	2012-09-17 18:53:35 UTC (rev 128788)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2012 Google, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FeatureObserver.h"
+
+#include "DOMWindow.h"
+#include "Document.h"
+#include "HistogramSupport.h"
+#include "Page.h"
+
+namespace WebCore {
+
+FeatureObserver::FeatureObserver()
+    : m_featureMask(0)
+{
+}
+
+FeatureObserver::~FeatureObserver()
+{
+    // We always log PageDestruction so that we have a scale for the rest of the features.
+    HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", PageDestruction, NumberOfFeatures);
+
+    if (!m_featureMask)
+        return;
+
+    for (int i = 0; i < NumberOfFeatures; ++i) {
+        if (m_featureMask & (1 << i))
+            HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", i, NumberOfFeatures);
+    }
+}
+
+void FeatureObserver::observe(DOMWindow* domWindow, Feature feature)
+{
+    Document* document = domWindow->document();
+    if (!document)
+        return;
+
+    Page* page = document->page();
+    if (!page)
+        return;
+
+    page->featureObserver()->didObserve(feature);
+}
+
+} // namespace WebCore

Copied: trunk/Source/WebCore/page/FeatureObserver.h (from rev 128787, trunk/Source/WebCore/Modules/notifications/DOMWindowNotifications.idl) (0 => 128788)


--- trunk/Source/WebCore/page/FeatureObserver.h	                        (rev 0)
+++ trunk/Source/WebCore/page/FeatureObserver.h	2012-09-17 18:53:35 UTC (rev 128788)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 Google, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FeatureObserver_h
+#define FeatureObserver_h
+
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+class DOMWindow;
+
+class FeatureObserver {
+    WTF_MAKE_NONCOPYABLE(FeatureObserver);
+public:
+    FeatureObserver();
+    ~FeatureObserver();
+
+    enum Feature {
+        PageDestruction,
+        LegacyNotifications,
+        // Add new features above this line.
+        NumberOfFeatures, // This enum value must be last.
+    };
+
+    static void observe(DOMWindow*, Feature);
+
+private:
+    void didObserve(Feature feature)
+    {
+        COMPILE_ASSERT(sizeof(m_featureMask) * 8 >= NumberOfFeatures, FeaturesMustNotOverflowBitmask);
+        ASSERT(feature != PageDestruction); // PageDestruction is reserved as a scaling factor.
+        ASSERT(feature < NumberOfFeatures);
+        m_featureMask |= 1 << static_cast<int>(feature);
+    }
+
+    int m_featureMask;
+};
+
+} // namespace WebCore
+    
+#endif // FeatureObserver_h

Modified: trunk/Source/WebCore/page/Page.h (128787 => 128788)


--- trunk/Source/WebCore/page/Page.h	2012-09-17 18:49:45 UTC (rev 128787)
+++ trunk/Source/WebCore/page/Page.h	2012-09-17 18:53:35 UTC (rev 128788)
@@ -21,6 +21,7 @@
 #ifndef Page_h
 #define Page_h
 
+#include "FeatureObserver.h"
 #include "FrameLoaderTypes.h"
 #include "FindOptions.h"
 #include "LayoutTypes.h"
@@ -197,6 +198,8 @@
         ProgressTracker* progress() const { return m_progress.get(); }
         BackForwardController* backForward() const { return m_backForwardController.get(); }
 
+        FeatureObserver* featureObserver() { return &m_featureObserver; }
+
         enum ViewMode {
             ViewModeInvalid,
             ViewModeWindowed,
@@ -391,6 +394,8 @@
         EditorClient* m_editorClient;
         ValidationMessageClient* m_validationMessageClient;
 
+        FeatureObserver m_featureObserver;
+
         int m_frameCount;
         String m_groupName;
         bool m_openedByDOM;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to