OLD | NEW |
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 Loading... |
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; | |
150 Resource::responseReceived(response, nullptr); | 148 Resource::responseReceived(response, nullptr); |
151 | |
152 ResourceClientWalker<RawResourceClient> w(m_clients); | 149 ResourceClientWalker<RawResourceClient> w(m_clients); |
153 ASSERT(count() <= 1 || !handle); | 150 ASSERT(count() <= 1 || !handle); |
154 while (RawResourceClient* c = w.next()) { | 151 while (RawResourceClient* c = w.next()) { |
155 // |handle| is cleared when passed, but it's not a problem because | 152 // |handle| is cleared when passed, but it's not a problem because |
156 // |handle| is null when there are two or more clients, as asserted. | 153 // |handle| is null when there are two or more clients, as asserted. |
157 c->responseReceived(this, m_response, handle); | 154 c->responseReceived(this, m_response, handle); |
158 } | 155 } |
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 } | |
167 } | 156 } |
168 | 157 |
169 void RawResource::setSerializedCachedMetadata(const char* data, size_t size) | 158 void RawResource::setSerializedCachedMetadata(const char* data, size_t size) |
170 { | 159 { |
171 ResourcePtr<RawResource> protect(this); | 160 ResourcePtr<RawResource> protect(this); |
172 Resource::setSerializedCachedMetadata(data, size); | 161 Resource::setSerializedCachedMetadata(data, size); |
173 ResourceClientWalker<RawResourceClient> w(m_clients); | 162 ResourceClientWalker<RawResourceClient> w(m_clients); |
174 while (RawResourceClient* c = w.next()) | 163 while (RawResourceClient* c = w.next()) |
175 c->setSerializedCachedMetadata(this, data, size); | 164 c->setSerializedCachedMetadata(this, data, size); |
176 } | 165 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 for (const auto& header : oldHeaders) { | 249 for (const auto& header : oldHeaders) { |
261 AtomicString headerName = header.key; | 250 AtomicString headerName = header.key; |
262 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != newH
eaders.get(headerName)) | 251 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != newH
eaders.get(headerName)) |
263 return false; | 252 return false; |
264 } | 253 } |
265 | 254 |
266 return true; | 255 return true; |
267 } | 256 } |
268 | 257 |
269 } // namespace blink | 258 } // namespace blink |
OLD | NEW |