Resource Load Statistics: Add alternate classification method
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2017 22:40:28 +0000 (22:40 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2017 22:40:28 +0000 (22:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168347
<rdar://problem/30352793>

Reviewed by Alex Christensen.

Source/WebCore:

This patch only adds test infrastructure in WebCore.

Tests: http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html
       http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html
       http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html
       http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html
       http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html
       http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html
       http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html
       http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html

* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::setSubframeUnderTopFrameOrigin):
(WebCore::ResourceLoadObserver::setSubresourceUnderTopFrameOrigin):
(WebCore::ResourceLoadObserver::setSubresourceUniqueRedirectTo):
* loader/ResourceLoadObserver.h:

Source/WebKit2:

This patch adds a CorePrediction-based classifier to the WebResourceLoadStatisticsStore.
The CorePrediction framework is introduced as a dependency for macOS and iOS. The patch
also adds functions to support layout tests of the feature.

* Configurations/BaseTarget.xcconfig:
* Configurations/WebKit.xcconfig:
    Added dependency on CorePrediction.
* Platform/classifier: Added.
* Platform/classifier/ResourceLoadStatisticsClassifier.h: Added.
    Pulls in the Cocoa-specific classifier for Cocoa-based platforms.
(WebKit::ResourceLoadStatisticsClassifier::ResourceLoadStatisticsClassifier):
* Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp: Added.
(WebKit::ResourceLoadStatisticsClassifierBase::hasPrevalentResourceCharacteristics):
    Shared classifier logic.
(WebKit::ResourceLoadStatisticsClassifierBase::classifyWithVectorThreshold):
    Fallback classifier for when we don't have CorePrediction.
* Platform/classifier/ResourceLoadStatisticsClassifierBase.h: Added.
(WebKit::ResourceLoadStatisticsClassifierBase::ResourceLoadStatisticsClassifierBase):
(WebKit::ResourceLoadStatisticsClassifierBase::~ResourceLoadStatisticsClassifierBase):
* Platform/classifier/cocoa: Added.
* Platform/classifier/cocoa/CorePredictionSPI.h: Added.
    Includes CorePrediction if available, otherwise declares needed symbols.
    Always redeclares the functions so we'll get a build error if
    CorePrediction changes.
* Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp: Added.
(WebKit::ResourceLoadStatisticsClassifier::classify):
(WebKit::ResourceLoadStatisticsClassifier::storagePath):
(WebKit::ResourceLoadStatisticsClassifier::shouldUseCorePrediction):
    The new classifier for Cocoa platforms.
* Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h: Added.
(WebKit::ResourceLoadStatisticsClassifier::ResourceLoadStatisticsClassifier):
* PlatformGTK.cmake:
   Added Platform/classifier directory and ResourceLoadStatisticsClassifierBase.cpp.
* PlatformMac.cmake:
   Added Platform/classifier and Platform/classifier/cocoa directories, and
   source files ResourceLoadStatisticsClassifierBase.cpp and
   ResourceLoadStatisticsClassifierCocoa.cpp
* Resources/ResourceLoadStatistics: Added.
* Resources/ResourceLoadStatistics/corePrediction_model: Added.
    Model file to load into CorePrediction.
* UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
(WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin):
(WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin):
(WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo):
    Test infrastructure.
* UIProcess/API/C/WKResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsManager.cpp:
(WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin):
(WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin):
(WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo):
    Test infrastructure.
* UIProcess/WebResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
    Renamed m_storagePath to m_statisticsStoragePath for clarity.
(WebKit::WebResourceLoadStatisticsStore::classifyResource):
    Now calls the classifier through its ResourceLoadStatisticsClassifier
    member variable.
(WebKit::WebResourceLoadStatisticsStore::persistentStoragePath):
    Renamed m_storagePath to m_statisticsStoragePath for clarity.
(WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
    Renamed m_storagePath to m_statisticsStoragePath for clarity.
(WebKit::WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics): Deleted.
* UIProcess/WebResourceLoadStatisticsStore.h:
* WebKit2.xcodeproj/project.pbxproj:
    Added the new classifier source files under Platform/classifier and the
    corePrediction_model file under Resources/ResourceLoadStatistics.

Source/WTF:

* wtf/Platform.h:
    Added support for HAVE(CORE_PREDICTION).

Tools:

Added three testRunner functions to facilitate layout tests:
- setStatisticsSubframeUnderTopFrameOrigin()
- setStatisticsSubresourceUnderTopFrameOrigin()
- setStatisticsSubresourceUniqueRedirectTo()

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setStatisticsSubframeUnderTopFrameOrigin):
(WTR::TestRunner::setStatisticsSubresourceUnderTopFrameOrigin):
(WTR::TestRunner::setStatisticsSubresourceUniqueRedirectTo):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setStatisticsSubframeUnderTopFrameOrigin):
(WTR::TestController::setStatisticsSubresourceUnderTopFrameOrigin):
(WTR::TestController::setStatisticsSubresourceUniqueRedirectTo):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

WebKitLibraries:

* WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework: Added.
* WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework/CorePrediction.tbd: Added.
    Stubs for private framework.

LayoutTests:

* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html: Added.
* platform/gtk/TestExpectations:
    The whole http/tests/loading/resourceLoadStatistics marked as crashing based on
    Carlos Garcia Campos's assessment in https://bugs.webkit.org/show_bug.cgi?id=168171.
* platform/wk2/TestExpectations:
    The above tests are only valid for WebKit2. Marked as [ Pass ].

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212757 268f45cc-cd09-0410-ab3c-d52691b4dbfc

52 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html [new file with mode: 0644]
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/wk2/TestExpectations
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoadObserver.cpp
Source/WebCore/loader/ResourceLoadObserver.h
Source/WebKit2/ChangeLog
Source/WebKit2/Configurations/BaseTarget.xcconfig
Source/WebKit2/Configurations/WebKit.xcconfig
Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifier.h [new file with mode: 0644]
Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp [new file with mode: 0644]
Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifierBase.h [new file with mode: 0644]
Source/WebKit2/Platform/classifier/cocoa/CorePredictionSPI.h [new file with mode: 0644]
Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp [new file with mode: 0644]
Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h [new file with mode: 0644]
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/PlatformMac.cmake
Source/WebKit2/Resources/ResourceLoadStatistics/corePrediction_model [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework/CorePrediction.tbd [new file with mode: 0644]

index 741e2a5..b11a689 100644 (file)
@@ -1,3 +1,33 @@
+2017-02-21  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Add alternate classification method
+        https://bugs.webkit.org/show_bug.cgi?id=168347
+        <rdar://problem/30352793>
+
+        Reviewed by Alex Christensen.
+
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html: Added.
+        * platform/gtk/TestExpectations:
+            The whole http/tests/loading/resourceLoadStatistics marked as crashing based on
+            Carlos Garcia Campos's assessment in https://bugs.webkit.org/show_bug.cgi?id=168171.
+        * platform/wk2/TestExpectations:
+            The above tests are only valid for WebKit2. Marked as [ Pass ].
+
 2017-02-21  Romain Bellessort  <romain.bellessort@crf.canon.fr>
 
         [Readable Streams API] Add ReadableStreamBYOBRequest view getter
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt
new file mode 100644 (file)
index 0000000..1d28dd7
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Mixed Statistics
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host did not get classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html
new file mode 100644 (file)
index 0000000..f779fce
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Mixed Statistics</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host classified as prevalent resource.");
+        else
+            testPassed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt
new file mode 100644 (file)
index 0000000..ed0973a
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Sub Frame Under Top Frame Origins
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host did not get classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html
new file mode 100644 (file)
index 0000000..6360e7b
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Sub Frame Under Top Frame Origins</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host classified as prevalent resource.");
+        else
+            testPassed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt
new file mode 100644 (file)
index 0000000..60fa2af
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Subresource Under Top Frame Origins
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host did not get classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html
new file mode 100644 (file)
index 0000000..fd847fd
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Subresource Under Top Frame Origins</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host classified as prevalent resource.");
+        else
+            testPassed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt
new file mode 100644 (file)
index 0000000..9cf0948
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Subresource Unique Redirects To
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host did not get classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html
new file mode 100644 (file)
index 0000000..b49bbdc
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Subresource Unique Redirects To</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host classified as prevalent resource.");
+        else
+            testPassed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt
new file mode 100644 (file)
index 0000000..a294285
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Mixed Statistics
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html
new file mode 100644 (file)
index 0000000..a82423e
--- /dev/null
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Mixed Statistics</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt
new file mode 100644 (file)
index 0000000..8c97c93
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Sub Frame Under Top Frame Origins
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html
new file mode 100644 (file)
index 0000000..d638cee
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Sub Frame Under Top Frame Origins</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt
new file mode 100644 (file)
index 0000000..11d43bf
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Subresource Under Top Frame Origins
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html
new file mode 100644 (file)
index 0000000..42c3f2e
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Subresource Under Top Frame Origins</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt
new file mode 100644 (file)
index 0000000..f3a11ce
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Subresource Unique Redirects To
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html
new file mode 100644 (file)
index 0000000..8df85c2
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Subresource Unique Redirects To</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin4);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
index 12006c0..8ca6227 100644 (file)
@@ -931,11 +931,7 @@ webkit.org/b/131546 media/track/track-in-band.html [ Crash Timeout Failure ]
 
 webkit.org/b/163782 media/video-played-ranges-1.html [ Crash Pass ]
 
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html [ Crash ]
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html [ Crash ]
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html [ Crash ]
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction.html [ Crash ]
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html [ Crash ]
+webkit.org/b/168171 http/tests/loading/resourceLoadStatistics [ Crash ]
 
 webkit.org/b/167576 imported/w3c/IndexedDB-private-browsing/idbcursor_iterating.html [ Crash ]
 webkit.org/b/167576 imported/w3c/IndexedDB-private-browsing/idbcursor_iterating_index.html [ Crash ]
