| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 void MemoryCache::removeInternal(ResourceMap* resourceMap, | 182 void MemoryCache::removeInternal(ResourceMap* resourceMap, |
| 183 const ResourceMap::iterator& it) { | 183 const ResourceMap::iterator& it) { |
| 184 DCHECK(WTF::isMainThread()); | 184 DCHECK(WTF::isMainThread()); |
| 185 DCHECK(resourceMap); | 185 DCHECK(resourceMap); |
| 186 | 186 |
| 187 Resource* resource = it->value->resource(); | 187 Resource* resource = it->value->resource(); |
| 188 DCHECK(resource); | 188 DCHECK(resource); |
| 189 | 189 |
| 190 update(resource, resource->size(), 0); | 190 update(resource, resource->size(), 0); |
| 191 resourceMap->remove(it); | 191 resourceMap->erase(it); |
| 192 } | 192 } |
| 193 | 193 |
| 194 bool MemoryCache::contains(const Resource* resource) const { | 194 bool MemoryCache::contains(const Resource* resource) const { |
| 195 if (!resource || resource->url().isEmpty()) | 195 if (!resource || resource->url().isEmpty()) |
| 196 return false; | 196 return false; |
| 197 const ResourceMap* resources = m_resourceMaps.at(resource->cacheIdentifier()); | 197 const ResourceMap* resources = m_resourceMaps.at(resource->cacheIdentifier()); |
| 198 if (!resources) | 198 if (!resources) |
| 199 return false; | 199 return false; |
| 200 KURL url = removeFragmentIdentifierIfNeeded(resource->url()); | 200 KURL url = removeFragmentIdentifierIfNeeded(resource->url()); |
| 201 MemoryCacheEntry* entry = resources->at(url); | 201 MemoryCacheEntry* entry = resources->at(url); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 unusedPreloads.push_back(resourceIter->value.get()); | 344 unusedPreloads.push_back(resourceIter->value.get()); |
| 345 } | 345 } |
| 346 removeInternal(resources, resourceIter); | 346 removeInternal(resources, resourceIter); |
| 347 } | 347 } |
| 348 for (const auto& unusedPreload : unusedPreloads) { | 348 for (const auto& unusedPreload : unusedPreloads) { |
| 349 addInternal(resources, unusedPreload); | 349 addInternal(resources, unusedPreload); |
| 350 } | 350 } |
| 351 // We may iterate multiple times over resourceMaps with unused preloads. | 351 // We may iterate multiple times over resourceMaps with unused preloads. |
| 352 // That's extremely unlikely to have any real-life performance impact. | 352 // That's extremely unlikely to have any real-life performance impact. |
| 353 if (!resources->size()) { | 353 if (!resources->size()) { |
| 354 m_resourceMaps.remove(resourceMapIter); | 354 m_resourceMaps.erase(resourceMapIter); |
| 355 resourceMapIter = m_resourceMaps.begin(); | 355 resourceMapIter = m_resourceMaps.begin(); |
| 356 } else { | 356 } else { |
| 357 ++resourceMapIter; | 357 ++resourceMapIter; |
| 358 } | 358 } |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 | 361 |
| 362 void MemoryCache::prune() { | 362 void MemoryCache::prune() { |
| 363 TRACE_EVENT0("renderer", "MemoryCache::prune()"); | 363 TRACE_EVENT0("renderer", "MemoryCache::prune()"); |
| 364 | 364 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 } | 457 } |
| 458 } | 458 } |
| 459 return true; | 459 return true; |
| 460 } | 460 } |
| 461 | 461 |
| 462 void MemoryCache::onMemoryPressure(WebMemoryPressureLevel level) { | 462 void MemoryCache::onMemoryPressure(WebMemoryPressureLevel level) { |
| 463 pruneAll(); | 463 pruneAll(); |
| 464 } | 464 } |
| 465 | 465 |
| 466 } // namespace blink | 466 } // namespace blink |
| OLD | NEW |