OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 7 rights reserved. |
7 | 8 |
8 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 11 License as published by the Free Software Foundation; either |
11 version 2 of the License, or (at your option) any later version. | 12 version 2 of the License, or (at your option) any later version. |
12 | 13 |
13 This library is distributed in the hope that it will be useful, | 14 This library is distributed in the hope that it will be useful, |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 Library General Public License for more details. | 17 Library General Public License for more details. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 DEFINE_TRACE(Resource::CachedMetadataHandlerImpl) { | 128 DEFINE_TRACE(Resource::CachedMetadataHandlerImpl) { |
128 visitor->trace(m_resource); | 129 visitor->trace(m_resource); |
129 CachedMetadataHandler::trace(visitor); | 130 CachedMetadataHandler::trace(visitor); |
130 } | 131 } |
131 | 132 |
132 void Resource::CachedMetadataHandlerImpl::setCachedMetadata( | 133 void Resource::CachedMetadataHandlerImpl::setCachedMetadata( |
133 uint32_t dataTypeID, | 134 uint32_t dataTypeID, |
134 const char* data, | 135 const char* data, |
135 size_t size, | 136 size_t size, |
136 CachedMetadataHandler::CacheType cacheType) { | 137 CachedMetadataHandler::CacheType cacheType) { |
137 // Currently, only one type of cached metadata per resource is supported. | 138 // Currently, only one type of cached metadata per resource is supported. If |
138 // If the need arises for multiple types of metadata per resource this could | 139 // the need arises for multiple types of metadata per resource this could be |
139 // be enhanced to store types of metadata in a map. | 140 // enhanced to store types of metadata in a map. |
140 DCHECK(!m_cachedMetadata); | 141 DCHECK(!m_cachedMetadata); |
141 m_cachedMetadata = CachedMetadata::create(dataTypeID, data, size); | 142 m_cachedMetadata = CachedMetadata::create(dataTypeID, data, size); |
142 if (cacheType == CachedMetadataHandler::SendToPlatform) | 143 if (cacheType == CachedMetadataHandler::SendToPlatform) |
143 sendToPlatform(); | 144 sendToPlatform(); |
144 } | 145 } |
145 | 146 |
146 void Resource::CachedMetadataHandlerImpl::clearCachedMetadata( | 147 void Resource::CachedMetadataHandlerImpl::clearCachedMetadata( |
147 CachedMetadataHandler::CacheType cacheType) { | 148 CachedMetadataHandler::CacheType cacheType) { |
148 m_cachedMetadata.clear(); | 149 m_cachedMetadata.clear(); |
149 if (cacheType == CachedMetadataHandler::SendToPlatform) | 150 if (cacheType == CachedMetadataHandler::SendToPlatform) |
150 sendToPlatform(); | 151 sendToPlatform(); |
151 } | 152 } |
152 | 153 |
153 PassRefPtr<CachedMetadata> Resource::CachedMetadataHandlerImpl::cachedMetadata( | 154 PassRefPtr<CachedMetadata> Resource::CachedMetadataHandlerImpl::cachedMetadata( |
154 uint32_t dataTypeID) const { | 155 uint32_t dataTypeID) const { |
155 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) | 156 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) |
156 return nullptr; | 157 return nullptr; |
157 return m_cachedMetadata.get(); | 158 return m_cachedMetadata.get(); |
158 } | 159 } |
159 | 160 |
160 String Resource::CachedMetadataHandlerImpl::encoding() const { | 161 String Resource::CachedMetadataHandlerImpl::encoding() const { |
161 return m_resource->encoding(); | 162 return m_resource->encoding(); |
162 } | 163 } |
163 | 164 |
164 void Resource::CachedMetadataHandlerImpl::setSerializedCachedMetadata( | 165 void Resource::CachedMetadataHandlerImpl::setSerializedCachedMetadata( |
165 const char* data, | 166 const char* data, |
166 size_t size) { | 167 size_t size) { |
167 // We only expect to receive cached metadata from the platform once. | 168 // We only expect to receive cached metadata from the platform once. If this |
168 // If this triggers, it indicates an efficiency problem which is most | 169 // triggers, it indicates an efficiency problem which is most likely |
169 // likely unexpected in code designed to improve performance. | 170 // unexpected in code designed to improve performance. |
170 DCHECK(!m_cachedMetadata); | 171 DCHECK(!m_cachedMetadata); |
171 m_cachedMetadata = CachedMetadata::createFromSerializedData(data, size); | 172 m_cachedMetadata = CachedMetadata::createFromSerializedData(data, size); |
172 } | 173 } |
173 | 174 |
174 void Resource::CachedMetadataHandlerImpl::sendToPlatform() { | 175 void Resource::CachedMetadataHandlerImpl::sendToPlatform() { |
175 if (m_cachedMetadata) { | 176 if (m_cachedMetadata) { |
176 const Vector<char>& serializedData = m_cachedMetadata->serializedData(); | 177 const Vector<char>& serializedData = m_cachedMetadata->serializedData(); |
177 Platform::current()->cacheMetadata( | 178 Platform::current()->cacheMetadata( |
178 response().url(), response().responseTime(), serializedData.data(), | 179 response().url(), response().responseTime(), serializedData.data(), |
179 serializedData.size()); | 180 serializedData.size()); |
(...skipping 28 matching lines...) Expand all Loading... |
208 Resource::ServiceWorkerResponseCachedMetadataHandler:: | 209 Resource::ServiceWorkerResponseCachedMetadataHandler:: |
209 ServiceWorkerResponseCachedMetadataHandler(Resource* resource, | 210 ServiceWorkerResponseCachedMetadataHandler(Resource* resource, |
210 SecurityOrigin* securityOrigin) | 211 SecurityOrigin* securityOrigin) |
211 : CachedMetadataHandlerImpl(resource), m_securityOrigin(securityOrigin) {} | 212 : CachedMetadataHandlerImpl(resource), m_securityOrigin(securityOrigin) {} |
212 | 213 |
213 DEFINE_TRACE(Resource::ServiceWorkerResponseCachedMetadataHandler) { | 214 DEFINE_TRACE(Resource::ServiceWorkerResponseCachedMetadataHandler) { |
214 CachedMetadataHandlerImpl::trace(visitor); | 215 CachedMetadataHandlerImpl::trace(visitor); |
215 } | 216 } |
216 | 217 |
217 void Resource::ServiceWorkerResponseCachedMetadataHandler::sendToPlatform() { | 218 void Resource::ServiceWorkerResponseCachedMetadataHandler::sendToPlatform() { |
218 // We don't support sending the metadata to the platform when the response | 219 // We don't support sending the metadata to the platform when the response was |
219 // was directly fetched via a ServiceWorker | 220 // directly fetched via a ServiceWorker (eg: |
220 // (eg: FetchEvent.respondWith(fetch(FetchEvent.request))) to prevent an | 221 // FetchEvent.respondWith(fetch(FetchEvent.request))) to prevent an attacker's |
221 // attacker's Service Worker from poisoning the metadata cache of HTTPCache. | 222 // Service Worker from poisoning the metadata cache of HTTPCache. |
222 if (response().cacheStorageCacheName().isNull()) | 223 if (response().cacheStorageCacheName().isNull()) |
223 return; | 224 return; |
224 | 225 |
225 if (m_cachedMetadata) { | 226 if (m_cachedMetadata) { |
226 const Vector<char>& serializedData = m_cachedMetadata->serializedData(); | 227 const Vector<char>& serializedData = m_cachedMetadata->serializedData(); |
227 Platform::current()->cacheMetadataInCacheStorage( | 228 Platform::current()->cacheMetadataInCacheStorage( |
228 response().url(), response().responseTime(), serializedData.data(), | 229 response().url(), response().responseTime(), serializedData.data(), |
229 serializedData.size(), WebSecurityOrigin(m_securityOrigin), | 230 serializedData.size(), WebSecurityOrigin(m_securityOrigin), |
230 response().cacheStorageCacheName()); | 231 response().cacheStorageCacheName()); |
231 } else { | 232 } else { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 m_type(type), | 310 m_type(type), |
310 m_status(NotStarted), | 311 m_status(NotStarted), |
311 m_needsSynchronousCacheHit(false), | 312 m_needsSynchronousCacheHit(false), |
312 m_linkPreload(false), | 313 m_linkPreload(false), |
313 m_isRevalidating(false), | 314 m_isRevalidating(false), |
314 m_isAlive(false), | 315 m_isAlive(false), |
315 m_options(options), | 316 m_options(options), |
316 m_responseTimestamp(currentTime()), | 317 m_responseTimestamp(currentTime()), |
317 m_cancelTimer(this, &Resource::cancelTimerFired), | 318 m_cancelTimer(this, &Resource::cancelTimerFired), |
318 m_resourceRequest(request) { | 319 m_resourceRequest(request) { |
319 DCHECK_EQ( | 320 // m_type is a bitfield, so this tests careless updates of the enum. |
320 m_type, | 321 DCHECK_EQ(m_type, unsigned(type)); |
321 unsigned( | |
322 type)); // m_type is a bitfield, so this tests careless updates of th
e enum. | |
323 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); | 322 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); |
324 | 323 |
325 // Currently we support the metadata caching only for HTTP family. | 324 // Currently we support the metadata caching only for HTTP family. |
326 if (m_resourceRequest.url().protocolIsInHTTPFamily()) | 325 if (m_resourceRequest.url().protocolIsInHTTPFamily()) |
327 m_cacheHandler = CachedMetadataHandlerImpl::create(this); | 326 m_cacheHandler = CachedMetadataHandlerImpl::create(this); |
328 MemoryCoordinator::instance().registerClient(this); | 327 MemoryCoordinator::instance().registerClient(this); |
329 } | 328 } |
330 | 329 |
331 Resource::~Resource() { | 330 Resource::~Resource() { |
332 InstanceCounters::decrementCounter(InstanceCounters::ResourceCounter); | 331 InstanceCounters::decrementCounter(InstanceCounters::ResourceCounter); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 return maxAgeValue; | 486 return maxAgeValue; |
488 double expiresValue = response.expires(); | 487 double expiresValue = response.expires(); |
489 double dateValue = response.date(); | 488 double dateValue = response.date(); |
490 double creationTime = | 489 double creationTime = |
491 std::isfinite(dateValue) ? dateValue : responseTimestamp; | 490 std::isfinite(dateValue) ? dateValue : responseTimestamp; |
492 if (std::isfinite(expiresValue)) | 491 if (std::isfinite(expiresValue)) |
493 return expiresValue - creationTime; | 492 return expiresValue - creationTime; |
494 double lastModifiedValue = response.lastModified(); | 493 double lastModifiedValue = response.lastModified(); |
495 if (std::isfinite(lastModifiedValue)) | 494 if (std::isfinite(lastModifiedValue)) |
496 return (creationTime - lastModifiedValue) * 0.1; | 495 return (creationTime - lastModifiedValue) * 0.1; |
497 // If no cache headers are present, the specification leaves the decision to t
he UA. Other browsers seem to opt for 0. | 496 // If no cache headers are present, the specification leaves the decision to |
| 497 // the UA. Other browsers seem to opt for 0. |
498 return 0; | 498 return 0; |
499 } | 499 } |
500 | 500 |
501 double Resource::freshnessLifetime() { | 501 double Resource::freshnessLifetime() { |
502 return blink::freshnessLifetime(m_response, m_responseTimestamp); | 502 return blink::freshnessLifetime(m_response, m_responseTimestamp); |
503 } | 503 } |
504 | 504 |
505 double Resource::stalenessLifetime() { | 505 double Resource::stalenessLifetime() { |
506 return m_response.cacheControlStaleWhileRevalidate(); | 506 return m_response.cacheControlStaleWhileRevalidate(); |
507 } | 507 } |
508 | 508 |
509 static bool canUseResponse(ResourceResponse& response, | 509 static bool canUseResponse(ResourceResponse& response, |
510 double responseTimestamp) { | 510 double responseTimestamp) { |
511 if (response.isNull()) | 511 if (response.isNull()) |
512 return false; | 512 return false; |
513 | 513 |
514 // FIXME: Why isn't must-revalidate considered a reason we can't use the respo
nse? | 514 // FIXME: Why isn't must-revalidate considered a reason we can't use the |
| 515 // response? |
515 if (response.cacheControlContainsNoCache() || | 516 if (response.cacheControlContainsNoCache() || |
516 response.cacheControlContainsNoStore()) | 517 response.cacheControlContainsNoStore()) |
517 return false; | 518 return false; |
518 | 519 |
519 if (response.httpStatusCode() == 303) { | 520 if (response.httpStatusCode() == 303) { |
520 // Must not be cached. | 521 // Must not be cached. |
521 return false; | 522 return false; |
522 } | 523 } |
523 | 524 |
524 if (response.httpStatusCode() == 302 || response.httpStatusCode() == 307) { | 525 if (response.httpStatusCode() == 302 || response.httpStatusCode() == 307) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 if (isLoaded()) { | 638 if (isLoaded()) { |
638 c->notifyFinished(this); | 639 c->notifyFinished(this); |
639 if (m_clients.contains(c)) { | 640 if (m_clients.contains(c)) { |
640 m_finishedClients.add(c); | 641 m_finishedClients.add(c); |
641 m_clients.remove(c); | 642 m_clients.remove(c); |
642 } | 643 } |
643 } | 644 } |
644 } | 645 } |
645 | 646 |
646 static bool shouldSendCachedDataSynchronouslyForType(Resource::Type type) { | 647 static bool shouldSendCachedDataSynchronouslyForType(Resource::Type type) { |
647 // Some resources types default to return data synchronously. | 648 // Some resources types default to return data synchronously. For most of |
648 // For most of these, it's because there are layout tests that | 649 // these, it's because there are layout tests that expect data to return |
649 // expect data to return synchronously in case of cache hit. In | 650 // synchronously in case of cache hit. In the case of fonts, there was a |
650 // the case of fonts, there was a performance regression. | 651 // performance regression. |
651 // FIXME: Get to the point where we don't need to special-case sync/async | 652 // FIXME: Get to the point where we don't need to special-case sync/async |
652 // behavior for different resource types. | 653 // behavior for different resource types. |
653 if (type == Resource::Image) | 654 if (type == Resource::Image) |
654 return true; | 655 return true; |
655 if (type == Resource::CSSStyleSheet) | 656 if (type == Resource::CSSStyleSheet) |
656 return true; | 657 return true; |
657 if (type == Resource::Script) | 658 if (type == Resource::Script) |
658 return true; | 659 return true; |
659 if (type == Resource::Font) | 660 if (type == Resource::Font) |
660 return true; | 661 return true; |
(...skipping 25 matching lines...) Expand all Loading... |
686 | 687 |
687 void Resource::addClient(ResourceClient* client, | 688 void Resource::addClient(ResourceClient* client, |
688 PreloadReferencePolicy policy) { | 689 PreloadReferencePolicy policy) { |
689 willAddClientOrObserver(policy); | 690 willAddClientOrObserver(policy); |
690 | 691 |
691 if (m_isRevalidating) { | 692 if (m_isRevalidating) { |
692 m_clients.add(client); | 693 m_clients.add(client); |
693 return; | 694 return; |
694 } | 695 } |
695 | 696 |
696 // If we have existing data to send to the new client and the resource type su
pprts it, send it asynchronously. | 697 // If we have existing data to send to the new client and the resource type |
| 698 // supprts it, send it asynchronously. |
697 if (!m_response.isNull() && | 699 if (!m_response.isNull() && |
698 !shouldSendCachedDataSynchronouslyForType(getType()) && | 700 !shouldSendCachedDataSynchronouslyForType(getType()) && |
699 !m_needsSynchronousCacheHit) { | 701 !m_needsSynchronousCacheHit) { |
700 m_clientsAwaitingCallback.add(client); | 702 m_clientsAwaitingCallback.add(client); |
701 ResourceCallback::callbackHandler().schedule(this); | 703 ResourceCallback::callbackHandler().schedule(this); |
702 return; | 704 return; |
703 } | 705 } |
704 | 706 |
705 m_clients.add(client); | 707 m_clients.add(client); |
706 didAddClient(client); | 708 didAddClient(client); |
(...skipping 17 matching lines...) Expand all Loading... |
724 didRemoveClientOrObserver(); | 726 didRemoveClientOrObserver(); |
725 } | 727 } |
726 | 728 |
727 void Resource::didRemoveClientOrObserver() { | 729 void Resource::didRemoveClientOrObserver() { |
728 if (!hasClientsOrObservers() && m_isAlive) { | 730 if (!hasClientsOrObservers() && m_isAlive) { |
729 m_isAlive = false; | 731 m_isAlive = false; |
730 memoryCache()->makeDead(this); | 732 memoryCache()->makeDead(this); |
731 allClientsAndObserversRemoved(); | 733 allClientsAndObserversRemoved(); |
732 | 734 |
733 // RFC2616 14.9.2: | 735 // RFC2616 14.9.2: |
734 // "no-store: ... MUST make a best-effort attempt to remove the information
from volatile storage as promptly as possible" | 736 // "no-store: ... MUST make a best-effort attempt to remove the information |
735 // "... History buffers MAY store such responses as part of their normal ope
ration." | 737 // from volatile storage as promptly as possible" |
736 // We allow non-secure content to be reused in history, but we do not allow
secure content to be reused. | 738 // "... History buffers MAY store such responses as part of their normal |
| 739 // operation." |
| 740 // We allow non-secure content to be reused in history, but we do not allow |
| 741 // secure content to be reused. |
737 if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) | 742 if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) |
738 memoryCache()->remove(this); | 743 memoryCache()->remove(this); |
739 } | 744 } |
740 } | 745 } |
741 | 746 |
742 void Resource::allClientsAndObserversRemoved() { | 747 void Resource::allClientsAndObserversRemoved() { |
743 if (!m_loader) | 748 if (!m_loader) |
744 return; | 749 return; |
745 if (m_type == Raw) | 750 if (m_type == Raw) |
746 cancelTimerFired(&m_cancelTimer); | 751 cancelTimerFired(&m_cancelTimer); |
(...skipping 23 matching lines...) Expand all Loading... |
770 m_encodedSize = encodedSize; | 775 m_encodedSize = encodedSize; |
771 memoryCache()->update(this, oldSize, size()); | 776 memoryCache()->update(this, oldSize, size()); |
772 } | 777 } |
773 | 778 |
774 void Resource::didAccessDecodedData() { | 779 void Resource::didAccessDecodedData() { |
775 memoryCache()->updateDecodedResource(this, UpdateForAccess); | 780 memoryCache()->updateDecodedResource(this, UpdateForAccess); |
776 memoryCache()->prune(); | 781 memoryCache()->prune(); |
777 } | 782 } |
778 | 783 |
779 void Resource::finishPendingClients() { | 784 void Resource::finishPendingClients() { |
780 // We're going to notify clients one by one. It is simple if the client does n
othing. | 785 // We're going to notify clients one by one. It is simple if the client does |
781 // However there are a couple other things that can happen. | 786 // nothing. However there are a couple other things that can happen. |
782 // | 787 // |
783 // 1. Clients can be added during the loop. Make sure they are not processed. | 788 // 1. Clients can be added during the loop. Make sure they are not processed. |
784 // 2. Clients can be removed during the loop. Make sure they are always availa
ble to be | 789 // 2. Clients can be removed during the loop. Make sure they are always |
785 // removed. Also don't call removed clients or add them back. | 790 // available to be removed. Also don't call removed clients or add them |
786 | 791 // back. |
787 // Handle case (1) by saving a list of clients to notify. A separate list also
ensure | 792 // |
788 // a client is either in m_clients or m_clientsAwaitingCallback. | 793 // Handle case (1) by saving a list of clients to notify. A separate list also |
| 794 // ensure a client is either in m_clients or m_clientsAwaitingCallback. |
789 HeapVector<Member<ResourceClient>> clientsToNotify; | 795 HeapVector<Member<ResourceClient>> clientsToNotify; |
790 copyToVector(m_clientsAwaitingCallback, clientsToNotify); | 796 copyToVector(m_clientsAwaitingCallback, clientsToNotify); |
791 | 797 |
792 for (const auto& client : clientsToNotify) { | 798 for (const auto& client : clientsToNotify) { |
793 // Handle case (2) to skip removed clients. | 799 // Handle case (2) to skip removed clients. |
794 if (!m_clientsAwaitingCallback.remove(client)) | 800 if (!m_clientsAwaitingCallback.remove(client)) |
795 continue; | 801 continue; |
796 m_clients.add(client); | 802 m_clients.add(client); |
797 | 803 |
798 // When revalidation starts after waiting clients are scheduled and | 804 // When revalidation starts after waiting clients are scheduled and |
799 // before they are added here. In such cases, we just add the clients | 805 // before they are added here. In such cases, we just add the clients |
800 // to |m_clients| without didAddClient(), as in Resource::addClient(). | 806 // to |m_clients| without didAddClient(), as in Resource::addClient(). |
801 if (!m_isRevalidating) | 807 if (!m_isRevalidating) |
802 didAddClient(client); | 808 didAddClient(client); |
803 } | 809 } |
804 | 810 |
805 // It is still possible for the above loop to finish a new client synchronousl
y. | 811 // It is still possible for the above loop to finish a new client |
806 // If there's no client waiting we should deschedule. | 812 // synchronously. If there's no client waiting we should deschedule. |
807 bool scheduled = ResourceCallback::callbackHandler().isScheduled(this); | 813 bool scheduled = ResourceCallback::callbackHandler().isScheduled(this); |
808 if (scheduled && m_clientsAwaitingCallback.isEmpty()) | 814 if (scheduled && m_clientsAwaitingCallback.isEmpty()) |
809 ResourceCallback::callbackHandler().cancel(this); | 815 ResourceCallback::callbackHandler().cancel(this); |
810 | 816 |
811 // Prevent the case when there are clients waiting but no callback scheduled. | 817 // Prevent the case when there are clients waiting but no callback scheduled. |
812 DCHECK(m_clientsAwaitingCallback.isEmpty() || scheduled); | 818 DCHECK(m_clientsAwaitingCallback.isEmpty() || scheduled); |
813 } | 819 } |
814 | 820 |
815 void Resource::prune() { | 821 void Resource::prune() { |
816 destroyDecodedDataIfPossible(); | 822 destroyDecodedDataIfPossible(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 SECURITY_CHECK(m_redirectChain.isEmpty()); | 913 SECURITY_CHECK(m_redirectChain.isEmpty()); |
908 SECURITY_CHECK(equalIgnoringFragmentIdentifier(validatingResponse.url(), | 914 SECURITY_CHECK(equalIgnoringFragmentIdentifier(validatingResponse.url(), |
909 m_response.url())); | 915 m_response.url())); |
910 m_response.setResourceLoadTiming(validatingResponse.resourceLoadTiming()); | 916 m_response.setResourceLoadTiming(validatingResponse.resourceLoadTiming()); |
911 | 917 |
912 // RFC2616 10.3.5 | 918 // RFC2616 10.3.5 |
913 // Update cached headers from the 304 response | 919 // Update cached headers from the 304 response |
914 const HTTPHeaderMap& newHeaders = validatingResponse.httpHeaderFields(); | 920 const HTTPHeaderMap& newHeaders = validatingResponse.httpHeaderFields(); |
915 for (const auto& header : newHeaders) { | 921 for (const auto& header : newHeaders) { |
916 // Entity headers should not be sent by servers when generating a 304 | 922 // Entity headers should not be sent by servers when generating a 304 |
917 // response; misconfigured servers send them anyway. We shouldn't allow | 923 // response; misconfigured servers send them anyway. We shouldn't allow such |
918 // such headers to update the original request. We'll base this on the | 924 // headers to update the original request. We'll base this on the list |
919 // list defined by RFC2616 7.1, with a few additions for extension headers | 925 // defined by RFC2616 7.1, with a few additions for extension headers we |
920 // we care about. | 926 // care about. |
921 if (!shouldUpdateHeaderAfterRevalidation(header.key)) | 927 if (!shouldUpdateHeaderAfterRevalidation(header.key)) |
922 continue; | 928 continue; |
923 m_response.setHTTPHeaderField(header.key, header.value); | 929 m_response.setHTTPHeaderField(header.key, header.value); |
924 } | 930 } |
925 | 931 |
926 m_isRevalidating = false; | 932 m_isRevalidating = false; |
927 } | 933 } |
928 | 934 |
929 void Resource::revalidationFailed() { | 935 void Resource::revalidationFailed() { |
930 SECURITY_CHECK(m_redirectChain.isEmpty()); | 936 SECURITY_CHECK(m_redirectChain.isEmpty()); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 case Resource::TextTrack: | 1074 case Resource::TextTrack: |
1069 case Resource::Media: | 1075 case Resource::Media: |
1070 case Resource::Manifest: | 1076 case Resource::Manifest: |
1071 return false; | 1077 return false; |
1072 } | 1078 } |
1073 NOTREACHED(); | 1079 NOTREACHED(); |
1074 return false; | 1080 return false; |
1075 } | 1081 } |
1076 | 1082 |
1077 } // namespace blink | 1083 } // namespace blink |
OLD | NEW |