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

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

Issue 1398523004: Revalidate using the same Resource, attempt #3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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.h
diff --git a/third_party/WebKit/Source/core/fetch/Resource.h b/third_party/WebKit/Source/core/fetch/Resource.h
index 7c8b3c48e1933f3507a27f0de105c9daeae5e9a1..747771655887501360715f053788b91a7a186da9 100644
--- a/third_party/WebKit/Source/core/fetch/Resource.h
+++ b/third_party/WebKit/Source/core/fetch/Resource.h
@@ -124,6 +124,8 @@ public:
const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
const ResourceRequest& lastResourceRequest() const;
+ void setRevalidatingRequest(const ResourceRequest& request) { m_revalidatingRequest = request; }
+
const KURL& url() const { return m_resourceRequest.url();}
Type type() const { return static_cast<Type>(m_type); }
const ResourceLoaderOptions& options() const { return m_options; }
@@ -134,7 +136,7 @@ public:
void addClient(ResourceClient*);
void removeClient(ResourceClient*);
- bool hasClients() const { return !m_clients.isEmpty() || !m_clientsAwaitingCallback.isEmpty(); }
+ bool hasClients() const { return !m_clients.isEmpty() || !m_clientsAwaitingCallback.isEmpty() || !m_finishedClients.isEmpty(); }
bool deleteIfPossible();
enum PreloadResult {
@@ -234,9 +236,7 @@ public:
bool canReuseRedirectChain();
bool mustRevalidateDueToCacheHeaders();
bool canUseCacheValidator();
- bool isCacheValidator() const { return m_resourceToRevalidate; }
- Resource* resourceToRevalidate() const { return m_resourceToRevalidate; }
- void setResourceToRevalidate(Resource*);
+ bool isCacheValidator() const { return !m_revalidatingRequest.isNull(); }
bool hasCacheControlNoStoreHeader();
bool hasVaryHeader() const;
virtual bool mustRefetchDueToIntegrityMetadata(const FetchRequest& request) const { return false; }
@@ -274,6 +274,8 @@ protected:
virtual void checkNotify();
virtual void finishOnePart();
+ virtual void destroyDecodedDataForFailedRevalidation() { }
+
// Normal resource pointers will silently switch what Resource* they reference when we
// successfully revalidated the resource. We need a way to guarantee that the Resource
// that received the 304 response survives long enough to switch everything over to the
@@ -304,13 +306,11 @@ protected:
void setDecodedSize(size_t);
void didAccessDecodedData();
- void clearResourceToRevalidate();
- void updateResponseAfterRevalidation(const ResourceResponse& validatingResponse);
-
void finishPendingClients();
HashCountedSet<ResourceClient*> m_clients;
HashCountedSet<ResourceClient*> m_clientsAwaitingCallback;
+ HashCountedSet<ResourceClient*> m_finishedClients;
class ResourceCallback : public NoBaseWillBeGarbageCollectedFinalized<ResourceCallback> {
public:
@@ -326,7 +326,7 @@ protected:
WillBeHeapHashSet<RawPtrWillBeMember<Resource>> m_resourcesWithPendingClients;
};
- bool hasClient(ResourceClient* client) { return m_clients.contains(client) || m_clientsAwaitingCallback.contains(client); }
+ bool hasClient(ResourceClient* client) { return m_clients.contains(client) || m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(client); }
struct RedirectPair {
ALLOW_ONLY_INLINE_ALLOCATION();
@@ -345,7 +345,10 @@ protected:
virtual bool isSafeToUnlock() const { return false; }
virtual void destroyDecodedDataIfPossible() { }
+ void markClientsFinished();
+
ResourceRequest m_resourceRequest;
+ ResourceRequest m_revalidatingRequest;
AtomicString m_accept;
PersistentWillBeMember<ResourceLoader> m_loader;
ResourceLoaderOptions m_options;
@@ -358,7 +361,6 @@ protected:
private:
class CacheHandler;
- bool addClientToSet(ResourceClient*);
void cancelTimerFired(Timer<Resource>*);
void switchClientsToRevalidatedResource();
@@ -410,18 +412,6 @@ private:
bool m_deleted;
#endif
- // If this field is non-null we are using the resource as a proxy for checking whether an existing resource is still up to date
- // using HTTP If-Modified-Since/If-None-Match headers. If the response is 304 all clients of this resource are moved
- // to to be clients of m_resourceToRevalidate and the resource is deleted. If not, the field is zeroed and this
- // resources becomes normal resource load.
- RawPtrWillBeMember<Resource> m_resourceToRevalidate;
-
- // If this field is non-null, the resource has a proxy for checking whether it is still up to date (see m_resourceToRevalidate).
- RawPtrWillBeMember<Resource> m_proxyResource;
-
- // These handles will need to be updated to point to the m_resourceToRevalidate in case we get 304 response.
- HashSet<ResourcePtrBase*> m_handlesToRevalidate;
-
// Ordered list of all redirects followed while fetching this resource.
Vector<RedirectPair> m_redirectChain;
};
« no previous file with comments | « third_party/WebKit/Source/core/fetch/RawResourceTest.cpp ('k') | third_party/WebKit/Source/core/fetch/Resource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698