| 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 encodedSizeDuplicatedInDataURLs += o->url().protocolIsData() ? o->encodedSiz
e() : 0; | 600 encodedSizeDuplicatedInDataURLs += o->url().protocolIsData() ? o->encodedSiz
e() : 0; |
| 601 purgeableSize += purgeable ? pageSize : 0; | 601 purgeableSize += purgeable ? pageSize : 0; |
| 602 } | 602 } |
| 603 | 603 |
| 604 MemoryCache::Statistics MemoryCache::getStatistics() | 604 MemoryCache::Statistics MemoryCache::getStatistics() |
| 605 { | 605 { |
| 606 Statistics stats; | 606 Statistics stats; |
| 607 for (const auto& resourceMapIter : m_resourceMaps) { | 607 for (const auto& resourceMapIter : m_resourceMaps) { |
| 608 for (const auto& resourceIter : *resourceMapIter.value) { | 608 for (const auto& resourceIter : *resourceMapIter.value) { |
| 609 Resource* resource = resourceIter.value->m_resource.get(); | 609 Resource* resource = resourceIter.value->m_resource.get(); |
| 610 switch (resource->type()) { | 610 switch (resource->getType()) { |
| 611 case Resource::Image: | 611 case Resource::Image: |
| 612 stats.images.addResource(resource); | 612 stats.images.addResource(resource); |
| 613 break; | 613 break; |
| 614 case Resource::CSSStyleSheet: | 614 case Resource::CSSStyleSheet: |
| 615 stats.cssStyleSheets.addResource(resource); | 615 stats.cssStyleSheets.addResource(resource); |
| 616 break; | 616 break; |
| 617 case Resource::Script: | 617 case Resource::Script: |
| 618 stats.scripts.addResource(resource); | 618 stats.scripts.addResource(resource); |
| 619 break; | 619 break; |
| 620 case Resource::XSLStyleSheet: | 620 case Resource::XSLStyleSheet: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 | 682 |
| 683 if (m_prunePending && m_deadSize > m_maxDeferredPruneDeadCapacity && justRel
easedResource) { | 683 if (m_prunePending && m_deadSize > m_maxDeferredPruneDeadCapacity && justRel
easedResource) { |
| 684 // The following eviction does not respect LRU order, but it can be done | 684 // The following eviction does not respect LRU order, but it can be done |
| 685 // immediately in constant time, as opposed to pruneDeadResources, which | 685 // immediately in constant time, as opposed to pruneDeadResources, which |
| 686 // we would rather defer because it is O(N), which would make tear-down
of N | 686 // we would rather defer because it is O(N), which would make tear-down
of N |
| 687 // objects O(N^2) if we pruned immediately. This immediate eviction is a | 687 // objects O(N^2) if we pruned immediately. This immediate eviction is a |
| 688 // safeguard against runaway memory consumption by dead resources | 688 // safeguard against runaway memory consumption by dead resources |
| 689 // while a prune is pending. | 689 // while a prune is pending. |
| 690 // Main Resources in the cache are only substitue data that was | 690 // Main Resources in the cache are only substitue data that was |
| 691 // precached and should not be evicted. | 691 // precached and should not be evicted. |
| 692 if (justReleasedResource->type() != Resource::MainResource) { | 692 if (justReleasedResource->getType() != Resource::MainResource) { |
| 693 if (MemoryCacheEntry* entry = getEntryForResource(justReleasedResour
ce)) | 693 if (MemoryCacheEntry* entry = getEntryForResource(justReleasedResour
ce)) |
| 694 evict(entry); | 694 evict(entry); |
| 695 } | 695 } |
| 696 | 696 |
| 697 // As a last resort, prune immediately | 697 // As a last resort, prune immediately |
| 698 if (m_deadSize > m_maxDeferredPruneDeadCapacity) | 698 if (m_deadSize > m_maxDeferredPruneDeadCapacity) |
| 699 pruneNow(currentTime, AutomaticPrune); | 699 pruneNow(currentTime, AutomaticPrune); |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 | 702 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decode
dSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSi
ze()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), currentR
esource->isPurgeable()); | 793 printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decode
dSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSi
ze()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), currentR
esource->isPurgeable()); |
| 794 | 794 |
| 795 current = current->m_previousInAllResourcesList; | 795 current = current->m_previousInAllResourcesList; |
| 796 } | 796 } |
| 797 } | 797 } |
| 798 } | 798 } |
| 799 | 799 |
| 800 #endif // MEMORY_CACHE_STATS | 800 #endif // MEMORY_CACHE_STATS |
| 801 | 801 |
| 802 } // namespace blink | 802 } // namespace blink |
| OLD | NEW |