Title: [177328] trunk/Source
Revision
177328
Author
[email protected]
Date
2014-12-15 18:08:23 -0800 (Mon, 15 Dec 2014)

Log Message

[iOS] Add feature counting support
https://bugs.webkit.org/show_bug.cgi?id=139652
<rdar://problem/19255690>

Reviewed by Gavin Barraclough.

Source/_javascript_Core:

Link against AppSupport framework on iOS as we need it to implement
the new FeatureCounter API in WTF.

* Configurations/_javascript_Core.xcconfig:

Source/WebCore:

Use FeatureCounter API to log PageCache failure reasons
as well as its success rate.

No new tests, no behavior change.

* history/PageCache.cpp:
(WebCore::logCanCacheFrameDecision):
(WebCore::logCanCachePageDecision):
(WebCore::PageCache::canCache):
* platform/FeatureCounterKeys.h: Added.

Source/WTF:

Add a FeatureCounter API for to log / count when a feature
is used. For now, this is only implementated on iOS.

* WTF.vcxproj/WTF.vcxproj:
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/FeatureCounter.cpp: Added.
(WTF::incrementFeatureCounterKey):
(WTF::setFeatureCounterKey):
* wtf/FeatureCounter.h: Added.
* wtf/ios/FeatureCounter.mm: Added.
(WTF::incrementFeatureCounterKey):
(WTF::setFeatureCounterKey):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (177327 => 177328)


--- trunk/Source/_javascript_Core/ChangeLog	2014-12-16 01:38:36 UTC (rev 177327)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-12-16 02:08:23 UTC (rev 177328)
@@ -1,3 +1,16 @@
+2014-12-15  Chris Dumez  <[email protected]>
+
+        [iOS] Add feature counting support
+        https://bugs.webkit.org/show_bug.cgi?id=139652
+        <rdar://problem/19255690>
+
+        Reviewed by Gavin Barraclough.
+
+        Link against AppSupport framework on iOS as we need it to implement
+        the new FeatureCounter API in WTF.
+
+        * Configurations/_javascript_Core.xcconfig:
+
 2014-12-15  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r177284.

Modified: trunk/Source/_javascript_Core/Configurations/_javascript_Core.xcconfig (177327 => 177328)


--- trunk/Source/_javascript_Core/Configurations/_javascript_Core.xcconfig	2014-12-16 01:38:36 UTC (rev 177327)
+++ trunk/Source/_javascript_Core/Configurations/_javascript_Core.xcconfig	2014-12-16 02:08:23 UTC (rev 177328)
@@ -37,7 +37,7 @@
 OTHER_LDFLAGS_HIDE_SYMBOLS = -Wl,-unexported_symbol -Wl,__ZTISt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTISt9exception -Wl,-unexported_symbol -Wl,__ZTSSt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTSSt9exception -Wl,-unexported_symbol -Wl,__ZdlPvS_ -Wl,-unexported_symbol -Wl,__ZnwmPv -Wl,-unexported_symbol -Wl,__ZNKSt3__18functionIFvvEEclEv -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvvEEC1EOS2_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvvEEC2EOS2_ -Wl,-unexported_symbol -Wl,__ZNKSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEEclES3_S5_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEED1Ev -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEED2Ev -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvvEED1Ev -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvvEED2Ev -Wl,-unexported_symbol -Wl,__ZTVNSt3__117bad_function_callE -Wl,-all_load;
 
 OTHER_LDFLAGS_BASE = -lobjc -Wl,-Y,3 $(OTHER_LDFLAGS_HIDE_SYMBOLS);
-OTHER_LDFLAGS[sdk=iphone*] = $(inherited) $(OTHER_LDFLAGS_BASE);
+OTHER_LDFLAGS[sdk=iphone*] = $(inherited) $(OTHER_LDFLAGS_BASE) -framework AppSupport;
 OTHER_LDFLAGS[sdk=macosx*] = $(inherited) $(OTHER_LDFLAGS_BASE) -sub_library libobjc -framework CoreServices;
 
 SECTORDER_FLAGS[sdk=iphoneos*] = $(SECTORDER_FLAGS_ios_$(CONFIGURATION));

