Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Unified Diff: third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp

Issue 2332333003: Make internals.isPreloaded() to remain the same before/after clearPreloads() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: const auto& Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
index 6168ae0dd6cdbf4e36ccb3a73b23f218bd98fb52..471f98fae3e9992d44a7f91549ee9d60213933c6 100644
--- a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
+++ b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
@@ -873,18 +873,27 @@ void ResourceFetcher::preloadStarted(Resource* resource)
if (!m_preloads)
m_preloads = new HeapListHashSet<Member<Resource>>;
m_preloads->add(resource);
+
+ if (m_preloadedURLsForTest)
+ m_preloadedURLsForTest->add(resource->url().getString());
}
-bool ResourceFetcher::isPreloaded(const KURL& url) const
+void ResourceFetcher::enableIsPreloadedForTest()
{
+ if (m_preloadedURLsForTest)
+ return;
+ m_preloadedURLsForTest = wrapUnique(new HashSet<String>);
+
if (m_preloads) {
- for (auto resource : *m_preloads) {
- if (resource->url() == url)
- return true;
- }
+ for (const auto& resource : *m_preloads)
+ m_preloadedURLsForTest->add(resource->url().getString());
}
+}
- return false;
+bool ResourceFetcher::isPreloadedForTest(const KURL& url) const
+{
+ DCHECK(m_preloadedURLsForTest);
+ return m_preloadedURLsForTest->contains(url.getString());
}
void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy)
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.h ('k') | third_party/WebKit/Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698