Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/core/fetch/MemoryCache.cpp

Issue 2585283002: Migrate WTF::Vector::append() to ::push_back() [part 6 of N] (Closed)
Patch Set: Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 HeapVector<Member<Resource>> MemoryCache::resourcesForURL( 226 HeapVector<Member<Resource>> MemoryCache::resourcesForURL(
227 const KURL& resourceURL) const { 227 const KURL& resourceURL) const {
228 DCHECK(WTF::isMainThread()); 228 DCHECK(WTF::isMainThread());
229 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); 229 KURL url = removeFragmentIdentifierIfNeeded(resourceURL);
230 HeapVector<Member<Resource>> results; 230 HeapVector<Member<Resource>> results;
231 for (const auto& resourceMapIter : m_resourceMaps) { 231 for (const auto& resourceMapIter : m_resourceMaps) {
232 if (MemoryCacheEntry* entry = resourceMapIter.value->get(url)) { 232 if (MemoryCacheEntry* entry = resourceMapIter.value->get(url)) {
233 Resource* resource = entry->resource(); 233 Resource* resource = entry->resource();
234 DCHECK(resource); 234 DCHECK(resource);
235 results.append(resource); 235 results.push_back(resource);
236 } 236 }
237 } 237 }
238 return results; 238 return results;
239 } 239 }
240 240
241 void MemoryCache::pruneResources(PruneStrategy strategy) { 241 void MemoryCache::pruneResources(PruneStrategy strategy) {
242 DCHECK(!m_prunePending); 242 DCHECK(!m_prunePending);
243 const size_t sizeLimit = (strategy == MaximalPrune) ? 0 : capacity(); 243 const size_t sizeLimit = (strategy == MaximalPrune) ? 0 : capacity();
244 if (m_size <= sizeLimit) 244 if (m_size <= sizeLimit)
245 return; 245 return;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 resourceIter != resources->end(); resourceIter = resources->begin()) { 335 resourceIter != resources->end(); resourceIter = resources->begin()) {
336 DCHECK(resourceIter.get()); 336 DCHECK(resourceIter.get());
337 DCHECK(resourceIter->value.get()); 337 DCHECK(resourceIter->value.get());
338 DCHECK(resourceIter->value->resource()); 338 DCHECK(resourceIter->value->resource());
339 Resource* resource = resourceIter->value->resource(); 339 Resource* resource = resourceIter->value->resource();
340 DCHECK(resource); 340 DCHECK(resource);
341 if (policy != EvictAllResources && resource->isUnusedPreload()) { 341 if (policy != EvictAllResources && resource->isUnusedPreload()) {
342 // Store unused preloads aside, so they could be added back later. 342 // Store unused preloads aside, so they could be added back later.
343 // That is in order to avoid the performance impact of iterating over 343 // That is in order to avoid the performance impact of iterating over
344 // the same resource multiple times. 344 // the same resource multiple times.
345 unusedPreloads.append(resourceIter->value.get()); 345 unusedPreloads.push_back(resourceIter->value.get());
346 } 346 }
347 removeInternal(resources, resourceIter); 347 removeInternal(resources, resourceIter);
348 } 348 }
349 for (const auto& unusedPreload : unusedPreloads) { 349 for (const auto& unusedPreload : unusedPreloads) {
350 addInternal(resources, unusedPreload); 350 addInternal(resources, unusedPreload);
351 } 351 }
352 // We may iterate multiple times over resourceMaps with unused preloads. 352 // We may iterate multiple times over resourceMaps with unused preloads.
353 // That's extremely unlikely to have any real-life performance impact. 353 // That's extremely unlikely to have any real-life performance impact.
354 if (!resources->size()) { 354 if (!resources->size()) {
355 m_resourceMaps.remove(resourceMapIter); 355 m_resourceMaps.remove(resourceMapIter);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 458 }
459 } 459 }
460 return true; 460 return true;
461 } 461 }
462 462
463 void MemoryCache::onMemoryPressure(WebMemoryPressureLevel level) { 463 void MemoryCache::onMemoryPressure(WebMemoryPressureLevel level) {
464 pruneAll(); 464 pruneAll();
465 } 465 }
466 466
467 } // namespace blink 467 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/CrossOriginAccessControl.cpp ('k') | third_party/WebKit/Source/core/fetch/Resource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698