index 758b220..81c8def 100644 (file)
@@ -705,6 +705,14 @@ http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interacti
 http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html [ Pass Timeout ]
 http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html [ Pass Timeout ]
 http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html [ Pass Timeout ]
+http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html [ Pass ]
 
 ### END OF (5) Progressions, expected successes that are expected failures in WebKit1.
 ########################################
index 29397b2..6aa713d 100644 (file)
@@ -1,3 +1,14 @@
+2017-02-21  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Add alternate classification method
+        https://bugs.webkit.org/show_bug.cgi?id=168347
+        <rdar://problem/30352793>
+
+        Reviewed by Alex Christensen.
+
+        * wtf/Platform.h:
+            Added support for HAVE(CORE_PREDICTION).
+
 2017-02-21  Alex Christensen  <achristensen@webkit.org>
 
         Unreviewed, rolling out r212699.
index 6f82938..d88cfad 100644 (file)
 #endif
 #endif /* PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201 && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 */
 
+/* CorePrediction only exists on 64-bit platforms. */
+#if USE(JSVALUE64) && (PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200))
+#define HAVE_CORE_PREDICTION 1
+#endif
+
 #endif /* WTF_Platform_h */
index a221690..5caa6ae 100644 (file)
@@ -1,3 +1,28 @@
+2017-02-21  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Add alternate classification method
+        https://bugs.webkit.org/show_bug.cgi?id=168347
+        <rdar://problem/30352793>
+
+        Reviewed by Alex Christensen.
+
+        This patch only adds test infrastructure in WebCore.
+
+        Tests: http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html
+               http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html
+               http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html
+               http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html
+               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html
+               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html
+               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html
+               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html
+
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::ResourceLoadObserver::setSubframeUnderTopFrameOrigin):
+        (WebCore::ResourceLoadObserver::setSubresourceUnderTopFrameOrigin):
+        (WebCore::ResourceLoadObserver::setSubresourceUniqueRedirectTo):
+        * loader/ResourceLoadObserver.h:
+
 2017-02-21  Alex Christensen  <achristensen@webkit.org>
 
         Fix CMake build.
index 8d3da3b..1026dae 100644 (file)
@@ -375,6 +375,33 @@ void ResourceLoadObserver::clearPrevalentResource(const URL& url)
     statistics.isPrevalentResource = false;
 }
 
+void ResourceLoadObserver::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame)
+{
+    if (subframe.isBlankURL() || subframe.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
+        return;
+    
+    auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subframe));
+    statistics.subframeUnderTopFrameOrigins.add(primaryDomain(topFrame));
+}
+
+void ResourceLoadObserver::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame)
+{
+    if (subresource.isBlankURL() || subresource.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
+        return;
+    
+    auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subresource));
+    statistics.subresourceUnderTopFrameOrigins.add(primaryDomain(topFrame));
+}
+
+void ResourceLoadObserver::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo)
+{
+    if (subresource.isBlankURL() || subresource.isEmpty() || hostNameRedirectedTo.isBlankURL() || hostNameRedirectedTo.isEmpty())
+        return;
+    
+    auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subresource));
+    statistics.subresourceUniqueRedirectsTo.add(primaryDomain(hostNameRedirectedTo));
+}
+
 void ResourceLoadObserver::setTimeToLiveUserInteraction(double seconds)
 {
     m_store->setTimeToLiveUserInteraction(seconds);
index c8cce7b..78449a7 100644 (file)
@@ -58,6 +58,10 @@ public:
     WEBCORE_EXPORT bool isPrevalentResource(const URL&);
     WEBCORE_EXPORT void clearPrevalentResource(const URL&);
 
+    WEBCORE_EXPORT void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame);
+    WEBCORE_EXPORT void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame);
+    WEBCORE_EXPORT void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo);
+
     WEBCORE_EXPORT void setTimeToLiveUserInteraction(double seconds);
     WEBCORE_EXPORT void setReducedTimestampResolution(double seconds);
 
