Changeset 212949 in webkit
- Timestamp:
- Feb 24, 2017 1:19:53 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 19 added
- 29 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r212948 r212949 1 2017-02-24 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Add alternate classification method 4 https://bugs.webkit.org/show_bug.cgi?id=168347 5 <rdar://problem/30352793> 6 <rdar://problem/30646710> 7 <rdar://problem/30660708> 8 9 Reviewed by Alex Christensen. 10 11 * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt: Added. 12 * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html: Added. 13 * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added. 14 * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added. 15 * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added. 16 * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html: Added. 17 * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added. 18 * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html: Added. 19 * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt: Added. 20 * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html: Added. 21 * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added. 22 * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added. 23 * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added. 24 * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html: Added. 25 * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added. 26 * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html: Added. 27 * http/tests/loading/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html: 28 Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone(). 29 * http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html: 30 Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone(). 31 * http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html: 32 Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone(). 33 * http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction.html: 34 Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone(). 35 * http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html: 36 Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone(). 37 * platform/gtk/TestExpectations: 38 The whole http/tests/loading/resourceLoadStatistics marked as crashing based on 39 Carlos Garcia Campos's assessment in https://bugs.webkit.org/show_bug.cgi?id=168171. 40 * platform/wk2/TestExpectations: 41 The above tests are only valid for WebKit2. Marked as [ Pass ]. 42 1 43 2017-02-23 Antoine Quint <graouts@apple.com> 2 44 -
trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html
r212183 r212949 39 39 testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie); 40 40 testRunner.statisticsResetToConsistentState(); 41 internals.setResourceLoadStatisticsEnabled(false); 41 42 testRunner.notifyDone(); 42 43 }); -
trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html
r212183 r212949 39 39 testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie); 40 40 testRunner.statisticsResetToConsistentState(); 41 internals.setResourceLoadStatisticsEnabled(false); 41 42 testRunner.notifyDone(); 42 43 }); -
trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html
r212183 r212949 32 32 testPassed("Cookie deleted."); 33 33 testRunner.statisticsResetToConsistentState(); 34 internals.setResourceLoadStatisticsEnabled(false); 34 35 testRunner.notifyDone(); 35 36 }); -
trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction.html
r212183 r212949 39 39 testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie); 40 40 testRunner.statisticsResetToConsistentState(); 41 internals.setResourceLoadStatisticsEnabled(false); 41 42 testRunner.notifyDone(); 42 43 }); -
trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html
r212183 r212949 32 32 testPassed("Cookie deleted."); 33 33 testRunner.statisticsResetToConsistentState(); 34 internals.setResourceLoadStatisticsEnabled(false); 34 35 testRunner.notifyDone(); 35 36 }); -
trunk/LayoutTests/platform/gtk/TestExpectations
r212944 r212949 950 950 webkit.org/b/163782 media/video-played-ranges-1.html [ Crash Pass ] 951 951 952 webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html [ Crash ] 953 webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html [ Crash ] 954 webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html [ Crash ] 955 webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction.html [ Crash ] 956 webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html [ Crash ] 952 webkit.org/b/168171 http/tests/loading/resourceLoadStatistics [ Crash ] 957 953 958 954 webkit.org/b/167576 imported/w3c/IndexedDB-private-browsing/idbcursor_iterating.html [ Crash ] -
trunk/LayoutTests/platform/wk2/TestExpectations
r212841 r212949 706 706 http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html [ Pass Timeout ] 707 707 http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html [ Pass Timeout ] 708 http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html [ Pass ] 709 http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html [ Pass ] 710 http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html [ Pass ] 711 http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html [ Pass ] 712 http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html [ Pass ] 713 http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html [ Pass ] 714 http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html [ Pass ] 715 http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html [ Pass ] 708 716 709 717 ### END OF (5) Progressions, expected successes that are expected failures in WebKit1. -
trunk/Source/WebCore/ChangeLog
r212948 r212949 1 2017-02-24 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Add alternate classification method 4 https://bugs.webkit.org/show_bug.cgi?id=168347 5 <rdar://problem/30352793> 6 <rdar://problem/30646710> 7 <rdar://problem/30660708> 8 9 Reviewed by Alex Christensen. 10 11 This patch only adds test infrastructure in WebCore. 12 13 Tests: http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html 14 http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html 15 http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html 16 http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html 17 http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html 18 http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html 19 http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html 20 http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html 21 22 * loader/ResourceLoadObserver.cpp: 23 (WebCore::ResourceLoadObserver::setSubframeUnderTopFrameOrigin): 24 (WebCore::ResourceLoadObserver::setSubresourceUnderTopFrameOrigin): 25 (WebCore::ResourceLoadObserver::setSubresourceUniqueRedirectTo): 26 * loader/ResourceLoadObserver.h: 27 1 28 2017-02-23 Antoine Quint <graouts@apple.com> 2 29 -
trunk/Source/WebCore/loader/ResourceLoadObserver.cpp
r212841 r212949 376 376 } 377 377 378 void ResourceLoadObserver::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame) 379 { 380 if (subframe.isBlankURL() || subframe.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty()) 381 return; 382 383 auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subframe)); 384 statistics.subframeUnderTopFrameOrigins.add(primaryDomain(topFrame)); 385 } 386 387 void ResourceLoadObserver::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame) 388 { 389 if (subresource.isBlankURL() || subresource.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty()) 390 return; 391 392 auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subresource)); 393 statistics.subresourceUnderTopFrameOrigins.add(primaryDomain(topFrame)); 394 } 395 396 void ResourceLoadObserver::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo) 397 { 398 if (subresource.isBlankURL() || subresource.isEmpty() || hostNameRedirectedTo.isBlankURL() || hostNameRedirectedTo.isEmpty()) 399 return; 400 401 auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subresource)); 402 statistics.subresourceUniqueRedirectsTo.add(primaryDomain(hostNameRedirectedTo)); 403 } 404 378 405 void ResourceLoadObserver::setTimeToLiveUserInteraction(double seconds) 379 406 { -
trunk/Source/WebCore/loader/ResourceLoadObserver.h
r212841 r212949 59 59 WEBCORE_EXPORT void clearPrevalentResource(const URL&); 60 60 61 WEBCORE_EXPORT void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame); 62 WEBCORE_EXPORT void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame); 63 WEBCORE_EXPORT void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo); 64 61 65 WEBCORE_EXPORT void setTimeToLiveUserInteraction(double seconds); 62 66 WEBCORE_EXPORT void setReducedTimestampResolution(double seconds); -
trunk/Source/WebKit2/ChangeLog
r212945 r212949 1 2017-02-24 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Add alternate classification method 4 https://bugs.webkit.org/show_bug.cgi?id=168347 5 <rdar://problem/30352793> 6 <rdar://problem/30646710> 7 <rdar://problem/30660708> 8 9 Reviewed by Alex Christensen. 10 11 This patch adds a CorePrediction-based classifier to the WebResourceLoadStatisticsStore. 12 The CorePrediction framework is introduced as a dependency for macOS and iOS. The patch 13 also adds functions to support layout tests of the feature. 14 15 * Platform/Logging.h: 16 Added channel ResourceLoadStatistics. 17 * Platform/classifier/ResourceLoadStatisticsClassifier.h: Added. 18 Pulls in the Cocoa-specific classifier for Cocoa-based platforms. 19 (WebKit::ResourceLoadStatisticsClassifier::ResourceLoadStatisticsClassifier): 20 * Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp: Added. 21 (WebKit::ResourceLoadStatisticsClassifierBase::hasPrevalentResourceCharacteristics): 22 Shared classifier logic. 23 (WebKit::ResourceLoadStatisticsClassifierBase::classifyWithVectorThreshold): 24 Fallback classifier for when we don't have CorePrediction. 25 * Platform/classifier/ResourceLoadStatisticsClassifierBase.h: Added. 26 (WebKit::ResourceLoadStatisticsClassifierBase::ResourceLoadStatisticsClassifierBase): 27 (WebKit::ResourceLoadStatisticsClassifierBase::~ResourceLoadStatisticsClassifierBase): 28 * Platform/classifier/cocoa/CorePredictionSoftLink.h: Added. 29 Soft links to CorePrediction and the two functions we use from it. 30 * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp: Added. 31 (WebKit::ResourceLoadStatisticsClassifier::classify): 32 (WebKit::ResourceLoadStatisticsClassifier::storagePath): 33 (WebKit::ResourceLoadStatisticsClassifier::shouldUseCorePredictionAndHaveModelLoaded): 34 (WebKit::ResourceLoadStatisticsClassifier::singletonPredictionModel): 35 The new classifier for Cocoa platforms. 36 * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h: Added. 37 * PlatformGTK.cmake: 38 Added Platform/classifier directory and ResourceLoadStatisticsClassifierBase.cpp. 39 * PlatformMac.cmake: 40 Added Platform/classifier and Platform/classifier/cocoa directories, and 41 source files ResourceLoadStatisticsClassifierBase.cpp and 42 ResourceLoadStatisticsClassifierCocoa.cpp 43 * Resources/ResourceLoadStatistics/corePrediction_model: Added. 44 Model file to load into CorePrediction. 45 * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp: 46 (WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin): 47 (WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin): 48 (WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo): 49 Test infrastructure. 50 * UIProcess/API/C/WKResourceLoadStatisticsManager.h: 51 * UIProcess/WebResourceLoadStatisticsManager.cpp: 52 (WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin): 53 (WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin): 54 (WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo): 55 Test infrastructure. 56 * UIProcess/WebResourceLoadStatisticsManager.h: 57 * UIProcess/WebResourceLoadStatisticsStore.cpp: 58 (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore): 59 Renamed m_storagePath to m_statisticsStoragePath for clarity. 60 (WebKit::WebResourceLoadStatisticsStore::classifyResource): 61 Now calls the classifier through its ResourceLoadStatisticsClassifier 62 member variable. 63 (WebKit::WebResourceLoadStatisticsStore::persistentStoragePath): 64 Renamed m_storagePath to m_statisticsStoragePath for clarity. 65 (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk): 66 Renamed m_storagePath to m_statisticsStoragePath for clarity. 67 (WebKit::WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics): Deleted. 68 * UIProcess/WebResourceLoadStatisticsStore.h: 69 * WebKit2.xcodeproj/project.pbxproj: 70 Added the new classifier source files under Platform/classifier and the 71 corePrediction_model file under Resources/ResourceLoadStatistics. 72 1 73 2017-02-23 Joseph Pecoraro <pecoraro@apple.com> 2 74 -
trunk/Source/WebKit2/Platform/Logging.h
r212312 r212949 64 64 M(RemoteLayerTree) \ 65 65 M(Resize) \ 66 M(ResourceLoadStatistics) \ 66 67 M(Selection) \ 67 68 M(SessionState) \ -
trunk/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifier.h
r212948 r212949 26 26 #pragma once 27 27 28 #include "APIObject.h" 29 30 #include <wtf/RefPtr.h> 31 #include <wtf/text/WTFString.h> 28 namespace WebCore { 29 struct ResourceLoadStatistics; 30 } 32 31 33 32 namespace WebKit { 34 33 35 class WebResourceLoadStatisticsManager : public API::ObjectImpl<API::Object::Type::WebResourceLoadStatisticsManager>{34 class ResourceLoadStatisticsClassifier { 36 35 public: 37 static Ref<WebResourceLoadStatisticsManager> create() 36 ResourceLoadStatisticsClassifier() = default; 37 virtual ~ResourceLoadStatisticsClassifier() = default; 38 bool hasPrevalentResourceCharacteristics(const WebCore::ResourceLoadStatistics& resourceStatistic); 39 protected: 40 virtual bool classify(unsigned subresourceUnderTopFrameOriginsCount, unsigned subresourceUniqueRedirectsToCount, unsigned subframeUnderTopFrameOriginsCount) 38 41 { 39 return adoptRef(*new WebResourceLoadStatisticsManager());42 return classifyWithVectorThreshold(subresourceUnderTopFrameOriginsCount, subresourceUniqueRedirectsToCount, subframeUnderTopFrameOriginsCount); 40 43 } 41 static void setPrevalentResource(const String& hostName, bool value); 42 static bool isPrevalentResource(const String& hostName); 43 static void setHasHadUserInteraction(const String& hostName, bool value); 44 static bool hasHadUserInteraction(const String& hostName); 45 static void setTimeToLiveUserInteraction(double seconds); 46 static void setReducedTimestampResolution(double seconds); 47 static void fireDataModificationHandler(); 48 static void setNotifyPagesWhenDataRecordsWereScanned(bool); 49 static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value); 50 static void setMinimumTimeBetweeenDataRecordsRemoval(double seconds); 51 static void resetToConsistentState(); 52 53 private: 44 bool classifyWithVectorThreshold(unsigned, unsigned, unsigned); 54 45 }; 55 46 56 } // namespace WebKit47 } -
trunk/Source/WebKit2/Platform/classifier/cocoa/CorePredictionSoftLink.h
r212948 r212949 26 26 #pragma once 27 27 28 #include "APIObject.h"28 #include <WebCore/SoftLinking.h> 29 29 30 #include <wtf/RefPtr.h> 31 #include <wtf/text/WTFString.h> 32 33 namespace WebKit { 34 35 class WebResourceLoadStatisticsManager : public API::ObjectImpl<API::Object::Type::WebResourceLoadStatisticsManager> { 36 public: 37 static Ref<WebResourceLoadStatisticsManager> create() 38 { 39 return adoptRef(*new WebResourceLoadStatisticsManager()); 40 } 41 static void setPrevalentResource(const String& hostName, bool value); 42 static bool isPrevalentResource(const String& hostName); 43 static void setHasHadUserInteraction(const String& hostName, bool value); 44 static bool hasHadUserInteraction(const String& hostName); 45 static void setTimeToLiveUserInteraction(double seconds); 46 static void setReducedTimestampResolution(double seconds); 47 static void fireDataModificationHandler(); 48 static void setNotifyPagesWhenDataRecordsWereScanned(bool); 49 static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value); 50 static void setMinimumTimeBetweeenDataRecordsRemoval(double seconds); 51 static void resetToConsistentState(); 52 53 private: 30 struct svm_model; 31 struct svm_node { 32 int index; 33 double value; 54 34 }; 55 35 56 } // namespace WebKit 36 SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(CorePrediction) 37 SOFT_LINK(CorePrediction, svm_predict_values, double, (const struct svm_model *model, const struct svm_node *x, double* dec_values), (model, x, dec_values)) 38 SOFT_LINK(CorePrediction, svm_load_model, svm_model*, (const char *model_file_name), (model_file_name)) -
trunk/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h
r212948 r212949 26 26 #pragma once 27 27 28 #include "APIObject.h" 28 #include "ResourceLoadStatisticsClassifier.h" 29 #include <wtf/Platform.h> 30 #include <wtf/text/WTFString.h> 29 31 30 #include <wtf/RefPtr.h> 31 #include <wtf/text/WTFString.h> 32 struct svm_model; 32 33 33 34 namespace WebKit { 34 35 35 class WebResourceLoadStatisticsManager : public API::ObjectImpl<API::Object::Type::WebResourceLoadStatisticsManager> { 36 public: 37 static Ref<WebResourceLoadStatisticsManager> create() 38 { 39 return adoptRef(*new WebResourceLoadStatisticsManager()); 40 } 41 static void setPrevalentResource(const String& hostName, bool value); 42 static bool isPrevalentResource(const String& hostName); 43 static void setHasHadUserInteraction(const String& hostName, bool value); 44 static bool hasHadUserInteraction(const String& hostName); 45 static void setTimeToLiveUserInteraction(double seconds); 46 static void setReducedTimestampResolution(double seconds); 47 static void fireDataModificationHandler(); 48 static void setNotifyPagesWhenDataRecordsWereScanned(bool); 49 static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value); 50 static void setMinimumTimeBetweeenDataRecordsRemoval(double seconds); 51 static void resetToConsistentState(); 52 36 class ResourceLoadStatisticsClassifierCocoa : public ResourceLoadStatisticsClassifier { 53 37 private: 38 bool classify(unsigned, unsigned, unsigned) override; 39 String storagePath(); 40 bool canUseCorePrediction(); 41 const struct svm_model* singletonPredictionModel(); 42 bool m_useCorePrediction { true }; 43 bool m_haveLoadedModel { false }; 54 44 }; 55 56 } // namespace WebKit45 46 } -
trunk/Source/WebKit2/PlatformGTK.cmake
r212841 r212949 46 46 Platform/IPC/unix/AttachmentUnix.cpp 47 47 Platform/IPC/unix/ConnectionUnix.cpp 48 49 Platform/classifier/ResourceLoadStatisticsClassifier.cpp 48 50 49 51 Platform/glib/ModuleGlib.cpp … … 866 868 "${WEBKIT2_DIR}/NetworkProcess/unix" 867 869 "${WEBKIT2_DIR}/Platform/IPC/glib" 870 "${WEBKIT2_DIR}/Platform/classifier" 868 871 "${WEBKIT2_DIR}/Shared/API/c/gtk" 869 872 "${WEBKIT2_DIR}/Shared/CoordinatedGraphics" -
trunk/Source/WebKit2/PlatformMac.cmake
r212841 r212949 49 49 50 50 Platform/cg/CGUtilities.cpp 51 52 Platform/classifier/ResourceLoadStatisticsClassifier.cpp 53 54 Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp 51 55 52 56 Platform/foundation/LoggingFoundation.mm … … 392 396 "${WEBKIT2_DIR}/UIProcess/ios" 393 397 "${WEBKIT2_DIR}/Platform/cg" 398 "${WEBKIT2_DIR}/Platform/classifier" 399 "${WEBKIT2_DIR}/Platform/classifier/cocoa" 394 400 "${WEBKIT2_DIR}/Platform/mac" 395 401 "${WEBKIT2_DIR}/Platform/unix" -
trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp
r212841 r212949 57 57 } 58 58 59 void WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName) 60 { 61 WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin(toWTFString(hostName), toWTFString(topFrameHostName)); 62 } 63 64 void WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName) 65 { 66 WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin(toWTFString(hostName), toWTFString(topFrameHostName)); 67 } 68 69 void WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo) 70 { 71 WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(toWTFString(hostName), toWTFString(hostNameRedirectedTo)); 72 } 73 59 74 void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds) 60 75 { -
trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h
r212841 r212949 39 39 WK_EXPORT void WKResourceLoadStatisticsManagerSetHasHadUserInteraction(WKStringRef hostName, bool value); 40 40 WK_EXPORT bool WKResourceLoadStatisticsManagerIsHasHadUserInteraction(WKStringRef hostName); 41 WK_EXPORT void WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName); 42 WK_EXPORT void WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName); 43 WK_EXPORT void WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo); 41 44 WK_EXPORT void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds); 42 45 WK_EXPORT void WKResourceLoadStatisticsManagerSetReducedTimestampResolution(double seconds); -
trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp
r212841 r212949 62 62 } 63 63 64 void WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName) 65 { 66 WebCore::ResourceLoadObserver::sharedObserver().setSubframeUnderTopFrameOrigin(URL(URL(), hostName), URL(URL(), topFrameHostName)); 67 } 68 69 void WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName) 70 { 71 WebCore::ResourceLoadObserver::sharedObserver().setSubresourceUnderTopFrameOrigin(URL(URL(), hostName), URL(URL(), topFrameHostName)); 72 } 73 74 void WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo) 75 { 76 WebCore::ResourceLoadObserver::sharedObserver().setSubresourceUniqueRedirectTo(URL(URL(), hostName), URL(URL(), hostNameRedirectedTo)); 77 } 78 64 79 void WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(double seconds) 65 80 { -
trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h
r212841 r212949 43 43 static void setHasHadUserInteraction(const String& hostName, bool value); 44 44 static bool hasHadUserInteraction(const String& hostName); 45 static void setSubframeUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName); 46 static void setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName); 47 static void setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo); 45 48 static void setTimeToLiveUserInteraction(double seconds); 46 49 static void setReducedTimestampResolution(double seconds); -
trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp
r212841 r212949 46 46 namespace WebKit { 47 47 48 static const auto featureVectorLengthThreshold = 3;49 48 static auto minimumTimeBetweeenDataRecordsRemoval = 60; 50 49 static OptionSet<WebKit::WebsiteDataType> dataTypesToRemove; … … 60 59 : m_resourceLoadStatisticsStore(ResourceLoadStatisticsStore::create()) 61 60 , m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue")) 62 , m_st oragePath(resourceLoadStatisticsDirectory)61 , m_statisticsStoragePath(resourceLoadStatisticsDirectory) 63 62 { 64 63 } … … 84 83 } 85 84 86 bool WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics(const ResourceLoadStatistics& resourceStatistic)87 {88 auto subresourceUnderTopFrameOriginsCount = resourceStatistic.subresourceUnderTopFrameOrigins.size();89 auto subresourceUniqueRedirectsToCount = resourceStatistic.subresourceUniqueRedirectsTo.size();90 auto subframeUnderTopFrameOriginsCount = resourceStatistic.subframeUnderTopFrameOrigins.size();91 92 if (!subresourceUnderTopFrameOriginsCount93 && !subresourceUniqueRedirectsToCount94 && !subframeUnderTopFrameOriginsCount)95 return false;96 97 if (subresourceUnderTopFrameOriginsCount > featureVectorLengthThreshold98 || subresourceUniqueRedirectsToCount > featureVectorLengthThreshold99 || subframeUnderTopFrameOriginsCount > featureVectorLengthThreshold)100 return true;101 102 // The resource is considered prevalent if the feature vector103 // is longer than the threshold.104 // Vector length for n dimensions is sqrt(a^2 + (...) + n^2).105 double vectorLength = 0;106 vectorLength += subresourceUnderTopFrameOriginsCount * subresourceUnderTopFrameOriginsCount;107 vectorLength += subresourceUniqueRedirectsToCount * subresourceUniqueRedirectsToCount;108 vectorLength += subframeUnderTopFrameOriginsCount * subframeUnderTopFrameOriginsCount;109 110 ASSERT(vectorLength > 0);111 112 return sqrt(vectorLength) > featureVectorLengthThreshold;113 }114 115 85 void WebResourceLoadStatisticsStore::classifyResource(ResourceLoadStatistics& resourceStatistic) 116 86 { 117 if (!resourceStatistic.isPrevalentResource && hasPrevalentResourceCharacteristics(resourceStatistic)) { 87 if (!resourceStatistic.isPrevalentResource 88 && m_resourceLoadStatisticsClassifier.hasPrevalentResourceCharacteristics(resourceStatistic)) 118 89 resourceStatistic.isPrevalentResource = true; 119 }120 90 } 121 91 … … 250 220 String WebResourceLoadStatisticsStore::persistentStoragePath(const String& label) const 251 221 { 252 if (m_st oragePath.isEmpty())222 if (m_statisticsStoragePath.isEmpty()) 253 223 return emptyString(); 254 224 255 225 // TODO Decide what to call this file 256 return pathByAppendingComponent(m_st oragePath, label + "_resourceLog.plist");226 return pathByAppendingComponent(m_statisticsStoragePath, label + "_resourceLog.plist"); 257 227 } 258 228 … … 267 237 return; 268 238 269 if (!m_st oragePath.isEmpty())270 makeAllDirectories(m_st oragePath);239 if (!m_statisticsStoragePath.isEmpty()) 240 makeAllDirectories(m_statisticsStoragePath); 271 241 272 242 auto handle = openFile(resourceLog, OpenForWrite); -
trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h
r212841 r212949 24 24 */ 25 25 26 #ifndef WebResourceLoadStatisticsStore_h 27 #define WebResourceLoadStatisticsStore_h 26 #pragma once 28 27 29 28 #include "APIObject.h" 30 29 #include "Connection.h" 30 #include "ResourceLoadStatisticsClassifier.h" 31 31 #include "WebsiteDataRecord.h" 32 32 #include <WebCore/ResourceLoadStatisticsStore.h> 33 33 #include <wtf/Vector.h> 34 34 #include <wtf/text/WTFString.h> 35 36 #if PLATFORM(COCOA) 37 #include "ResourceLoadStatisticsClassifierCocoa.h" 38 #endif 35 39 36 40 namespace WTF { … … 77 81 void processStatisticsAndDataRecords(); 78 82 79 bool hasPrevalentResourceCharacteristics(const WebCore::ResourceLoadStatistics&);80 83 void classifyResource(WebCore::ResourceLoadStatistics&); 81 84 void removeDataRecords(); … … 90 93 91 94 Ref<WebCore::ResourceLoadStatisticsStore> m_resourceLoadStatisticsStore; 95 #if PLATFORM(COCOA) 96 ResourceLoadStatisticsClassifierCocoa m_resourceLoadStatisticsClassifier; 97 #else 98 ResourceLoadStatisticsClassifier m_resourceLoadStatisticsClassifier; 99 #endif 92 100 Ref<WTF::WorkQueue> m_statisticsQueue; 93 String m_st oragePath;101 String m_statisticsStoragePath; 94 102 bool m_resourceLoadStatisticsEnabled { false }; 95 103 … … 99 107 100 108 } // namespace WebKit 101 102 #endif // WebResourceLoadStatisticsStore_h -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r212929 r212949 1148 1148 659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; }; 1149 1149 65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1150 6B2E09BA1E57B88100C8A8B9 /* CorePredictionSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */; }; 1150 1151 6BE9699C1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1151 1152 6BE9699E1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */; }; 1152 1153 6BE969A01E43B86E008B7483 /* WebResourceLoadStatisticsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE9699F1E43B86E008B7483 /* WebResourceLoadStatisticsManager.h */; }; 1153 1154 6BE969A21E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969A11E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp */; }; 1155 6BE969C11E54D452008B7483 /* corePrediction_model in Resources */ = {isa = PBXBuildFile; fileRef = 6BE969C01E54D452008B7483 /* corePrediction_model */; }; 1156 6BE969C71E54D4B6008B7483 /* ResourceLoadStatisticsClassifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifier.cpp */; }; 1157 6BE969CA1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */; }; 1158 6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */; }; 1159 6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h */; }; 1154 1160 6EE849C81368D9390038D481 /* WKInspectorPrivateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE849C61368D92D0038D481 /* WKInspectorPrivateMac.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1155 1161 728E86F11795188C0087879E /* WebColorPickerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 728E86EF1795188C0087879E /* WebColorPickerMac.h */; }; … … 3343 3349 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleInspector.cpp; sourceTree = "<group>"; }; 3344 3350 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleInspector.h; sourceTree = "<group>"; }; 3351 6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorePredictionSoftLink.h; sourceTree = "<group>"; }; 3345 3352 6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKResourceLoadStatisticsManager.h; sourceTree = "<group>"; }; 3346 3353 6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKResourceLoadStatisticsManager.cpp; sourceTree = "<group>"; }; 3347 3354 6BE9699F1E43B86E008B7483 /* WebResourceLoadStatisticsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebResourceLoadStatisticsManager.h; sourceTree = "<group>"; }; 3348 3355 6BE969A11E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebResourceLoadStatisticsManager.cpp; sourceTree = "<group>"; }; 3356 6BE969C01E54D452008B7483 /* corePrediction_model */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = corePrediction_model; sourceTree = "<group>"; }; 3357 6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsClassifier.cpp; sourceTree = "<group>"; }; 3358 6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsClassifierCocoa.cpp; sourceTree = "<group>"; }; 3359 6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsClassifierCocoa.h; sourceTree = "<group>"; }; 3360 6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsClassifier.h; sourceTree = "<group>"; }; 3349 3361 6D8A91A511F0EFD100DD01FE /* com.apple.WebProcess.sb.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = com.apple.WebProcess.sb.in; path = WebProcess/com.apple.WebProcess.sb.in; sourceTree = "<group>"; }; 3350 3362 6EE849C61368D92D0038D481 /* WKInspectorPrivateMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKInspectorPrivateMac.h; path = mac/WKInspectorPrivateMac.h; sourceTree = "<group>"; }; … … 4365 4377 isa = PBXGroup; 4366 4378 children = ( 4379 6BE969BF1E54D452008B7483 /* ResourceLoadStatistics */, 4367 4380 37F8C94F1AE22BD8007DAB9E /* mac */, 4368 4381 7CB16FE11724B9B5007A0A95 /* PlugInSandboxProfiles */, … … 6130 6143 sourceTree = "<group>"; 6131 6144 }; 6145 6BE969BF1E54D452008B7483 /* ResourceLoadStatistics */ = { 6146 isa = PBXGroup; 6147 children = ( 6148 6BE969C01E54D452008B7483 /* corePrediction_model */, 6149 ); 6150 name = ResourceLoadStatistics; 6151 path = Resources/ResourceLoadStatistics; 6152 sourceTree = "<group>"; 6153 }; 6154 6BE969C21E54D467008B7483 /* classifier */ = { 6155 isa = PBXGroup; 6156 children = ( 6157 6BE969C31E54D467008B7483 /* cocoa */, 6158 6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifier.cpp */, 6159 6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h */, 6160 ); 6161 path = classifier; 6162 sourceTree = "<group>"; 6163 }; 6164 6BE969C31E54D467008B7483 /* cocoa */ = { 6165 isa = PBXGroup; 6166 children = ( 6167 6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */, 6168 6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */, 6169 6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */, 6170 ); 6171 path = cocoa; 6172 sourceTree = "<group>"; 6173 }; 6132 6174 6EE849C41368D9040038D481 /* mac */ = { 6133 6175 isa = PBXGroup; … … 7031 7073 isa = PBXGroup; 7032 7074 children = ( 7075 6BE969C21E54D467008B7483 /* classifier */, 7033 7076 3709504118A88BA40087AE5D /* cf */, 7034 7077 1AA2E51A12E4C05600BC4966 /* cg */, … … 7914 7957 7C1BA33E1A4A0E600043E249 /* APIDictionary.h in Headers */, 7915 7958 1F7D36C118DA513F00D9D659 /* APIDownloadClient.h in Headers */, 7959 6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */, 7916 7960 516A4A5D120A2CCD00C05B7F /* APIError.h in Headers */, 7917 7961 317FE7C51C487A6C00A0CA89 /* APIExperimentalFeature.h in Headers */, … … 8421 8465 7C4694D11A51E36800AD5845 /* WebPasteboardProxy.h in Headers */, 8422 8466 7C4694CA1A4B4EA100AD5845 /* WebPasteboardProxyMessages.h in Headers */, 8467 6B2E09BA1E57B88100C8A8B9 /* CorePredictionSoftLink.h in Headers */, 8423 8468 1AB1F7971D1B3613007C9BD1 /* WebPaymentCoordinatorMessages.h in Headers */, 8424 8469 1AB1F78C1D1B3355007C9BD1 /* WebPaymentCoordinatorProxy.h in Headers */, … … 8539 8584 1AB474D8184D43FD0051B622 /* WKBundlePageLoaderClient.h in Headers */, 8540 8585 ED82A7F2128C6FAF004477B3 /* WKBundlePageOverlay.h in Headers */, 8586 6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */, 8541 8587 1AB474EA184D45130051B622 /* WKBundlePagePolicyClient.h in Headers */, 8542 8588 BC1B419811D41D570011E8DD /* WKBundlePagePrivate.h in Headers */, … … 9072 9118 8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */, 9073 9119 93A2A3461D246125002B59D3 /* mediaIcon.pdf in Resources */, 9120 6BE969C11E54D452008B7483 /* corePrediction_model in Resources */, 9074 9121 ); 9075 9122 runOnlyForDeploymentPostprocessing = 0; … … 9659 9706 5163199416289A6000E22F00 /* NetworkProcessMessageReceiver.cpp in Sources */, 9660 9707 E14A954916E016A40068DE82 /* NetworkProcessPlatformStrategies.cpp in Sources */, 9708 6BE969CA1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp in Sources */, 9661 9709 5179556D162877B100FA43B6 /* NetworkProcessProxy.cpp in Sources */, 9662 9710 516319921628980A00E22F00 /* NetworkProcessProxyMac.mm in Sources */, … … 10003 10051 BCC43AC7127B99DE00317F16 /* WebPopupMenuMac.mm in Sources */, 10004 10052 BC5750981268F3C6006F0F12 /* WebPopupMenuProxyMac.mm in Sources */, 10053 6BE969C71E54D4B6008B7483 /* ResourceLoadStatisticsClassifier.cpp in Sources */, 10005 10054 BCD59800112B57BE00EC8C23 /* WebPreferences.cpp in Sources */, 10006 10055 7C85FD7F19341665000177C4 /* WebPreferencesKeys.cpp in Sources */, -
trunk/Tools/ChangeLog
r212945 r212949 1 2017-02-24 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Add alternate classification method 4 https://bugs.webkit.org/show_bug.cgi?id=168347 5 <rdar://problem/30352793> 6 <rdar://problem/30646710> 7 <rdar://problem/30660708> 8 9 Reviewed by Alex Christensen. 10 11 Added three testRunner functions to facilitate layout tests: 12 - setStatisticsSubframeUnderTopFrameOrigin() 13 - setStatisticsSubresourceUnderTopFrameOrigin() 14 - setStatisticsSubresourceUniqueRedirectTo() 15 16 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 17 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 18 (WTR::TestRunner::setStatisticsSubframeUnderTopFrameOrigin): 19 (WTR::TestRunner::setStatisticsSubresourceUnderTopFrameOrigin): 20 (WTR::TestRunner::setStatisticsSubresourceUniqueRedirectTo): 21 * WebKitTestRunner/InjectedBundle/TestRunner.h: 22 * WebKitTestRunner/TestController.cpp: 23 (WTR::TestController::setStatisticsSubframeUnderTopFrameOrigin): 24 (WTR::TestController::setStatisticsSubresourceUnderTopFrameOrigin): 25 (WTR::TestController::setStatisticsSubresourceUniqueRedirectTo): 26 * WebKitTestRunner/TestController.h: 27 * WebKitTestRunner/TestInvocation.cpp: 28 (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): 29 1 30 2017-02-23 Joseph Pecoraro <pecoraro@apple.com> 2 31 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r212841 r212949 254 254 void setStatisticsHasHadUserInteraction(DOMString hostName, boolean value); 255 255 boolean isStatisticsHasHadUserInteraction(DOMString hostName); 256 void setStatisticsSubframeUnderTopFrameOrigin(DOMString hostName, DOMString topFrameHostName); 257 void setStatisticsSubresourceUnderTopFrameOrigin(DOMString hostName, DOMString topFrameHostName); 258 void setStatisticsSubresourceUniqueRedirectTo(DOMString hostName, DOMString hostNameRedirectedTo); 256 259 void setStatisticsTimeToLiveUserInteraction(double seconds); 257 260 void statisticsFireDataModificationHandler(); -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r212841 r212949 1227 1227 } 1228 1228 1229 void TestRunner::setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName) 1230 { 1231 Vector<WKRetainPtr<WKStringRef>> keys; 1232 Vector<WKRetainPtr<WKTypeRef>> values; 1233 1234 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") }); 1235 values.append({ AdoptWK, WKStringCreateWithJSString(hostName) }); 1236 1237 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName") }); 1238 values.append({ AdoptWK, WKStringCreateWithJSString(topFrameHostName) }); 1239 1240 Vector<WKStringRef> rawKeys(keys.size()); 1241 Vector<WKTypeRef> rawValues(values.size()); 1242 1243 for (size_t i = 0; i < keys.size(); ++i) { 1244 rawKeys[i] = keys[i].get(); 1245 rawValues[i] = values[i].get(); 1246 } 1247 1248 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubframeUnderTopFrameOrigin")); 1249 WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size())); 1250 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1251 } 1252 1253 void TestRunner::setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName) 1254 { 1255 Vector<WKRetainPtr<WKStringRef>> keys; 1256 Vector<WKRetainPtr<WKTypeRef>> values; 1257 1258 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") }); 1259 values.append({ AdoptWK, WKStringCreateWithJSString(hostName) }); 1260 1261 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName") }); 1262 values.append({ AdoptWK, WKStringCreateWithJSString(topFrameHostName) }); 1263 1264 Vector<WKStringRef> rawKeys(keys.size()); 1265 Vector<WKTypeRef> rawValues(values.size()); 1266 1267 for (size_t i = 0; i < keys.size(); ++i) { 1268 rawKeys[i] = keys[i].get(); 1269 rawValues[i] = values[i].get(); 1270 } 1271 1272 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubresourceUnderTopFrameOrigin")); 1273 WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size())); 1274 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1275 } 1276 1277 void TestRunner::setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo) 1278 { 1279 Vector<WKRetainPtr<WKStringRef>> keys; 1280 Vector<WKRetainPtr<WKTypeRef>> values; 1281 1282 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") }); 1283 values.append({ AdoptWK, WKStringCreateWithJSString(hostName) }); 1284 1285 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedTo") }); 1286 values.append({ AdoptWK, WKStringCreateWithJSString(hostNameRedirectedTo) }); 1287 1288 Vector<WKStringRef> rawKeys(keys.size()); 1289 Vector<WKTypeRef> rawValues(values.size()); 1290 1291 for (size_t i = 0; i < keys.size(); ++i) { 1292 rawKeys[i] = keys[i].get(); 1293 rawValues[i] = values[i].get(); 1294 } 1295 1296 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubresourceUniqueRedirectTo")); 1297 WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size())); 1298 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1299 } 1300 1229 1301 void TestRunner::setStatisticsTimeToLiveUserInteraction(double seconds) 1230 1302 { -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r212841 r212949 355 355 void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value); 356 356 bool isStatisticsHasHadUserInteraction(JSStringRef hostName); 357 void setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName); 358 void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName); 359 void setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo); 357 360 void setStatisticsTimeToLiveUserInteraction(double seconds); 358 361 void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool); -
trunk/Tools/WebKitTestRunner/TestController.cpp
r212878 r212949 2230 2230 } 2231 2231 2232 void TestController::setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName) 2233 { 2234 WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(hostName, topFrameHostName); 2235 } 2236 2237 void TestController::setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName) 2238 { 2239 WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(hostName, topFrameHostName); 2240 } 2241 2242 void TestController::setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo) 2243 { 2244 WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(hostName, hostNameRedirectedTo); 2245 } 2246 2232 2247 void TestController::setStatisticsTimeToLiveUserInteraction(double seconds) 2233 2248 { -
trunk/Tools/WebKitTestRunner/TestController.h
r212841 r212949 153 153 void setStatisticsHasHadUserInteraction(WKStringRef hostName, bool value); 154 154 bool isStatisticsHasHadUserInteraction(WKStringRef hostName); 155 void setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName); 156 void setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName); 157 void setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo); 155 158 void setStatisticsTimeToLiveUserInteraction(double seconds); 156 159 void statisticsFireDataModificationHandler(); -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r212841 r212949 933 933 } 934 934 935 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubframeUnderTopFrameOrigin")) { 936 ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); 937 938 WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); 939 WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName")); 940 WKRetainPtr<WKStringRef> topFrameHostNameKey(AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName")); 941 942 WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get())); 943 WKStringRef topFrameHostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, topFrameHostNameKey.get())); 944 945 TestController::singleton().setStatisticsSubframeUnderTopFrameOrigin(hostName, topFrameHostName); 946 return nullptr; 947 } 948 949 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubresourceUnderTopFrameOrigin")) { 950 ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); 951 952 WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); 953 WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName")); 954 WKRetainPtr<WKStringRef> topFrameHostNameKey(AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName")); 955 956 WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get())); 957 WKStringRef topFrameHostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, topFrameHostNameKey.get())); 958 959 TestController::singleton().setStatisticsSubresourceUnderTopFrameOrigin(hostName, topFrameHostName); 960 return nullptr; 961 } 962 963 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubresourceUniqueRedirectTo")) { 964 ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); 965 966 WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); 967 WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName")); 968 WKRetainPtr<WKStringRef> hostNameRedirectedToKey(AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedTo")); 969 970 WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get())); 971 WKStringRef hostNameRedirectedTo = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameRedirectedToKey.get())); 972 973 TestController::singleton().setStatisticsSubresourceUniqueRedirectTo(hostName, hostNameRedirectedTo); 974 return nullptr; 975 } 976 935 977 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsTimeToLiveUserInteraction")) { 936 978 ASSERT(WKGetTypeID(messageBody) == WKDoubleGetTypeID());
Note: See TracChangeset
for help on using the changeset viewer.