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

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

Issue 2390583002: [WIP] WebFonts cache-aware timeout adaption (Closed)
Patch Set: remove flag in finish() instead of responseReceived() Created 4 years, 2 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/Resource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/Resource.cpp b/third_party/WebKit/Source/core/fetch/Resource.cpp
index 9d88d0191a75c2bba0f1e63d567acc4874e14f93..95dc785cc091b67ed14acf0ec7c66798097adac0 100644
--- a/third_party/WebKit/Source/core/fetch/Resource.cpp
+++ b/third_party/WebKit/Source/core/fetch/Resource.cpp
@@ -312,6 +312,7 @@ Resource::Resource(const ResourceRequest& request,
m_linkPreload(false),
m_isRevalidating(false),
m_isAlive(false),
+ m_isAddRemoveClientProhibited(false),
m_options(options),
m_responseTimestamp(currentTime()),
m_cancelTimer(this, &Resource::cancelTimerFired),
@@ -416,6 +417,8 @@ void Resource::error(const ResourceError& error) {
void Resource::finish(double loadFinishTime) {
DCHECK(!m_isRevalidating);
+ if (m_resourceRequest.isCacheAwareLoadingActivated())
hiroshige 2016/10/05 08:27:10 I'd like to prevent Resource from participating st
Shao-Chuan Lee 2016/10/07 08:10:06 Moved manipulation logic to ResourceFetcher. Still
+ m_resourceRequest.deactivateCacheAwareLoading();
m_loadFinishTime = loadFinishTime;
if (!errorOccurred())
m_status = Cached;
@@ -552,6 +555,8 @@ void Resource::willFollowRedirect(ResourceRequest& newRequest,
const ResourceResponse& redirectResponse) {
if (m_isRevalidating)
revalidationFailed();
+ if (m_resourceRequest.isCacheAwareLoadingActivated())
+ m_resourceRequest.deactivateCacheAwareLoading();
m_redirectChain.append(RedirectPair(newRequest, redirectResponse));
}
@@ -686,6 +691,8 @@ void Resource::willAddClientOrObserver(PreloadReferencePolicy policy) {
void Resource::addClient(ResourceClient* client,
PreloadReferencePolicy policy) {
+ DCHECK(!m_isAddRemoveClientProhibited);
+
willAddClientOrObserver(policy);
if (m_isRevalidating) {
@@ -708,6 +715,8 @@ void Resource::addClient(ResourceClient* client,
}
void Resource::removeClient(ResourceClient* client) {
+ DCHECK(!m_isAddRemoveClientProhibited);
+
// This code may be called in a pre-finalizer, where weak members in the
// HashCountedSet are already swept out.
@@ -1074,4 +1083,16 @@ bool Resource::isLoadEventBlockingResourceType() const {
return false;
}
+void Resource::willReloadAfterDiskCacheMiss() {
+ m_resourceRequest.deactivateCacheAwareLoading();
+
+ DCHECK(!m_isAddRemoveClientProhibited);
+ m_isAddRemoveClientProhibited = true;
+ ResourceClientWalker<ResourceClient> w(m_clients);
+ while (ResourceClient* c = w.next()) {
Takashi Toyoshima 2016/10/05 07:06:18 nit: we do not use {} for one-liner.
Shao-Chuan Lee 2016/10/05 10:16:10 Done.
+ c->willReloadAfterDiskCacheMiss(this);
+ }
+ m_isAddRemoveClientProhibited = false;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698