| 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) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 6 | 6 |
| 7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
| 8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
| 9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
| 10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 visitor->trace(m_nextInLiveResourcesList); | 68 visitor->trace(m_nextInLiveResourcesList); |
| 69 visitor->trace(m_previousInAllResourcesList); | 69 visitor->trace(m_previousInAllResourcesList); |
| 70 visitor->trace(m_nextInAllResourcesList); | 70 visitor->trace(m_nextInAllResourcesList); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void MemoryCacheEntry::dispose() | 73 void MemoryCacheEntry::dispose() |
| 74 { | 74 { |
| 75 m_resource.clear(); | 75 m_resource.clear(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 Resource* MemoryCacheEntry::resource() |
| 79 { |
| 80 return m_resource.get(); |
| 81 } |
| 82 |
| 78 DEFINE_TRACE(MemoryCacheLRUList) | 83 DEFINE_TRACE(MemoryCacheLRUList) |
| 79 { | 84 { |
| 80 visitor->trace(m_head); | 85 visitor->trace(m_head); |
| 81 visitor->trace(m_tail); | 86 visitor->trace(m_tail); |
| 82 } | 87 } |
| 83 | 88 |
| 84 inline MemoryCache::MemoryCache() | 89 inline MemoryCache::MemoryCache() |
| 85 : m_inPruneResources(false) | 90 : m_inPruneResources(false) |
| 86 , m_prunePending(false) | 91 , m_prunePending(false) |
| 87 , m_maxPruneDeferralDelay(cMaxPruneDeferralDelay) | 92 , m_maxPruneDeferralDelay(cMaxPruneDeferralDelay) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 if (!resourceURL.isValid() || resourceURL.isNull()) | 194 if (!resourceURL.isValid() || resourceURL.isNull()) |
| 190 return nullptr; | 195 return nullptr; |
| 191 ASSERT(!cacheIdentifier.isNull()); | 196 ASSERT(!cacheIdentifier.isNull()); |
| 192 ResourceMap* resources = m_resourceMaps.get(cacheIdentifier); | 197 ResourceMap* resources = m_resourceMaps.get(cacheIdentifier); |
| 193 if (!resources) | 198 if (!resources) |
| 194 return nullptr; | 199 return nullptr; |
| 195 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); | 200 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); |
| 196 MemoryCacheEntry* entry = resources->get(url); | 201 MemoryCacheEntry* entry = resources->get(url); |
| 197 if (!entry) | 202 if (!entry) |
| 198 return nullptr; | 203 return nullptr; |
| 199 Resource* resource = entry->m_resource.get(); | 204 Resource* resource = entry->resource(); |
| 200 if (resource && !resource->lock()) | 205 if (resource && !resource->lock()) |
| 201 return nullptr; | 206 return nullptr; |
| 202 return resource; | 207 return resource; |
| 203 } | 208 } |
| 204 | 209 |
| 205 HeapVector<Member<Resource>> MemoryCache::resourcesForURL(const KURL& resourceUR
L) | 210 HeapVector<Member<Resource>> MemoryCache::resourcesForURL(const KURL& resourceUR
L) |
| 206 { | 211 { |
| 207 ASSERT(WTF::isMainThread()); | 212 ASSERT(WTF::isMainThread()); |
| 208 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); | 213 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); |
| 209 HeapVector<Member<Resource>> results; | 214 HeapVector<Member<Resource>> results; |
| 210 for (const auto& resourceMapIter : m_resourceMaps) { | 215 for (const auto& resourceMapIter : m_resourceMaps) { |
| 211 if (MemoryCacheEntry* entry = resourceMapIter.value->get(url)) | 216 if (MemoryCacheEntry* entry = resourceMapIter.value->get(url)) |
| 212 results.append(entry->m_resource.get()); | 217 results.append(entry->resource()); |
| 213 } | 218 } |
| 214 return results; | 219 return results; |
| 215 } | 220 } |
| 216 | 221 |
| 217 size_t MemoryCache::deadCapacity() const | 222 size_t MemoryCache::deadCapacity() const |
| 218 { | 223 { |
| 219 // Dead resource capacity is whatever space is not occupied by live resource
s, bounded by an independent minimum and maximum. | 224 // Dead resource capacity is whatever space is not occupied by live resource
s, bounded by an independent minimum and maximum. |
| 220 size_t capacity = m_capacity - std::min(m_liveSize, m_capacity); // Start wi
th available capacity. | 225 size_t capacity = m_capacity - std::min(m_liveSize, m_capacity); // Start wi
th available capacity. |
| 221 capacity = std::max(capacity, m_minDeadCapacity); // Make sure it's above th
e minimum. | 226 capacity = std::max(capacity, m_minDeadCapacity); // Make sure it's above th
e minimum. |
| 222 capacity = std::min(capacity, m_maxDeadCapacity); // Make sure it's below th
e maximum. | 227 capacity = std::min(capacity, m_maxDeadCapacity); // Make sure it's below th
e maximum. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 245 // and least recently accessed of the objects. | 250 // and least recently accessed of the objects. |
| 246 | 251 |
| 247 // The list might not be sorted by the m_lastDecodedFrameTimeStamp. The impa
ct | 252 // The list might not be sorted by the m_lastDecodedFrameTimeStamp. The impa
ct |
| 248 // of this weaker invariant is minor as the below if statement to check the | 253 // of this weaker invariant is minor as the below if statement to check the |
| 249 // elapsedTime will evaluate to false as the current time will be a lot | 254 // elapsedTime will evaluate to false as the current time will be a lot |
| 250 // greater than the current->m_lastDecodedFrameTimeStamp. | 255 // greater than the current->m_lastDecodedFrameTimeStamp. |
| 251 // For more details see: https://bugs.webkit.org/show_bug.cgi?id=30209 | 256 // For more details see: https://bugs.webkit.org/show_bug.cgi?id=30209 |
| 252 | 257 |
| 253 MemoryCacheEntry* current = m_liveDecodedResources.m_tail; | 258 MemoryCacheEntry* current = m_liveDecodedResources.m_tail; |
| 254 while (current) { | 259 while (current) { |
| 260 Resource* resource = current->resource(); |
| 255 MemoryCacheEntry* previous = current->m_previousInLiveResourcesList; | 261 MemoryCacheEntry* previous = current->m_previousInLiveResourcesList; |
| 256 ASSERT(current->m_resource->hasClientsOrObservers()); | 262 ASSERT(resource->hasClientsOrObservers()); |
| 257 if (current->m_resource->isLoaded() && current->m_resource->decodedSize(
)) { | 263 |
| 264 if (resource->isLoaded() && resource->decodedSize()) { |
| 258 // Check to see if the remaining resources are too new to prune. | 265 // Check to see if the remaining resources are too new to prune. |
| 259 double elapsedTime = m_pruneFrameTimeStamp - current->m_lastDecodedA
ccessTime; | 266 double elapsedTime = m_pruneFrameTimeStamp - current->m_lastDecodedA
ccessTime; |
| 260 if (strategy == AutomaticPrune && elapsedTime < m_delayBeforeLiveDec
odedPrune) | 267 if (strategy == AutomaticPrune && elapsedTime < m_delayBeforeLiveDec
odedPrune) |
| 261 return; | 268 return; |
| 262 | 269 |
| 263 // Destroy our decoded data if possible. This will remove us | 270 // Destroy our decoded data if possible. This will remove us |
| 264 // from m_liveDecodedResources, and possibly move us to a | 271 // from m_liveDecodedResources, and possibly move us to a |
| 265 // different LRU list in m_allResources. | 272 // different LRU list in m_allResources. |
| 266 current->m_resource->prune(); | 273 resource->prune(); |
| 267 | 274 |
| 268 if (targetSize && m_liveSize <= targetSize) | 275 if (targetSize && m_liveSize <= targetSize) |
| 269 return; | 276 return; |
| 270 } | 277 } |
| 271 current = previous; | 278 current = previous; |
| 272 } | 279 } |
| 273 } | 280 } |
| 274 | 281 |
| 275 void MemoryCache::pruneDeadResources(PruneStrategy strategy) | 282 void MemoryCache::pruneDeadResources(PruneStrategy strategy) |
| 276 { | 283 { |
| 277 size_t capacity = deadCapacity(); | 284 size_t capacity = deadCapacity(); |
| 278 if (strategy == MaximalPrune) | 285 if (strategy == MaximalPrune) |
| 279 capacity = 0; | 286 capacity = 0; |
| 280 if (!m_deadSize || (capacity && m_deadSize <= capacity)) | 287 if (!m_deadSize || (capacity && m_deadSize <= capacity)) |
| 281 return; | 288 return; |
| 282 | 289 |
| 283 size_t targetSize = static_cast<size_t>(capacity * cTargetPrunePercentage);
// Cut by a percentage to avoid immediately pruning again. | 290 size_t targetSize = static_cast<size_t>(capacity * cTargetPrunePercentage);
// Cut by a percentage to avoid immediately pruning again. |
| 284 | 291 |
| 285 int size = m_allResources.size(); | 292 int size = m_allResources.size(); |
| 286 if (targetSize && m_deadSize <= targetSize) | 293 if (targetSize && m_deadSize <= targetSize) |
| 287 return; | 294 return; |
| 288 | 295 |
| 289 bool canShrinkLRULists = true; | 296 bool canShrinkLRULists = true; |
| 290 for (int i = size - 1; i >= 0; i--) { | 297 for (int i = size - 1; i >= 0; i--) { |
| 291 // Remove from the tail, since this is the least frequently accessed of
the objects. | 298 // Remove from the tail, since this is the least frequently accessed of
the objects. |
| 292 MemoryCacheEntry* current = m_allResources[i].m_tail; | 299 MemoryCacheEntry* current = m_allResources[i].m_tail; |
| 293 if (current) { | |
| 294 ASSERT(current->m_resource); | |
| 295 ASSERT(contains(current->m_resource.get())); | |
| 296 } | |
| 297 | 300 |
| 298 // First flush all the decoded data in this queue. | 301 // First flush all the decoded data in this queue. |
| 299 while (current) { | 302 while (current) { |
| 303 Resource* resource = current->resource(); |
| 300 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; | 304 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; |
| 301 if (previous) { | 305 |
| 302 ASSERT(previous->m_resource); | 306 // Decoded data may reference other resources. Skip |current| if |
| 303 ASSERT(contains(previous->m_resource.get())); | 307 // |current| somehow got kicked out of cache during |
| 308 // destroyDecodedData(). |
| 309 if (!resource || !contains(resource)) { |
| 310 current = previous; |
| 311 continue; |
| 304 } | 312 } |
| 305 if (!current->m_resource->hasClientsOrObservers() && !current->m_res
ource->isPreloaded() && current->m_resource->isLoaded()) { | 313 |
| 314 if (!resource->hasClientsOrObservers() && !resource->isPreloaded() &
& resource->isLoaded()) { |
| 306 // Destroy our decoded data. This will remove us from | 315 // Destroy our decoded data. This will remove us from |
| 307 // m_liveDecodedResources, and possibly move us to a different | 316 // m_liveDecodedResources, and possibly move us to a different |
| 308 // LRU list in m_allResources. | 317 // LRU list in m_allResources. |
| 309 current->m_resource->prune(); | 318 resource->prune(); |
| 310 | 319 |
| 311 if (targetSize && m_deadSize <= targetSize) | 320 if (targetSize && m_deadSize <= targetSize) |
| 312 return; | 321 return; |
| 313 } | 322 } |
| 314 // Decoded data may reference other resources. Stop iterating if 'pr
evious' somehow got | |
| 315 // kicked out of cache during destroyDecodedData(). | |
| 316 if (!previous || !previous->m_resource || !contains(previous->m_reso
urce.get())) | |
| 317 break; | |
| 318 current = previous; | 323 current = previous; |
| 319 } | 324 } |
| 320 | 325 |
| 321 // Now evict objects from this queue. | 326 // Now evict objects from this queue. |
| 322 current = m_allResources[i].m_tail; | 327 current = m_allResources[i].m_tail; |
| 323 if (current) { | |
| 324 ASSERT(current->m_resource); | |
| 325 ASSERT(contains(current->m_resource.get())); | |
| 326 } | |
| 327 while (current) { | 328 while (current) { |
| 329 Resource* resource = current->resource(); |
| 328 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; | 330 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; |
| 329 if (previous) { | 331 if (!resource || !contains(resource)) { |
| 330 ASSERT(previous->m_resource); | 332 current = previous; |
| 331 ASSERT(contains(previous->m_resource.get())); | 333 continue; |
| 332 } | 334 } |
| 333 if (!current->m_resource->hasClientsOrObservers() && !current->m_res
ource->isPreloaded()) { | 335 if (!resource->hasClientsOrObservers() && !resource->isPreloaded())
{ |
| 334 evict(current); | 336 evict(current); |
| 335 if (targetSize && m_deadSize <= targetSize) | 337 if (targetSize && m_deadSize <= targetSize) |
| 336 return; | 338 return; |
| 337 } | 339 } |
| 338 if (!previous || !previous->m_resource || !contains(previous->m_reso
urce.get())) | |
| 339 break; | |
| 340 current = previous; | 340 current = previous; |
| 341 } | 341 } |
| 342 | 342 |
| 343 // Shrink the vector back down so we don't waste time inspecting | 343 // Shrink the vector back down so we don't waste time inspecting |
| 344 // empty LRU lists on future prunes. | 344 // empty LRU lists on future prunes. |
| 345 if (m_allResources[i].m_head) | 345 if (m_allResources[i].m_head) |
| 346 canShrinkLRULists = false; | 346 canShrinkLRULists = false; |
| 347 else if (canShrinkLRULists) | 347 else if (canShrinkLRULists) |
| 348 m_allResources.resize(i); | 348 m_allResources.resize(i); |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 | 351 |
| 352 void MemoryCache::setCapacities(size_t minDeadBytes, size_t maxDeadBytes, size_t
totalBytes) | 352 void MemoryCache::setCapacities(size_t minDeadBytes, size_t maxDeadBytes, size_t
totalBytes) |
| 353 { | 353 { |
| 354 ASSERT(minDeadBytes <= maxDeadBytes); | 354 ASSERT(minDeadBytes <= maxDeadBytes); |
| 355 ASSERT(maxDeadBytes <= totalBytes); | 355 ASSERT(maxDeadBytes <= totalBytes); |
| 356 m_minDeadCapacity = minDeadBytes; | 356 m_minDeadCapacity = minDeadBytes; |
| 357 m_maxDeadCapacity = maxDeadBytes; | 357 m_maxDeadCapacity = maxDeadBytes; |
| 358 m_maxDeferredPruneDeadCapacity = cDeferredPruneDeadCapacityFactor * maxDeadB
ytes; | 358 m_maxDeferredPruneDeadCapacity = cDeferredPruneDeadCapacityFactor * maxDeadB
ytes; |
| 359 m_capacity = totalBytes; | 359 m_capacity = totalBytes; |
| 360 prune(); | 360 prune(); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void MemoryCache::evict(MemoryCacheEntry* entry) | 363 void MemoryCache::evict(MemoryCacheEntry* entry) |
| 364 { | 364 { |
| 365 ASSERT(WTF::isMainThread()); | 365 ASSERT(WTF::isMainThread()); |
| 366 | 366 |
| 367 Resource* resource = entry->m_resource.get(); | 367 Resource* resource = entry->resource(); |
| 368 WTF_LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", resourc
e, resource->url().getString().latin1().data()); | 368 WTF_LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", resourc
e, resource->url().getString().latin1().data()); |
| 369 // The resource may have already been removed by someone other than our call
er, | 369 // The resource may have already been removed by someone other than our call
er, |
| 370 // who needed a fresh copy for a reload. See <http://bugs.webkit.org/show_bu
g.cgi?id=12479#c6>. | 370 // who needed a fresh copy for a reload. See <http://bugs.webkit.org/show_bu
g.cgi?id=12479#c6>. |
| 371 update(resource, resource->size(), 0, false); | 371 update(resource, resource->size(), 0, false); |
| 372 removeFromLiveDecodedResourcesList(entry); | 372 removeFromLiveDecodedResourcesList(entry); |
| 373 | 373 |
| 374 ResourceMap* resources = m_resourceMaps.get(resource->cacheIdentifier()); | 374 ResourceMap* resources = m_resourceMaps.get(resource->cacheIdentifier()); |
| 375 ASSERT(resources); | 375 ASSERT(resources); |
| 376 KURL url = removeFragmentIdentifierIfNeeded(resource->url()); | 376 KURL url = removeFragmentIdentifierIfNeeded(resource->url()); |
| 377 ResourceMap::iterator it = resources->find(url); | 377 ResourceMap::iterator it = resources->find(url); |
| 378 ASSERT(it != resources->end()); | 378 ASSERT(it != resources->end()); |
| 379 | 379 |
| 380 MemoryCacheEntry* entryPtr = it->value; | 380 MemoryCacheEntry* entryPtr = it->value; |
| 381 resources->remove(it); | 381 resources->remove(it); |
| 382 if (entryPtr) | 382 if (entryPtr) |
| 383 entryPtr->dispose(); | 383 entryPtr->dispose(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 MemoryCacheEntry* MemoryCache::getEntryForResource(const Resource* resource) con
st | 386 MemoryCacheEntry* MemoryCache::getEntryForResource(const Resource* resource) con
st |
| 387 { | 387 { |
| 388 if (resource->url().isNull() || resource->url().isEmpty()) | 388 if (resource->url().isNull() || resource->url().isEmpty()) |
| 389 return nullptr; | 389 return nullptr; |
| 390 ResourceMap* resources = m_resourceMaps.get(resource->cacheIdentifier()); | 390 ResourceMap* resources = m_resourceMaps.get(resource->cacheIdentifier()); |
| 391 if (!resources) | 391 if (!resources) |
| 392 return nullptr; | 392 return nullptr; |
| 393 KURL url = removeFragmentIdentifierIfNeeded(resource->url()); | 393 KURL url = removeFragmentIdentifierIfNeeded(resource->url()); |
| 394 MemoryCacheEntry* entry = resources->get(url); | 394 MemoryCacheEntry* entry = resources->get(url); |
| 395 if (!entry || entry->m_resource != resource) | 395 if (!entry || entry->resource() != resource) |
| 396 return nullptr; | 396 return nullptr; |
| 397 return entry; | 397 return entry; |
| 398 } | 398 } |
| 399 | 399 |
| 400 MemoryCacheLRUList* MemoryCache::lruListFor(unsigned accessCount, size_t size) | 400 MemoryCacheLRUList* MemoryCache::lruListFor(unsigned accessCount, size_t size) |
| 401 { | 401 { |
| 402 ASSERT(accessCount > 0); | 402 ASSERT(accessCount > 0); |
| 403 unsigned queueIndex = WTF::fastLog2(size / accessCount); | 403 unsigned queueIndex = WTF::fastLog2(size / accessCount); |
| 404 if (m_allResources.size() <= queueIndex) | 404 if (m_allResources.size() <= queueIndex) |
| 405 m_allResources.grow(queueIndex + 1); | 405 m_allResources.grow(queueIndex + 1); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 encodedSize += o->encodedSize(); | 597 encodedSize += o->encodedSize(); |
| 598 encodedSizeDuplicatedInDataURLs += o->url().protocolIsData() ? o->encodedSiz
e() : 0; | 598 encodedSizeDuplicatedInDataURLs += o->url().protocolIsData() ? o->encodedSiz
e() : 0; |
| 599 purgeableSize += purgeable ? pageSize : 0; | 599 purgeableSize += purgeable ? pageSize : 0; |
| 600 } | 600 } |
| 601 | 601 |
| 602 MemoryCache::Statistics MemoryCache::getStatistics() | 602 MemoryCache::Statistics MemoryCache::getStatistics() |
| 603 { | 603 { |
| 604 Statistics stats; | 604 Statistics stats; |
| 605 for (const auto& resourceMapIter : m_resourceMaps) { | 605 for (const auto& resourceMapIter : m_resourceMaps) { |
| 606 for (const auto& resourceIter : *resourceMapIter.value) { | 606 for (const auto& resourceIter : *resourceMapIter.value) { |
| 607 Resource* resource = resourceIter.value->m_resource.get(); | 607 Resource* resource = resourceIter.value->resource(); |
| 608 switch (resource->getType()) { | 608 switch (resource->getType()) { |
| 609 case Resource::Image: | 609 case Resource::Image: |
| 610 stats.images.addResource(resource); | 610 stats.images.addResource(resource); |
| 611 break; | 611 break; |
| 612 case Resource::CSSStyleSheet: | 612 case Resource::CSSStyleSheet: |
| 613 stats.cssStyleSheets.addResource(resource); | 613 stats.cssStyleSheets.addResource(resource); |
| 614 break; | 614 break; |
| 615 case Resource::Script: | 615 case Resource::Script: |
| 616 stats.scripts.addResource(resource); | 616 stats.scripts.addResource(resource); |
| 617 break; | 617 break; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 | 727 |
| 728 void MemoryCache::updateFramePaintTimestamp() | 728 void MemoryCache::updateFramePaintTimestamp() |
| 729 { | 729 { |
| 730 m_lastFramePaintTimeStamp = currentTime(); | 730 m_lastFramePaintTimeStamp = currentTime(); |
| 731 } | 731 } |
| 732 | 732 |
| 733 void MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProc
essMemoryDump* memoryDump) | 733 void MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProc
essMemoryDump* memoryDump) |
| 734 { | 734 { |
| 735 for (const auto& resourceMapIter : m_resourceMaps) { | 735 for (const auto& resourceMapIter : m_resourceMaps) { |
| 736 for (const auto& resourceIter : *resourceMapIter.value) { | 736 for (const auto& resourceIter : *resourceMapIter.value) { |
| 737 Resource* resource = resourceIter.value->m_resource.get(); | 737 Resource* resource = resourceIter.value->resource(); |
| 738 resource->onMemoryDump(levelOfDetail, memoryDump); | 738 resource->onMemoryDump(levelOfDetail, memoryDump); |
| 739 } | 739 } |
| 740 } | 740 } |
| 741 } | 741 } |
| 742 | 742 |
| 743 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y) | 743 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y) |
| 744 { | 744 { |
| 745 MemoryCacheEntry* ex = getEntryForResource(x); | 745 MemoryCacheEntry* ex = getEntryForResource(x); |
| 746 MemoryCacheEntry* ey = getEntryForResource(y); | 746 MemoryCacheEntry* ey = getEntryForResource(y); |
| 747 ASSERT(ex); | 747 ASSERT(ex); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 775 | 775 |
| 776 void MemoryCache::dumpLRULists(bool includeLive) const | 776 void MemoryCache::dumpLRULists(bool includeLive) const |
| 777 { | 777 { |
| 778 printf("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded
, Access count, Referenced, isPurgeable):\n"); | 778 printf("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded
, Access count, Referenced, isPurgeable):\n"); |
| 779 | 779 |
| 780 int size = m_allResources.size(); | 780 int size = m_allResources.size(); |
| 781 for (int i = size - 1; i >= 0; i--) { | 781 for (int i = size - 1; i >= 0; i--) { |
| 782 printf("\n\nList %d: ", i); | 782 printf("\n\nList %d: ", i); |
| 783 MemoryCacheEntry* current = m_allResources[i].m_tail; | 783 MemoryCacheEntry* current = m_allResources[i].m_tail; |
| 784 while (current) { | 784 while (current) { |
| 785 Resource* currentResource = current->m_resource; | 785 Resource* currentResource = current->resource(); |
| 786 if (includeLive || !currentResource->hasClientsOrObservers()) | 786 if (includeLive || !currentResource->hasClientsOrObservers()) |
| 787 printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decode
dSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSi
ze()) / 1024.0f, current->m_accessCount, currentResource->hasClientsOrObservers(
), currentResource->isPurgeable()); | 787 printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decode
dSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSi
ze()) / 1024.0f, current->m_accessCount, currentResource->hasClientsOrObservers(
), currentResource->isPurgeable()); |
| 788 | 788 |
| 789 current = current->m_previousInAllResourcesList; | 789 current = current->m_previousInAllResourcesList; |
| 790 } | 790 } |
| 791 } | 791 } |
| 792 } | 792 } |
| 793 | 793 |
| 794 #endif // MEMORY_CACHE_STATS | 794 #endif // MEMORY_CACHE_STATS |
| 795 | 795 |
| 796 } // namespace blink | 796 } // namespace blink |
| OLD | NEW |