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

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

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/RawResource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/RawResource.cpp b/third_party/WebKit/Source/core/fetch/RawResource.cpp
index c7c460a43e5c5c202826eec68cbc74461dabe0d2..945a349cf041dda0f7915df85aad5003920f611c 100644
--- a/third_party/WebKit/Source/core/fetch/RawResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/RawResource.cpp
@@ -145,7 +145,10 @@ void RawResource::updateRequest(const ResourceRequest& request)
void RawResource::responseReceived(const ResourceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle)
{
InternalResourcePtr protect(this);
+
+ bool isSuccessfulRevalidation = isCacheValidator() && response.httpStatusCode() == 304;
Resource::responseReceived(response, nullptr);
+
ResourceClientWalker<RawResourceClient> w(m_clients);
ASSERT(count() <= 1 || !handle);
while (RawResourceClient* c = w.next()) {
@@ -153,6 +156,14 @@ void RawResource::responseReceived(const ResourceResponse& response, PassOwnPtr<
// |handle| is null when there are two or more clients, as asserted.
c->responseReceived(this, m_response, handle);
}
+
+ // If we successfully revalidated, we won't get appendData() calls.
+ // Forward the data to clients now instead.
+ if (isSuccessfulRevalidation) {
+ ResourceClientWalker<RawResourceClient> w(m_clients);
+ while (RawResourceClient* c = w.next())
+ c->dataReceived(this, m_data->data(), m_data->size());
+ }
}
void RawResource::setSerializedCachedMetadata(const char* data, size_t size)
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.cpp ('k') | third_party/WebKit/Source/core/fetch/RawResourceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698