Modified: trunk/Source/WTF/ChangeLog (177327 => 177328)


--- trunk/Source/WTF/ChangeLog	2014-12-16 01:38:36 UTC (rev 177327)
+++ trunk/Source/WTF/ChangeLog	2014-12-16 02:08:23 UTC (rev 177328)
@@ -1,3 +1,25 @@
+2014-12-15  Chris Dumez  <[email protected]>
+
+        [iOS] Add feature counting support
+        https://bugs.webkit.org/show_bug.cgi?id=139652
+        <rdar://problem/19255690>
+
+        Reviewed by Gavin Barraclough.
+
+        Add a FeatureCounter API for to log / count when a feature
+        is used. For now, this is only implementated on iOS.
+
+        * WTF.vcxproj/WTF.vcxproj:
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/FeatureCounter.cpp: Added.
+        (WTF::incrementFeatureCounterKey):
+        (WTF::setFeatureCounterKey):
+        * wtf/FeatureCounter.h: Added.
+        * wtf/ios/FeatureCounter.mm: Added.
+        (WTF::incrementFeatureCounterKey):
+        (WTF::setFeatureCounterKey):
+
 2014-12-12  Anders Carlsson  <[email protected]>
 
         Get rid of the DONT_FINALIZE_ON_MAIN_THREAD #define

Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj (177327 => 177328)


--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj	2014-12-16 01:38:36 UTC (rev 177327)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj	2014-12-16 02:08:23 UTC (rev 177328)
@@ -72,6 +72,7 @@
     <ClCompile Include="..\wtf\dtoa\strtod.cc" />
     <ClCompile Include="..\wtf\FastBitVector.cpp" />
     <ClCompile Include="..\wtf\FastMalloc.cpp" />
+    <ClCompile Include="..\wtf\FeatureCounter.cpp" />
     <ClCompile Include="..\wtf\FilePrintStream.cpp" />
     <ClCompile Include="..\wtf\FunctionDispatcher.cpp" />
     <ClCompile Include="..\wtf\gobject\GlibUtilities.cpp">
@@ -197,6 +198,7 @@
     <ClInclude Include="..\wtf\dtoa\utils.h" />
     <ClInclude Include="..\wtf\FastBitVector.h" />
     <ClInclude Include="..\wtf\FastMalloc.h" />
+    <ClInclude Include="..\wtf\FeatureCounter.h" />
     <ClInclude Include="..\wtf\FeatureDefines.h" />
     <ClInclude Include="..\wtf\FilePrintStream.h" />
     <ClInclude Include="..\wtf\FlipBytes.h" />
@@ -775,4 +777,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (177327 => 177328)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2014-12-16 01:38:36 UTC (rev 177327)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2014-12-16 02:08:23 UTC (rev 177328)
@@ -73,6 +73,9 @@
 		2CDED0EF18115C38004DBA70 /* RunLoopCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */; };
 		2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0F118115C85004DBA70 /* RunLoop.cpp */; };
 		2CDED0F418115C85004DBA70 /* RunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CDED0F218115C85004DBA70 /* RunLoop.h */; };
+		463111841A3F729A00E925A3 /* FeatureCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 463111831A3F729A00E925A3 /* FeatureCounter.h */; };
+		463111861A3F72B800E925A3 /* FeatureCounter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 463111851A3F72B800E925A3 /* FeatureCounter.mm */; };
+		463111881A3F899100E925A3 /* FeatureCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 463111871A3F899100E925A3 /* FeatureCounter.cpp */; };
 		7CBBA07419BB7FDC00BBF025 /* OSObjectPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */; };
 		7CDD7FF8186D291E007433CD /* IteratorAdaptors.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDD7FF7186D291E007433CD /* IteratorAdaptors.h */; };
 		7CDD7FFA186D2A54007433CD /* IteratorRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDD7FF9186D2A54007433CD /* IteratorRange.h */; };