index 7858532..ae2dc94 100644 (file)
@@ -1,3 +1,79 @@
+2017-02-21  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Add alternate classification method
+        https://bugs.webkit.org/show_bug.cgi?id=168347
+        <rdar://problem/30352793>
+
+        Reviewed by Alex Christensen.
+
+        This patch adds a CorePrediction-based classifier to the WebResourceLoadStatisticsStore.
+        The CorePrediction framework is introduced as a dependency for macOS and iOS. The patch
+        also adds functions to support layout tests of the feature.
+
+        * Configurations/BaseTarget.xcconfig:
+        * Configurations/WebKit.xcconfig:
+            Added dependency on CorePrediction.
+        * Platform/classifier: Added.
+        * Platform/classifier/ResourceLoadStatisticsClassifier.h: Added.
+            Pulls in the Cocoa-specific classifier for Cocoa-based platforms.
+        (WebKit::ResourceLoadStatisticsClassifier::ResourceLoadStatisticsClassifier):
+        * Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp: Added.
+        (WebKit::ResourceLoadStatisticsClassifierBase::hasPrevalentResourceCharacteristics):
+            Shared classifier logic.
+        (WebKit::ResourceLoadStatisticsClassifierBase::classifyWithVectorThreshold):
+            Fallback classifier for when we don't have CorePrediction.
+        * Platform/classifier/ResourceLoadStatisticsClassifierBase.h: Added.
+        (WebKit::ResourceLoadStatisticsClassifierBase::ResourceLoadStatisticsClassifierBase):
+        (WebKit::ResourceLoadStatisticsClassifierBase::~ResourceLoadStatisticsClassifierBase):
+        * Platform/classifier/cocoa: Added.
+        * Platform/classifier/cocoa/CorePredictionSPI.h: Added.
+            Includes CorePrediction if available, otherwise declares needed symbols.
+            Always redeclares the functions so we'll get a build error if
+            CorePrediction changes.
+        * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp: Added.
+        (WebKit::ResourceLoadStatisticsClassifier::classify):
+        (WebKit::ResourceLoadStatisticsClassifier::storagePath):
+        (WebKit::ResourceLoadStatisticsClassifier::shouldUseCorePrediction):
+            The new classifier for Cocoa platforms.
+        * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h: Added.
+        (WebKit::ResourceLoadStatisticsClassifier::ResourceLoadStatisticsClassifier):
+        * PlatformGTK.cmake:
+           Added Platform/classifier directory and ResourceLoadStatisticsClassifierBase.cpp.
+        * PlatformMac.cmake:
+           Added Platform/classifier and Platform/classifier/cocoa directories, and
+           source files ResourceLoadStatisticsClassifierBase.cpp and
+           ResourceLoadStatisticsClassifierCocoa.cpp
+        * Resources/ResourceLoadStatistics: Added.
+        * Resources/ResourceLoadStatistics/corePrediction_model: Added.
+            Model file to load into CorePrediction.
+        * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
+        (WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin):
+        (WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin):
+        (WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo):
+            Test infrastructure.
+        * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
+        * UIProcess/WebResourceLoadStatisticsManager.cpp:
+        (WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin):
+        (WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin):
+        (WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo):
+            Test infrastructure.
+        * UIProcess/WebResourceLoadStatisticsManager.h:
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
+            Renamed m_storagePath to m_statisticsStoragePath for clarity.
+        (WebKit::WebResourceLoadStatisticsStore::classifyResource):
+            Now calls the classifier through its ResourceLoadStatisticsClassifier
+            member variable.
+        (WebKit::WebResourceLoadStatisticsStore::persistentStoragePath):
+            Renamed m_storagePath to m_statisticsStoragePath for clarity.
+        (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
+            Renamed m_storagePath to m_statisticsStoragePath for clarity.
+        (WebKit::WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics): Deleted.
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+            Added the new classifier source files under Platform/classifier and the
+            corePrediction_model file under Resources/ResourceLoadStatistics.
+
 2017-02-21  Alex Christensen  <achristensen@webkit.org>
 
         Fix CMake build.
index cd90d0b..6bac75c 100644 (file)
@@ -32,7 +32,7 @@ WK_PRIVATE_FRAMEWORKS_DIR_[sdk=iphoneos*] = $(WK_PRIVATE_FRAMEWORKS_DIR_iphoneos
 WK_PRIVATE_FRAMEWORKS_DIR_iphoneos_YES = $(SRCROOT)/../../WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/$(WK_TARGET_IOS_VERSION_MAJOR);
 WK_PRIVATE_FRAMEWORKS_DIR_iphoneos_NO = $(PRODUCTION_FRAMEWORKS_DIR);
 
-FRAMEWORK_SEARCH_PATHS_base = "$(UMBRELLA_FRAMEWORKS_DIR)" $(FRAMEWORK_SEARCH_PATHS);
+FRAMEWORK_SEARCH_PATHS_base = "$(UMBRELLA_FRAMEWORKS_DIR)" /System/Library/PrivateFrameworks $(FRAMEWORK_SEARCH_PATHS);
 FRAMEWORK_SEARCH_PATHS[sdk=iphone*] = $(FRAMEWORK_SEARCH_PATHS_base) $(WK_PRIVATE_FRAMEWORKS_DIR);
 FRAMEWORK_SEARCH_PATHS = $(FRAMEWORK_SEARCH_PATHS_base);
 
index 4ec878a..a6b9698 100644 (file)
@@ -34,12 +34,14 @@ MODULEMAP_FILE[sdk=iphone*]=Modules/iOS.modulemap;
 INSTALL_PATH = $(WEBKIT_FRAMEWORKS_DIR);
 DYLIB_INSTALL_NAME_BASE = $(NORMAL_WEBKIT_FRAMEWORKS_DIR);
 
-FRAMEWORK_AND_LIBRARY_LDFLAGS_BASE_ios = -lobjc -framework AssertionServices -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CorePDF -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework UIKit -framework OpenGLES -framework MobileCoreServices -lMobileGestalt $(FRAMEWORK_AND_LIBRARY_LDFLAGS_PLATFORM_$(PLATFORM_NAME));
+FRAMEWORK_AND_LIBRARY_LDFLAGS_BASE_ios = -lobjc -framework AssertionServices -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CorePDF -framework CorePrediction -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework UIKit -framework OpenGLES -framework MobileCoreServices -lMobileGestalt $(FRAMEWORK_AND_LIBRARY_LDFLAGS_PLATFORM_$(PLATFORM_NAME));
 FRAMEWORK_AND_LIBRARY_LDFLAGS[sdk=iphoneos*] = $(FRAMEWORK_AND_LIBRARY_LDFLAGS_BASE_ios) -framework IOSurface;
 FRAMEWORK_AND_LIBRARY_LDFLAGS[sdk=iphonesimulator*] = $(FRAMEWORK_AND_LIBRARY_LDFLAGS_BASE_ios);
 FRAMEWORK_AND_LIBRARY_LDFLAGS_PLATFORM_iphoneos = ;
 FRAMEWORK_AND_LIBRARY_LDFLAGS_PLATFORM_iphonesimulator = ;
-FRAMEWORK_AND_LIBRARY_LDFLAGS[sdk=macosx*] = -framework ApplicationServices -framework Carbon -framework Cocoa -framework CoreServices -framework IOKit -framework CoreAudio -framework IOSurface -framework OpenGL;
+FRAMEWORK_AND_LIBRARY_LDFLAGS[sdk=macosx*] = -framework ApplicationServices -framework Carbon -framework Cocoa -framework CoreServices -framework IOKit -framework CoreAudio -framework IOSurface -framework OpenGL $(EXTRA_FRAMEWORK_AND_LIBRARY_LDFLAGS_$(TARGET_MAC_OS_X_VERSION_MAJOR));
+EXTRA_FRAMEWORK_AND_LIBRARY_LDFLAGS_101200 = -framework CorePrediction;
+EXTRA_FRAMEWORK_AND_LIBRARY_LDFLAGS_101300 = -framework CorePrediction;
 
 // Prevent C++ standard library operator new, delete and their related exception types from being exported as weak symbols.
 UNEXPORTED_SYMBOL_LDFLAGS = -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,__Znwm -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2EOS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1EOS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSEDn -Wl,-unexported_symbol, -Wl,__ZNKSt3__18functionIFvN7WebCore12PolicyActionEEEclES2_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEE4swapERS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1ERKS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2ERKS4_ -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEED1Ev -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEED2Ev -Wl,-unexported_symbol, -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSERKS4_ -Wl,-unexported_symbol, -Wl,__ZTVNSt3__117bad_function_callE;
diff --git a/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifier.h b/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifier.h
new file mode 100644 (file)
index 0000000..953a380
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2017 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 INC. 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 INC. 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.
+ */
+
+#pragma once
+
+#include <wtf/Platform.h>
+
+#if PLATFORM(COCOA)
+#include "ResourceLoadStatisticsClassifierCocoa.h"
+#else
+
+#include "ResourceLoadStatisticsClassifierBase.h"
+
+namespace WebKit {
+
+class ResourceLoadStatisticsClassifier : public ResourceLoadStatisticsClassifierBase {
+public:
+    ResourceLoadStatisticsClassifier()
+    : ResourceLoadStatisticsClassifierBase() { }
+    
+protected:
+    bool classify(const unsigned a, const unsigned b, const unsigned c) override
+    {
+        return classifyWithVectorThreshold(a, b, c);
+    }
+};
+
+}
+
+#endif
diff --git a/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp b/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp
new file mode 100644 (file)
index 0000000..a13e980
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2017 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 INC. 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 INC. 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 "ResourceLoadStatisticsClassifierBase.h"
+
+#include <WebCore/ResourceLoadStatistics.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const auto featureVectorLengthThreshold = 3;
+bool ResourceLoadStatisticsClassifierBase::hasPrevalentResourceCharacteristics(const ResourceLoadStatistics& resourceStatistic)
+{
+    auto subresourceUnderTopFrameOriginsCount = resourceStatistic.subresourceUnderTopFrameOrigins.size();
+    auto subresourceUniqueRedirectsToCount = resourceStatistic.subresourceUniqueRedirectsTo.size();
+    auto subframeUnderTopFrameOriginsCount = resourceStatistic.subframeUnderTopFrameOrigins.size();
+    
+    if (!subresourceUnderTopFrameOriginsCount
+        && !subresourceUniqueRedirectsToCount
+        && !subframeUnderTopFrameOriginsCount)
+        return false;
+    
+    if (subresourceUnderTopFrameOriginsCount > featureVectorLengthThreshold
+        || subresourceUniqueRedirectsToCount > featureVectorLengthThreshold
+        || subframeUnderTopFrameOriginsCount > featureVectorLengthThreshold)
+        return true;
+
+    return classify(subresourceUnderTopFrameOriginsCount, subresourceUniqueRedirectsToCount, subframeUnderTopFrameOriginsCount);
+}
+
+bool ResourceLoadStatisticsClassifierBase::classifyWithVectorThreshold(const unsigned a, const unsigned b, const unsigned c)
+{
+    return sqrt(a * a + b * b + c * c) > featureVectorLengthThreshold;
+}
+    
+}
diff --git a/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifierBase.h b/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifierBase.h
new file mode 100644 (file)
index 0000000..b8b23ff
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2017 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 INC. 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 INC. 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.
+ */
+
+#pragma once
+
+namespace WebCore {
+struct ResourceLoadStatistics;
+}
+
+namespace WebKit {
+
+class ResourceLoadStatisticsClassifierBase {
+public:
+    bool hasPrevalentResourceCharacteristics(const WebCore::ResourceLoadStatistics& resourceStatistic);
+protected:
+    ResourceLoadStatisticsClassifierBase() { }
+    virtual ~ResourceLoadStatisticsClassifierBase() { }
+    virtual bool classify(const unsigned, const unsigned, const unsigned) = 0;
+    bool classifyWithVectorThreshold(const unsigned, const unsigned, const unsigned);
+};
+
+}
diff --git a/Source/WebKit2/Platform/classifier/cocoa/CorePredictionSPI.h b/Source/WebKit2/Platform/classifier/cocoa/CorePredictionSPI.h
new file mode 100644 (file)
index 0000000..8a39a0a
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 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 INC. 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 INC. 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.
+ */
+
+#pragma once
+
+#if USE(APPLE_INTERNAL_SDK) && HAVE(CORE_PREDICTION)
+#include <CorePrediction/svm.h>
+#else
+
+struct svm_node {
+    int index;
+    double value;
+};
+
+struct svm_model { };
+
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+double svm_predict_values(const struct svm_model*, const struct svm_node*, double*);
+
+struct svm_model *svm_load_model(const char*);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp b/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp
new file mode 100644 (file)
index 0000000..5ef0e3e
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2017 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 INC. 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 INC. 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 "ResourceLoadStatisticsClassifierCocoa.h"
+
+#include "Logging.h"
+
+namespace WebKit {
+
+bool ResourceLoadStatisticsClassifier::classify(const unsigned subresourceUnderTopFrameOriginsCount, const unsigned subresourceUniqueRedirectsToCount, const unsigned subframeUnderTopFrameOriginsCount)
+{
+    if (!shouldUseCorePrediction())
+        return classifyWithVectorThreshold(subresourceUnderTopFrameOriginsCount, subresourceUniqueRedirectsToCount, subframeUnderTopFrameOriginsCount);
+
+#if HAVE(CORE_PREDICTION)
+    Vector<unsigned> nonZeroFeatures;
+    Vector<unsigned> indices;
+
+    if (subresourceUnderTopFrameOriginsCount) {
+        nonZeroFeatures.append(subresourceUnderTopFrameOriginsCount);
+        indices.append(1);
+    }
+    if (subresourceUniqueRedirectsToCount) {
+        nonZeroFeatures.append(subresourceUniqueRedirectsToCount);
+        indices.append(2);
+    }
+    if (subframeUnderTopFrameOriginsCount) {
+        nonZeroFeatures.append(subframeUnderTopFrameOriginsCount);
+        indices.append(3);
+    }
+
+    svm_node* exampleVector = new svm_node[nonZeroFeatures.size() + 1];
+    for (size_t i = 0; i < nonZeroFeatures.size(); i++) {
+        exampleVector[i].index = indices.at(i);
+        exampleVector[i].value = nonZeroFeatures.at(i);
+    }
+    // Add termination node with index -1.
+    exampleVector[nonZeroFeatures.size()].index = -1;
+    exampleVector[nonZeroFeatures.size()].value = -1;
+
+    int classification;
+    double score;
+    classification = svm_predict_values(m_corePredictionModel, exampleVector, &score);
+    delete[] exampleVector;
+    return classification < 0;
+#endif
+    return false;
+}
+
+String ResourceLoadStatisticsClassifier::storagePath()
+{
+    CFBundleRef webKitBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit"));
+    RetainPtr<CFURLRef> resourceUrl = adoptCF(CFBundleCopyResourcesDirectoryURL(webKitBundle));
+    resourceUrl = adoptCF(CFURLCreateCopyAppendingPathComponent(nullptr, resourceUrl.get(), CFSTR("corePrediction_model"), false));
+    CFErrorRef error = nullptr;
+    resourceUrl = adoptCF(CFURLCreateFilePathURL(nullptr, resourceUrl.get(), &error));
+
+    if (error || !resourceUrl)
+        return String();
+
+    RetainPtr<CFStringRef> resourceUrlString = adoptCF(CFURLCopyFileSystemPath(resourceUrl.get(), kCFURLPOSIXPathStyle));
+    return String(resourceUrlString.get());
+}
+
+bool ResourceLoadStatisticsClassifier::shouldUseCorePrediction()
+{
+#if HAVE(CORE_PREDICTION)
+    if (m_corePredictionModel)
+        return true;
+
+    if (!m_useCorePrediction)
+        return false;
+
+    String storagePathStr = storagePath();
+    if (storagePathStr.isNull() || storagePathStr.isEmpty()) {
+        m_useCorePrediction = false;
+        return false;
+    }
+
+    m_corePredictionModel = svm_load_model((storagePathStr).utf8().data());
+    
+    if (m_corePredictionModel)
+        return true;
+
+    WTFLogAlways("ResourceLoadStatisticsClassifier::shouldUseCorePrediction(): Couldn't load model file at path %s.", storagePathStr.utf8().data());
+    m_useCorePrediction = false;
+#endif
+    return false;
+}
+
+}
diff --git a/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h b/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h
new file mode 100644 (file)
index 0000000..2f532fb
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 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 INC. 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 INC. 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.
+ */
+
+#pragma once
+
+#if HAVE(CORE_PREDICTION)
+#include "CorePredictionSPI.h"
+#endif
+#include "ResourceLoadStatisticsClassifierBase.h"
+#include <CoreFoundation/CoreFoundation.h>
+#include <wtf/Platform.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+class ResourceLoadStatisticsClassifier : public ResourceLoadStatisticsClassifierBase {
+
+public:
+    ResourceLoadStatisticsClassifier()
+        : ResourceLoadStatisticsClassifierBase() { }
+
+private:
+    bool classify(const unsigned, const unsigned, const unsigned) override;
+    String storagePath();
+    bool shouldUseCorePrediction();
+#if HAVE(CORE_PREDICTION)
+    struct svm_model* m_corePredictionModel;
+    bool m_useCorePrediction { true };
+#endif
+};
+
+}
index 88d5eae..f47713f 100644 (file)
@@ -46,6 +46,8 @@ list(APPEND WebKit2_SOURCES
     Platform/IPC/unix/AttachmentUnix.cpp
     Platform/IPC/unix/ConnectionUnix.cpp
 
+    Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp
+
     Platform/glib/ModuleGlib.cpp
 
     Platform/unix/LoggingUnix.cpp
@@ -865,6 +867,7 @@ list(APPEND WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/NetworkProcess/soup"
     "${WEBKIT2_DIR}/NetworkProcess/unix"
     "${WEBKIT2_DIR}/Platform/IPC/glib"
+    "${WEBKIT2_DIR}/Platform/classifier"
     "${WEBKIT2_DIR}/Shared/API/c/gtk"
     "${WEBKIT2_DIR}/Shared/CoordinatedGraphics"
     "${WEBKIT2_DIR}/Shared/CoordinatedGraphics/threadedcompositor"
index f0bdeba..63a37e2 100644 (file)
@@ -49,6 +49,10 @@ list(APPEND WebKit2_SOURCES
 
     Platform/cg/CGUtilities.cpp
 
+    Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp
+
+    Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp
+
     Platform/foundation/LoggingFoundation.mm
 
     Platform/cocoa/SharedMemoryCocoa.cpp
@@ -391,6 +395,8 @@ list(APPEND WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/UIProcess/Scrolling"
     "${WEBKIT2_DIR}/UIProcess/ios"
     "${WEBKIT2_DIR}/Platform/cg"
+    "${WEBKIT2_DIR}/Platform/classifier"
+    "${WEBKIT2_DIR}/Platform/classifier/cocoa"
     "${WEBKIT2_DIR}/Platform/mac"
     "${WEBKIT2_DIR}/Platform/unix"
     "${WEBKIT2_DIR}/Platform/spi/Cocoa"
diff --git a/Source/WebKit2/Resources/ResourceLoadStatistics/corePrediction_model b/Source/WebKit2/Resources/ResourceLoadStatistics/corePrediction_model
new file mode 100644 (file)
index 0000000..9ace838
--- /dev/null
@@ -0,0 +1,678 @@
+svm_type c_svc
+kernel_type rbf
+gamma 0.1
+nr_class 2
+total_sv 330
+rho 0.287945642261
+label -1 1
+nr_sv 300 30
+SV
+-0.0546697038724 1:14.0 2:3.0 3:7.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:12.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:3.0 2:16.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 2:1.0 
+-0.0546697038724 1:5.0 
+-0.0546697038724 1:16.0 2:2.0 3:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:11.0 
+-0.0546697038724 1:4.0 3:3.0 
+-0.0546697038724 1:28.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:22.0 2:1.0 3:12.0 
+-0.0546697038724 1:14.0 3:5.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:48.0 2:1.0 
+-0.0546697038724 1:25.0 3:16.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:3.0 3:2.0 
+-0.0546697038724 1:7.0 2:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:5.0 2:2.0 3:3.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:9.0 3:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:47.0 2:21.0 3:33.0 
+-0.0546697038724 1:11.0 2:2.0 3:5.0 
+-0.0546697038724 1:11.0 2:3.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:43.0 3:2.0 
+-0.0546697038724 1:13.0 3:7.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:13.0 3:4.0 
+-0.0546697038724 1:42.0 2:4.0 3:32.0 
+-0.0546697038724 1:10.0 2:5.0 3:1.0 
+-0.0546697038724 1:7.0 3:4.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:16.0 2:4.0 
+-0.0546697038724 1:10.0 2:1.0 3:2.0 
+-0.0546697038724 1:18.0 2:3.0 3:6.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:21.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 2:2.0 
+-0.0546697038724 1:14.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:4.0 3:3.0 
+-0.0546697038724 1:2.0 3:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:39.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 3:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 2:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:16.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:20.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:8.0 
+-0.0546697038724 1:7.0 2:1.0 3:2.0 
+-0.0546697038724 1:8.0 2:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:12.0 3:7.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:8.0 2:2.0 
+-0.0546697038724 1:17.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:13.0 2:4.0 3:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:16.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:11.0 3:11.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:15.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:20.0 2:12.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:7.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 3:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 2:3.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:7.0 2:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:14.0 
+-0.0546697038724 1:12.0 3:6.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:4.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:9.0 2:1.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 2:1.0 
+-0.0546697038724 1:3.0 2:3.0 
+-0.0546697038724 1:2.0 2:2.0 
+-0.0546697038724 1:1.0 2:1.0 3:1.0 
+-0.0546697038724 1:8.0 2:1.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:9.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:36.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:4.0 3:2.0 
+-0.0546697038724 1:13.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0402075178942 1:1.0 
+0.585365853659 1:1.0 
+0.479276139001 1:6.0 2:3.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 
+0.585365853659 1:3.0 3:3.0 
+0.585365853659 1:42.0 2:2.0 3:28.0 
+0.585365853659 1:2.0 
+0.585365853659 1:12.0 
+0.479283046578 1:7.0 
+0.300397873476 1:3.0 3:1.0 
+0.0543173306442 1:6.0 3:2.0 
+0.563465126299 1:11.0 
+0.585365853659 1:2.0 
+0.585365853659 1:10.0 2:3.0 3:6.0 
+0.585365853659 1:1.0 2:1.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 2:1.0 
+0.585365853659 1:3.0 3:1.0 
+0.585365853659 1:1.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 2:1.0 
+0.584989719909 1:7.0 
+0.585365853659 1:3.0 
+0.585365853659 1:3.0 
+0.525925136983 1:3.0 2:2.0 
+0.585365853659 1:1.0 
+0.585365853659 1:1.0 
+0.585365853659 1:3.0 3:1.0 
+0.585365853659 1:1.0 
+0.520745822374 1:3.0 
+svm_type c_svc
+kernel_type rbf
+gamma 0.1
+nr_class 2
+total_sv 330
+rho 0.287945642261
+label -1 1
+nr_sv 300 30
+SV
+-0.0546697038724 1:14.0 2:3.0 3:7.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:12.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:3.0 2:16.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 2:1.0 
+-0.0546697038724 1:5.0 
+-0.0546697038724 1:16.0 2:2.0 3:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:11.0 
+-0.0546697038724 1:4.0 3:3.0 
+-0.0546697038724 1:28.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:22.0 2:1.0 3:12.0 
+-0.0546697038724 1:14.0 3:5.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:48.0 2:1.0 
+-0.0546697038724 1:25.0 3:16.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:3.0 3:2.0 
+-0.0546697038724 1:7.0 2:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:5.0 2:2.0 3:3.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:9.0 3:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:47.0 2:21.0 3:33.0 
+-0.0546697038724 1:11.0 2:2.0 3:5.0 
+-0.0546697038724 1:11.0 2:3.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:43.0 3:2.0 
+-0.0546697038724 1:13.0 3:7.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:13.0 3:4.0 
+-0.0546697038724 1:42.0 2:4.0 3:32.0 
+-0.0546697038724 1:10.0 2:5.0 3:1.0 
+-0.0546697038724 1:7.0 3:4.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:16.0 2:4.0 
+-0.0546697038724 1:10.0 2:1.0 3:2.0 
+-0.0546697038724 1:18.0 2:3.0 3:6.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:21.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 2:2.0 
+-0.0546697038724 1:14.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:4.0 3:3.0 
+-0.0546697038724 1:2.0 3:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:39.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 3:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 2:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:16.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:20.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:8.0 
+-0.0546697038724 1:7.0 2:1.0 3:2.0 
+-0.0546697038724 1:8.0 2:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:12.0 3:7.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:8.0 2:2.0 
+-0.0546697038724 1:17.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:13.0 2:4.0 3:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:16.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:11.0 3:11.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:15.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:20.0 2:12.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:7.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 3:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 2:3.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:7.0 2:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:14.0 
+-0.0546697038724 1:12.0 3:6.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:4.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:9.0 2:1.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 2:1.0 
+-0.0546697038724 1:3.0 2:3.0 
+-0.0546697038724 1:2.0 2:2.0 
+-0.0546697038724 1:1.0 2:1.0 3:1.0 
+-0.0546697038724 1:8.0 2:1.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:9.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:36.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:4.0 3:2.0 
+-0.0546697038724 1:13.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0402075178942 1:1.0 
+0.585365853659 1:1.0 
+0.479276139001 1:6.0 2:3.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 
+0.585365853659 1:3.0 3:3.0 
+0.585365853659 1:42.0 2:2.0 3:28.0 
+0.585365853659 1:2.0 
+0.585365853659 1:12.0 
+0.479283046578 1:7.0 
+0.300397873476 1:3.0 3:1.0 
+0.0543173306442 1:6.0 3:2.0 
+0.563465126299 1:11.0 
+0.585365853659 1:2.0 
+0.585365853659 1:10.0 2:3.0 3:6.0 
+0.585365853659 1:1.0 2:1.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 2:1.0 
+0.585365853659 1:3.0 3:1.0 
+0.585365853659 1:1.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 2:1.0 
+0.584989719909 1:7.0 
+0.585365853659 1:3.0 
+0.585365853659 1:3.0 
+0.525925136983 1:3.0 2:2.0 
+0.585365853659 1:1.0 
+0.585365853659 1:1.0 
+0.585365853659 1:3.0 3:1.0 
+0.585365853659 1:1.0 
+0.520745822374 1:3.0 
index 879abeb..9edb84f 100644 (file)
@@ -56,6 +56,21 @@ bool WKResourceLoadStatisticsManagerIsHasHadUserInteraction(WKStringRef hostName
     return WebResourceLoadStatisticsManager::hasHadUserInteraction(toWTFString(hostName));
 }
 
+void WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
+{
+    WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin(toWTFString(hostName), toWTFString(topFrameHostName));
+}
+
+void WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
+{
+    WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin(toWTFString(hostName), toWTFString(topFrameHostName));
+}
+
+void WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo)
+{
+    WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(toWTFString(hostName), toWTFString(hostNameRedirectedTo));
+}
+
 void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds)
 {
     WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(seconds);
index 2b83f5c..89a17b9 100644 (file)
@@ -38,6 +38,9 @@ extern "C" {
     WK_EXPORT bool WKResourceLoadStatisticsManagerIsPrevalentResource(WKStringRef hostName);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetHasHadUserInteraction(WKStringRef hostName, bool value);
     WK_EXPORT bool WKResourceLoadStatisticsManagerIsHasHadUserInteraction(WKStringRef hostName);
+    WK_EXPORT void WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
+    WK_EXPORT void WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
+    WK_EXPORT void WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetReducedTimestampResolution(double seconds);
     WK_EXPORT void WKResourceLoadStatisticsManagerFireDataModificationHandler();
index ddc8cc3..b028d8f 100644 (file)
@@ -61,6 +61,21 @@ bool WebResourceLoadStatisticsManager::hasHadUserInteraction(const String& hostN
     return WebCore::ResourceLoadObserver::sharedObserver().hasHadUserInteraction(URL(URL(), hostName));
 }
 
+void WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName)
+{
+    WebCore::ResourceLoadObserver::sharedObserver().setSubframeUnderTopFrameOrigin(URL(URL(), hostName), URL(URL(), topFrameHostName));
+}
+
+void WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName)
+{
+    WebCore::ResourceLoadObserver::sharedObserver().setSubresourceUnderTopFrameOrigin(URL(URL(), hostName), URL(URL(), topFrameHostName));
+}
+
+void WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo)
+{
+    WebCore::ResourceLoadObserver::sharedObserver().setSubresourceUniqueRedirectTo(URL(URL(), hostName), URL(URL(), hostNameRedirectedTo));
+}
+
 void WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(double seconds)
 {
     WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(seconds);
index 0e8102f..7223cda 100644 (file)
@@ -42,6 +42,9 @@ public:
     static bool isPrevalentResource(const String& hostName);
     static void setHasHadUserInteraction(const String& hostName, bool value);
     static bool hasHadUserInteraction(const String& hostName);
+    static void setSubframeUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName);
+    static void setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName);
+    static void setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo);
     static void setTimeToLiveUserInteraction(double seconds);
     static void setReducedTimestampResolution(double seconds);
     static void fireDataModificationHandler();
