| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 m_resourceMaps.insert(cacheIdentifier, new ResourceMap); | 127 m_resourceMaps.insert(cacheIdentifier, new ResourceMap); |
| 128 CHECK(result.isNewEntry); | 128 CHECK(result.isNewEntry); |
| 129 } | 129 } |
| 130 return m_resourceMaps.get(cacheIdentifier); | 130 return m_resourceMaps.get(cacheIdentifier); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void MemoryCache::add(Resource* resource) { | 133 void MemoryCache::add(Resource* resource) { |
| 134 DCHECK(resource); | 134 DCHECK(resource); |
| 135 ResourceMap* resources = ensureResourceMap(resource->cacheIdentifier()); | 135 ResourceMap* resources = ensureResourceMap(resource->cacheIdentifier()); |
| 136 addInternal(resources, MemoryCacheEntry::create(resource)); | 136 addInternal(resources, MemoryCacheEntry::create(resource)); |
| 137 RESOURCE_LOADING_DVLOG(1) << "MemoryCache::add Added " | 137 RESOURCE_LOADING_DVLOG(1) |
| 138 << resource->url().getString() << ", resource " | 138 << "MemoryCache::add Added " << resource->url().getString() |
| 139 << resource; | 139 << ", resource " << resource; |
| 140 } | 140 } |
| 141 | 141 |
| 142 void MemoryCache::addInternal(ResourceMap* resourceMap, | 142 void MemoryCache::addInternal(ResourceMap* resourceMap, |
| 143 MemoryCacheEntry* entry) { | 143 MemoryCacheEntry* entry) { |
| 144 DCHECK(WTF::isMainThread()); | 144 DCHECK(WTF::isMainThread()); |
| 145 DCHECK(resourceMap); | 145 DCHECK(resourceMap); |
| 146 | 146 |
| 147 Resource* resource = entry->resource(); | 147 Resource* resource = entry->resource(); |
| 148 if (!resource) | 148 if (!resource) |
| 149 return; | 149 return; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 bool MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, | 423 bool MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, |
| 424 WebProcessMemoryDump* memoryDump) { | 424 WebProcessMemoryDump* memoryDump) { |
| 425 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Background) { | 425 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Background) { |
| 426 Statistics stats = getStatistics(); | 426 Statistics stats = getStatistics(); |
| 427 WebMemoryAllocatorDump* dump1 = | 427 WebMemoryAllocatorDump* dump1 = |
| 428 memoryDump->createMemoryAllocatorDump("web_cache/Image_resources"); | 428 memoryDump->createMemoryAllocatorDump("web_cache/Image_resources"); |
| 429 dump1->addScalar("size", "bytes", | 429 dump1->addScalar("size", "bytes", |
| 430 stats.images.encodedSize + stats.images.overheadSize); | 430 stats.images.encodedSize + stats.images.overheadSize); |
| 431 WebMemoryAllocatorDump* dump2 = memoryDump->createMemoryAllocatorDump( | 431 WebMemoryAllocatorDump* dump2 = memoryDump->createMemoryAllocatorDump( |
| 432 "web_cache/CSS stylesheet_resources"); | 432 "web_cache/CSS stylesheet_resources"); |
| 433 dump2->addScalar("size", "bytes", stats.cssStyleSheets.encodedSize + | 433 dump2->addScalar( |
| 434 stats.cssStyleSheets.overheadSize); | 434 "size", "bytes", |
| 435 stats.cssStyleSheets.encodedSize + stats.cssStyleSheets.overheadSize); |
| 435 WebMemoryAllocatorDump* dump3 = | 436 WebMemoryAllocatorDump* dump3 = |
| 436 memoryDump->createMemoryAllocatorDump("web_cache/Script_resources"); | 437 memoryDump->createMemoryAllocatorDump("web_cache/Script_resources"); |
| 437 dump3->addScalar("size", "bytes", | 438 dump3->addScalar("size", "bytes", |
| 438 stats.scripts.encodedSize + stats.scripts.overheadSize); | 439 stats.scripts.encodedSize + stats.scripts.overheadSize); |
| 439 WebMemoryAllocatorDump* dump4 = memoryDump->createMemoryAllocatorDump( | 440 WebMemoryAllocatorDump* dump4 = memoryDump->createMemoryAllocatorDump( |
| 440 "web_cache/XSL stylesheet_resources"); | 441 "web_cache/XSL stylesheet_resources"); |
| 441 dump4->addScalar("size", "bytes", stats.xslStyleSheets.encodedSize + | 442 dump4->addScalar( |
| 442 stats.xslStyleSheets.overheadSize); | 443 "size", "bytes", |
| 444 stats.xslStyleSheets.encodedSize + stats.xslStyleSheets.overheadSize); |
| 443 WebMemoryAllocatorDump* dump5 = | 445 WebMemoryAllocatorDump* dump5 = |
| 444 memoryDump->createMemoryAllocatorDump("web_cache/Font_resources"); | 446 memoryDump->createMemoryAllocatorDump("web_cache/Font_resources"); |
| 445 dump5->addScalar("size", "bytes", | 447 dump5->addScalar("size", "bytes", |
| 446 stats.fonts.encodedSize + stats.fonts.overheadSize); | 448 stats.fonts.encodedSize + stats.fonts.overheadSize); |
| 447 WebMemoryAllocatorDump* dump6 = | 449 WebMemoryAllocatorDump* dump6 = |
| 448 memoryDump->createMemoryAllocatorDump("web_cache/Other_resources"); | 450 memoryDump->createMemoryAllocatorDump("web_cache/Other_resources"); |
| 449 dump6->addScalar("size", "bytes", | 451 dump6->addScalar("size", "bytes", |
| 450 stats.other.encodedSize + stats.other.overheadSize); | 452 stats.other.encodedSize + stats.other.overheadSize); |
| 451 return true; | 453 return true; |
| 452 } | 454 } |
| 453 | 455 |
| 454 for (const auto& resourceMapIter : m_resourceMaps) { | 456 for (const auto& resourceMapIter : m_resourceMaps) { |
| 455 for (const auto& resourceIter : *resourceMapIter.value) { | 457 for (const auto& resourceIter : *resourceMapIter.value) { |
| 456 Resource* resource = resourceIter.value->resource(); | 458 Resource* resource = resourceIter.value->resource(); |
| 457 resource->onMemoryDump(levelOfDetail, memoryDump); | 459 resource->onMemoryDump(levelOfDetail, memoryDump); |
| 458 } | 460 } |
| 459 } | 461 } |
| 460 return true; | 462 return true; |
| 461 } | 463 } |
| 462 | 464 |
| 463 void MemoryCache::onMemoryPressure(WebMemoryPressureLevel level) { | 465 void MemoryCache::onMemoryPressure(WebMemoryPressureLevel level) { |
| 464 pruneAll(); | 466 pruneAll(); |
| 465 } | 467 } |
| 466 | 468 |
| 467 } // namespace blink | 469 } // namespace blink |
| OLD | NEW |