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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 { 138 {
139 ResourcePtr<RawResource> protect(this); 139 ResourcePtr<RawResource> protect(this);
140 ResourceClientWalker<RawResourceClient> w(m_clients); 140 ResourceClientWalker<RawResourceClient> w(m_clients);
141 while (RawResourceClient* c = w.next()) 141 while (RawResourceClient* c = w.next())
142 c->updateRequest(this, request); 142 c->updateRequest(this, request);
143 } 143 }
144 144
145 void RawResource::responseReceived(const ResourceResponse& response, PassOwnPtr< WebDataConsumerHandle> handle) 145 void RawResource::responseReceived(const ResourceResponse& response, PassOwnPtr< WebDataConsumerHandle> handle)
146 { 146 {
147 InternalResourcePtr protect(this); 147 InternalResourcePtr protect(this);
148
149 bool isSuccessfulRevalidation = isCacheValidator() && response.httpStatusCod e() == 304;
148 Resource::responseReceived(response, nullptr); 150 Resource::responseReceived(response, nullptr);
151
149 ResourceClientWalker<RawResourceClient> w(m_clients); 152 ResourceClientWalker<RawResourceClient> w(m_clients);
150 ASSERT(count() <= 1 || !handle); 153 ASSERT(count() <= 1 || !handle);
151 while (RawResourceClient* c = w.next()) { 154 while (RawResourceClient* c = w.next()) {
152 // |handle| is cleared when passed, but it's not a problem because 155 // |handle| is cleared when passed, but it's not a problem because
153 // |handle| is null when there are two or more clients, as asserted. 156 // |handle| is null when there are two or more clients, as asserted.
154 c->responseReceived(this, m_response, handle); 157 c->responseReceived(this, m_response, handle);
155 } 158 }
159
160 // If we successfully revalidated, we won't get appendData() calls.
161 // Forward the data to clients now instead.
162 if (isSuccessfulRevalidation) {
163 ResourceClientWalker<RawResourceClient> w(m_clients);
164 while (RawResourceClient* c = w.next())
165 c->dataReceived(this, m_data->data(), m_data->size());
166 }
156 } 167 }
157 168
158 void RawResource::setSerializedCachedMetadata(const char* data, size_t size) 169 void RawResource::setSerializedCachedMetadata(const char* data, size_t size)
159 { 170 {
160 ResourcePtr<RawResource> protect(this); 171 ResourcePtr<RawResource> protect(this);
161 Resource::setSerializedCachedMetadata(data, size); 172 Resource::setSerializedCachedMetadata(data, size);
162 ResourceClientWalker<RawResourceClient> w(m_clients); 173 ResourceClientWalker<RawResourceClient> w(m_clients);
163 while (RawResourceClient* c = w.next()) 174 while (RawResourceClient* c = w.next())
164 c->setSerializedCachedMetadata(this, data, size); 175 c->setSerializedCachedMetadata(this, data, size);
165 } 176 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 for (const auto& header : oldHeaders) { 260 for (const auto& header : oldHeaders) {
250 AtomicString headerName = header.key; 261 AtomicString headerName = header.key;
251 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != newH eaders.get(headerName)) 262 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != newH eaders.get(headerName))
252 return false; 263 return false;
253 } 264 }
254 265
255 return true; 266 return true;
256 } 267 }
257 268
258 } // namespace blink 269 } // namespace blink
OLDNEW
« 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