index 7871acf..d979351 100644 (file)
@@ -45,7 +45,6 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static const auto featureVectorLengthThreshold = 3;
 static auto minimumTimeBetweeenDataRecordsRemoval = 60;
 static OptionSet<WebKit::WebsiteDataType> dataTypesToRemove;
 static auto notifyPages = false;
@@ -59,7 +58,7 @@ Ref<WebResourceLoadStatisticsStore> WebResourceLoadStatisticsStore::create(const
 WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(const String& resourceLoadStatisticsDirectory)
     : m_resourceLoadStatisticsStore(ResourceLoadStatisticsStore::create())
     , m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue"))
-    , m_storagePath(resourceLoadStatisticsDirectory)
+    , m_statisticsStoragePath(resourceLoadStatisticsDirectory)
 {
 }
 
@@ -83,40 +82,11 @@ void WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval(do
         minimumTimeBetweeenDataRecordsRemoval = seconds;
 }
 
-bool WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics(const ResourceLoadStatistics& resourceStatistic)
-{
-    auto subresourceUnderTopFrameOriginsCount = resourceStatistic.subresourceUnderTopFrameOrigins.size();
-    auto subresourceUniqueRedirectsToCount = resourceStatistic.subresourceUniqueRedirectsTo.size();
-    auto subframeUnderTopFrameOriginsCount = resourceStatistic.subframeUnderTopFrameOrigins.size();
-    
-    if (!subresourceUnderTopFrameOriginsCount
-        && !subresourceUniqueRedirectsToCount
-        && !subframeUnderTopFrameOriginsCount)
-        return false;
-
-    if (subresourceUnderTopFrameOriginsCount > featureVectorLengthThreshold
-        || subresourceUniqueRedirectsToCount > featureVectorLengthThreshold
-        || subframeUnderTopFrameOriginsCount > featureVectorLengthThreshold)
-        return true;
-
-    // The resource is considered prevalent if the feature vector
-    // is longer than the threshold.
-    // Vector length for n dimensions is sqrt(a^2 + (...) + n^2).
-    double vectorLength = 0;
-    vectorLength += subresourceUnderTopFrameOriginsCount * subresourceUnderTopFrameOriginsCount;
-    vectorLength += subresourceUniqueRedirectsToCount * subresourceUniqueRedirectsToCount;
-    vectorLength += subframeUnderTopFrameOriginsCount * subframeUnderTopFrameOriginsCount;
-
-    ASSERT(vectorLength > 0);
-
-    return sqrt(vectorLength) > featureVectorLengthThreshold;
-}
-    
 void WebResourceLoadStatisticsStore::classifyResource(ResourceLoadStatistics& resourceStatistic)
 {
-    if (!resourceStatistic.isPrevalentResource && hasPrevalentResourceCharacteristics(resourceStatistic)) {
+    if (!resourceStatistic.isPrevalentResource
+        && m_resourceLoadStatisticsClassifier.hasPrevalentResourceCharacteristics(resourceStatistic))
         resourceStatistic.isPrevalentResource = true;
-    }
 }
 
 void WebResourceLoadStatisticsStore::removeDataRecords()
@@ -248,11 +218,11 @@ void WebResourceLoadStatisticsStore::applicationWillTerminate()
 
 String WebResourceLoadStatisticsStore::persistentStoragePath(const String& label) const
 {
-    if (m_storagePath.isEmpty())
+    if (m_statisticsStoragePath.isEmpty())
         return emptyString();
 
     // TODO Decide what to call this file
-    return pathByAppendingComponent(m_storagePath, label + "_resourceLog.plist");
+    return pathByAppendingComponent(m_statisticsStoragePath, label + "_resourceLog.plist");
 }
 
 void WebResourceLoadStatisticsStore::writeEncoderToDisk(KeyedEncoder& encoder, const String& label) const
@@ -265,8 +235,8 @@ void WebResourceLoadStatisticsStore::writeEncoderToDisk(KeyedEncoder& encoder, c
     if (resourceLog.isEmpty())
         return;
 
-    if (!m_storagePath.isEmpty())
-        makeAllDirectories(m_storagePath);
+    if (!m_statisticsStoragePath.isEmpty())
+        makeAllDirectories(m_statisticsStoragePath);
 
     auto handle = openFile(resourceLog, OpenForWrite);
     if (!handle)
index 5e49007..80b8100 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "APIObject.h"
 #include "Connection.h"
+#include "ResourceLoadStatisticsClassifier.h"
 #include "WebsiteDataRecord.h"
 #include <WebCore/ResourceLoadStatisticsStore.h>
 #include <wtf/Vector.h>
@@ -76,7 +77,6 @@ private:
 
     void processStatisticsAndDataRecords();
 
-    bool hasPrevalentResourceCharacteristics(const WebCore::ResourceLoadStatistics&);
     void classifyResource(WebCore::ResourceLoadStatistics&);
     void removeDataRecords();
 
@@ -89,8 +89,9 @@ private:
     std::unique_ptr<WebCore::KeyedDecoder> createDecoderFromDisk(const String& label) const;
 
     Ref<WebCore::ResourceLoadStatisticsStore> m_resourceLoadStatisticsStore;
+    ResourceLoadStatisticsClassifier m_resourceLoadStatisticsClassifier;
     Ref<WTF::WorkQueue> m_statisticsQueue;
-    String m_storagePath;
+    String m_statisticsStoragePath;
     bool m_resourceLoadStatisticsEnabled { false };
 
     double m_lastTimeDataRecordsWereRemoved { 0 };
index bfcf628..2525e6c 100644 (file)
                6501BD1A12F1243400E9F248 /* WKBundleInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */; };
                659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
                65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               6B2E09BA1E57B88100C8A8B9 /* CorePredictionSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2E09B91E57B88100C8A8B9 /* CorePredictionSPI.h */; };
                6BE9699C1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
                6BE9699E1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */; };
                6BE969A01E43B86E008B7483 /* WebResourceLoadStatisticsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE9699F1E43B86E008B7483 /* WebResourceLoadStatisticsManager.h */; };
                6BE969A21E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969A11E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp */; };