@@ -361,6 +364,9 @@
 		2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoopCF.cpp; sourceTree = "<group>"; };
 		2CDED0F118115C85004DBA70 /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = "<group>"; };
 		2CDED0F218115C85004DBA70 /* RunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoop.h; sourceTree = "<group>"; };
+		463111831A3F729A00E925A3 /* FeatureCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FeatureCounter.h; sourceTree = "<group>"; };
+		463111851A3F72B800E925A3 /* FeatureCounter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FeatureCounter.mm; sourceTree = "<group>"; };
+		463111871A3F899100E925A3 /* FeatureCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FeatureCounter.cpp; sourceTree = "<group>"; };
 		5D247B6214689B8600E78B76 /* libWTF.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWTF.a; sourceTree = BUILT_PRODUCTS_DIR; };
 		5D247B6E14689C4700E78B76 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
 		5D247B7014689C4700E78B76 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
@@ -616,6 +622,7 @@
 		1FA47C87152502DA00568D1B /* ios */ = {
 			isa = PBXGroup;
 			children = (
+				463111851A3F72B800E925A3 /* FeatureCounter.mm */,
 				1FA47C88152502DA00568D1B /* WebCoreThread.cpp */,
 				1FA47C89152502DA00568D1B /* WebCoreThread.h */,
 			);
@@ -754,6 +761,8 @@
 				0FD81AC4154FB22E00983E72 /* FastBitVector.h */,
 				A8A472A1151A825A004123FF /* FastMalloc.cpp */,
 				A8A472A2151A825A004123FF /* FastMalloc.h */,
+				463111871A3F899100E925A3 /* FeatureCounter.cpp */,
+				463111831A3F729A00E925A3 /* FeatureCounter.h */,
 				B38FD7BC168953E80065C969 /* FeatureDefines.h */,
 				0F9D335B165DBA73005AD387 /* FilePrintStream.cpp */,
 				0F9D335C165DBA73005AD387 /* FilePrintStream.h */,
@@ -1178,6 +1187,7 @@
 				1AFDE648195201C300C48FFA /* TypeCastsCF.h in Headers */,
 				A8A47423151A825B004123FF /* SimpleStats.h in Headers */,
 				A8A47424151A825B004123FF /* SinglyLinkedList.h in Headers */,
+				463111841A3F729A00E925A3 /* FeatureCounter.h in Headers */,
 				A748745317A0BDAE00FA04CB /* SixCharacterHash.h in Headers */,
 				A8A47426151A825B004123FF /* Spectrum.h in Headers */,
 				A8A47428151A825B004123FF /* StackBounds.h in Headers */,
@@ -1345,6 +1355,7 @@
 				86F46F601A2840EE00CCBF22 /* RefCounter.cpp in Sources */,
 				A8A4739E151A825B004123FF /* DataLog.cpp in Sources */,
 				A8A473A0151A825B004123FF /* DateMath.cpp in Sources */,
+				463111861A3F72B800E925A3 /* FeatureCounter.mm in Sources */,
 				A8A473A2151A825B004123FF /* DecimalNumber.cpp in Sources */,
 				A8A473AE151A825B004123FF /* diy-fp.cc in Sources */,
 				A8A473B0151A825B004123FF /* double-conversion.cc in Sources */,
@@ -1365,6 +1376,7 @@
 				CD5497AC15857D0300B5BC30 /* MediaTime.cpp in Sources */,
 				A8A473EC151A825B004123FF /* MetaAllocator.cpp in Sources */,
 				A8A473F4151A825B004123FF /* NumberOfCores.cpp in Sources */,
+				463111881A3F899100E925A3 /* FeatureCounter.cpp in Sources */,
 				A8A473F7151A825B004123FF /* OSAllocatorPosix.cpp in Sources */,
 				93F1993E19D7958D00C2390B /* StringView.cpp in Sources */,
 				A8A473F9151A825B004123FF /* OSRandomSource.cpp in Sources */,

Modified: trunk/Source/WTF/wtf/CMakeLists.txt (177327 => 177328)


--- trunk/Source/WTF/wtf/CMakeLists.txt	2014-12-16 01:38:36 UTC (rev 177327)
+++ trunk/Source/WTF/wtf/CMakeLists.txt	2014-12-16 02:08:23 UTC (rev 177328)
@@ -24,6 +24,7 @@
     DisallowCType.h
     DoublyLinkedList.h
     FastMalloc.h
+    FeatureCounter.h
     FeatureDefines.h
     FilePrintStream.h
     FlipBytes.h
@@ -159,6 +160,7 @@
     DecimalNumber.cpp
     FastBitVector.cpp
     FastMalloc.cpp
+    FeatureCounter.cpp
     FilePrintStream.cpp
     FunctionDispatcher.cpp
     GregorianDateTime.cpp

Added: trunk/Source/WTF/wtf/FeatureCounter.cpp (0 => 177328)


--- trunk/Source/WTF/wtf/FeatureCounter.cpp	                        (rev 0)
+++ trunk/Source/WTF/wtf/FeatureCounter.cpp	2014-12-16 02:08:23 UTC (rev 177328)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2014 Apple 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 APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 "FeatureCounter.h"
+
+namespace WTF {
+
+#if !PLATFORM(IOS)
+
+void incrementFeatureCounterKey(const char* const key)
+{
+    UNUSED_PARAM(key);
+}
+
+void setFeatureCounterKey(const char* const key, int64_t value)
+{
+    UNUSED_PARAM(key);
+    UNUSED_PARAM(value);
+}
+
+#endif
+
+} // namespace WTF

Added: trunk/Source/WTF/wtf/FeatureCounter.h (0 => 177328)


--- trunk/Source/WTF/wtf/FeatureCounter.h	                        (rev 0)
+++ trunk/Source/WTF/wtf/FeatureCounter.h	2014-12-16 02:08:23 UTC (rev 177328)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2014 Apple 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 APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 FeatureCounter_h
+#define FeatureCounter_h
+
+namespace WTF {
+
+WTF_EXPORT_PRIVATE void incrementFeatureCounterKey(const char* const key);
+WTF_EXPORT_PRIVATE void setFeatureCounterKey(const char* const key, int64_t value);
+
+#define FEATURE_COUNTER_INCREMENT_KEY(key)   WTF::incrementFeatureCounterKey(key)
+#define FEATURE_COUNTER_SET_KEY(key, value)  WTF::setFeatureCounterKey(key, value)
+
+} // namespace WTF
+
+#endif // FeatureCounter_h

Added: trunk/Source/WTF/wtf/ios/FeatureCounter.mm (0 => 177328)


--- trunk/Source/WTF/wtf/ios/FeatureCounter.mm	                        (rev 0)
+++ trunk/Source/WTF/wtf/ios/FeatureCounter.mm	2014-12-16 02:08:23 UTC (rev 177328)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2014 Apple 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 APPLE AND ITS CONTRIBUTORS "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 OR ITS 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.
+ */
+
+#import "config.h"
+#import "FeatureCounter.h"
+
+#if PLATFORM(IOS)
+#import <AppSupport/CPAggregateDictionary.h>
+
+namespace WTF {
+
+void incrementFeatureCounterKey(const char* const key)
+{
+    NSString *nsKey = [[NSString alloc] initWithCharactersNoCopy:reinterpret_cast<unichar*>(const_cast<char*>(key)) length:strlen(key) freeWhenDone:NO];
+    [[CPAggregateDictionary sharedAggregateDictionary] incrementKey:nsKey];
+}
+
+void setFeatureCounterKey(const char* const key, int64_t value)
+{
+    NSString *nsKey = [[NSString alloc] initWithCharactersNoCopy:reinterpret_cast<unichar*>(const_cast<char*>(key)) length:strlen(key) freeWhenDone:NO];
+    [[CPAggregateDictionary sharedAggregateDictionary] setValue:value forScalarKey:nsKey];
+}
+
+} // namespace WTF
+
+#endif // PLATFORM(IOS)

Modified: trunk/Source/WebCore/ChangeLog (177327 => 177328)


--- trunk/Source/WebCore/ChangeLog	2014-12-16 01:38:36 UTC (rev 177327)
+++ trunk/Source/WebCore/ChangeLog	2014-12-16 02:08:23 UTC (rev 177328)
@@ -1,3 +1,22 @@
+2014-12-15  Chris Dumez  <[email protected]>
+
+        [iOS] Add feature counting support
+        https://bugs.webkit.org/show_bug.cgi?id=139652
+        <rdar://problem/19255690>
+
+        Reviewed by Gavin Barraclough.
+
+        Use FeatureCounter API to log PageCache failure reasons
+        as well as its success rate.
+
+        No new tests, no behavior change.
+
+        * history/PageCache.cpp:
+        (WebCore::logCanCacheFrameDecision):
+        (WebCore::logCanCachePageDecision):
+        (WebCore::PageCache::canCache):
+        * platform/FeatureCounterKeys.h: Added.
+
 2014-12-15  Beth Dakin  <[email protected]>
 
         Speculative build fix.

Modified: trunk/Source/WebCore/history/PageCache.cpp (177327 => 177328)


--- trunk/Source/WebCore/history/PageCache.cpp	2014-12-16 01:38:36 UTC (rev 177327)
+++ trunk/Source/WebCore/history/PageCache.cpp	2014-12-16 02:08:23 UTC (rev 177328)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2007, 2014 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@
 #include "DeviceOrientationController.h"
 #include "Document.h"
 #include "DocumentLoader.h"
+#include "FeatureCounterKeys.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
 #include "FrameLoaderStateMachine.h"
@@ -66,6 +67,12 @@
 #if !defined(NDEBUG)
 
 #define PCLOG(...) LOG(PageCache, "%*s%s", indentLevel*4, "", makeString(__VA_ARGS__).utf8().data())
+
+#else
+
+#define PCLOG(...) ((void)0)
+
+#endif // !defined(NDEBUG)
     
 // Used in histograms, please only add at the end, and do not remove elements (renaming e.g. to "FooEnumUnused1" is fine).
 // This is because statistics may be gathered from histograms between versions over time, and re-using values causes collisions.
@@ -93,6 +100,7 @@
     PCLOG("+---");
     if (!frame->loader().documentLoader()) {
         PCLOG("   -There is no DocumentLoader object");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureNoDocumentLoaderKey);
         return 1 << NoDocumentLoader;
     }
 
