| 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 #include "core/fetch/Resource.h" | 24 #include "core/fetch/Resource.h" |
| 25 | 25 |
| 26 #include "core/fetch/CachedMetadata.h" | 26 #include "core/fetch/CachedMetadata.h" |
| 27 #include "core/fetch/CrossOriginAccessControl.h" | 27 #include "core/fetch/CrossOriginAccessControl.h" |
| 28 #include "core/fetch/FetchInitiatorTypeNames.h" | 28 #include "core/fetch/FetchInitiatorTypeNames.h" |
| 29 #include "core/fetch/MemoryCache.h" | 29 #include "core/fetch/MemoryCache.h" |
| 30 #include "core/fetch/ResourceClient.h" | 30 #include "core/fetch/ResourceClient.h" |
| 31 #include "core/fetch/ResourceClientOrObserverWalker.h" | 31 #include "core/fetch/ResourceClientOrObserverWalker.h" |
| 32 #include "core/fetch/ResourceLoader.h" | 32 #include "core/fetch/ResourceLoader.h" |
| 33 #include "core/fetch/ScriptResource.h" |
| 33 #include "core/inspector/InstanceCounters.h" | 34 #include "core/inspector/InstanceCounters.h" |
| 34 #include "platform/Histogram.h" | 35 #include "platform/Histogram.h" |
| 35 #include "platform/Logging.h" | 36 #include "platform/Logging.h" |
| 36 #include "platform/RuntimeEnabledFeatures.h" | 37 #include "platform/RuntimeEnabledFeatures.h" |
| 37 #include "platform/SharedBuffer.h" | 38 #include "platform/SharedBuffer.h" |
| 38 #include "platform/TraceEvent.h" | 39 #include "platform/TraceEvent.h" |
| 39 #include "platform/network/HTTPParsers.h" | 40 #include "platform/network/HTTPParsers.h" |
| 40 #include "platform/weborigin/KURL.h" | 41 #include "platform/weborigin/KURL.h" |
| 41 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
| 42 #include "public/platform/WebScheduler.h" | 43 #include "public/platform/WebScheduler.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 103 } |
| 103 ~CachedMetadataHandlerImpl() override {} | 104 ~CachedMetadataHandlerImpl() override {} |
| 104 DECLARE_VIRTUAL_TRACE(); | 105 DECLARE_VIRTUAL_TRACE(); |
| 105 void setCachedMetadata(unsigned, const char*, size_t, CacheType) override; | 106 void setCachedMetadata(unsigned, const char*, size_t, CacheType) override; |
| 106 void clearCachedMetadata(CacheType) override; | 107 void clearCachedMetadata(CacheType) override; |
| 107 CachedMetadata* cachedMetadata(unsigned) const override; | 108 CachedMetadata* cachedMetadata(unsigned) const override; |
| 108 String encoding() const override; | 109 String encoding() const override; |
| 109 // Sets the serialized metadata retrieved from the platform's cache. | 110 // Sets the serialized metadata retrieved from the platform's cache. |
| 110 void setSerializedCachedMetadata(const char*, size_t); | 111 void setSerializedCachedMetadata(const char*, size_t); |
| 111 | 112 |
| 113 void prune() override; |
| 114 |
| 112 protected: | 115 protected: |
| 113 explicit CachedMetadataHandlerImpl(Resource*); | 116 explicit CachedMetadataHandlerImpl(Resource*); |
| 114 virtual void sendToPlatform(); | 117 virtual void sendToPlatform(); |
| 115 const ResourceResponse& response() const { return m_resource->response(); } | 118 const ResourceResponse& response() const { return m_resource->response(); } |
| 116 | 119 |
| 117 RefPtr<CachedMetadata> m_cachedMetadata; | 120 RefPtr<CachedMetadata> m_cachedMetadata; |
| 118 | 121 |
| 119 private: | 122 private: |
| 120 Member<Resource> m_resource; | 123 Member<Resource> m_resource; |
| 121 }; | 124 }; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 void Resource::CachedMetadataHandlerImpl::sendToPlatform() | 176 void Resource::CachedMetadataHandlerImpl::sendToPlatform() |
| 174 { | 177 { |
| 175 if (m_cachedMetadata) { | 178 if (m_cachedMetadata) { |
| 176 const Vector<char>& serializedData = m_cachedMetadata->serialize(); | 179 const Vector<char>& serializedData = m_cachedMetadata->serialize(); |
| 177 Platform::current()->cacheMetadata(response().url(), response().response
Time(), serializedData.data(), serializedData.size()); | 180 Platform::current()->cacheMetadata(response().url(), response().response
Time(), serializedData.data(), serializedData.size()); |
| 178 } else { | 181 } else { |
| 179 Platform::current()->cacheMetadata(response().url(), response().response
Time(), nullptr, 0); | 182 Platform::current()->cacheMetadata(response().url(), response().response
Time(), nullptr, 0); |
| 180 } | 183 } |
| 181 } | 184 } |
| 182 | 185 |
| 186 void Resource::CachedMetadataHandlerImpl::prune() |
| 187 { |
| 188 clearCachedMetadata(CachedMetadataHandler::CacheLocally); |
| 189 } |
| 190 |
| 183 class Resource::ServiceWorkerResponseCachedMetadataHandler : public Resource::Ca
chedMetadataHandlerImpl { | 191 class Resource::ServiceWorkerResponseCachedMetadataHandler : public Resource::Ca
chedMetadataHandlerImpl { |
| 184 public: | 192 public: |
| 185 static Resource::CachedMetadataHandlerImpl* create(Resource* resource, Secur
ityOrigin* securityOrigin) | 193 static Resource::CachedMetadataHandlerImpl* create(Resource* resource, Secur
ityOrigin* securityOrigin) |
| 186 { | 194 { |
| 187 return new ServiceWorkerResponseCachedMetadataHandler(resource, security
Origin); | 195 return new ServiceWorkerResponseCachedMetadataHandler(resource, security
Origin); |
| 188 } | 196 } |
| 189 ~ServiceWorkerResponseCachedMetadataHandler() override {} | 197 ~ServiceWorkerResponseCachedMetadataHandler() override {} |
| 190 DECLARE_VIRTUAL_TRACE(); | 198 DECLARE_VIRTUAL_TRACE(); |
| 191 | 199 |
| 192 protected: | 200 protected: |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 if (scheduled && m_clientsAwaitingCallback.isEmpty()) | 832 if (scheduled && m_clientsAwaitingCallback.isEmpty()) |
| 825 ResourceCallback::callbackHandler().cancel(this); | 833 ResourceCallback::callbackHandler().cancel(this); |
| 826 | 834 |
| 827 // Prevent the case when there are clients waiting but no callback scheduled
. | 835 // Prevent the case when there are clients waiting but no callback scheduled
. |
| 828 ASSERT(m_clientsAwaitingCallback.isEmpty() || scheduled); | 836 ASSERT(m_clientsAwaitingCallback.isEmpty() || scheduled); |
| 829 } | 837 } |
| 830 | 838 |
| 831 void Resource::prune() | 839 void Resource::prune() |
| 832 { | 840 { |
| 833 destroyDecodedDataIfPossible(); | 841 destroyDecodedDataIfPossible(); |
| 842 if (m_cacheHandler) |
| 843 m_cacheHandler->prune(); |
| 834 unlock(); | 844 unlock(); |
| 835 } | 845 } |
| 836 | 846 |
| 837 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcess
MemoryDump* memoryDump) const | 847 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcess
MemoryDump* memoryDump) const |
| 838 { | 848 { |
| 839 static const size_t kMaxURLReportLength = 128; | 849 static const size_t kMaxURLReportLength = 128; |
| 840 static const int kMaxResourceClientToShowInMemoryInfra = 10; | 850 static const int kMaxResourceClientToShowInMemoryInfra = 10; |
| 841 | 851 |
| 842 const String dumpName = getMemoryDumpName(); | 852 const String dumpName = getMemoryDumpName(); |
| 843 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpNam
e); | 853 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpNam
e); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 case Resource::Media: | 1148 case Resource::Media: |
| 1139 return "Media"; | 1149 return "Media"; |
| 1140 case Resource::Manifest: | 1150 case Resource::Manifest: |
| 1141 return "Manifest"; | 1151 return "Manifest"; |
| 1142 } | 1152 } |
| 1143 ASSERT_NOT_REACHED(); | 1153 ASSERT_NOT_REACHED(); |
| 1144 return "Unknown"; | 1154 return "Unknown"; |
| 1145 } | 1155 } |
| 1146 | 1156 |
| 1147 } // namespace blink | 1157 } // namespace blink |
| OLD | NEW |