+               6BE969C11E54D452008B7483 /* corePrediction_model in Resources */ = {isa = PBXBuildFile; fileRef = 6BE969C01E54D452008B7483 /* corePrediction_model */; };
+               6BE969C51E54D4A4008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969C41E54D4A4008B7483 /* ResourceLoadStatisticsClassifier.h */; };
+               6BE969C71E54D4B6008B7483 /* ResourceLoadStatisticsClassifierBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifierBase.cpp */; };
+               6BE969CA1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */; };
+               6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */; };
+               6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifierBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifierBase.h */; };
                6EE849C81368D9390038D481 /* WKInspectorPrivateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE849C61368D92D0038D481 /* WKInspectorPrivateMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                728E86F11795188C0087879E /* WebColorPickerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 728E86EF1795188C0087879E /* WebColorPickerMac.h */; };
                728E86F21795188C0087879E /* WebColorPickerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 728E86F01795188C0087879E /* WebColorPickerMac.mm */; };
                6546A82A13000164000CEB1C /* InjectedBundlePageResourceLoadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageResourceLoadClient.h; sourceTree = "<group>"; };
                65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleInspector.cpp; sourceTree = "<group>"; };
                65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleInspector.h; sourceTree = "<group>"; };
+               6B2E09B91E57B88100C8A8B9 /* CorePredictionSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorePredictionSPI.h; sourceTree = "<group>"; };
                6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKResourceLoadStatisticsManager.h; sourceTree = "<group>"; };
                6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKResourceLoadStatisticsManager.cpp; sourceTree = "<group>"; };
                6BE9699F1E43B86E008B7483 /* WebResourceLoadStatisticsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebResourceLoadStatisticsManager.h; sourceTree = "<group>"; };
                6BE969A11E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebResourceLoadStatisticsManager.cpp; sourceTree = "<group>"; };
+               6BE969C01E54D452008B7483 /* corePrediction_model */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = corePrediction_model; sourceTree = "<group>"; };
+               6BE969C41E54D4A4008B7483 /* ResourceLoadStatisticsClassifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsClassifier.h; sourceTree = "<group>"; };
+               6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifierBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsClassifierBase.cpp; sourceTree = "<group>"; };
+               6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsClassifierCocoa.cpp; sourceTree = "<group>"; };
+               6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsClassifierCocoa.h; sourceTree = "<group>"; };
+               6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifierBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsClassifierBase.h; sourceTree = "<group>"; };
                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>"; };
                6EE849C61368D92D0038D481 /* WKInspectorPrivateMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKInspectorPrivateMac.h; path = mac/WKInspectorPrivateMac.h; sourceTree = "<group>"; };
                728E86EF1795188C0087879E /* WebColorPickerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebColorPickerMac.h; sourceTree = "<group>"; };
                089C1665FE841158C02AAC07 /* Resources */ = {
                        isa = PBXGroup;
                        children = (
+                               6BE969BF1E54D452008B7483 /* ResourceLoadStatistics */,
                                37F8C94F1AE22BD8007DAB9E /* mac */,
                                7CB16FE11724B9B5007A0A95 /* PlugInSandboxProfiles */,
                                A78CCDD5193AC9E3005ECC25 /* SandboxProfiles */,
                        name = Cocoa;
                        sourceTree = "<group>";
                };
+               6BE969BF1E54D452008B7483 /* ResourceLoadStatistics */ = {
+                       isa = PBXGroup;
+                       children = (
+                               6BE969C01E54D452008B7483 /* corePrediction_model */,
+                       );
+                       name = ResourceLoadStatistics;
+                       path = Resources/ResourceLoadStatistics;
+                       sourceTree = "<group>";
+               };
+               6BE969C21E54D467008B7483 /* classifier */ = {
+                       isa = PBXGroup;
+                       children = (
+                               6BE969C31E54D467008B7483 /* cocoa */,
+                               6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifierBase.cpp */,
+                               6BE969C41E54D4A4008B7483 /* ResourceLoadStatisticsClassifier.h */,
+                               6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifierBase.h */,
+                       );
+                       path = classifier;
+                       sourceTree = "<group>";
+               };
+               6BE969C31E54D467008B7483 /* cocoa */ = {
+                       isa = PBXGroup;
+                       children = (
+                               6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */,
+                               6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */,
+                               6B2E09B91E57B88100C8A8B9 /* CorePredictionSPI.h */,
+                       );
+                       path = cocoa;
+                       sourceTree = "<group>";
+               };
                6EE849C41368D9040038D481 /* mac */ = {
                        isa = PBXGroup;
                        children = (
                BC2E6E74114196F000A63B1E /* Platform */ = {
                        isa = PBXGroup;
                        children = (
+                               6BE969C21E54D467008B7483 /* classifier */,
                                3709504118A88BA40087AE5D /* cf */,
                                1AA2E51A12E4C05600BC4966 /* cg */,
                                4450AEBE1DC3FAAC009943F2 /* cocoa */,
                                41DC45961E3D6E2200B11F51 /* NetworkRTCProvider.h in Headers */,
                                7C1BA33E1A4A0E600043E249 /* APIDictionary.h in Headers */,
                                1F7D36C118DA513F00D9D659 /* APIDownloadClient.h in Headers */,
+                               6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */,
                                516A4A5D120A2CCD00C05B7F /* APIError.h in Headers */,
                                317FE7C51C487A6C00A0CA89 /* APIExperimentalFeature.h in Headers */,
                                00B9661618E24CBA00CE1F88 /* APIFindClient.h in Headers */,
                                3309344A1315B9220097A7BC /* WebCookieManagerProxyMessages.h in Headers */,
                                BC1DD7B2114DC396005ADAF3 /* WebCoreArgumentCoders.h in Headers */,
                                512F589B12A8838800629530 /* WebCredential.h in Headers */,
+                               6BE969C51E54D4A4008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */,
                                1AA83F6D1A5B63FF00026EC6 /* WebDatabaseProvider.h in Headers */,
                                CD19A26E1A13E834008D650E /* WebDiagnosticLoggingClient.h in Headers */,
                                1A5B1C5518987EDF004FCF9B /* WebDocumentLoader.h in Headers */,
                                512127C41908239A00DAF35C /* WebPasteboardOverrides.h in Headers */,
                                7C4694D11A51E36800AD5845 /* WebPasteboardProxy.h in Headers */,
                                7C4694CA1A4B4EA100AD5845 /* WebPasteboardProxyMessages.h in Headers */,
+                               6B2E09BA1E57B88100C8A8B9 /* CorePredictionSPI.h in Headers */,
                                1AB1F7971D1B3613007C9BD1 /* WebPaymentCoordinatorMessages.h in Headers */,
                                1AB1F78C1D1B3355007C9BD1 /* WebPaymentCoordinatorProxy.h in Headers */,
                                1AB1F77E1D1B30A9007C9BD1 /* WebPaymentCoordinatorProxyCocoa.h in Headers */,
                                BC7B633D12A45D1200D174A4 /* WKBundlePageGroup.h in Headers */,
                                1AB474D8184D43FD0051B622 /* WKBundlePageLoaderClient.h in Headers */,
                                ED82A7F2128C6FAF004477B3 /* WKBundlePageOverlay.h in Headers */,
+                               6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifierBase.h in Headers */,
                                1AB474EA184D45130051B622 /* WKBundlePagePolicyClient.h in Headers */,
                                BC1B419811D41D570011E8DD /* WKBundlePagePrivate.h in Headers */,
                                1AB474DA184D44250051B622 /* WKBundlePageResourceLoadClient.h in Headers */,
                                7A5E394A1D5BD8BE00B4B7CE /* com.macromedia.Flash Player ESR.plugin.sb in Resources */,
                                8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */,
                                93A2A3461D246125002B59D3 /* mediaIcon.pdf in Resources */,
+                               6BE969C11E54D452008B7483 /* corePrediction_model in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                51795567162876CB00FA43B6 /* NetworkProcessMac.mm in Sources */,
                                5163199416289A6000E22F00 /* NetworkProcessMessageReceiver.cpp in Sources */,
                                E14A954916E016A40068DE82 /* NetworkProcessPlatformStrategies.cpp in Sources */,
+                               6BE969CA1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp in Sources */,
                                5179556D162877B100FA43B6 /* NetworkProcessProxy.cpp in Sources */,
                                516319921628980A00E22F00 /* NetworkProcessProxyMac.mm in Sources */,
                                513A163C163088F6005D7D22 /* NetworkProcessProxyMessageReceiver.cpp in Sources */,
                                D3B9484611FF4B6500032B39 /* WebPopupMenu.cpp in Sources */,
                                BCC43AC7127B99DE00317F16 /* WebPopupMenuMac.mm in Sources */,
                                BC5750981268F3C6006F0F12 /* WebPopupMenuProxyMac.mm in Sources */,
+                               6BE969C71E54D4B6008B7483 /* ResourceLoadStatisticsClassifierBase.cpp in Sources */,
                                BCD59800112B57BE00EC8C23 /* WebPreferences.cpp in Sources */,
                                7C85FD7F19341665000177C4 /* WebPreferencesKeys.cpp in Sources */,
                                BC84EB1812A7100C0083F2DA /* WebPreferencesMac.mm in Sources */,
index 34dbf88..2f80db8 100644 (file)
@@ -1,3 +1,30 @@
+2017-02-21  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Add alternate classification method
+        https://bugs.webkit.org/show_bug.cgi?id=168347
+        <rdar://problem/30352793>
+
+        Reviewed by Alex Christensen.
+
+        Added three testRunner functions to facilitate layout tests:
+        - setStatisticsSubframeUnderTopFrameOrigin()
+        - setStatisticsSubresourceUnderTopFrameOrigin()
+        - setStatisticsSubresourceUniqueRedirectTo()
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setStatisticsSubframeUnderTopFrameOrigin):
+        (WTR::TestRunner::setStatisticsSubresourceUnderTopFrameOrigin):
+        (WTR::TestRunner::setStatisticsSubresourceUniqueRedirectTo):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::setStatisticsSubframeUnderTopFrameOrigin):
+        (WTR::TestController::setStatisticsSubresourceUnderTopFrameOrigin):
+        (WTR::TestController::setStatisticsSubresourceUniqueRedirectTo):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2017-02-21  Jonathan Bedard  <jbedard@apple.com>
 
         webkitpy: Refactor Device class
index 352fa0a..6e4387f 100644 (file)
@@ -253,6 +253,9 @@ interface TestRunner {
     boolean isStatisticsPrevalentResource(DOMString hostName);
     void setStatisticsHasHadUserInteraction(DOMString hostName, boolean value);
     boolean isStatisticsHasHadUserInteraction(DOMString hostName);
+    void setStatisticsSubframeUnderTopFrameOrigin(DOMString hostName, DOMString topFrameHostName);
+    void setStatisticsSubresourceUnderTopFrameOrigin(DOMString hostName, DOMString topFrameHostName);
+    void setStatisticsSubresourceUniqueRedirectTo(DOMString hostName, DOMString hostNameRedirectedTo);
     void setStatisticsTimeToLiveUserInteraction(double seconds);
     void statisticsFireDataModificationHandler();
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(boolean value);
index 6f7eb0c..49d2bdd 100644 (file)
@@ -1226,6 +1226,84 @@ bool TestRunner::isStatisticsHasHadUserInteraction(JSStringRef hostName)
     return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
 }
 
+void TestRunner::setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName)
+{
+    Vector<WKRetainPtr<WKStringRef>> keys;
+    Vector<WKRetainPtr<WKTypeRef>> values;
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(hostName) });
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(topFrameHostName) });
+    
+    Vector<WKStringRef> rawKeys;
+    Vector<WKTypeRef> rawValues;
+    rawKeys.resize(keys.size());
+    rawValues.resize(values.size());
+    
+    for (size_t i = 0; i < keys.size(); ++i) {
+        rawKeys[i] = keys[i].get();
+        rawValues[i] = values[i].get();
+    }
+    
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubframeUnderTopFrameOrigin"));
+    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
+void TestRunner::setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName)
+{
+    Vector<WKRetainPtr<WKStringRef>> keys;
+    Vector<WKRetainPtr<WKTypeRef>> values;
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(hostName) });
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(topFrameHostName) });
+    
+    Vector<WKStringRef> rawKeys;
+    Vector<WKTypeRef> rawValues;
+    rawKeys.resize(keys.size());
+    rawValues.resize(values.size());
+    
+    for (size_t i = 0; i < keys.size(); ++i) {
+        rawKeys[i] = keys[i].get();
+        rawValues[i] = values[i].get();
+    }
+    
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubresourceUnderTopFrameOrigin"));
+    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
+void TestRunner::setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo)
+{
+    Vector<WKRetainPtr<WKStringRef>> keys;
+    Vector<WKRetainPtr<WKTypeRef>> values;
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(hostName) });
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedTo") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(hostNameRedirectedTo) });
+    
+    Vector<WKStringRef> rawKeys;
+    Vector<WKTypeRef> rawValues;
+    rawKeys.resize(keys.size());
+    rawValues.resize(values.size());
+    
+    for (size_t i = 0; i < keys.size(); ++i) {
+        rawKeys[i] = keys[i].get();
+        rawValues[i] = values[i].get();
+    }
+    
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubresourceUniqueRedirectTo"));
+    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
 void TestRunner::setStatisticsTimeToLiveUserInteraction(double seconds)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsTimeToLiveUserInteraction"));
index 764c9e4..79147a9 100644 (file)
@@ -354,6 +354,9 @@ public:
     bool isStatisticsPrevalentResource(JSStringRef hostName);
     void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value);
     bool isStatisticsHasHadUserInteraction(JSStringRef hostName);
+    void setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
+    void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
+    void setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
     void setStatisticsTimeToLiveUserInteraction(double seconds);
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
index 2ae93ce..4c90ff7 100644 (file)
@@ -2229,6 +2229,21 @@ bool TestController::isStatisticsHasHadUserInteraction(WKStringRef hostName)
     return WKResourceLoadStatisticsManagerIsHasHadUserInteraction(hostName);
 }
 
+void TestController::setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
+{
+    WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(hostName, topFrameHostName);
+}
+
+void TestController::setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
+{
+    WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(hostName, topFrameHostName);
+}
+    
+void TestController::setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo)
+{
+    WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(hostName, hostNameRedirectedTo);
+}
+
 void TestController::setStatisticsTimeToLiveUserInteraction(double seconds)
 {
     WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(seconds);
index cc753c2..e49f37f 100644 (file)
@@ -152,6 +152,9 @@ public:
     bool isStatisticsPrevalentResource(WKStringRef hostName);
     void setStatisticsHasHadUserInteraction(WKStringRef hostName, bool value);
     bool isStatisticsHasHadUserInteraction(WKStringRef hostName);
+    void setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
+    void setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
+    void setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo);
     void setStatisticsTimeToLiveUserInteraction(double seconds);
     void statisticsFireDataModificationHandler();
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
index b0a0442..8f350ae 100644 (file)
@@ -932,6 +932,48 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB
         return result;
     }
     