@@ -106,6 +114,7 @@
     unsigned rejectReasons = 0;
     if (!frame->loader().documentLoader()->mainDocumentError().isNull()) {
         PCLOG("   -Main document has an error");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureMainDocumentErrorKey);
 #if !PLATFORM(IOS)
         rejectReasons |= 1 << MainDocumentError;
 #else
@@ -117,56 +126,71 @@
     }
     if (frame->loader().documentLoader()->substituteData().isValid() && frame->loader().documentLoader()->substituteData().failingURL().isEmpty()) {
         PCLOG("   -Frame is an error page");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureIsErrorPageKey);
         rejectReasons |= 1 << IsErrorPage;
     }
     if (frame->loader().subframeLoader().containsPlugins() && !frame->page()->settings().pageCacheSupportsPlugins()) {
         PCLOG("   -Frame contains plugins");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureHasPlugins);
         rejectReasons |= 1 << HasPlugins;
     }
     if (frame->document()->url().protocolIs("https")
         && (frame->loader().documentLoader()->response().cacheControlContainsNoCache()
             || frame->loader().documentLoader()->response().cacheControlContainsNoStore())) {
+        if (frame->loader().documentLoader()->response().cacheControlContainsNoCache())
+            FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureHTTPSNoCacheKey);
+        if (frame->loader().documentLoader()->response().cacheControlContainsNoStore())
+            FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureHTTPSNoStoreKey);
         PCLOG("   -Frame is HTTPS, and cache control prohibits caching or storing");
         rejectReasons |= 1 << IsHttpsAndCacheControlled;
     }
 #if ENABLE(SQL_DATABASE)
     if (DatabaseManager::manager().hasOpenDatabases(frame->document())) {
         PCLOG("   -Frame has open database handles");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureHasOpenDatabasesKey);
         rejectReasons |= 1 << HasDatabaseHandles;
     }
 #endif
 #if ENABLE(SHARED_WORKERS)
     if (SharedWorkerRepository::hasSharedWorkers(frame->document())) {
         PCLOG("   -Frame has associated SharedWorkers");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureHasSharedWorkersKey);
         rejectReasons |= 1 << HasSharedWorkers;
     }
 #endif
     if (!frame->loader().history().currentItem()) {
         PCLOG("   -No current history item");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureNoCurrentHistoryItemKey);
         rejectReasons |= 1 << NoHistoryItem;
     }
     if (frame->loader().quickRedirectComing()) {
         PCLOG("   -Quick redirect is coming");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureQuirkRedirectComingKey);
         rejectReasons |= 1 << QuickRedirectComing;
     }
     if (frame->loader().documentLoader()->isLoadingInAPISense()) {
         PCLOG("   -DocumentLoader is still loading in API sense");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureLoadingAPISenseKey);
         rejectReasons |= 1 << IsLoadingInAPISense;
     }
     if (frame->loader().documentLoader()->isStopping()) {
         PCLOG("   -DocumentLoader is in the middle of stopping");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureDocumentLoaderStoppingKey);
         rejectReasons |= 1 << IsStopping;
     }
     if (!frame->document()->canSuspendActiveDOMObjects()) {
-        PCLOG("   -The document cannot suspect its active DOM Objects");
+        PCLOG("   -The document cannot suspend its active DOM Objects");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureCannotSuspendActiveDOMObjectsKey);
         rejectReasons |= 1 << CannotSuspendActiveDOMObjects;
     }
     if (!frame->loader().documentLoader()->applicationCacheHost()->canCacheInPageCache()) {
         PCLOG("   -The DocumentLoader uses an application cache");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureApplicationCacheKey);
         rejectReasons |= 1 << DocumentLoaderUsesApplicationCache;
     }
     if (!frame->loader().client().canCachePage()) {
         PCLOG("   -The client says this frame cannot be cached");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureDeniedByClientKey);
         rejectReasons |= 1 << ClientDeniesCaching;
     }
 
