Chromium Code Reviews| 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. | |
|
Yoav Weiss
2016/10/03 08:52:20
indentation?
Charlie Harrison
2016/10/03 12:36:54
Done.
| |
| 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 didAddClient(client); | 803 didAddClient(client); |
| 798 } | 804 } |
| 799 | 805 |
| 800 // It is still possible for the above loop to finish a new client synchronousl y. | 806 // It is still possible for the above loop to finish a new client |
| 801 // If there's no client waiting we should deschedule. | 807 // synchronously. If there's no client waiting we should deschedule. |
| 802 bool scheduled = ResourceCallback::callbackHandler().isScheduled(this); | 808 bool scheduled = ResourceCallback::callbackHandler().isScheduled(this); |
| 803 if (scheduled && m_clientsAwaitingCallback.isEmpty()) | 809 if (scheduled && m_clientsAwaitingCallback.isEmpty()) |
| 804 ResourceCallback::callbackHandler().cancel(this); | 810 ResourceCallback::callbackHandler().cancel(this); |
| 805 | 811 |
| 806 // Prevent the case when there are clients waiting but no callback scheduled. | 812 // Prevent the case when there are clients waiting but no callback scheduled. |
| 807 DCHECK(m_clientsAwaitingCallback.isEmpty() || scheduled); | 813 DCHECK(m_clientsAwaitingCallback.isEmpty() || scheduled); |
| 808 } | 814 } |
| 809 | 815 |
| 810 void Resource::prune() { | 816 void Resource::prune() { |
| 811 destroyDecodedDataIfPossible(); | 817 destroyDecodedDataIfPossible(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 902 SECURITY_CHECK(m_redirectChain.isEmpty()); | 908 SECURITY_CHECK(m_redirectChain.isEmpty()); |
| 903 SECURITY_CHECK(equalIgnoringFragmentIdentifier(validatingResponse.url(), | 909 SECURITY_CHECK(equalIgnoringFragmentIdentifier(validatingResponse.url(), |
| 904 m_response.url())); | 910 m_response.url())); |
| 905 m_response.setResourceLoadTiming(validatingResponse.resourceLoadTiming()); | 911 m_response.setResourceLoadTiming(validatingResponse.resourceLoadTiming()); |
| 906 | 912 |
| 907 // RFC2616 10.3.5 | 913 // RFC2616 10.3.5 |
| 908 // Update cached headers from the 304 response | 914 // Update cached headers from the 304 response |
| 909 const HTTPHeaderMap& newHeaders = validatingResponse.httpHeaderFields(); | 915 const HTTPHeaderMap& newHeaders = validatingResponse.httpHeaderFields(); |
| 910 for (const auto& header : newHeaders) { | 916 for (const auto& header : newHeaders) { |
| 911 // Entity headers should not be sent by servers when generating a 304 | 917 // Entity headers should not be sent by servers when generating a 304 |
| 912 // response; misconfigured servers send them anyway. We shouldn't allow | 918 // response; misconfigured servers send them anyway. We shouldn't allow such |
| 913 // such headers to update the original request. We'll base this on the | 919 // headers to update the original request. We'll base this on the list |
| 914 // list defined by RFC2616 7.1, with a few additions for extension headers | 920 // defined by RFC2616 7.1, with a few additions for extension headers we |
| 915 // we care about. | 921 // care about. |
| 916 if (!shouldUpdateHeaderAfterRevalidation(header.key)) | 922 if (!shouldUpdateHeaderAfterRevalidation(header.key)) |
| 917 continue; | 923 continue; |
| 918 m_response.setHTTPHeaderField(header.key, header.value); | 924 m_response.setHTTPHeaderField(header.key, header.value); |
| 919 } | 925 } |
| 920 | 926 |
| 921 m_isRevalidating = false; | 927 m_isRevalidating = false; |
| 922 } | 928 } |
| 923 | 929 |
| 924 void Resource::revalidationFailed() { | 930 void Resource::revalidationFailed() { |
| 925 SECURITY_CHECK(m_redirectChain.isEmpty()); | 931 SECURITY_CHECK(m_redirectChain.isEmpty()); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1063 case Resource::TextTrack: | 1069 case Resource::TextTrack: |
| 1064 case Resource::Media: | 1070 case Resource::Media: |
| 1065 case Resource::Manifest: | 1071 case Resource::Manifest: |
| 1066 return false; | 1072 return false; |
| 1067 } | 1073 } |
| 1068 NOTREACHED(); | 1074 NOTREACHED(); |
| 1069 return false; | 1075 return false; |
| 1070 } | 1076 } |
| 1071 | 1077 |
| 1072 } // namespace blink | 1078 } // namespace blink |
| OLD | NEW |