Changeset 212757 in webkit


Ignore:
Timestamp:
Feb 21, 2017 2:40:28 PM (7 years ago)
Author:
wilander@apple.com
Message:

Resource Load Statistics: Add alternate classification method
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 ].

Location:
trunk
Files:
24 added
28 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r212748 r212757  
     12017-02-21  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics: Add alternate classification method
     4        https://bugs.webkit.org/show_bug.cgi?id=168347
     5        <rdar://problem/30352793>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt: Added.
     10        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html: Added.
     11        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added.
     12        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added.
     13        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added.
     14        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html: Added.
     15        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added.
     16        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html: Added.
     17        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt: Added.
     18        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html: Added.
     19        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added.
     20        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added.
     21        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added.
     22        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html: Added.
     23        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added.
     24        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html: Added.
     25        * platform/gtk/TestExpectations:
     26            The whole http/tests/loading/resourceLoadStatistics marked as crashing based on
     27            Carlos Garcia Campos's assessment in https://bugs.webkit.org/show_bug.cgi?id=168171.
     28        * platform/wk2/TestExpectations:
     29            The above tests are only valid for WebKit2. Marked as [ Pass ].
     30
    1312017-02-21  Romain Bellessort  <romain.bellessort@crf.canon.fr>
    232
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r212704 r212757  
    932932webkit.org/b/163782 media/video-played-ranges-1.html [ Crash Pass ]
    933933
    934 webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html [ Crash ]
    935 webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html [ Crash ]
    936 webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html [ Crash ]
    937 webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction.html [ Crash ]
    938 webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html [ Crash ]
     934webkit.org/b/168171 http/tests/loading/resourceLoadStatistics [ Crash ]
    939935
    940936webkit.org/b/167576 imported/w3c/IndexedDB-private-browsing/idbcursor_iterating.html [ Crash ]
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r212691 r212757  
    706706http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html [ Pass Timeout ]
    707707http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html [ Pass Timeout ]
     708http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html [ Pass ]
     709http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html [ Pass ]
     710http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html [ Pass ]
     711http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html [ Pass ]
     712http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html [ Pass ]
     713http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html [ Pass ]
     714http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html [ Pass ]
     715http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html [ Pass ]
    708716
    709717### END OF (5) Progressions, expected successes that are expected failures in WebKit1.
  • trunk/Source/WTF/ChangeLog

    r212704 r212757  
     12017-02-21  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics: Add alternate classification method
     4        https://bugs.webkit.org/show_bug.cgi?id=168347
     5        <rdar://problem/30352793>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * wtf/Platform.h:
     10            Added support for HAVE(CORE_PREDICTION).
     11
    1122017-02-21  Alex Christensen  <achristensen@webkit.org>
    213
  • trunk/Source/WTF/wtf/Platform.h

    r212704 r212757  
    12091209#endif /* PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201 && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 */
    12101210
     1211/* CorePrediction only exists on 64-bit platforms. */
     1212#if USE(JSVALUE64) && (PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200))
     1213#define HAVE_CORE_PREDICTION 1
     1214#endif
     1215
    12111216#endif /* WTF_Platform_h */
  • trunk/Source/WebCore/ChangeLog

    r212756 r212757  
     12017-02-21  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics: Add alternate classification method
     4        https://bugs.webkit.org/show_bug.cgi?id=168347
     5        <rdar://problem/30352793>
     6
     7        Reviewed by Alex Christensen.
     8
     9        This patch only adds test infrastructure in WebCore.
     10
     11        Tests: http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html
     12               http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html
     13               http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html
     14               http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html
     15               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html
     16               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html
     17               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html
     18               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html
     19
     20        * loader/ResourceLoadObserver.cpp:
     21        (WebCore::ResourceLoadObserver::setSubframeUnderTopFrameOrigin):
     22        (WebCore::ResourceLoadObserver::setSubresourceUnderTopFrameOrigin):
     23        (WebCore::ResourceLoadObserver::setSubresourceUniqueRedirectTo):
     24        * loader/ResourceLoadObserver.h:
     25
    1262017-02-21  Alex Christensen  <achristensen@webkit.org>
    227
  • trunk/Source/WebCore/loader/ResourceLoadObserver.cpp

    r212691 r212757  
    376376}
    377377
     378void ResourceLoadObserver::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame)
     379{
     380    if (subframe.isBlankURL() || subframe.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
     381        return;
     382   
     383    auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subframe));
     384    statistics.subframeUnderTopFrameOrigins.add(primaryDomain(topFrame));
     385}
     386
     387void ResourceLoadObserver::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame)
     388{
     389    if (subresource.isBlankURL() || subresource.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
     390        return;
     391   
     392    auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subresource));
     393    statistics.subresourceUnderTopFrameOrigins.add(primaryDomain(topFrame));
     394}
     395
     396void ResourceLoadObserver::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo)
     397{
     398    if (subresource.isBlankURL() || subresource.isEmpty() || hostNameRedirectedTo.isBlankURL() || hostNameRedirectedTo.isEmpty())
     399        return;
     400   
     401    auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subresource));
     402    statistics.subresourceUniqueRedirectsTo.add(primaryDomain(hostNameRedirectedTo));
     403}
     404
    378405void ResourceLoadObserver::setTimeToLiveUserInteraction(double seconds)
    379406{
  • trunk/Source/WebCore/loader/ResourceLoadObserver.h

    r212691 r212757  
    5959    WEBCORE_EXPORT void clearPrevalentResource(const URL&);
    6060
     61    WEBCORE_EXPORT void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame);
     62    WEBCORE_EXPORT void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame);
     63    WEBCORE_EXPORT void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo);
     64
    6165    WEBCORE_EXPORT void setTimeToLiveUserInteraction(double seconds);
    6266    WEBCORE_EXPORT void setReducedTimestampResolution(double seconds);
  • trunk/Source/WebKit2/ChangeLog

    r212756 r212757  
     12017-02-21  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics: Add alternate classification method
     4        https://bugs.webkit.org/show_bug.cgi?id=168347
     5        <rdar://problem/30352793>
     6
     7        Reviewed by Alex Christensen.
     8
     9        This patch adds a CorePrediction-based classifier to the WebResourceLoadStatisticsStore.
     10        The CorePrediction framework is introduced as a dependency for macOS and iOS. The patch
     11        also adds functions to support layout tests of the feature.
     12
     13        * Configurations/BaseTarget.xcconfig:
     14        * Configurations/WebKit.xcconfig:
     15            Added dependency on CorePrediction.
     16        * Platform/classifier: Added.
     17        * Platform/classifier/ResourceLoadStatisticsClassifier.h: Added.
     18            Pulls in the Cocoa-specific classifier for Cocoa-based platforms.
     19        (WebKit::ResourceLoadStatisticsClassifier::ResourceLoadStatisticsClassifier):
     20        * Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp: Added.
     21        (WebKit::ResourceLoadStatisticsClassifierBase::hasPrevalentResourceCharacteristics):
     22            Shared classifier logic.
     23        (WebKit::ResourceLoadStatisticsClassifierBase::classifyWithVectorThreshold):
     24            Fallback classifier for when we don't have CorePrediction.
     25        * Platform/classifier/ResourceLoadStatisticsClassifierBase.h: Added.
     26        (WebKit::ResourceLoadStatisticsClassifierBase::ResourceLoadStatisticsClassifierBase):
     27        (WebKit::ResourceLoadStatisticsClassifierBase::~ResourceLoadStatisticsClassifierBase):
     28        * Platform/classifier/cocoa: Added.
     29        * Platform/classifier/cocoa/CorePredictionSPI.h: Added.
     30            Includes CorePrediction if available, otherwise declares needed symbols.
     31            Always redeclares the functions so we'll get a build error if
     32            CorePrediction changes.
     33        * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp: Added.
     34        (WebKit::ResourceLoadStatisticsClassifier::classify):
     35        (WebKit::ResourceLoadStatisticsClassifier::storagePath):
     36        (WebKit::ResourceLoadStatisticsClassifier::shouldUseCorePrediction):
     37            The new classifier for Cocoa platforms.
     38        * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h: Added.
     39        (WebKit::ResourceLoadStatisticsClassifier::ResourceLoadStatisticsClassifier):
     40        * PlatformGTK.cmake:
     41           Added Platform/classifier directory and ResourceLoadStatisticsClassifierBase.cpp.
     42        * PlatformMac.cmake:
     43           Added Platform/classifier and Platform/classifier/cocoa directories, and
     44           source files ResourceLoadStatisticsClassifierBase.cpp and
     45           ResourceLoadStatisticsClassifierCocoa.cpp
     46        * Resources/ResourceLoadStatistics: Added.
     47        * Resources/ResourceLoadStatistics/corePrediction_model: Added.
     48            Model file to load into CorePrediction.
     49        * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
     50        (WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin):
     51        (WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin):
     52        (WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo):
     53            Test infrastructure.
     54        * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
     55        * UIProcess/WebResourceLoadStatisticsManager.cpp:
     56        (WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin):
     57        (WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin):
     58        (WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo):
     59            Test infrastructure.
     60        * UIProcess/WebResourceLoadStatisticsManager.h:
     61        * UIProcess/WebResourceLoadStatisticsStore.cpp:
     62        (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
     63            Renamed m_storagePath to m_statisticsStoragePath for clarity.
     64        (WebKit::WebResourceLoadStatisticsStore::classifyResource):
     65            Now calls the classifier through its ResourceLoadStatisticsClassifier
     66            member variable.
     67        (WebKit::WebResourceLoadStatisticsStore::persistentStoragePath):
     68            Renamed m_storagePath to m_statisticsStoragePath for clarity.
     69        (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
     70            Renamed m_storagePath to m_statisticsStoragePath for clarity.
     71        (WebKit::WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics): Deleted.
     72        * UIProcess/WebResourceLoadStatisticsStore.h:
     73        * WebKit2.xcodeproj/project.pbxproj:
     74            Added the new classifier source files under Platform/classifier and the
     75            corePrediction_model file under Resources/ResourceLoadStatistics.
     76
    1772017-02-21  Alex Christensen  <achristensen@webkit.org>
    278
  • trunk/Source/WebKit2/Configurations/BaseTarget.xcconfig

    r212691 r212757  
    3333WK_PRIVATE_FRAMEWORKS_DIR_iphoneos_NO = $(PRODUCTION_FRAMEWORKS_DIR);
    3434
    35 FRAMEWORK_SEARCH_PATHS_base = "$(UMBRELLA_FRAMEWORKS_DIR)" $(FRAMEWORK_SEARCH_PATHS);
     35FRAMEWORK_SEARCH_PATHS_base = "$(UMBRELLA_FRAMEWORKS_DIR)" /System/Library/PrivateFrameworks $(FRAMEWORK_SEARCH_PATHS);
    3636FRAMEWORK_SEARCH_PATHS[sdk=iphone*] = $(FRAMEWORK_SEARCH_PATHS_base) $(WK_PRIVATE_FRAMEWORKS_DIR);
    3737FRAMEWORK_SEARCH_PATHS = $(FRAMEWORK_SEARCH_PATHS_base);
  • trunk/Source/WebKit2/Configurations/WebKit.xcconfig

    r212704 r212757  
    3535DYLIB_INSTALL_NAME_BASE = $(NORMAL_WEBKIT_FRAMEWORKS_DIR);
    3636
    37 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));
     37FRAMEWORK_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));
    3838FRAMEWORK_AND_LIBRARY_LDFLAGS[sdk=iphoneos*] = $(FRAMEWORK_AND_LIBRARY_LDFLAGS_BASE_ios) -framework IOSurface;
    3939FRAMEWORK_AND_LIBRARY_LDFLAGS[sdk=iphonesimulator*] = $(FRAMEWORK_AND_LIBRARY_LDFLAGS_BASE_ios);
    4040FRAMEWORK_AND_LIBRARY_LDFLAGS_PLATFORM_iphoneos = ;
    4141FRAMEWORK_AND_LIBRARY_LDFLAGS_PLATFORM_iphonesimulator = ;
    42 FRAMEWORK_AND_LIBRARY_LDFLAGS[sdk=macosx*] = -framework ApplicationServices -framework Carbon -framework Cocoa -framework CoreServices -framework IOKit -framework CoreAudio -framework IOSurface -framework OpenGL;
     42FRAMEWORK_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));
     43EXTRA_FRAMEWORK_AND_LIBRARY_LDFLAGS_101200 = -framework CorePrediction;
     44EXTRA_FRAMEWORK_AND_LIBRARY_LDFLAGS_101300 = -framework CorePrediction;
    4345
    4446// Prevent C++ standard library operator new, delete and their related exception types from being exported as weak symbols.
  • trunk/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifier.h

    r212756 r212757  
    2626#pragma once
    2727
    28 #include "APIObject.h"
     28#include <wtf/Platform.h>
    2929
    30 #include <wtf/RefPtr.h>
    31 #include <wtf/text/WTFString.h>
     30#if PLATFORM(COCOA)
     31#include "ResourceLoadStatisticsClassifierCocoa.h"
     32#else
     33
     34#include "ResourceLoadStatisticsClassifierBase.h"
    3235
    3336namespace WebKit {
    3437
    35 class WebResourceLoadStatisticsManager : public API::ObjectImpl<API::Object::Type::WebResourceLoadStatisticsManager> {
     38class ResourceLoadStatisticsClassifier : public ResourceLoadStatisticsClassifierBase {
    3639public:
    37     static Ref<WebResourceLoadStatisticsManager> create()
     40    ResourceLoadStatisticsClassifier()
     41    : ResourceLoadStatisticsClassifierBase() { }
     42   
     43protected:
     44    bool classify(const unsigned a, const unsigned b, const unsigned c) override
    3845    {
    39         return adoptRef(*new WebResourceLoadStatisticsManager());
     46        return classifyWithVectorThreshold(a, b, c);
    4047    }
    41     static void setPrevalentResource(const String& hostName, bool value);
    42     static bool isPrevalentResource(const String& hostName);
    43     static void setHasHadUserInteraction(const String& hostName, bool value);
    44     static bool hasHadUserInteraction(const String& hostName);
    45     static void setTimeToLiveUserInteraction(double seconds);
    46     static void setReducedTimestampResolution(double seconds);
    47     static void fireDataModificationHandler();
    48     static void setNotifyPagesWhenDataRecordsWereScanned(bool);
    49     static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value);
    50     static void setMinimumTimeBetweeenDataRecordsRemoval(double seconds);
    51     static void resetToConsistentState();
    52 
    53 private:
    5448};
    5549
    56 } // namespace WebKit
     50}
     51
     52#endif
  • trunk/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifierBase.h

    r212756 r212757  
    2626#pragma once
    2727
    28 #include "APIObject.h"
    29 
    30 #include <wtf/RefPtr.h>
    31 #include <wtf/text/WTFString.h>
     28namespace WebCore {
     29struct ResourceLoadStatistics;
     30}
    3231
    3332namespace WebKit {
    3433
    35 class WebResourceLoadStatisticsManager : public API::ObjectImpl<API::Object::Type::WebResourceLoadStatisticsManager> {
     34class ResourceLoadStatisticsClassifierBase {
    3635public:
    37     static Ref<WebResourceLoadStatisticsManager> create()
    38     {
    39         return adoptRef(*new WebResourceLoadStatisticsManager());
    40     }
    41     static void setPrevalentResource(const String& hostName, bool value);
    42     static bool isPrevalentResource(const String& hostName);
    43     static void setHasHadUserInteraction(const String& hostName, bool value);
    44     static bool hasHadUserInteraction(const String& hostName);
    45     static void setTimeToLiveUserInteraction(double seconds);
    46     static void setReducedTimestampResolution(double seconds);
    47     static void fireDataModificationHandler();
    48     static void setNotifyPagesWhenDataRecordsWereScanned(bool);
    49     static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value);
    50     static void setMinimumTimeBetweeenDataRecordsRemoval(double seconds);
    51     static void resetToConsistentState();
    52 
    53 private:
     36    bool hasPrevalentResourceCharacteristics(const WebCore::ResourceLoadStatistics& resourceStatistic);
     37protected:
     38    ResourceLoadStatisticsClassifierBase() { }
     39    virtual ~ResourceLoadStatisticsClassifierBase() { }
     40    virtual bool classify(const unsigned, const unsigned, const unsigned) = 0;
     41    bool classifyWithVectorThreshold(const unsigned, const unsigned, const unsigned);
    5442};
    5543
    56 } // namespace WebKit
     44}
  • trunk/Source/WebKit2/Platform/classifier/cocoa/CorePredictionSPI.h

    r212756 r212757  
    2626#pragma once
    2727
    28 #include "APIObject.h"
     28#if USE(APPLE_INTERNAL_SDK) && HAVE(CORE_PREDICTION)
     29#include <CorePrediction/svm.h>
     30#else
    2931
    30 #include <wtf/RefPtr.h>
    31 #include <wtf/text/WTFString.h>
    32 
    33 namespace WebKit {
    34 
    35 class WebResourceLoadStatisticsManager : public API::ObjectImpl<API::Object::Type::WebResourceLoadStatisticsManager> {
    36 public:
    37     static Ref<WebResourceLoadStatisticsManager> create()
    38     {
    39         return adoptRef(*new WebResourceLoadStatisticsManager());
    40     }
    41     static void setPrevalentResource(const String& hostName, bool value);
    42     static bool isPrevalentResource(const String& hostName);
    43     static void setHasHadUserInteraction(const String& hostName, bool value);
    44     static bool hasHadUserInteraction(const String& hostName);
    45     static void setTimeToLiveUserInteraction(double seconds);
    46     static void setReducedTimestampResolution(double seconds);
    47     static void fireDataModificationHandler();
    48     static void setNotifyPagesWhenDataRecordsWereScanned(bool);
    49     static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value);
    50     static void setMinimumTimeBetweeenDataRecordsRemoval(double seconds);
    51     static void resetToConsistentState();
    52 
    53 private:
     32struct svm_node {
     33    int index;
     34    double value;
    5435};
    5536
    56 } // namespace WebKit
     37struct svm_model { };
     38
     39#endif
     40
     41#ifdef __cplusplus
     42extern "C" {
     43#endif
     44
     45double svm_predict_values(const struct svm_model*, const struct svm_node*, double*);
     46
     47struct svm_model *svm_load_model(const char*);
     48
     49#ifdef __cplusplus
     50}
     51#endif
  • trunk/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h

    r212756 r212757  
    2626#pragma once
    2727
    28 #include "APIObject.h"
    29 
    30 #include <wtf/RefPtr.h>
     28#if HAVE(CORE_PREDICTION)
     29#include "CorePredictionSPI.h"
     30#endif
     31#include "ResourceLoadStatisticsClassifierBase.h"
     32#include <CoreFoundation/CoreFoundation.h>
     33#include <wtf/Platform.h>
    3134#include <wtf/text/WTFString.h>
    3235
    3336namespace WebKit {
    3437
    35 class WebResourceLoadStatisticsManager : public API::ObjectImpl<API::Object::Type::WebResourceLoadStatisticsManager> {
     38class ResourceLoadStatisticsClassifier : public ResourceLoadStatisticsClassifierBase {
     39
    3640public:
    37     static Ref<WebResourceLoadStatisticsManager> create()
    38     {
    39         return adoptRef(*new WebResourceLoadStatisticsManager());
    40     }
    41     static void setPrevalentResource(const String& hostName, bool value);
    42     static bool isPrevalentResource(const String& hostName);
    43     static void setHasHadUserInteraction(const String& hostName, bool value);
    44     static bool hasHadUserInteraction(const String& hostName);
    45     static void setTimeToLiveUserInteraction(double seconds);
    46     static void setReducedTimestampResolution(double seconds);
    47     static void fireDataModificationHandler();
    48     static void setNotifyPagesWhenDataRecordsWereScanned(bool);
    49     static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value);
    50     static void setMinimumTimeBetweeenDataRecordsRemoval(double seconds);
    51     static void resetToConsistentState();
     41    ResourceLoadStatisticsClassifier()
     42        : ResourceLoadStatisticsClassifierBase() { }
    5243
    5344private:
     45    bool classify(const unsigned, const unsigned, const unsigned) override;
     46    String storagePath();
     47    bool shouldUseCorePrediction();
     48#if HAVE(CORE_PREDICTION)
     49    struct svm_model* m_corePredictionModel;
     50    bool m_useCorePrediction { true };
     51#endif
    5452};
    5553
    56 } // namespace WebKit
     54}
  • trunk/Source/WebKit2/PlatformGTK.cmake

    r212724 r212757  
    4646    Platform/IPC/unix/AttachmentUnix.cpp
    4747    Platform/IPC/unix/ConnectionUnix.cpp
     48
     49    Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp
    4850
    4951    Platform/glib/ModuleGlib.cpp
     
    866868    "${WEBKIT2_DIR}/NetworkProcess/unix"
    867869    "${WEBKIT2_DIR}/Platform/IPC/glib"
     870    "${WEBKIT2_DIR}/Platform/classifier"
    868871    "${WEBKIT2_DIR}/Shared/API/c/gtk"
    869872    "${WEBKIT2_DIR}/Shared/CoordinatedGraphics"
  • trunk/Source/WebKit2/PlatformMac.cmake

    r212756 r212757  
    4949
    5050    Platform/cg/CGUtilities.cpp
     51
     52    Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp
     53
     54    Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp
    5155
    5256    Platform/foundation/LoggingFoundation.mm
     
    392396    "${WEBKIT2_DIR}/UIProcess/ios"
    393397    "${WEBKIT2_DIR}/Platform/cg"
     398    "${WEBKIT2_DIR}/Platform/classifier"
     399    "${WEBKIT2_DIR}/Platform/classifier/cocoa"
    394400    "${WEBKIT2_DIR}/Platform/mac"
    395401    "${WEBKIT2_DIR}/Platform/unix"
  • trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp

    r212691 r212757  
    5757}
    5858
     59void WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
     60{
     61    WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin(toWTFString(hostName), toWTFString(topFrameHostName));
     62}
     63
     64void WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
     65{
     66    WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin(toWTFString(hostName), toWTFString(topFrameHostName));
     67}
     68
     69void WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo)
     70{
     71    WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(toWTFString(hostName), toWTFString(hostNameRedirectedTo));
     72}
     73
    5974void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds)
    6075{
  • trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h

    r212691 r212757  
    3939    WK_EXPORT void WKResourceLoadStatisticsManagerSetHasHadUserInteraction(WKStringRef hostName, bool value);
    4040    WK_EXPORT bool WKResourceLoadStatisticsManagerIsHasHadUserInteraction(WKStringRef hostName);
     41    WK_EXPORT void WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
     42    WK_EXPORT void WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
     43    WK_EXPORT void WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo);
    4144    WK_EXPORT void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds);
    4245    WK_EXPORT void WKResourceLoadStatisticsManagerSetReducedTimestampResolution(double seconds);
  • trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp

    r212691 r212757  
    6262}
    6363
     64void WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName)
     65{
     66    WebCore::ResourceLoadObserver::sharedObserver().setSubframeUnderTopFrameOrigin(URL(URL(), hostName), URL(URL(), topFrameHostName));
     67}
     68
     69void WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName)
     70{
     71    WebCore::ResourceLoadObserver::sharedObserver().setSubresourceUnderTopFrameOrigin(URL(URL(), hostName), URL(URL(), topFrameHostName));
     72}
     73
     74void WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo)
     75{
     76    WebCore::ResourceLoadObserver::sharedObserver().setSubresourceUniqueRedirectTo(URL(URL(), hostName), URL(URL(), hostNameRedirectedTo));
     77}
     78
    6479void WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(double seconds)
    6580{
  • trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h

    r212691 r212757  
    4343    static void setHasHadUserInteraction(const String& hostName, bool value);
    4444    static bool hasHadUserInteraction(const String& hostName);
     45    static void setSubframeUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName);
     46    static void setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName);
     47    static void setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo);
    4548    static void setTimeToLiveUserInteraction(double seconds);
    4649    static void setReducedTimestampResolution(double seconds);
  • trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp

    r212691 r212757  
    4646namespace WebKit {
    4747
    48 static const auto featureVectorLengthThreshold = 3;
    4948static auto minimumTimeBetweeenDataRecordsRemoval = 60;
    5049static OptionSet<WebKit::WebsiteDataType> dataTypesToRemove;
     
    6059    : m_resourceLoadStatisticsStore(ResourceLoadStatisticsStore::create())
    6160    , m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue"))
    62     , m_storagePath(resourceLoadStatisticsDirectory)
     61    , m_statisticsStoragePath(resourceLoadStatisticsDirectory)
    6362{
    6463}
     
    8483}
    8584
    86 bool WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics(const ResourceLoadStatistics& resourceStatistic)
    87 {
    88     auto subresourceUnderTopFrameOriginsCount = resourceStatistic.subresourceUnderTopFrameOrigins.size();
    89     auto subresourceUniqueRedirectsToCount = resourceStatistic.subresourceUniqueRedirectsTo.size();
    90     auto subframeUnderTopFrameOriginsCount = resourceStatistic.subframeUnderTopFrameOrigins.size();
    91    
    92     if (!subresourceUnderTopFrameOriginsCount
    93         && !subresourceUniqueRedirectsToCount
    94         && !subframeUnderTopFrameOriginsCount)
    95         return false;
    96 
    97     if (subresourceUnderTopFrameOriginsCount > featureVectorLengthThreshold
    98         || subresourceUniqueRedirectsToCount > featureVectorLengthThreshold
    99         || subframeUnderTopFrameOriginsCount > featureVectorLengthThreshold)
    100         return true;
    101 
    102     // The resource is considered prevalent if the feature vector
    103     // is longer than the threshold.
    104     // Vector length for n dimensions is sqrt(a^2 + (...) + n^2).
    105     double vectorLength = 0;
    106     vectorLength += subresourceUnderTopFrameOriginsCount * subresourceUnderTopFrameOriginsCount;
    107     vectorLength += subresourceUniqueRedirectsToCount * subresourceUniqueRedirectsToCount;
    108     vectorLength += subframeUnderTopFrameOriginsCount * subframeUnderTopFrameOriginsCount;
    109 
    110     ASSERT(vectorLength > 0);
    111 
    112     return sqrt(vectorLength) > featureVectorLengthThreshold;
    113 }
    114    
    11585void WebResourceLoadStatisticsStore::classifyResource(ResourceLoadStatistics& resourceStatistic)
    11686{
    117     if (!resourceStatistic.isPrevalentResource && hasPrevalentResourceCharacteristics(resourceStatistic)) {
     87    if (!resourceStatistic.isPrevalentResource
     88        && m_resourceLoadStatisticsClassifier.hasPrevalentResourceCharacteristics(resourceStatistic))
    11889        resourceStatistic.isPrevalentResource = true;
    119     }
    12090}
    12191
     
    249219String WebResourceLoadStatisticsStore::persistentStoragePath(const String& label) const
    250220{
    251     if (m_storagePath.isEmpty())
     221    if (m_statisticsStoragePath.isEmpty())
    252222        return emptyString();
    253223
    254224    // TODO Decide what to call this file
    255     return pathByAppendingComponent(m_storagePath, label + "_resourceLog.plist");
     225    return pathByAppendingComponent(m_statisticsStoragePath, label + "_resourceLog.plist");
    256226}
    257227
     
    266236        return;
    267237
    268     if (!m_storagePath.isEmpty())
    269         makeAllDirectories(m_storagePath);
     238    if (!m_statisticsStoragePath.isEmpty())
     239        makeAllDirectories(m_statisticsStoragePath);
    270240
    271241    auto handle = openFile(resourceLog, OpenForWrite);
  • trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h

    r212691 r212757  
    2929#include "APIObject.h"
    3030#include "Connection.h"
     31#include "ResourceLoadStatisticsClassifier.h"
    3132#include "WebsiteDataRecord.h"
    3233#include <WebCore/ResourceLoadStatisticsStore.h>
     
    7778    void processStatisticsAndDataRecords();
    7879
    79     bool hasPrevalentResourceCharacteristics(const WebCore::ResourceLoadStatistics&);
    8080    void classifyResource(WebCore::ResourceLoadStatistics&);
    8181    void removeDataRecords();
     
    9090
    9191    Ref<WebCore::ResourceLoadStatisticsStore> m_resourceLoadStatisticsStore;
     92    ResourceLoadStatisticsClassifier m_resourceLoadStatisticsClassifier;
    9293    Ref<WTF::WorkQueue> m_statisticsQueue;
    93     String m_storagePath;
     94    String m_statisticsStoragePath;
    9495    bool m_resourceLoadStatisticsEnabled { false };
    9596
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r212724 r212757  
    11481148                659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
    11491149                65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1150                6B2E09BA1E57B88100C8A8B9 /* CorePredictionSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2E09B91E57B88100C8A8B9 /* CorePredictionSPI.h */; };
    11501151                6BE9699C1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11511152                6BE9699E1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */; };
    11521153                6BE969A01E43B86E008B7483 /* WebResourceLoadStatisticsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE9699F1E43B86E008B7483 /* WebResourceLoadStatisticsManager.h */; };
    11531154                6BE969A21E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969A11E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp */; };
     1155                6BE969C11E54D452008B7483 /* corePrediction_model in Resources */ = {isa = PBXBuildFile; fileRef = 6BE969C01E54D452008B7483 /* corePrediction_model */; };
     1156                6BE969C51E54D4A4008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969C41E54D4A4008B7483 /* ResourceLoadStatisticsClassifier.h */; };
     1157                6BE969C71E54D4B6008B7483 /* ResourceLoadStatisticsClassifierBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifierBase.cpp */; };
     1158                6BE969CA1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */; };
     1159                6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */; };
     1160                6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifierBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifierBase.h */; };
    11541161                6EE849C81368D9390038D481 /* WKInspectorPrivateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE849C61368D92D0038D481 /* WKInspectorPrivateMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11551162                728E86F11795188C0087879E /* WebColorPickerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 728E86EF1795188C0087879E /* WebColorPickerMac.h */; };
     
    33413348                65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleInspector.cpp; sourceTree = "<group>"; };
    33423349                65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleInspector.h; sourceTree = "<group>"; };
     3350                6B2E09B91E57B88100C8A8B9 /* CorePredictionSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorePredictionSPI.h; sourceTree = "<group>"; };
    33433351                6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKResourceLoadStatisticsManager.h; sourceTree = "<group>"; };
    33443352                6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKResourceLoadStatisticsManager.cpp; sourceTree = "<group>"; };
    33453353                6BE9699F1E43B86E008B7483 /* WebResourceLoadStatisticsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebResourceLoadStatisticsManager.h; sourceTree = "<group>"; };
    33463354                6BE969A11E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebResourceLoadStatisticsManager.cpp; sourceTree = "<group>"; };
     3355                6BE969C01E54D452008B7483 /* corePrediction_model */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = corePrediction_model; sourceTree = "<group>"; };
     3356                6BE969C41E54D4A4008B7483 /* ResourceLoadStatisticsClassifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsClassifier.h; sourceTree = "<group>"; };
     3357                6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifierBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsClassifierBase.cpp; sourceTree = "<group>"; };
     3358                6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsClassifierCocoa.cpp; sourceTree = "<group>"; };
     3359                6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsClassifierCocoa.h; sourceTree = "<group>"; };
     3360                6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifierBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsClassifierBase.h; sourceTree = "<group>"; };
    33473361                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>"; };
    33483362                6EE849C61368D92D0038D481 /* WKInspectorPrivateMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKInspectorPrivateMac.h; path = mac/WKInspectorPrivateMac.h; sourceTree = "<group>"; };
     
    43614375                        isa = PBXGroup;
    43624376                        children = (
     4377                                6BE969BF1E54D452008B7483 /* ResourceLoadStatistics */,
    43634378                                37F8C94F1AE22BD8007DAB9E /* mac */,
    43644379                                7CB16FE11724B9B5007A0A95 /* PlugInSandboxProfiles */,
     
    61246139                        sourceTree = "<group>";
    61256140                };
     6141                6BE969BF1E54D452008B7483 /* ResourceLoadStatistics */ = {
     6142                        isa = PBXGroup;
     6143                        children = (
     6144                                6BE969C01E54D452008B7483 /* corePrediction_model */,
     6145                        );
     6146                        name = ResourceLoadStatistics;
     6147                        path = Resources/ResourceLoadStatistics;
     6148                        sourceTree = "<group>";
     6149                };
     6150                6BE969C21E54D467008B7483 /* classifier */ = {
     6151                        isa = PBXGroup;
     6152                        children = (
     6153                                6BE969C31E54D467008B7483 /* cocoa */,
     6154                                6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifierBase.cpp */,
     6155                                6BE969C41E54D4A4008B7483 /* ResourceLoadStatisticsClassifier.h */,
     6156                                6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifierBase.h */,
     6157                        );
     6158                        path = classifier;
     6159                        sourceTree = "<group>";
     6160                };
     6161                6BE969C31E54D467008B7483 /* cocoa */ = {
     6162                        isa = PBXGroup;
     6163                        children = (
     6164                                6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */,
     6165                                6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */,
     6166                                6B2E09B91E57B88100C8A8B9 /* CorePredictionSPI.h */,
     6167                        );
     6168                        path = cocoa;
     6169                        sourceTree = "<group>";
     6170                };
    61266171                6EE849C41368D9040038D481 /* mac */ = {
    61276172                        isa = PBXGroup;
     
    70257070                        isa = PBXGroup;
    70267071                        children = (
     7072                                6BE969C21E54D467008B7483 /* classifier */,
    70277073                                3709504118A88BA40087AE5D /* cf */,
    70287074                                1AA2E51A12E4C05600BC4966 /* cg */,
     
    79087954                                7C1BA33E1A4A0E600043E249 /* APIDictionary.h in Headers */,
    79097955                                1F7D36C118DA513F00D9D659 /* APIDownloadClient.h in Headers */,
     7956                                6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */,
    79107957                                516A4A5D120A2CCD00C05B7F /* APIError.h in Headers */,
    79117958                                317FE7C51C487A6C00A0CA89 /* APIExperimentalFeature.h in Headers */,
     
    83298376                                BC1DD7B2114DC396005ADAF3 /* WebCoreArgumentCoders.h in Headers */,
    83308377                                512F589B12A8838800629530 /* WebCredential.h in Headers */,
     8378                                6BE969C51E54D4A4008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */,
    83318379                                1AA83F6D1A5B63FF00026EC6 /* WebDatabaseProvider.h in Headers */,
    83328380                                CD19A26E1A13E834008D650E /* WebDiagnosticLoggingClient.h in Headers */,
     
    84148462                                7C4694D11A51E36800AD5845 /* WebPasteboardProxy.h in Headers */,
    84158463                                7C4694CA1A4B4EA100AD5845 /* WebPasteboardProxyMessages.h in Headers */,
     8464                                6B2E09BA1E57B88100C8A8B9 /* CorePredictionSPI.h in Headers */,
    84168465                                1AB1F7971D1B3613007C9BD1 /* WebPaymentCoordinatorMessages.h in Headers */,
    84178466                                1AB1F78C1D1B3355007C9BD1 /* WebPaymentCoordinatorProxy.h in Headers */,
     
    85328581                                1AB474D8184D43FD0051B622 /* WKBundlePageLoaderClient.h in Headers */,
    85338582                                ED82A7F2128C6FAF004477B3 /* WKBundlePageOverlay.h in Headers */,
     8583                                6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifierBase.h in Headers */,
    85348584                                1AB474EA184D45130051B622 /* WKBundlePagePolicyClient.h in Headers */,
    85358585                                BC1B419811D41D570011E8DD /* WKBundlePagePrivate.h in Headers */,
     
    90659115                                8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */,
    90669116                                93A2A3461D246125002B59D3 /* mediaIcon.pdf in Resources */,
     9117                                6BE969C11E54D452008B7483 /* corePrediction_model in Resources */,
    90679118                        );
    90689119                        runOnlyForDeploymentPostprocessing = 0;
     
    96529703                                5163199416289A6000E22F00 /* NetworkProcessMessageReceiver.cpp in Sources */,
    96539704                                E14A954916E016A40068DE82 /* NetworkProcessPlatformStrategies.cpp in Sources */,
     9705                                6BE969CA1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp in Sources */,
    96549706                                5179556D162877B100FA43B6 /* NetworkProcessProxy.cpp in Sources */,
    96559707                                516319921628980A00E22F00 /* NetworkProcessProxyMac.mm in Sources */,
     
    999610048                                BCC43AC7127B99DE00317F16 /* WebPopupMenuMac.mm in Sources */,
    999710049                                BC5750981268F3C6006F0F12 /* WebPopupMenuProxyMac.mm in Sources */,
     10050                                6BE969C71E54D4B6008B7483 /* ResourceLoadStatisticsClassifierBase.cpp in Sources */,
    999810051                                BCD59800112B57BE00EC8C23 /* WebPreferences.cpp in Sources */,
    999910052                                7C85FD7F19341665000177C4 /* WebPreferencesKeys.cpp in Sources */,
  • trunk/Tools/ChangeLog

    r212741 r212757  
     12017-02-21  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics: Add alternate classification method
     4        https://bugs.webkit.org/show_bug.cgi?id=168347
     5        <rdar://problem/30352793>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Added three testRunner functions to facilitate layout tests:
     10        - setStatisticsSubframeUnderTopFrameOrigin()
     11        - setStatisticsSubresourceUnderTopFrameOrigin()
     12        - setStatisticsSubresourceUniqueRedirectTo()
     13
     14        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     15        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     16        (WTR::TestRunner::setStatisticsSubframeUnderTopFrameOrigin):
     17        (WTR::TestRunner::setStatisticsSubresourceUnderTopFrameOrigin):
     18        (WTR::TestRunner::setStatisticsSubresourceUniqueRedirectTo):
     19        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     20        * WebKitTestRunner/TestController.cpp:
     21        (WTR::TestController::setStatisticsSubframeUnderTopFrameOrigin):
     22        (WTR::TestController::setStatisticsSubresourceUnderTopFrameOrigin):
     23        (WTR::TestController::setStatisticsSubresourceUniqueRedirectTo):
     24        * WebKitTestRunner/TestController.h:
     25        * WebKitTestRunner/TestInvocation.cpp:
     26        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     27
    1282017-02-21  Jonathan Bedard  <jbedard@apple.com>
    229
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r212691 r212757  
    254254    void setStatisticsHasHadUserInteraction(DOMString hostName, boolean value);
    255255    boolean isStatisticsHasHadUserInteraction(DOMString hostName);
     256    void setStatisticsSubframeUnderTopFrameOrigin(DOMString hostName, DOMString topFrameHostName);
     257    void setStatisticsSubresourceUnderTopFrameOrigin(DOMString hostName, DOMString topFrameHostName);
     258    void setStatisticsSubresourceUniqueRedirectTo(DOMString hostName, DOMString hostNameRedirectedTo);
    256259    void setStatisticsTimeToLiveUserInteraction(double seconds);
    257260    void statisticsFireDataModificationHandler();
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r212691 r212757  
    12271227}
    12281228
    1229 void TestRunner::setStatisticsTimeToLiveUserInteraction(double seconds)
    1230 {
    1231     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsTimeToLiveUserInteraction"));
    1232     WKRetainPtr<WKDoubleRef> messageBody(AdoptWK, WKDoubleCreate(seconds));
    1233     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
    1234 }
    1235 
    1236 void TestRunner::installStatisticsDidModifyDataRecordsCallback(JSValueRef callback)
    1237 {
    1238     cacheTestRunnerCallback(StatisticsDidModifyDataRecordsCallbackID, callback);
    1239 }
    1240 
    1241 void TestRunner::statisticsDidModifyDataRecordsCallback()
    1242 {
    1243     callTestRunnerCallback(StatisticsDidModifyDataRecordsCallbackID);
    1244 }
    1245 
    1246 void TestRunner::statisticsFireDataModificationHandler()
    1247 {
    1248     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsFireDataModificationHandler"));
    1249     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
    1250 }
    1251 
    1252 void TestRunner::setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool value)
    1253 {
    1254     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsNotifyPagesWhenDataRecordsWereScanned"));
    1255     WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
    1256     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
    1257 }
    1258 
    1259 void TestRunner::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool value)
    1260 {
    1261     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsShouldClassifyResourcesBeforeDataRecordsRemoval"));
    1262     WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
    1263     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
    1264 }
    1265 
    1266 void TestRunner::setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double seconds)
    1267 {
    1268     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsMinimumTimeBetweeenDataRecordsRemoval"));
    1269     WKRetainPtr<WKDoubleRef> messageBody(AdoptWK, WKDoubleCreate(seconds));
    1270     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
    1271 }
    1272    
    1273 void TestRunner::statisticsResetToConsistentState()
    1274 {
    1275     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsResetToConsistentState"));
    1276     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
    1277 }
    1278 
    1279 #if PLATFORM(MAC)
    1280 void TestRunner::connectMockGamepad(unsigned index)
    1281 {
    1282     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ConnectMockGamepad"));
    1283     WKRetainPtr<WKTypeRef> messageBody(AdoptWK, WKUInt64Create(index));
    1284 
    1285     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
    1286 }
    1287 
    1288 void TestRunner::disconnectMockGamepad(unsigned index)
    1289 {
    1290     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("DisconnectMockGamepad"));
    1291     WKRetainPtr<WKTypeRef> messageBody(AdoptWK, WKUInt64Create(index));
    1292 
    1293     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
    1294 }
    1295 
    1296 void TestRunner::setMockGamepadDetails(unsigned index, JSStringRef gamepadID, unsigned axisCount, unsigned buttonCount)
     1229void TestRunner::setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName)
    12971230{
    12981231    Vector<WKRetainPtr<WKStringRef>> keys;
    12991232    Vector<WKRetainPtr<WKTypeRef>> values;
    1300 
    1301     keys.append({ AdoptWK, WKStringCreateWithUTF8CString("GamepadID") });
    1302     values.append(toWK(gamepadID));
    1303 
    1304     keys.append({ AdoptWK, WKStringCreateWithUTF8CString("GamepadIndex") });
    1305     values.append({ AdoptWK, WKUInt64Create(index) });
    1306 
    1307     keys.append({ AdoptWK, WKStringCreateWithUTF8CString("AxisCount") });
    1308     values.append({ AdoptWK, WKUInt64Create(axisCount) });
    1309 
    1310     keys.append({ AdoptWK, WKStringCreateWithUTF8CString("ButtonCount") });
    1311     values.append({ AdoptWK, WKUInt64Create(buttonCount) });
    1312 
     1233   
     1234    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") });
     1235    values.append({ AdoptWK, WKStringCreateWithJSString(hostName) });
     1236   
     1237    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName") });
     1238    values.append({ AdoptWK, WKStringCreateWithJSString(topFrameHostName) });
     1239   
    13131240    Vector<WKStringRef> rawKeys;
    13141241    Vector<WKTypeRef> rawValues;
    13151242    rawKeys.resize(keys.size());
    13161243    rawValues.resize(values.size());
    1317 
     1244   
    13181245    for (size_t i = 0; i < keys.size(); ++i) {
    13191246        rawKeys[i] = keys[i].get();
    13201247        rawValues[i] = values[i].get();
    13211248    }
    1322 
    1323     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetMockGamepadDetails"));
     1249   
     1250    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubframeUnderTopFrameOrigin"));
    13241251    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
    1325 
    1326     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
    1327 }
    1328 
    1329 void TestRunner::setMockGamepadAxisValue(unsigned index, unsigned axisIndex, double value)
     1252    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1253}
     1254
     1255void TestRunner::setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName)
    13301256{
    13311257    Vector<WKRetainPtr<WKStringRef>> keys;
    13321258    Vector<WKRetainPtr<WKTypeRef>> values;
    1333 
    1334     keys.append({ AdoptWK, WKStringCreateWithUTF8CString("GamepadIndex") });
    1335     values.append({ AdoptWK, WKUInt64Create(index) });
    1336 
    1337     keys.append({ AdoptWK, WKStringCreateWithUTF8CString("AxisIndex") });
    1338     values.append({ AdoptWK, WKUInt64Create(axisIndex) });
    1339 
    1340     keys.append({ AdoptWK, WKStringCreateWithUTF8CString("Value") });
    1341     values.append({ AdoptWK, WKDoubleCreate(value) });
    1342 
     1259   
     1260    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") });
     1261    values.append({ AdoptWK, WKStringCreateWithJSString(hostName) });
     1262   
     1263    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName") });
     1264    values.append({ AdoptWK, WKStringCreateWithJSString(topFrameHostName) });
     1265   
    13431266    Vector<WKStringRef> rawKeys;
    13441267    Vector<WKTypeRef> rawValues;
    13451268    rawKeys.resize(keys.size());
    13461269    rawValues.resize(values.size());
    1347 
     1270   
    13481271    for (size_t i = 0; i < keys.size(); ++i) {
    13491272        rawKeys[i] = keys[i].get();
    13501273        rawValues[i] = values[i].get();
    13511274    }
    1352 
    1353     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetMockGamepadAxisValue"));
     1275   
     1276    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubresourceUnderTopFrameOrigin"));
    13541277    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
    1355 
    1356     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
    1357 }
    1358 
    1359 void TestRunner::setMockGamepadButtonValue(unsigned index, unsigned buttonIndex, double value)
     1278    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1279}
     1280
     1281void TestRunner::setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo)
    13601282{
    13611283    Vector<WKRetainPtr<WKStringRef>> keys;
    13621284    Vector<WKRetainPtr<WKTypeRef>> values;
    1363 
    1364     keys.append({ AdoptWK, WKStringCreateWithUTF8CString("GamepadIndex") });
    1365     values.append({ AdoptWK, WKUInt64Create(index) });
    1366 
    1367     keys.append({ AdoptWK, WKStringCreateWithUTF8CString("ButtonIndex") });
    1368     values.append({ AdoptWK, WKUInt64Create(buttonIndex) });
    1369 
    1370     keys.append({ AdoptWK, WKStringCreateWithUTF8CString("Value") });
    1371     values.append({ AdoptWK, WKDoubleCreate(value) });
    1372 
     1285   
     1286    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") });
     1287    values.append({ AdoptWK, WKStringCreateWithJSString(hostName) });
     1288   
     1289    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedTo") });
     1290    values.append({ AdoptWK, WKStringCreateWithJSString(hostNameRedirectedTo) });
     1291   
    13731292    Vector<WKStringRef> rawKeys;
    13741293    Vector<WKTypeRef> rawValues;
    13751294    rawKeys.resize(keys.size());
    13761295    rawValues.resize(values.size());
    1377 
     1296   
    13781297    for (size_t i = 0; i < keys.size(); ++i) {
    13791298        rawKeys[i] = keys[i].get();
    13801299        rawValues[i] = values[i].get();
    13811300    }
     1301   
     1302    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubresourceUniqueRedirectTo"));
     1303    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
     1304    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1305}
     1306
     1307void TestRunner::setStatisticsTimeToLiveUserInteraction(double seconds)
     1308{
     1309    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsTimeToLiveUserInteraction"));
     1310    WKRetainPtr<WKDoubleRef> messageBody(AdoptWK, WKDoubleCreate(seconds));
     1311    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1312}
     1313
     1314void TestRunner::installStatisticsDidModifyDataRecordsCallback(JSValueRef callback)
     1315{
     1316    cacheTestRunnerCallback(StatisticsDidModifyDataRecordsCallbackID, callback);
     1317}
     1318
     1319void TestRunner::statisticsDidModifyDataRecordsCallback()
     1320{
     1321    callTestRunnerCallback(StatisticsDidModifyDataRecordsCallbackID);
     1322}
     1323
     1324void TestRunner::statisticsFireDataModificationHandler()
     1325{
     1326    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsFireDataModificationHandler"));
     1327    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
     1328}
     1329
     1330void TestRunner::setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool value)
     1331{
     1332    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsNotifyPagesWhenDataRecordsWereScanned"));
     1333    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
     1334    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1335}
     1336
     1337void TestRunner::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool value)
     1338{
     1339    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsShouldClassifyResourcesBeforeDataRecordsRemoval"));
     1340    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
     1341    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1342}
     1343
     1344void TestRunner::setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double seconds)
     1345{
     1346    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsMinimumTimeBetweeenDataRecordsRemoval"));
     1347    WKRetainPtr<WKDoubleRef> messageBody(AdoptWK, WKDoubleCreate(seconds));
     1348    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1349}
     1350   
     1351void TestRunner::statisticsResetToConsistentState()
     1352{
     1353    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsResetToConsistentState"));
     1354    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
     1355}
     1356
     1357#if PLATFORM(MAC)
     1358void TestRunner::connectMockGamepad(unsigned index)
     1359{
     1360    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("ConnectMockGamepad"));
     1361    WKRetainPtr<WKTypeRef> messageBody(AdoptWK, WKUInt64Create(index));
     1362
     1363    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1364}
     1365
     1366void TestRunner::disconnectMockGamepad(unsigned index)
     1367{
     1368    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("DisconnectMockGamepad"));
     1369    WKRetainPtr<WKTypeRef> messageBody(AdoptWK, WKUInt64Create(index));
     1370
     1371    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1372}
     1373
     1374void TestRunner::setMockGamepadDetails(unsigned index, JSStringRef gamepadID, unsigned axisCount, unsigned buttonCount)
     1375{
     1376    Vector<WKRetainPtr<WKStringRef>> keys;
     1377    Vector<WKRetainPtr<WKTypeRef>> values;
     1378
     1379    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("GamepadID") });
     1380    values.append(toWK(gamepadID));
     1381
     1382    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("GamepadIndex") });
     1383    values.append({ AdoptWK, WKUInt64Create(index) });
     1384
     1385    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("AxisCount") });
     1386    values.append({ AdoptWK, WKUInt64Create(axisCount) });
     1387
     1388    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("ButtonCount") });
     1389    values.append({ AdoptWK, WKUInt64Create(buttonCount) });
     1390
     1391    Vector<WKStringRef> rawKeys;
     1392    Vector<WKTypeRef> rawValues;
     1393    rawKeys.resize(keys.size());
     1394    rawValues.resize(values.size());
     1395
     1396    for (size_t i = 0; i < keys.size(); ++i) {
     1397        rawKeys[i] = keys[i].get();
     1398        rawValues[i] = values[i].get();
     1399    }
     1400
     1401    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetMockGamepadDetails"));
     1402    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
     1403
     1404    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1405}
     1406
     1407void TestRunner::setMockGamepadAxisValue(unsigned index, unsigned axisIndex, double value)
     1408{
     1409    Vector<WKRetainPtr<WKStringRef>> keys;
     1410    Vector<WKRetainPtr<WKTypeRef>> values;
     1411
     1412    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("GamepadIndex") });
     1413    values.append({ AdoptWK, WKUInt64Create(index) });
     1414
     1415    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("AxisIndex") });
     1416    values.append({ AdoptWK, WKUInt64Create(axisIndex) });
     1417
     1418    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("Value") });
     1419    values.append({ AdoptWK, WKDoubleCreate(value) });
     1420
     1421    Vector<WKStringRef> rawKeys;
     1422    Vector<WKTypeRef> rawValues;
     1423    rawKeys.resize(keys.size());
     1424    rawValues.resize(values.size());
     1425
     1426    for (size_t i = 0; i < keys.size(); ++i) {
     1427        rawKeys[i] = keys[i].get();
     1428        rawValues[i] = values[i].get();
     1429    }
     1430
     1431    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetMockGamepadAxisValue"));
     1432    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
     1433
     1434    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1435}
     1436
     1437void TestRunner::setMockGamepadButtonValue(unsigned index, unsigned buttonIndex, double value)
     1438{
     1439    Vector<WKRetainPtr<WKStringRef>> keys;
     1440    Vector<WKRetainPtr<WKTypeRef>> values;
     1441
     1442    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("GamepadIndex") });
     1443    values.append({ AdoptWK, WKUInt64Create(index) });
     1444
     1445    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("ButtonIndex") });
     1446    values.append({ AdoptWK, WKUInt64Create(buttonIndex) });
     1447
     1448    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("Value") });
     1449    values.append({ AdoptWK, WKDoubleCreate(value) });
     1450
     1451    Vector<WKStringRef> rawKeys;
     1452    Vector<WKTypeRef> rawValues;
     1453    rawKeys.resize(keys.size());
     1454    rawValues.resize(values.size());
     1455
     1456    for (size_t i = 0; i < keys.size(); ++i) {
     1457        rawKeys[i] = keys[i].get();
     1458        rawValues[i] = values[i].get();
     1459    }
    13821460
    13831461    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetMockGamepadButtonValue"));
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r212691 r212757  
    355355    void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value);
    356356    bool isStatisticsHasHadUserInteraction(JSStringRef hostName);
     357    void setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
     358    void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
     359    void setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
    357360    void setStatisticsTimeToLiveUserInteraction(double seconds);
    358361    void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r212691 r212757  
    22302230}
    22312231
     2232void TestController::setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
     2233{
     2234    WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(hostName, topFrameHostName);
     2235}
     2236
     2237void TestController::setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
     2238{
     2239    WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(hostName, topFrameHostName);
     2240}
     2241   
     2242void TestController::setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo)
     2243{
     2244    WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(hostName, hostNameRedirectedTo);
     2245}
     2246
    22322247void TestController::setStatisticsTimeToLiveUserInteraction(double seconds)
    22332248{
  • trunk/Tools/WebKitTestRunner/TestController.h

    r212691 r212757  
    153153    void setStatisticsHasHadUserInteraction(WKStringRef hostName, bool value);
    154154    bool isStatisticsHasHadUserInteraction(WKStringRef hostName);
     155    void setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
     156    void setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
     157    void setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo);
    155158    void setStatisticsTimeToLiveUserInteraction(double seconds);
    156159    void statisticsFireDataModificationHandler();
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r212691 r212757  
    933933    }
    934934   
     935    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubframeUnderTopFrameOrigin")) {
     936        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     937       
     938        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     939        WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName"));
     940        WKRetainPtr<WKStringRef> topFrameHostNameKey(AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName"));
     941       
     942        WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
     943        WKStringRef topFrameHostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, topFrameHostNameKey.get()));
     944
     945        TestController::singleton().setStatisticsSubframeUnderTopFrameOrigin(hostName, topFrameHostName);
     946        return nullptr;
     947    }
     948   
     949    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubresourceUnderTopFrameOrigin")) {
     950        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     951       
     952        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     953        WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName"));
     954        WKRetainPtr<WKStringRef> topFrameHostNameKey(AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName"));
     955       
     956        WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
     957        WKStringRef topFrameHostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, topFrameHostNameKey.get()));
     958       
     959        TestController::singleton().setStatisticsSubresourceUnderTopFrameOrigin(hostName, topFrameHostName);
     960        return nullptr;
     961    }
     962   
     963    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubresourceUniqueRedirectTo")) {
     964        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     965       
     966        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     967        WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName"));
     968        WKRetainPtr<WKStringRef> hostNameRedirectedToKey(AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedTo"));
     969       
     970        WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
     971        WKStringRef hostNameRedirectedTo = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameRedirectedToKey.get()));
     972       
     973        TestController::singleton().setStatisticsSubresourceUniqueRedirectTo(hostName, hostNameRedirectedTo);
     974        return nullptr;
     975    }
     976
    935977    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsTimeToLiveUserInteraction")) {
    936978        ASSERT(WKGetTypeID(messageBody) == WKDoubleGetTypeID());
  • trunk/WebKitLibraries/ChangeLog

    r212691 r212757  
     12017-02-21  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics: Add alternate classification method
     4        https://bugs.webkit.org/show_bug.cgi?id=168347
     5        <rdar://problem/30352793>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework: Added.
     10        * WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework/CorePrediction.tbd: Added.
     11            Stubs for private framework.
     12
    1132017-02-20  Ryan Haddad  <ryanhaddad@apple.com>
    214
Note: See TracChangeset for help on using the changeset viewer.