+    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubframeUnderTopFrameOrigin")) {
+        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
+        
+        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+        WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName"));
+        WKRetainPtr<WKStringRef> topFrameHostNameKey(AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName"));
+        
+        WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
+        WKStringRef topFrameHostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, topFrameHostNameKey.get()));
+
+        TestController::singleton().setStatisticsSubframeUnderTopFrameOrigin(hostName, topFrameHostName);
+        return nullptr;
+    }
+    
+    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubresourceUnderTopFrameOrigin")) {
+        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
+        
+        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+        WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName"));
+        WKRetainPtr<WKStringRef> topFrameHostNameKey(AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName"));
+        
+        WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
+        WKStringRef topFrameHostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, topFrameHostNameKey.get()));
+        
+        TestController::singleton().setStatisticsSubresourceUnderTopFrameOrigin(hostName, topFrameHostName);
+        return nullptr;
+    }
+    
+    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubresourceUniqueRedirectTo")) {
+        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
+        
+        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+        WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName"));
+        WKRetainPtr<WKStringRef> hostNameRedirectedToKey(AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedTo"));
+        
+        WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
+        WKStringRef hostNameRedirectedTo = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameRedirectedToKey.get()));
+        
+        TestController::singleton().setStatisticsSubresourceUniqueRedirectTo(hostName, hostNameRedirectedTo);
+        return nullptr;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsTimeToLiveUserInteraction")) {
         ASSERT(WKGetTypeID(messageBody) == WKDoubleGetTypeID());
         WKDoubleRef seconds = static_cast<WKDoubleRef>(messageBody);
index 1d9646a..ee67bc9 100644 (file)
@@ -1,3 +1,15 @@
+2017-02-21  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Add alternate classification method
+        https://bugs.webkit.org/show_bug.cgi?id=168347
+        <rdar://problem/30352793>
+
+        Reviewed by Alex Christensen.
+
+        * WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework: Added.
+        * WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework/CorePrediction.tbd: Added.
+            Stubs for private framework.
+
 2017-02-20  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r212685.
diff --git a/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework/CorePrediction.tbd b/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework/CorePrediction.tbd
new file mode 100644 (file)
index 0000000..3145748
--- /dev/null
@@ -0,0 +1,18 @@
+--- !tapi-tbd-v2
+archs:
+  - armv7
+  - armv7s
+  - arm64
+exports:
+  -
+    archs:
+      - armv7
+      - armv7s
+      - arm64
+    symbols:
+      - _svm_load_model
+      - _svm_predict_values
+install-name: /System/Library/PrivateFrameworks/CorePrediction.framework
+objc-constraint: none
+platform: ios
+...