@@ -218,38 +242,48 @@
 #if ENABLE(DEVICE_ORIENTATION) && !PLATFORM(IOS)
     if (DeviceMotionController::isActiveAt(page)) {
         PCLOG("   -Page is using DeviceMotion");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureDeviceMotionKey);
         rejectReasons |= 1 << UsesDeviceMotion;
     }
     if (DeviceOrientationController::isActiveAt(page)) {
         PCLOG("   -Page is using DeviceOrientation");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureDeviceOrientationKey);
         rejectReasons |= 1 << UsesDeviceOrientation;
     }
 #endif
 #if ENABLE(PROXIMITY_EVENTS)
     if (DeviceProximityController::isActiveAt(page)) {
         PCLOG("   -Page is using DeviceProximity");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureDeviceProximityKey);
         rejectReasons |= 1 << UsesDeviceMotion;
     }
 #endif
     FrameLoadType loadType = page->mainFrame().loader().loadType();
     if (loadType == FrameLoadType::Reload) {
         PCLOG("   -Load type is: Reload");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureReloadKey);
         rejectReasons |= 1 << IsReload;
     }
     if (loadType == FrameLoadType::ReloadFromOrigin) {
         PCLOG("   -Load type is: Reload from origin");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureReloadFromOriginKey);
         rejectReasons |= 1 << IsReloadFromOrigin;
     }
     if (loadType == FrameLoadType::Same) {
         PCLOG("   -Load type is: Same");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureSameLoadKey);
         rejectReasons |= 1 << IsSameLoad;
     }
     
