| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 for (size_t i = 0; i < WTF_ARRAY_LENGTH(headerPrefixesToIgnoreAfterRevalidat
ion); i++) { | 87 for (size_t i = 0; i < WTF_ARRAY_LENGTH(headerPrefixesToIgnoreAfterRevalidat
ion); i++) { |
| 88 if (header.startsWith(headerPrefixesToIgnoreAfterRevalidation[i], TextCa
seInsensitive)) | 88 if (header.startsWith(headerPrefixesToIgnoreAfterRevalidation[i], TextCa
seInsensitive)) |
| 89 return false; | 89 return false; |
| 90 } | 90 } |
| 91 return true; | 91 return true; |
| 92 } | 92 } |
| 93 | 93 |
| 94 class Resource::CacheHandler : public CachedMetadataHandler { | 94 class Resource::CacheHandler : public CachedMetadataHandler { |
| 95 public: | 95 public: |
| 96 static PassOwnPtrWillBeRawPtr<CacheHandler> create(Resource* resource) | 96 static RawPtr<CacheHandler> create(Resource* resource) |
| 97 { | 97 { |
| 98 return adoptPtrWillBeNoop(new CacheHandler(resource)); | 98 return (new CacheHandler(resource)); |
| 99 } | 99 } |
| 100 ~CacheHandler() override { } | 100 ~CacheHandler() override { } |
| 101 DECLARE_VIRTUAL_TRACE(); | 101 DECLARE_VIRTUAL_TRACE(); |
| 102 void setCachedMetadata(unsigned, const char*, size_t, CacheType) override; | 102 void setCachedMetadata(unsigned, const char*, size_t, CacheType) override; |
| 103 void clearCachedMetadata(CacheType) override; | 103 void clearCachedMetadata(CacheType) override; |
| 104 CachedMetadata* cachedMetadata(unsigned) const override; | 104 CachedMetadata* cachedMetadata(unsigned) const override; |
| 105 String encoding() const override; | 105 String encoding() const override; |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 explicit CacheHandler(Resource*); | 108 explicit CacheHandler(Resource*); |
| 109 RawPtrWillBeMember<Resource> m_resource; | 109 Member<Resource> m_resource; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 Resource::CacheHandler::CacheHandler(Resource* resource) | 112 Resource::CacheHandler::CacheHandler(Resource* resource) |
| 113 : m_resource(resource) | 113 : m_resource(resource) |
| 114 { | 114 { |
| 115 } | 115 } |
| 116 | 116 |
| 117 DEFINE_TRACE(Resource::CacheHandler) | 117 DEFINE_TRACE(Resource::CacheHandler) |
| 118 { | 118 { |
| 119 #if ENABLE(OILPAN) | 119 #if ENABLE(OILPAN) |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 } | 500 } |
| 501 | 501 |
| 502 void Resource::clearCachedMetadata(CachedMetadataHandler::CacheType cacheType) | 502 void Resource::clearCachedMetadata(CachedMetadataHandler::CacheType cacheType) |
| 503 { | 503 { |
| 504 m_cachedMetadata.clear(); | 504 m_cachedMetadata.clear(); |
| 505 | 505 |
| 506 if (cacheType == CachedMetadataHandler::SendToPlatform) | 506 if (cacheType == CachedMetadataHandler::SendToPlatform) |
| 507 Platform::current()->cacheMetadata(m_response.url(), m_response.response
Time(), 0, 0); | 507 Platform::current()->cacheMetadata(m_response.url(), m_response.response
Time(), 0, 0); |
| 508 } | 508 } |
| 509 | 509 |
| 510 WeakPtrWillBeRawPtr<Resource> Resource::asWeakPtr() | 510 RawPtr<Resource> Resource::asWeakPtr() |
| 511 { | 511 { |
| 512 #if ENABLE(OILPAN) | 512 #if ENABLE(OILPAN) |
| 513 return this; | 513 return this; |
| 514 #else | 514 #else |
| 515 return m_weakPtrFactory.createWeakPtr(); | 515 return m_weakPtrFactory.createWeakPtr(); |
| 516 #endif | 516 #endif |
| 517 } | 517 } |
| 518 | 518 |
| 519 String Resource::reasonNotDeletable() const | 519 String Resource::reasonNotDeletable() const |
| 520 { | 520 { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 m_clientsAwaitingCallback.remove(client); | 635 m_clientsAwaitingCallback.remove(client); |
| 636 else | 636 else |
| 637 m_clients.remove(client); | 637 m_clients.remove(client); |
| 638 | 638 |
| 639 didRemoveClient(client); | 639 didRemoveClient(client); |
| 640 | 640 |
| 641 if (m_clientsAwaitingCallback.isEmpty()) | 641 if (m_clientsAwaitingCallback.isEmpty()) |
| 642 ResourceCallback::callbackHandler()->cancel(this); | 642 ResourceCallback::callbackHandler()->cancel(this); |
| 643 | 643 |
| 644 if (!hasClients()) { | 644 if (!hasClients()) { |
| 645 RefPtrWillBeRawPtr<Resource> protect(this); | 645 RawPtr<Resource> protect(this); |
| 646 memoryCache()->makeDead(this); | 646 memoryCache()->makeDead(this); |
| 647 allClientsRemoved(); | 647 allClientsRemoved(); |
| 648 | 648 |
| 649 // RFC2616 14.9.2: | 649 // RFC2616 14.9.2: |
| 650 // "no-store: ... MUST make a best-effort attempt to remove the informat
ion from volatile storage as promptly as possible" | 650 // "no-store: ... MUST make a best-effort attempt to remove the informat
ion from volatile storage as promptly as possible" |
| 651 // "... History buffers MAY store such responses as part of their normal
operation." | 651 // "... History buffers MAY store such responses as part of their normal
operation." |
| 652 // We allow non-secure content to be reused in history, but we do not al
low secure content to be reused. | 652 // We allow non-secure content to be reused in history, but we do not al
low secure content to be reused. |
| 653 if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) { | 653 if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) { |
| 654 memoryCache()->remove(this); | 654 memoryCache()->remove(this); |
| 655 memoryCache()->prune(); | 655 memoryCache()->prune(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 670 m_cancelTimer.startOneShot(0, BLINK_FROM_HERE); | 670 m_cancelTimer.startOneShot(0, BLINK_FROM_HERE); |
| 671 | 671 |
| 672 unlock(); | 672 unlock(); |
| 673 } | 673 } |
| 674 | 674 |
| 675 void Resource::cancelTimerFired(Timer<Resource>* timer) | 675 void Resource::cancelTimerFired(Timer<Resource>* timer) |
| 676 { | 676 { |
| 677 ASSERT_UNUSED(timer, timer == &m_cancelTimer); | 677 ASSERT_UNUSED(timer, timer == &m_cancelTimer); |
| 678 if (hasClients() || !m_loader) | 678 if (hasClients() || !m_loader) |
| 679 return; | 679 return; |
| 680 RefPtrWillBeRawPtr<Resource> protect(this); | 680 RawPtr<Resource> protect(this); |
| 681 m_loader->cancelIfNotFinishing(); | 681 m_loader->cancelIfNotFinishing(); |
| 682 if (m_status != Cached) | 682 if (m_status != Cached) |
| 683 memoryCache()->remove(this); | 683 memoryCache()->remove(this); |
| 684 } | 684 } |
| 685 | 685 |
| 686 void Resource::setDecodedSize(size_t decodedSize) | 686 void Resource::setDecodedSize(size_t decodedSize) |
| 687 { | 687 { |
| 688 if (decodedSize == m_decodedSize) | 688 if (decodedSize == m_decodedSize) |
| 689 return; | 689 return; |
| 690 size_t oldSize = size(); | 690 size_t oldSize = size(); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 } | 929 } |
| 930 | 930 |
| 931 Resource::ResourceCallback* Resource::ResourceCallback::callbackHandler() | 931 Resource::ResourceCallback* Resource::ResourceCallback::callbackHandler() |
| 932 { | 932 { |
| 933 // Oilpan + LSan: as the callbackHandler() singleton is used by Resource | 933 // Oilpan + LSan: as the callbackHandler() singleton is used by Resource |
| 934 // and ResourcePtr finalizers, it cannot be released upon shutdown in | 934 // and ResourcePtr finalizers, it cannot be released upon shutdown in |
| 935 // preparation for leak detection. | 935 // preparation for leak detection. |
| 936 // | 936 // |
| 937 // Keep it out of LSan's reach instead. | 937 // Keep it out of LSan's reach instead. |
| 938 LEAK_SANITIZER_DISABLED_SCOPE; | 938 LEAK_SANITIZER_DISABLED_SCOPE; |
| 939 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<ResourceCallback>, callbackHandle
r, (adoptPtrWillBeNoop(new ResourceCallback))); | 939 DEFINE_STATIC_LOCAL(Persistent<ResourceCallback>, callbackHandler, ((new Res
ourceCallback))); |
| 940 return callbackHandler.get(); | 940 return callbackHandler.get(); |
| 941 } | 941 } |
| 942 | 942 |
| 943 DEFINE_TRACE(Resource::ResourceCallback) | 943 DEFINE_TRACE(Resource::ResourceCallback) |
| 944 { | 944 { |
| 945 #if ENABLE(OILPAN) | 945 #if ENABLE(OILPAN) |
| 946 visitor->trace(m_resourcesWithPendingClients); | 946 visitor->trace(m_resourcesWithPendingClients); |
| 947 #endif | 947 #endif |
| 948 } | 948 } |
| 949 | 949 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 968 m_callbackTaskFactory->cancel(); | 968 m_callbackTaskFactory->cancel(); |
| 969 } | 969 } |
| 970 | 970 |
| 971 bool Resource::ResourceCallback::isScheduled(Resource* resource) const | 971 bool Resource::ResourceCallback::isScheduled(Resource* resource) const |
| 972 { | 972 { |
| 973 return m_resourcesWithPendingClients.contains(resource); | 973 return m_resourcesWithPendingClients.contains(resource); |
| 974 } | 974 } |
| 975 | 975 |
| 976 void Resource::ResourceCallback::runTask() | 976 void Resource::ResourceCallback::runTask() |
| 977 { | 977 { |
| 978 WillBeHeapVector<RefPtrWillBeMember<Resource>> resources; | 978 HeapVector<Member<Resource>> resources; |
| 979 for (const RefPtrWillBeMember<Resource>& resource : m_resourcesWithPendingCl
ients) | 979 for (const Member<Resource>& resource : m_resourcesWithPendingClients) |
| 980 resources.append(resource.get()); | 980 resources.append(resource.get()); |
| 981 m_resourcesWithPendingClients.clear(); | 981 m_resourcesWithPendingClients.clear(); |
| 982 | 982 |
| 983 for (const auto& resource : resources) { | 983 for (const auto& resource : resources) { |
| 984 resource->assertAlive(); | 984 resource->assertAlive(); |
| 985 resource->finishPendingClients(); | 985 resource->finishPendingClients(); |
| 986 resource->assertAlive(); | 986 resource->assertAlive(); |
| 987 } | 987 } |
| 988 | 988 |
| 989 for (const auto& resource : resources) | 989 for (const auto& resource : resources) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 case Resource::Media: | 1111 case Resource::Media: |
| 1112 return "Media"; | 1112 return "Media"; |
| 1113 case Resource::Manifest: | 1113 case Resource::Manifest: |
| 1114 return "Manifest"; | 1114 return "Manifest"; |
| 1115 } | 1115 } |
| 1116 ASSERT_NOT_REACHED(); | 1116 ASSERT_NOT_REACHED(); |
| 1117 return "Unknown"; | 1117 return "Unknown"; |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 } // namespace blink | 1120 } // namespace blink |
| OLD | NEW |