| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 class Resource::CachedMetadataHandlerImpl : public CachedMetadataHandler { | 97 class Resource::CachedMetadataHandlerImpl : public CachedMetadataHandler { |
| 98 public: | 98 public: |
| 99 static Resource::CachedMetadataHandlerImpl* create(Resource* resource) | 99 static Resource::CachedMetadataHandlerImpl* create(Resource* resource) |
| 100 { | 100 { |
| 101 return new CachedMetadataHandlerImpl(resource); | 101 return new CachedMetadataHandlerImpl(resource); |
| 102 } | 102 } |
| 103 ~CachedMetadataHandlerImpl() override {} | 103 ~CachedMetadataHandlerImpl() override {} |
| 104 DECLARE_VIRTUAL_TRACE(); | 104 DECLARE_VIRTUAL_TRACE(); |
| 105 void setCachedMetadata(unsigned, const char*, size_t, CacheType) override; | 105 void setCachedMetadata(unsigned, const char*, size_t, CacheType) override; |
| 106 void clearCachedMetadata(CacheType) override; | 106 void clearCachedMetadata(CacheType) override; |
| 107 CachedMetadata* cachedMetadata(unsigned) const override; | 107 PassRefPtr<CachedMetadata> cachedMetadata(unsigned) const override; |
| 108 String encoding() const override; | 108 String encoding() const override; |
| 109 // Sets the serialized metadata retrieved from the platform's cache. | 109 // Sets the serialized metadata retrieved from the platform's cache. |
| 110 void setSerializedCachedMetadata(const char*, size_t); | 110 void setSerializedCachedMetadata(const char*, size_t); |
| 111 | 111 |
| 112 protected: | 112 protected: |
| 113 explicit CachedMetadataHandlerImpl(Resource*); | 113 explicit CachedMetadataHandlerImpl(Resource*); |
| 114 virtual void sendToPlatform(); | 114 virtual void sendToPlatform(); |
| 115 const ResourceResponse& response() const { return m_resource->response(); } | 115 const ResourceResponse& response() const { return m_resource->response(); } |
| 116 | 116 |
| 117 RefPtr<CachedMetadata> m_cachedMetadata; | 117 RefPtr<CachedMetadata> m_cachedMetadata; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 142 sendToPlatform(); | 142 sendToPlatform(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void Resource::CachedMetadataHandlerImpl::clearCachedMetadata(CachedMetadataHand
ler::CacheType cacheType) | 145 void Resource::CachedMetadataHandlerImpl::clearCachedMetadata(CachedMetadataHand
ler::CacheType cacheType) |
| 146 { | 146 { |
| 147 m_cachedMetadata.clear(); | 147 m_cachedMetadata.clear(); |
| 148 if (cacheType == CachedMetadataHandler::SendToPlatform) | 148 if (cacheType == CachedMetadataHandler::SendToPlatform) |
| 149 sendToPlatform(); | 149 sendToPlatform(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 CachedMetadata* Resource::CachedMetadataHandlerImpl::cachedMetadata(unsigned dat
aTypeID) const | 152 PassRefPtr<CachedMetadata> Resource::CachedMetadataHandlerImpl::cachedMetadata(u
nsigned dataTypeID) const |
| 153 { | 153 { |
| 154 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) | 154 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) |
| 155 return nullptr; | 155 return nullptr; |
| 156 return m_cachedMetadata.get(); | 156 return m_cachedMetadata.get(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 String Resource::CachedMetadataHandlerImpl::encoding() const | 159 String Resource::CachedMetadataHandlerImpl::encoding() const |
| 160 { | 160 { |
| 161 return m_resource->encoding(); | 161 return m_resource->encoding(); |
| 162 } | 162 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 , m_responseTimestamp(currentTime()) | 312 , m_responseTimestamp(currentTime()) |
| 313 , m_cancelTimer(this, &Resource::cancelTimerFired) | 313 , m_cancelTimer(this, &Resource::cancelTimerFired) |
| 314 , m_resourceRequest(request) | 314 , m_resourceRequest(request) |
| 315 { | 315 { |
| 316 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car
eless updates of the enum. | 316 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car
eless updates of the enum. |
| 317 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); | 317 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); |
| 318 | 318 |
| 319 // Currently we support the metadata caching only for HTTP family. | 319 // Currently we support the metadata caching only for HTTP family. |
| 320 if (m_resourceRequest.url().protocolIsInHTTPFamily()) | 320 if (m_resourceRequest.url().protocolIsInHTTPFamily()) |
| 321 m_cacheHandler = CachedMetadataHandlerImpl::create(this); | 321 m_cacheHandler = CachedMetadataHandlerImpl::create(this); |
| 322 MemoryCoordinator::instance().registerClient(this); |
| 322 } | 323 } |
| 323 | 324 |
| 324 Resource::~Resource() | 325 Resource::~Resource() |
| 325 { | 326 { |
| 326 InstanceCounters::decrementCounter(InstanceCounters::ResourceCounter); | 327 InstanceCounters::decrementCounter(InstanceCounters::ResourceCounter); |
| 327 } | 328 } |
| 328 | 329 |
| 329 DEFINE_TRACE(Resource) | 330 DEFINE_TRACE(Resource) |
| 330 { | 331 { |
| 331 visitor->trace(m_loader); | 332 visitor->trace(m_loader); |
| 332 visitor->trace(m_cacheHandler); | 333 visitor->trace(m_cacheHandler); |
| 334 MemoryCoordinatorClient::trace(visitor); |
| 333 } | 335 } |
| 334 | 336 |
| 335 void Resource::setLoader(ResourceLoader* loader) | 337 void Resource::setLoader(ResourceLoader* loader) |
| 336 { | 338 { |
| 337 RELEASE_ASSERT(!m_loader); | 339 RELEASE_ASSERT(!m_loader); |
| 338 ASSERT(stillNeedsLoad()); | 340 ASSERT(stillNeedsLoad()); |
| 339 m_loader = loader; | 341 m_loader = loader; |
| 340 m_status = Pending; | 342 m_status = Pending; |
| 341 } | 343 } |
| 342 | 344 |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 // Prevent the case when there are clients waiting but no callback scheduled
. | 830 // Prevent the case when there are clients waiting but no callback scheduled
. |
| 829 ASSERT(m_clientsAwaitingCallback.isEmpty() || scheduled); | 831 ASSERT(m_clientsAwaitingCallback.isEmpty() || scheduled); |
| 830 } | 832 } |
| 831 | 833 |
| 832 void Resource::prune() | 834 void Resource::prune() |
| 833 { | 835 { |
| 834 destroyDecodedDataIfPossible(); | 836 destroyDecodedDataIfPossible(); |
| 835 unlock(); | 837 unlock(); |
| 836 } | 838 } |
| 837 | 839 |
| 840 void Resource::prepareToSuspend() |
| 841 { |
| 842 prune(); |
| 843 if (!m_cacheHandler) |
| 844 return; |
| 845 m_cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); |
| 846 } |
| 847 |
| 838 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcess
MemoryDump* memoryDump) const | 848 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcess
MemoryDump* memoryDump) const |
| 839 { | 849 { |
| 840 static const size_t kMaxURLReportLength = 128; | 850 static const size_t kMaxURLReportLength = 128; |
| 841 static const int kMaxResourceClientToShowInMemoryInfra = 10; | 851 static const int kMaxResourceClientToShowInMemoryInfra = 10; |
| 842 | 852 |
| 843 const String dumpName = getMemoryDumpName(); | 853 const String dumpName = getMemoryDumpName(); |
| 844 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpNam
e); | 854 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpNam
e); |
| 845 dump->addScalar("encoded_size", "bytes", m_encodedSize); | 855 dump->addScalar("encoded_size", "bytes", m_encodedSize); |
| 846 if (m_data && m_data->isLocked()) | 856 if (m_data && m_data->isLocked()) |
| 847 dump->addScalar("live_size", "bytes", m_encodedSize); | 857 dump->addScalar("live_size", "bytes", m_encodedSize); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 case Resource::TextTrack: | 1118 case Resource::TextTrack: |
| 1109 case Resource::Media: | 1119 case Resource::Media: |
| 1110 case Resource::Manifest: | 1120 case Resource::Manifest: |
| 1111 return false; | 1121 return false; |
| 1112 } | 1122 } |
| 1113 ASSERT_NOT_REACHED(); | 1123 ASSERT_NOT_REACHED(); |
| 1114 return false; | 1124 return false; |
| 1115 } | 1125 } |
| 1116 | 1126 |
| 1117 } // namespace blink | 1127 } // namespace blink |
| OLD | NEW |