-    PCLOG(rejectReasons ? " Page CANNOT be cached\n--------" : " Page CAN be cached\n--------");
+    if (rejectReasons) {
+        PCLOG(" Page CANNOT be cached\n--------");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheFailureKey);
+    } else {
+        PCLOG(" Page CAN be cached\n--------");
+        FEATURE_COUNTER_INCREMENT_KEY(FeatureCounterPageCacheSuccessKey);
+    }
 }
 
-#endif // !defined(NDEBUG)
-
 PageCache* pageCache()
 {
     static PageCache* staticPageCache = new PageCache;
@@ -308,9 +342,7 @@
     if (!page)
         return false;
     
-#if !defined(NDEBUG)
     logCanCachePageDecision(page);
-#endif
 
     if (memoryPressureHandler().isUnderMemoryPressure())
         return false;

Added: trunk/Source/WebCore/platform/FeatureCounterKeys.h (0 => 177328)


--- trunk/Source/WebCore/platform/FeatureCounterKeys.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/FeatureCounterKeys.h	2014-12-16 02:08:23 UTC (rev 177328)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2014 Apple 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 APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 FeatureCounterKeys_h
+#define FeatureCounterKeys_h
+
+#include <wtf/FeatureCounter.h>
+
+namespace WebCore {
+
+// Page cache.
+static const char FeatureCounterPageCacheFailureNoDocumentLoaderKey[] = "com.apple.WebKit.pageCache.failure.noDocumentLoader";
+static const char FeatureCounterPageCacheFailureMainDocumentErrorKey[] = "com.apple.WebKit.pageCache.failure.mainDocumentError";
+static const char FeatureCounterPageCacheFailureIsErrorPageKey[] = "com.apple.WebKit.pageCache.failure.isErrorPage";
+static const char FeatureCounterPageCacheFailureHasPlugins[] = "com.apple.WebKit.pageCache.failure.hasPlugins";
+static const char FeatureCounterPageCacheFailureHTTPSNoCacheKey[] = "com.apple.WebKit.pageCache.failure.httpsNoCache";
+static const char FeatureCounterPageCacheFailureHTTPSNoStoreKey[] = "com.apple.WebKit.pageCache.failure.httpsNoStore";
+#if ENABLE(SQL_DATABASE)
+static const char FeatureCounterPageCacheFailureHasOpenDatabasesKey[] = "com.apple.WebKit.pageCache.failure.hasOpenDatabases";
+#endif
+#if ENABLE(SHARED_WORKERS)
+static const char FeatureCounterPageCacheFailureHasSharedWorkersKey[] = "com.apple.WebKit.pageCache.failure.hasSharedWorkers";
+#endif
+static const char FeatureCounterPageCacheFailureNoCurrentHistoryItemKey[] = "com.apple.WebKit.pageCache.failure.noCurrentHistoryItem";
+static const char FeatureCounterPageCacheFailureQuirkRedirectComingKey[] = "com.apple.WebKit.pageCache.failure.quirkRedirectComing";
+static const char FeatureCounterPageCacheFailureLoadingAPISenseKey[] = "com.apple.WebKit.pageCache.failure.loadingAPISense";
+static const char FeatureCounterPageCacheFailureDocumentLoaderStoppingKey[] = "com.apple.WebKit.pageCache.failure.documentLoaderStopping";
+static const char FeatureCounterPageCacheFailureCannotSuspendActiveDOMObjectsKey[] = "com.apple.WebKit.pageCache.failure.cannotSuspendActiveDOMObjects";
+static const char FeatureCounterPageCacheFailureApplicationCacheKey[] = "com.apple.WebKit.pageCache.failure.applicationCache";
+static const char FeatureCounterPageCacheFailureDeniedByClientKey[] = "com.apple.WebKit.pageCache.failure.deniedByClient";
+#if ENABLE(DEVICE_ORIENTATION)
+static const char FeatureCounterPageCacheFailureDeviceMotionKey[] = "com.apple.WebKit.pageCache.failure.deviceMotion";
+static const char FeatureCounterPageCacheFailureDeviceOrientationKey[] = "com.apple.WebKit.pageCache.failure.deviceOrientation";
+#endif
+#if ENABLE(PROXIMITY_EVENTS)
+static const char FeatureCounterPageCacheFailureDeviceProximityKey[] = "com.apple.WebKit.pageCache.failure.deviceProximity";
+#endif
+static const char FeatureCounterPageCacheFailureReloadKey[] = "com.apple.WebKit.pageCache.failure.reload";
+static const char FeatureCounterPageCacheFailureReloadFromOriginKey[] = "com.apple.WebKit.pageCache.failure.reloadFromOrigin";
+static const char FeatureCounterPageCacheFailureSameLoadKey[] = "com.apple.WebKit.pageCache.failure.sameLoad";
+static const char FeatureCounterPageCacheFailureKey[] = "com.apple.WebKit.pageCache.failure";
+static const char FeatureCounterPageCacheSuccessKey[] = "com.apple.WebKit.pageCache.success";
+
+} // namespace WebCore
+
+#endif // FeatureCounterKeys_h
+
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to