<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[206869] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/206869">206869</a></dd>
<dt>Author</dt> <dd>wilander@apple.com</dd>
<dt>Date</dt> <dd>2016-10-06 10:40:12 -0700 (Thu, 06 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update Resource Load Statistics
https://bugs.webkit.org/show_bug.cgi?id=162811

Reviewed by Alex Christensen.

Source/WebCore:

No new tests. The counting is based on top privately owned domains
which currently is not supported by layout tests nor API tests.

* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::connect):
    Now captures statistics for web sockets too.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadResourceSynchronously):
* loader/ResourceLoadObserver.cpp:
    Now captures statistics for synchronous XHR too.
(WebCore::is3xxRedirect):
    Convenience function.
(WebCore::ResourceLoadObserver::shouldLog):
    Convenience function.
(WebCore::ResourceLoadObserver::logFrameNavigation):
    Updated to make use of new convenience functions.
(WebCore::ResourceLoadObserver::logSubresourceLoading):
    Updated to make use of new convenience functions.
(WebCore::ResourceLoadObserver::logWebSocketLoading):
    Added.
(WebCore::ResourceLoadObserver::logUserInteraction):
    Updated to make use of new convenience functions.
(WebCore::ResourceLoadObserver::primaryDomain):
    Now makes use of the Public Suffix list.
    Removed old custom parsing of primary domain.
* loader/ResourceLoadObserver.h:
* loader/ResourceLoadStatisticsStore.cpp:
(WebCore::ResourceLoadStatisticsStore::prevalentResourceDomainsWithoutUserInteraction):
    Convenience function.
(WebCore::ResourceLoadStatisticsStore::processStatistics): Deleted.
* loader/ResourceLoadStatisticsStore.h:
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::willSendRequestInternal):
    Moved logging call higher up and added a check for whether we
    are loading the main resource. The reason for moving it up is
    to capture the request before some data may be cleared out in
    redirect handling. We also want to capture failed CORS requests
    since they are sent and then cancelled on the way back.

Source/WebKit2:

* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics):
    Switched to vector-based classification.
(WebKit::WebResourceLoadStatisticsStore::classifyResource):
    Simplified logic and moved the split between has and has
    no user interaction into ResourceLoadStatisticsStore.
(WebKit::WebResourceLoadStatisticsStore::clearDataRecords):
    Added.
(WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
    Updated to make use of the new functions.
(WebKit::WebResourceLoadStatisticsStore::persistentStoragePath):
    Removed stray whitespace.
(WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
    Removed stray whitespace.
(WebKit::WebResourceLoadStatisticsStore::createDecoderFromDisk):
    Removed stray whitespace.
(WebKit::hasPrevalentResourceCharacteristics): Deleted.
(WebKit::classifyPrevalentResources): Deleted.
* UIProcess/WebResourceLoadStatisticsStore.h:
    Added member variables for clearing of data records.

Tools:

* TestWebKitAPI/Tests/mac/PublicSuffix.mm:
    Change from USE(PUBLIC_SUFFIX_LIST) to ENABLE(PUBLIC_SUFFIX_LIST)</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsWebSocketcpp">trunk/Source/WebCore/Modules/websockets/WebSocket.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadObservercpp">trunk/Source/WebCore/loader/ResourceLoadObserver.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadObserverh">trunk/Source/WebCore/loader/ResourceLoadObserver.h</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadStatisticsStorecpp">trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadStatisticsStoreh">trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h</a></li>
<li><a href="#trunkSourceWebCoreloaderSubresourceLoadercpp">trunk/Source/WebCore/loader/SubresourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebResourceLoadStatisticsStorecpp">trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebResourceLoadStatisticsStoreh">trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsmacPublicSuffixmm">trunk/Tools/TestWebKitAPI/Tests/mac/PublicSuffix.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Source/WebCore/ChangeLog        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2016-10-06  John Wilander  &lt;wilander@apple.com&gt;
+
+        Update Resource Load Statistics
+        https://bugs.webkit.org/show_bug.cgi?id=162811
+
+        Reviewed by Alex Christensen.
+
+        No new tests. The counting is based on top privately owned domains
+        which currently is not supported by layout tests nor API tests.
+
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::WebSocket::connect):
+            Now captures statistics for web sockets too.
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadResourceSynchronously):
+        * loader/ResourceLoadObserver.cpp:
+            Now captures statistics for synchronous XHR too.
+        (WebCore::is3xxRedirect):
+            Convenience function.
+        (WebCore::ResourceLoadObserver::shouldLog):
+            Convenience function.
+        (WebCore::ResourceLoadObserver::logFrameNavigation):
+            Updated to make use of new convenience functions.
+        (WebCore::ResourceLoadObserver::logSubresourceLoading):
+            Updated to make use of new convenience functions.
+        (WebCore::ResourceLoadObserver::logWebSocketLoading):
+            Added.
+        (WebCore::ResourceLoadObserver::logUserInteraction):
+            Updated to make use of new convenience functions.
+        (WebCore::ResourceLoadObserver::primaryDomain):
+            Now makes use of the Public Suffix list.
+            Removed old custom parsing of primary domain.
+        * loader/ResourceLoadObserver.h:
+        * loader/ResourceLoadStatisticsStore.cpp:
+        (WebCore::ResourceLoadStatisticsStore::prevalentResourceDomainsWithoutUserInteraction):
+            Convenience function.
+        (WebCore::ResourceLoadStatisticsStore::processStatistics): Deleted.
+        * loader/ResourceLoadStatisticsStore.h:
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::willSendRequestInternal):
+            Moved logging call higher up and added a check for whether we
+            are loading the main resource. The reason for moving it up is
+            to capture the request before some data may be cleared out in
+            redirect handling. We also want to capture failed CORS requests
+            since they are sent and then cancelled on the way back.
+
</ins><span class="cx"> 2016-10-06  Adam Bergkvist  &lt;adam.bergkvist@ericsson.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebRTC: Add support for the iceconnectionstatechange event in MediaEndpointPeerConnection
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsWebSocketcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="cx"> #include &quot;MessageEvent.h&quot;
</span><ins>+#include &quot;ResourceLoadObserver.h&quot;
</ins><span class="cx"> #include &quot;ScriptController.h&quot;
</span><span class="cx"> #include &quot;ScriptExecutionContext.h&quot;
</span><span class="cx"> #include &quot;SecurityOrigin.h&quot;
</span><span class="lines">@@ -318,7 +319,8 @@
</span><span class="cx">             });
</span><span class="cx"> #endif
</span><span class="cx">             return;
</span><del>-        }
</del><ins>+        } else
+            ResourceLoadObserver::sharedObserver().logWebSocketLoading(document.frame(), m_url);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     String protocolString;
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -97,6 +97,7 @@
</span><span class="cx"> #include &quot;ProgressTracker.h&quot;
</span><span class="cx"> #include &quot;ResourceHandle.h&quot;
</span><span class="cx"> #include &quot;ResourceLoadInfo.h&quot;
</span><ins>+#include &quot;ResourceLoadObserver.h&quot;
</ins><span class="cx"> #include &quot;ResourceRequest.h&quot;
</span><span class="cx"> #include &quot;SVGDocument.h&quot;
</span><span class="cx"> #include &quot;SVGLocatable.h&quot;
</span><span class="lines">@@ -2774,6 +2775,7 @@
</span><span class="cx">             platformStrategies()-&gt;loaderStrategy()-&gt;loadResourceSynchronously(networkingContext(), identifier, newRequest, storedCredentials, clientCredentialPolicy, error, response, buffer);
</span><span class="cx">             data = SharedBuffer::adoptVector(buffer);
</span><span class="cx">             documentLoader()-&gt;applicationCacheHost()-&gt;maybeLoadFallbackSynchronously(newRequest, error, response, data);
</span><ins>+            ResourceLoadObserver::sharedObserver().logSubresourceLoading(&amp;m_frame, newRequest, response);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     notifier().sendRemainingDelegateMessages(m_documentLoader.get(), identifier, request, response, data ? data-&gt;data() : nullptr, data ? data-&gt;size() : 0, -1, error);
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadObservercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;NetworkStorageSession.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;PlatformStrategies.h&quot;
</span><ins>+#include &quot;PublicSuffix.h&quot;
</ins><span class="cx"> #include &quot;ResourceLoadStatistics.h&quot;
</span><span class="cx"> #include &quot;ResourceLoadStatisticsStore.h&quot;
</span><span class="cx"> #include &quot;ResourceRequest.h&quot;
</span><span class="lines">@@ -57,23 +58,31 @@
</span><span class="cx">     m_store = WTFMove(store);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ResourceLoadObserver::logFrameNavigation(const Frame&amp; frame, const Frame&amp; topFrame, const ResourceRequest&amp; newRequest, const ResourceResponse&amp; redirectResponse)
</del><ins>+static inline bool is3xxRedirect(const ResourceResponse&amp; response)
</ins><span class="cx"> {
</span><del>-    if (!Settings::resourceLoadStatisticsEnabled())
-        return;
</del><ins>+    return response.httpStatusCode() &gt;= 300 &amp;&amp; response.httpStatusCode() &lt;= 399;
+}
</ins><span class="cx"> 
</span><del>-    if (!m_store)
-        return;
</del><ins>+bool ResourceLoadObserver::shouldLog(Page* page)
+{
+    // FIXME: Err on the safe side until we have sorted out what to do in worker contexts
+    if (!page)
+        return false;
+    return Settings::resourceLoadStatisticsEnabled()
+        &amp;&amp; !page-&gt;usesEphemeralSession()
+        &amp;&amp; m_store;
+}
</ins><span class="cx"> 
</span><ins>+void ResourceLoadObserver::logFrameNavigation(const Frame&amp; frame, const Frame&amp; topFrame, const ResourceRequest&amp; newRequest, const ResourceResponse&amp; redirectResponse)
+{
</ins><span class="cx">     ASSERT(frame.document());
</span><span class="cx">     ASSERT(topFrame.document());
</span><span class="cx">     ASSERT(topFrame.page());
</span><del>-
-    bool needPrivacy = topFrame.page() ? topFrame.page()-&gt;usesEphemeralSession() : false;
-    if (needPrivacy)
</del><ins>+    
+    if (!shouldLog(topFrame.page()))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    bool isRedirect = !redirectResponse.isNull();
</del><ins>+    bool isRedirect = is3xxRedirect(redirectResponse);
</ins><span class="cx">     bool isMainFrame = frame.isMainFrame();
</span><span class="cx">     const URL&amp; sourceURL = frame.document()-&gt;url();
</span><span class="cx">     const URL&amp; targetURL = newRequest.url();
</span><span class="lines">@@ -148,17 +157,12 @@
</span><span class="cx">     
</span><span class="cx"> void ResourceLoadObserver::logSubresourceLoading(const Frame* frame, const ResourceRequest&amp; newRequest, const ResourceResponse&amp; redirectResponse)
</span><span class="cx"> {
</span><del>-    if (!Settings::resourceLoadStatisticsEnabled())
-        return;
</del><ins>+    ASSERT(frame-&gt;page());
</ins><span class="cx"> 
</span><del>-    if (!m_store)
</del><ins>+    if (!shouldLog(frame-&gt;page()))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    bool needPrivacy = (frame &amp;&amp; frame-&gt;page()) ? frame-&gt;page()-&gt;usesEphemeralSession() : false;
-    if (needPrivacy)
-        return;
-    
-    bool isRedirect = !redirectResponse.isNull();
</del><ins>+    bool isRedirect = is3xxRedirect(redirectResponse);
</ins><span class="cx">     const URL&amp; sourceURL = redirectResponse.url();
</span><span class="cx">     const URL&amp; targetURL = newRequest.url();
</span><span class="cx">     const URL&amp; mainFrameURL = frame ? frame-&gt;mainFrame().document()-&gt;url() : URL();
</span><span class="lines">@@ -166,7 +170,10 @@
</span><span class="cx">     auto targetHost = targetURL.host();
</span><span class="cx">     auto mainFrameHost = mainFrameURL.host();
</span><span class="cx"> 
</span><del>-    if (targetHost.isEmpty() || mainFrameHost.isEmpty() || targetHost == mainFrameHost || targetHost == sourceURL.host())
</del><ins>+    if (targetHost.isEmpty()
+        || mainFrameHost.isEmpty()
+        || targetHost == mainFrameHost
+        || (isRedirect &amp;&amp; targetHost == sourceURL.host()))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     auto targetPrimaryDomain = primaryDomain(targetURL);
</span><span class="lines">@@ -173,7 +180,7 @@
</span><span class="cx">     auto mainFramePrimaryDomain = primaryDomain(mainFrameURL);
</span><span class="cx">     auto sourcePrimaryDomain = primaryDomain(sourceURL);
</span><span class="cx">     
</span><del>-    if (targetPrimaryDomain == mainFramePrimaryDomain || targetPrimaryDomain == sourcePrimaryDomain)
</del><ins>+    if (targetPrimaryDomain == mainFramePrimaryDomain || (isRedirect &amp;&amp; targetPrimaryDomain == sourcePrimaryDomain))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     auto&amp; targetStatistics = m_store-&gt;ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain);
</span><span class="lines">@@ -210,20 +217,60 @@
</span><span class="cx">     
</span><span class="cx">     m_store-&gt;fireDataModificationHandler();
</span><span class="cx"> }
</span><ins>+
+void ResourceLoadObserver::logWebSocketLoading(const Frame* frame, const URL&amp; targetURL)
+{
+    // FIXME: Web sockets can run in detached frames. Decide how to count such connections.
+    // See LayoutTests/http/tests/websocket/construct-in-detached-frame.html
+    if (!frame)
+        return;
+
+    if (!shouldLog(frame-&gt;page()))
+        return;
+
+    const URL&amp; mainFrameURL = frame-&gt;mainFrame().document()-&gt;url();
+
+    auto targetHost = targetURL.host();
+    auto mainFrameHost = mainFrameURL.host();
</ins><span class="cx">     
</span><ins>+    if (targetHost.isEmpty()
+        || mainFrameHost.isEmpty()
+        || targetHost == mainFrameHost)
+        return;
+    
+    auto targetPrimaryDomain = primaryDomain(targetURL);
+    auto mainFramePrimaryDomain = primaryDomain(mainFrameURL);
+    
+    if (targetPrimaryDomain == mainFramePrimaryDomain)
+        return;
+
+    auto&amp; targetStatistics = m_store-&gt;ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain);
+    
+    auto mainFrameOrigin = SecurityOrigin::create(mainFrameURL);
+    targetStatistics.subresourceUnderTopFrameOrigins.add(mainFramePrimaryDomain);
+    
+    ++targetStatistics.subresourceHasBeenSubresourceCount;
+    
+    auto totalVisited = std::max(m_originsVisitedMap.size(), 1U);
+    
+    targetStatistics.subresourceHasBeenSubresourceCountDividedByTotalNumberOfOriginsVisited = static_cast&lt;double&gt;(targetStatistics.subresourceHasBeenSubresourceCount) / totalVisited;
+
+    m_store-&gt;fireDataModificationHandler();
+}
+
</ins><span class="cx"> void ResourceLoadObserver::logUserInteraction(const Document&amp; document)
</span><span class="cx"> {
</span><del>-    if (!Settings::resourceLoadStatisticsEnabled())
-        return;
</del><ins>+    ASSERT(document.page());
</ins><span class="cx"> 
</span><del>-    if (!m_store)
</del><ins>+    if (!shouldLog(document.page()))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    bool needPrivacy = document.page() ? document.page()-&gt;usesEphemeralSession() : false;
-    if (needPrivacy)
</del><ins>+    auto&amp; url = document.url();
+
+    if (url.isBlankURL() || url.isEmpty())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto&amp; statistics = m_store-&gt;ensureResourceStatisticsForPrimaryDomain(primaryDomain(document.url()));
</del><ins>+    auto&amp; statistics = m_store-&gt;ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
</ins><span class="cx">     statistics.hadUserInteraction = true;
</span><span class="cx">     m_store-&gt;fireDataModificationHandler();
</span><span class="cx"> }
</span><span class="lines">@@ -230,42 +277,22 @@
</span><span class="cx">     
</span><span class="cx"> String ResourceLoadObserver::primaryDomain(const URL&amp; url)
</span><span class="cx"> {
</span><ins>+    String primaryDomain;
</ins><span class="cx">     String host = url.host();
</span><del>-    Vector&lt;String&gt; hostSplitOnDot;
-    
-    host.split('.', false, hostSplitOnDot);
-
-    String primaryDomain;
-    if (host.isNull())
</del><ins>+    if (host.isNull() || host.isEmpty())
</ins><span class="cx">         primaryDomain = &quot;nullOrigin&quot;;
</span><del>-    else if (hostSplitOnDot.size() &lt; 3)
-        primaryDomain = host;
</del><ins>+#if ENABLE(PUBLIC_SUFFIX_LIST)
</ins><span class="cx">     else {
</span><del>-        // Skip TLD and then up to two domains smaller than 4 characters
-        int primaryDomainCutOffIndex = hostSplitOnDot.size() - 2;
-
-        // Start with TLD as a given part
-        size_t numberOfParts = 1;
-        for (; primaryDomainCutOffIndex &gt;= 0; --primaryDomainCutOffIndex) {
-            ++numberOfParts;
-
-            // We have either a domain part that's 4 chars or longer, or 3 domain parts including TLD
-            if (hostSplitOnDot.at(primaryDomainCutOffIndex).length() &gt;= 4 || numberOfParts &gt;= 3)
-                break;
-        }
-
-        if (primaryDomainCutOffIndex &lt; 0)
</del><ins>+        primaryDomain = topPrivatelyControlledDomain(host);
+        // We will have an empty string here if there is no TLD.
+        // Use the host in such case.
+        if (primaryDomain.isEmpty())
</ins><span class="cx">             primaryDomain = host;
</span><del>-        else {
-            StringBuilder builder;
-            builder.append(hostSplitOnDot.at(primaryDomainCutOffIndex));
-            for (size_t j = primaryDomainCutOffIndex + 1; j &lt; hostSplitOnDot.size(); ++j) {
-                builder.append('.');
-                builder.append(hostSplitOnDot[j]);
-            }
-            primaryDomain = builder.toString();
-        }
</del><span class="cx">     }
</span><ins>+#else
+    else
+        primaryDomain = host;
+#endif
</ins><span class="cx"> 
</span><span class="cx">     return primaryDomain;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadObserverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.h (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoadObserver.h        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> 
</span><span class="cx"> class Document;
</span><span class="cx"> class Frame;
</span><ins>+class Page;
</ins><span class="cx"> class ResourceRequest;
</span><span class="cx"> class ResourceResponse;
</span><span class="cx"> class URL;
</span><span class="lines">@@ -47,6 +48,7 @@
</span><span class="cx">     
</span><span class="cx">     void logFrameNavigation(const Frame&amp; frame, const Frame&amp; topFrame, const ResourceRequest&amp; newRequest, const ResourceResponse&amp; redirectResponse);
</span><span class="cx">     void logSubresourceLoading(const Frame*, const ResourceRequest&amp; newRequest, const ResourceResponse&amp; redirectResponse);
</span><ins>+    void logWebSocketLoading(const Frame*, const URL&amp;);
</ins><span class="cx"> 
</span><span class="cx">     void logUserInteraction(const Document&amp;);
</span><span class="cx">     
</span><span class="lines">@@ -55,6 +57,7 @@
</span><span class="cx">     WEBCORE_EXPORT String statisticsForOrigin(const String&amp;);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    bool shouldLog(Page*);
</ins><span class="cx">     static String primaryDomain(const URL&amp;);
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;ResourceLoadStatisticsStore&gt; m_store;
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadStatisticsStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -154,4 +154,14 @@
</span><span class="cx">     for (auto&amp; resourceStatistic : m_resourceStatisticsMap.values())
</span><span class="cx">         processFunction(resourceStatistic);
</span><span class="cx"> }
</span><ins>+
+Vector&lt;String&gt; ResourceLoadStatisticsStore::prevalentResourceDomainsWithoutUserInteraction()
+{
+    Vector&lt;String&gt; prevalentResources;
+    for (auto&amp; resourceStatistic : m_resourceStatisticsMap.values()) {
+        if (resourceStatistic.isPrevalentResource &amp;&amp; !resourceStatistic.hadUserInteraction)
+            prevalentResources.append(resourceStatistic.highLevelDomain);
+    }
+    return prevalentResources;
</ins><span class="cx"> }
</span><ins>+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadStatisticsStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -63,6 +63,8 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT bool hasEnoughDataForStatisticsProcessing();
</span><span class="cx">     WEBCORE_EXPORT void processStatistics(std::function&lt;void(ResourceLoadStatistics&amp;)&gt;&amp;&amp;);
</span><ins>+
+    WEBCORE_EXPORT Vector&lt;String&gt; prevalentResourceDomainsWithoutUserInteraction();
</ins><span class="cx"> private:
</span><span class="cx">     ResourceLoadStatisticsStore() = default;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderSubresourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/SubresourceLoader.cpp        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -173,6 +173,9 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (newRequest.requester() != ResourceRequestBase::Requester::Main)
+        ResourceLoadObserver::sharedObserver().logSubresourceLoading(m_frame.get(), newRequest, redirectResponse);
+
</ins><span class="cx">     ASSERT(!newRequest.isNull());
</span><span class="cx">     if (!redirectResponse.isNull()) {
</span><span class="cx">         if (options().redirect != FetchOptions::Redirect::Follow) {
</span><span class="lines">@@ -228,8 +231,6 @@
</span><span class="cx">     ResourceLoader::willSendRequestInternal(newRequest, redirectResponse);
</span><span class="cx">     if (newRequest.isNull())
</span><span class="cx">         cancel();
</span><del>-
-    ResourceLoadObserver::sharedObserver().logSubresourceLoading(m_frame.get(), newRequest, redirectResponse);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SubresourceLoader::didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Source/WebKit2/ChangeLog        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2016-10-06  John Wilander  &lt;wilander@apple.com&gt;
+
+        Update Resource Load Statistics
+        https://bugs.webkit.org/show_bug.cgi?id=162811
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics):
+            Switched to vector-based classification.
+        (WebKit::WebResourceLoadStatisticsStore::classifyResource):
+            Simplified logic and moved the split between has and has
+            no user interaction into ResourceLoadStatisticsStore.
+        (WebKit::WebResourceLoadStatisticsStore::clearDataRecords):
+            Added.
+        (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
+            Updated to make use of the new functions.
+        (WebKit::WebResourceLoadStatisticsStore::persistentStoragePath):
+            Removed stray whitespace.
+        (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
+            Removed stray whitespace.
+        (WebKit::WebResourceLoadStatisticsStore::createDecoderFromDisk):
+            Removed stray whitespace.
+        (WebKit::hasPrevalentResourceCharacteristics): Deleted.
+        (WebKit::classifyPrevalentResources): Deleted.
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+            Added member variables for clearing of data records.
+
</ins><span class="cx"> 2016-10-06  Youenn Fablet  &lt;youenn@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WK2] 304 revalidation on the network process does not update the validated response
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebResourceLoadStatisticsStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -26,11 +26,18 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;WebResourceLoadStatisticsStore.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;APIWebsiteDataStore.h&quot;
</ins><span class="cx"> #include &quot;WebProcessMessages.h&quot;
</span><span class="cx"> #include &quot;WebProcessPool.h&quot;
</span><span class="cx"> #include &quot;WebResourceLoadStatisticsStoreMessages.h&quot;
</span><ins>+#include &quot;WebsiteDataFetchOption.h&quot;
+#include &quot;WebsiteDataType.h&quot;
</ins><span class="cx"> #include &lt;WebCore/KeyedCoding.h&gt;
</span><span class="cx"> #include &lt;WebCore/ResourceLoadStatistics.h&gt;
</span><ins>+#include &lt;wtf/CurrentTime.h&gt;
+#include &lt;wtf/MainThread.h&gt;
+#include &lt;wtf/MathExtras.h&gt;
+#include &lt;wtf/RunLoop.h&gt;
</ins><span class="cx"> #include &lt;wtf/threads/BinarySemaphore.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="lines">@@ -37,13 +44,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-// Sub frame classification thresholds
-static const unsigned subframeUnderTopFrameOriginsThreshold = 3;
-    
-// Subresource classification thresholds
-static const unsigned subresourceUnderTopFrameOriginsThreshold = 5;
-static const unsigned subresourceHasBeenRedirectedFromToUniqueDomainsThreshold = 3;
-static const unsigned redirectedToOtherPrevalentResourceOriginsThreshold = 2;
</del><ins>+static const auto numberOfSecondsBetweenClearingDataRecords = 600;
+static const auto featureVectorLengthThreshold = 3;
</ins><span class="cx"> 
</span><span class="cx"> Ref&lt;WebResourceLoadStatisticsStore&gt; WebResourceLoadStatisticsStore::create(const String&amp; resourceLoadStatisticsDirectory)
</span><span class="cx"> {
</span><span class="lines">@@ -51,7 +53,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(const String&amp; resourceLoadStatisticsDirectory)
</span><del>-    : m_resourceStatisticsStore(WebCore::ResourceLoadStatisticsStore::create())
</del><ins>+    : m_resourceStatisticsStore(ResourceLoadStatisticsStore::create())
</ins><span class="cx">     , m_statisticsQueue(WorkQueue::create(&quot;WebResourceLoadStatisticsStore Process Data Queue&quot;))
</span><span class="cx">     , m_storagePath(resourceLoadStatisticsDirectory)
</span><span class="cx"> {
</span><span class="lines">@@ -61,37 +63,103 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline bool hasPrevalentResourceCharacteristics(const ResourceLoadStatistics&amp; resourceStatistic)
</del><ins>+bool WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics(const ResourceLoadStatistics&amp; resourceStatistic)
</ins><span class="cx"> {
</span><del>-    return resourceStatistic.subframeUnderTopFrameOrigins.size() &gt; subframeUnderTopFrameOriginsThreshold
-        || resourceStatistic.subresourceUnderTopFrameOrigins.size() &gt; subresourceUnderTopFrameOriginsThreshold
-        || resourceStatistic.subresourceUniqueRedirectsTo.size() &gt; subresourceHasBeenRedirectedFromToUniqueDomainsThreshold
-        || resourceStatistic.redirectedToOtherPrevalentResourceOrigins.size() &gt; redirectedToOtherPrevalentResourceOriginsThreshold;
</del><ins>+    auto subresourceUnderTopFrameOriginsCount = resourceStatistic.subresourceUnderTopFrameOrigins.size();
+    auto subresourceUniqueRedirectsToCount = resourceStatistic.subresourceUniqueRedirectsTo.size();
+    auto subframeUnderTopFrameOriginsCount = resourceStatistic.subframeUnderTopFrameOrigins.size();
+    
+    if (!subresourceUnderTopFrameOriginsCount
+        &amp;&amp; !subresourceUniqueRedirectsToCount
+        &amp;&amp; !subframeUnderTopFrameOriginsCount)
+        return false;
+
+    if (subresourceUnderTopFrameOriginsCount &gt; featureVectorLengthThreshold
+        || subresourceUniqueRedirectsToCount &gt; featureVectorLengthThreshold
+        || subframeUnderTopFrameOriginsCount &gt; 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 &gt; 0);
+
+    return sqrt(vectorLength) &gt; featureVectorLengthThreshold;
</ins><span class="cx"> }
</span><span class="cx">     
</span><del>-static inline void classifyPrevalentResources(ResourceLoadStatistics&amp; resourceStatistic, Vector&lt;String&gt;&amp; prevalentResources, Vector&lt;String&gt;&amp; prevalentResourcesWithUserInteraction)
</del><ins>+void WebResourceLoadStatisticsStore::classifyResource(ResourceLoadStatistics&amp; resourceStatistic)
</ins><span class="cx"> {
</span><del>-    if (resourceStatistic.isPrevalentResource || hasPrevalentResourceCharacteristics(resourceStatistic)) {
</del><ins>+    if (!resourceStatistic.isPrevalentResource &amp;&amp; hasPrevalentResourceCharacteristics(resourceStatistic)) {
</ins><span class="cx">         resourceStatistic.isPrevalentResource = true;
</span><del>-        if (resourceStatistic.hadUserInteraction)
-            prevalentResourcesWithUserInteraction.append(resourceStatistic.highLevelDomain);
-        else
-            prevalentResources.append(resourceStatistic.highLevelDomain);
</del><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebResourceLoadStatisticsStore::clearDataRecords()
+{
+    if (m_dataStoreClearPending)
+        return;
+
+    Vector&lt;String&gt; prevalentResourceDomains = coreStore().prevalentResourceDomainsWithoutUserInteraction();
+    if (!prevalentResourceDomains.size())
+        return;
+
+    double now = currentTime();
+    if (!m_lastTimeDataRecordsWereCleared) {
+        m_lastTimeDataRecordsWereCleared = now;
+        return;
+    }
+
+    if (now &lt; (m_lastTimeDataRecordsWereCleared + numberOfSecondsBetweenClearingDataRecords))
+        return;
+
+    m_dataStoreClearPending = true;
+    m_lastTimeDataRecordsWereCleared = now;
+
+    // Switch to the main thread to get the default website data store
+    RunLoop::main().dispatch([prevalentResourceDomains = WTFMove(prevalentResourceDomains), this] () mutable {
+        auto&amp; websiteDataStore = API::WebsiteDataStore::defaultDataStore()-&gt;websiteDataStore();
+
+        websiteDataStore.fetchData(WebsiteDataType::Cookies, { }, [prevalentResourceDomains = WTFMove(prevalentResourceDomains), this](auto websiteDataRecords) {
+            Vector&lt;WebsiteDataRecord&gt; dataRecords;
+            for (auto&amp; websiteDataRecord : websiteDataRecords) {
+                for (auto&amp; prevalentResourceDomain : prevalentResourceDomains) {
+                    if (websiteDataRecord.displayName.endsWithIgnoringASCIICase(prevalentResourceDomain)) {
+                        auto suffixStart = websiteDataRecord.displayName.length() - prevalentResourceDomain.length();
+                        if (!suffixStart || websiteDataRecord.displayName[suffixStart - 1] == '.')
+                            dataRecords.append(websiteDataRecord);
+                    }
+                }
+            }
+
+            if (!dataRecords.size()) {
+                m_dataStoreClearPending = false;
+                return;
+            }
+
+            auto&amp; websiteDataStore = API::WebsiteDataStore::defaultDataStore()-&gt;websiteDataStore();
+            websiteDataStore.removeData(WebsiteDataType::Cookies, { WTFMove(dataRecords) }, [this] {
+                m_dataStoreClearPending = false;
+            });
+        });
+    });
+}
+
</ins><span class="cx"> void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(const Vector&lt;WebCore::ResourceLoadStatistics&gt;&amp; origins)
</span><span class="cx"> {
</span><span class="cx">     coreStore().mergeStatistics(origins);
</span><span class="cx"> 
</span><del>-    Vector&lt;String&gt; prevalentResources, prevalentResourcesWithUserInteraction;
</del><span class="cx">     if (coreStore().hasEnoughDataForStatisticsProcessing()) {
</span><del>-        coreStore().processStatistics([this, &amp;prevalentResources, &amp;prevalentResourcesWithUserInteraction] (ResourceLoadStatistics&amp; resourceStatistic) {
-            classifyPrevalentResources(resourceStatistic, prevalentResources, prevalentResourcesWithUserInteraction);
</del><ins>+        coreStore().processStatistics([this] (ResourceLoadStatistics&amp; resourceStatistic) {
+            classifyResource(resourceStatistic);
+            clearDataRecords();
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // FIXME: Notify individual WebProcesses of prevalent domains using the two vectors populated by the classifier. &lt;rdar://problem/24703099&gt;
</del><span class="cx">     auto encoder = coreStore().createEncoderFromData();
</span><span class="cx">     
</span><span class="cx">     writeEncoderToDisk(*encoder.get(), &quot;full_browsing_session&quot;);
</span><span class="lines">@@ -152,7 +220,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (m_storagePath.isEmpty())
</span><span class="cx">         return emptyString();
</span><del>-    
</del><ins>+
</ins><span class="cx">     // TODO Decide what to call this file
</span><span class="cx">     return pathByAppendingComponent(m_storagePath, label + &quot;_resourceLog.plist&quot;);
</span><span class="cx"> }
</span><span class="lines">@@ -162,14 +230,14 @@
</span><span class="cx">     RefPtr&lt;SharedBuffer&gt; rawData = encoder.finishEncoding();
</span><span class="cx">     if (!rawData)
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     String resourceLog = persistentStoragePath(label);
</span><span class="cx">     if (resourceLog.isEmpty())
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (!m_storagePath.isEmpty())
</span><span class="cx">         makeAllDirectories(m_storagePath);
</span><del>-    
</del><ins>+
</ins><span class="cx">     auto handle = openFile(resourceLog, OpenForWrite);
</span><span class="cx">     if (!handle)
</span><span class="cx">         return;
</span><span class="lines">@@ -176,7 +244,7 @@
</span><span class="cx">     
</span><span class="cx">     int64_t writtenBytes = writeToFile(handle, rawData-&gt;data(), rawData-&gt;size());
</span><span class="cx">     closeFile(handle);
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (writtenBytes != static_cast&lt;int64_t&gt;(rawData-&gt;size()))
</span><span class="cx">         WTFLogAlways(&quot;WebResourceLoadStatisticsStore: We only wrote %d out of %d bytes to disk&quot;, static_cast&lt;unsigned&gt;(writtenBytes), rawData-&gt;size());
</span><span class="cx"> }
</span><span class="lines">@@ -186,11 +254,11 @@
</span><span class="cx">     String resourceLog = persistentStoragePath(label);
</span><span class="cx">     if (resourceLog.isEmpty())
</span><span class="cx">         return nullptr;
</span><del>-    
</del><ins>+
</ins><span class="cx">     RefPtr&lt;SharedBuffer&gt; rawData = SharedBuffer::createWithContentsOfFile(resourceLog);
</span><span class="cx">     if (!rawData)
</span><span class="cx">         return nullptr;
</span><del>-    
</del><ins>+
</ins><span class="cx">     return KeyedDecoder::decoder(reinterpret_cast&lt;const uint8_t*&gt;(rawData-&gt;data()), rawData-&gt;size());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebResourceLoadStatisticsStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;APIObject.h&quot;
</span><span class="cx"> #include &quot;Connection.h&quot;
</span><ins>+#include &quot;WebsiteDataRecord.h&quot;
</ins><span class="cx"> #include &lt;WebCore/ResourceLoadStatisticsStore.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -71,6 +72,10 @@
</span><span class="cx"> private:
</span><span class="cx">     explicit WebResourceLoadStatisticsStore(const String&amp;);
</span><span class="cx"> 
</span><ins>+    bool hasPrevalentResourceCharacteristics(const WebCore::ResourceLoadStatistics&amp;);
+    void classifyResource(WebCore::ResourceLoadStatistics&amp;);
+    void clearDataRecords();
+
</ins><span class="cx">     String persistentStoragePath(const String&amp; label) const;
</span><span class="cx"> 
</span><span class="cx">     // IPC::MessageReceiver
</span><span class="lines">@@ -83,6 +88,9 @@
</span><span class="cx">     Ref&lt;WTF::WorkQueue&gt; m_statisticsQueue;
</span><span class="cx">     String m_storagePath;
</span><span class="cx">     bool m_resourceLoadStatisticsEnabled { false };
</span><ins>+
+    double m_lastTimeDataRecordsWereCleared { 0 };
+    bool m_dataStoreClearPending { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Tools/ChangeLog        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-10-06  John Wilander  &lt;wilander@apple.com&gt;
+
+        Update Resource Load Statistics
+        https://bugs.webkit.org/show_bug.cgi?id=162811
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/Tests/mac/PublicSuffix.mm:
+            Change from USE(PUBLIC_SUFFIX_LIST) to ENABLE(PUBLIC_SUFFIX_LIST)
+
</ins><span class="cx"> 2016-10-05  Philippe Normand  &lt;pnormand@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GStreamer][OWR] GL rendering support
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacPublicSuffixmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/mac/PublicSuffix.mm (206868 => 206869)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/PublicSuffix.mm        2016-10-06 17:27:23 UTC (rev 206868)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/PublicSuffix.mm        2016-10-06 17:40:12 UTC (rev 206869)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> 
</span><del>-#if USE(PUBLIC_SUFFIX_LIST)
</del><ins>+#if ENABLE(PUBLIC_SUFFIX_LIST)
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;WTFStringUtilities.h&quot;
</span><span class="cx"> #include &lt;WebCore/PublicSuffix.h&gt;
</span></span></pre>
</div>
</div>

</body>
</html>