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

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: Reflect comments 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..e492113b01b8e2ce062c89a83af37adfd5f2aaeb 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 (auto resource : *m_preloads)
Yoav Weiss 2016/09/15 08:34:31 nit: const auto& (I changed all other m_preloads
hiroshige 2016/09/15 08:39:11 Done.
+ 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