Limit number of prefetches of a given page
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 May 2019 06:44:13 +0000 (06:44 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 May 2019 06:44:13 +0000 (06:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197736

Patch by Rob Buis <rbuis@igalia.com> on 2019-05-09
Reviewed by Darin Adler.

Limit prefetches for same url to 1.

* NetworkProcess/cache/PrefetchCache.cpp:
(WebKit::PrefetchCache::store):

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

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/PrefetchCache.cpp

index 362afc2..bfd5839 100644 (file)
@@ -1,3 +1,15 @@
+2019-05-09  Rob Buis  <rbuis@igalia.com>
+
+        Limit number of prefetches of a given page
+        https://bugs.webkit.org/show_bug.cgi?id=197736
+
+        Reviewed by Darin Adler.
+
+        Limit prefetches for same url to 1.
+
+        * NetworkProcess/cache/PrefetchCache.cpp:
+        (WebKit::PrefetchCache::store):
+
 2019-05-09  Alex Christensen  <achristensen@webkit.org>
 
         Unreviewed, rolling out most of r245151.
index 73cab47..0401fc9 100644 (file)
@@ -69,7 +69,10 @@ void PrefetchCache::store(const URL& requestUrl, WebCore::ResourceResponse&& res
 {
     if (!m_sessionPrefetches)
         m_sessionPrefetches = std::make_unique<PrefetchEntriesMap>();
-    m_sessionPrefetches->set(requestUrl, std::make_unique<PrefetchCache::Entry>(WTFMove(response), WTFMove(buffer)));
+    auto addResult = m_sessionPrefetches->add(requestUrl, std::make_unique<PrefetchCache::Entry>(WTFMove(response), WTFMove(buffer)));
+    // Limit prefetches for same url to 1.
+    if (!addResult.isNewEntry)
+        return;
     m_sessionExpirationList.append(std::make_tuple(requestUrl, WallTime::now()));
     if (!m_expirationTimer.isActive())
         m_expirationTimer.startOneShot(expirationTimeout);