| 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
rights reserved. |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 for (size_t i = 0; i < WTF_ARRAY_LENGTH(headerPrefixesToIgnoreAfterRevalidat
ion); i++) { | 89 for (size_t i = 0; i < WTF_ARRAY_LENGTH(headerPrefixesToIgnoreAfterRevalidat
ion); i++) { |
| 90 if (header.startsWith(headerPrefixesToIgnoreAfterRevalidation[i], TextCa
seInsensitive)) | 90 if (header.startsWith(headerPrefixesToIgnoreAfterRevalidation[i], TextCa
seInsensitive)) |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 class Resource::CacheHandler : public CachedMetadataHandler { | 96 class Resource::CacheHandler : public CachedMetadataHandler { |
| 97 public: | 97 public: |
| 98 static PassOwnPtrWillBeRawPtr<CacheHandler> create(Resource* resource) | 98 static RawPtr<CacheHandler> create(Resource* resource) |
| 99 { | 99 { |
| 100 return adoptPtrWillBeNoop(new CacheHandler(resource)); | 100 return new CacheHandler(resource); |
| 101 } | 101 } |
| 102 ~CacheHandler() override { } | 102 ~CacheHandler() override { } |
| 103 DECLARE_VIRTUAL_TRACE(); | 103 DECLARE_VIRTUAL_TRACE(); |
| 104 void setCachedMetadata(unsigned, const char*, size_t, CacheType) override; | 104 void setCachedMetadata(unsigned, const char*, size_t, CacheType) override; |
| 105 void clearCachedMetadata(CacheType) override; | 105 void clearCachedMetadata(CacheType) override; |
| 106 CachedMetadata* cachedMetadata(unsigned) const override; | 106 CachedMetadata* cachedMetadata(unsigned) const override; |
| 107 String encoding() const override; | 107 String encoding() const override; |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 explicit CacheHandler(Resource*); | 110 explicit CacheHandler(Resource*); |
| 111 RawPtrWillBeMember<Resource> m_resource; | 111 Member<Resource> m_resource; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 Resource::CacheHandler::CacheHandler(Resource* resource) | 114 Resource::CacheHandler::CacheHandler(Resource* resource) |
| 115 : m_resource(resource) | 115 : m_resource(resource) |
| 116 { | 116 { |
| 117 } | 117 } |
| 118 | 118 |
| 119 DEFINE_TRACE(Resource::CacheHandler) | 119 DEFINE_TRACE(Resource::CacheHandler) |
| 120 { | 120 { |
| 121 #if ENABLE(OILPAN) | 121 #if ENABLE(OILPAN) |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 488 } |
| 489 | 489 |
| 490 void Resource::clearCachedMetadata(CachedMetadataHandler::CacheType cacheType) | 490 void Resource::clearCachedMetadata(CachedMetadataHandler::CacheType cacheType) |
| 491 { | 491 { |
| 492 m_cachedMetadata.clear(); | 492 m_cachedMetadata.clear(); |
| 493 | 493 |
| 494 if (cacheType == CachedMetadataHandler::SendToPlatform) | 494 if (cacheType == CachedMetadataHandler::SendToPlatform) |
| 495 Platform::current()->cacheMetadata(m_response.url(), m_response.response
Time(), 0, 0); | 495 Platform::current()->cacheMetadata(m_response.url(), m_response.response
Time(), 0, 0); |
| 496 } | 496 } |
| 497 | 497 |
| 498 WeakPtrWillBeRawPtr<Resource> Resource::asWeakPtr() | 498 RawPtr<Resource> Resource::asWeakPtr() |
| 499 { | 499 { |
| 500 #if ENABLE(OILPAN) | 500 #if ENABLE(OILPAN) |
| 501 return this; | 501 return this; |
| 502 #else | 502 #else |
| 503 return m_weakPtrFactory.createWeakPtr(); | 503 return m_weakPtrFactory.createWeakPtr(); |
| 504 #endif | 504 #endif |
| 505 } | 505 } |
| 506 | 506 |
| 507 String Resource::reasonNotDeletable() const | 507 String Resource::reasonNotDeletable() const |
| 508 { | 508 { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 if (m_clientsAwaitingCallback.isEmpty()) | 631 if (m_clientsAwaitingCallback.isEmpty()) |
| 632 ResourceCallback::callbackHandler()->cancel(this); | 632 ResourceCallback::callbackHandler()->cancel(this); |
| 633 | 633 |
| 634 didRemoveClientOrObserver(); | 634 didRemoveClientOrObserver(); |
| 635 // This object may be dead here. | 635 // This object may be dead here. |
| 636 } | 636 } |
| 637 | 637 |
| 638 void Resource::didRemoveClientOrObserver() | 638 void Resource::didRemoveClientOrObserver() |
| 639 { | 639 { |
| 640 if (!hasClientsOrObservers()) { | 640 if (!hasClientsOrObservers()) { |
| 641 RefPtrWillBeRawPtr<Resource> protect(this); | 641 RawPtr<Resource> protect(this); |
| 642 memoryCache()->makeDead(this); | 642 memoryCache()->makeDead(this); |
| 643 allClientsAndObserversRemoved(); | 643 allClientsAndObserversRemoved(); |
| 644 | 644 |
| 645 // RFC2616 14.9.2: | 645 // RFC2616 14.9.2: |
| 646 // "no-store: ... MUST make a best-effort attempt to remove the informat
ion from volatile storage as promptly as possible" | 646 // "no-store: ... MUST make a best-effort attempt to remove the informat
ion from volatile storage as promptly as possible" |
| 647 // "... History buffers MAY store such responses as part of their normal
operation." | 647 // "... History buffers MAY store such responses as part of their normal
operation." |
| 648 // We allow non-secure content to be reused in history, but we do not al
low secure content to be reused. | 648 // We allow non-secure content to be reused in history, but we do not al
low secure content to be reused. |
| 649 if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) { | 649 if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) { |
| 650 memoryCache()->remove(this); | 650 memoryCache()->remove(this); |
| 651 memoryCache()->prune(); | 651 memoryCache()->prune(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 666 m_cancelTimer.startOneShot(0, BLINK_FROM_HERE); | 666 m_cancelTimer.startOneShot(0, BLINK_FROM_HERE); |
| 667 | 667 |
| 668 unlock(); | 668 unlock(); |
| 669 } | 669 } |
| 670 | 670 |
| 671 void Resource::cancelTimerFired(Timer<Resource>* timer) | 671 void Resource::cancelTimerFired(Timer<Resource>* timer) |
| 672 { | 672 { |
| 673 ASSERT_UNUSED(timer, timer == &m_cancelTimer); | 673 ASSERT_UNUSED(timer, timer == &m_cancelTimer); |
| 674 if (hasClientsOrObservers() || !m_loader) | 674 if (hasClientsOrObservers() || !m_loader) |
| 675 return; | 675 return; |
| 676 RefPtrWillBeRawPtr<Resource> protect(this); | 676 RawPtr<Resource> protect(this); |
| 677 m_loader->cancelIfNotFinishing(); | 677 m_loader->cancelIfNotFinishing(); |
| 678 memoryCache()->remove(this); | 678 memoryCache()->remove(this); |
| 679 } | 679 } |
| 680 | 680 |
| 681 void Resource::setDecodedSize(size_t decodedSize) | 681 void Resource::setDecodedSize(size_t decodedSize) |
| 682 { | 682 { |
| 683 if (decodedSize == m_decodedSize) | 683 if (decodedSize == m_decodedSize) |
| 684 return; | 684 return; |
| 685 size_t oldSize = size(); | 685 size_t oldSize = size(); |
| 686 m_decodedSize = decodedSize; | 686 m_decodedSize = decodedSize; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 } | 913 } |
| 914 | 914 |
| 915 Resource::ResourceCallback* Resource::ResourceCallback::callbackHandler() | 915 Resource::ResourceCallback* Resource::ResourceCallback::callbackHandler() |
| 916 { | 916 { |
| 917 // Oilpan + LSan: as the callbackHandler() singleton is used by Resource | 917 // Oilpan + LSan: as the callbackHandler() singleton is used by Resource |
| 918 // and ResourcePtr finalizers, it cannot be released upon shutdown in | 918 // and ResourcePtr finalizers, it cannot be released upon shutdown in |
| 919 // preparation for leak detection. | 919 // preparation for leak detection. |
| 920 // | 920 // |
| 921 // Keep it out of LSan's reach instead. | 921 // Keep it out of LSan's reach instead. |
| 922 LEAK_SANITIZER_DISABLED_SCOPE; | 922 LEAK_SANITIZER_DISABLED_SCOPE; |
| 923 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<ResourceCallback>, callbackHandle
r, (adoptPtrWillBeNoop(new ResourceCallback))); | 923 DEFINE_STATIC_LOCAL(Persistent<ResourceCallback>, callbackHandler, (adoptPtr
WillBeNoop(new ResourceCallback))); |
| 924 return callbackHandler.get(); | 924 return callbackHandler.get(); |
| 925 } | 925 } |
| 926 | 926 |
| 927 DEFINE_TRACE(Resource::ResourceCallback) | 927 DEFINE_TRACE(Resource::ResourceCallback) |
| 928 { | 928 { |
| 929 #if ENABLE(OILPAN) | 929 #if ENABLE(OILPAN) |
| 930 visitor->trace(m_resourcesWithPendingClients); | 930 visitor->trace(m_resourcesWithPendingClients); |
| 931 #endif | 931 #endif |
| 932 } | 932 } |
| 933 | 933 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 950 m_callbackTaskFactory->cancel(); | 950 m_callbackTaskFactory->cancel(); |
| 951 } | 951 } |
| 952 | 952 |
| 953 bool Resource::ResourceCallback::isScheduled(Resource* resource) const | 953 bool Resource::ResourceCallback::isScheduled(Resource* resource) const |
| 954 { | 954 { |
| 955 return m_resourcesWithPendingClients.contains(resource); | 955 return m_resourcesWithPendingClients.contains(resource); |
| 956 } | 956 } |
| 957 | 957 |
| 958 void Resource::ResourceCallback::runTask() | 958 void Resource::ResourceCallback::runTask() |
| 959 { | 959 { |
| 960 WillBeHeapVector<RefPtrWillBeMember<Resource>> resources; | 960 HeapVector<Member<Resource>> resources; |
| 961 for (const RefPtrWillBeMember<Resource>& resource : m_resourcesWithPendingCl
ients) | 961 for (const Member<Resource>& resource : m_resourcesWithPendingClients) |
| 962 resources.append(resource.get()); | 962 resources.append(resource.get()); |
| 963 m_resourcesWithPendingClients.clear(); | 963 m_resourcesWithPendingClients.clear(); |
| 964 | 964 |
| 965 for (const auto& resource : resources) | 965 for (const auto& resource : resources) |
| 966 resource->finishPendingClients(); | 966 resource->finishPendingClients(); |
| 967 } | 967 } |
| 968 | 968 |
| 969 static const char* initatorTypeNameToString(const AtomicString& initiatorTypeNam
e) | 969 static const char* initatorTypeNameToString(const AtomicString& initiatorTypeNam
e) |
| 970 { | 970 { |
| 971 if (initiatorTypeName == FetchInitiatorTypeNames::css) | 971 if (initiatorTypeName == FetchInitiatorTypeNames::css) |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 case Resource::Media: | 1087 case Resource::Media: |
| 1088 return "Media"; | 1088 return "Media"; |
| 1089 case Resource::Manifest: | 1089 case Resource::Manifest: |
| 1090 return "Manifest"; | 1090 return "Manifest"; |
| 1091 } | 1091 } |
| 1092 ASSERT_NOT_REACHED(); | 1092 ASSERT_NOT_REACHED(); |
| 1093 return "Unknown"; | 1093 return "Unknown"; |
| 1094 } | 1094 } |
| 1095 | 1095 |
| 1096 } // namespace blink | 1096 } // namespace blink |
| OLD | NEW |