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

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

Issue 2299603002: MemoryCache: Remove MEMORY_CACHE_STATS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WeakMemoryCache_revert
Patch Set: Rebase Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/MemoryCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 4 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // depending on the live resource load. Here's an example of cache growth over t ime, 49 // depending on the live resource load. Here's an example of cache growth over t ime,
50 // with a min dead resource capacity of 25% and a max dead resource capacity of 50%: 50 // with a min dead resource capacity of 25% and a max dead resource capacity of 50%:
51 51
52 // |-----| Dead: - 52 // |-----| Dead: -
53 // |----------| Live: + 53 // |----------| Live: +
54 // --|----------| Cache boundary: | (objects outsid e this mark have been evicted) 54 // --|----------| Cache boundary: | (objects outsid e this mark have been evicted)
55 // --|----------++++++++++| 55 // --|----------++++++++++|
56 // -------|-----+++++++++++++++| 56 // -------|-----+++++++++++++++|
57 // -------|-----+++++++++++++++|+++++ 57 // -------|-----+++++++++++++++|+++++
58 58
59 // Enable this macro to periodically log information about the memory cache.
60 #undef MEMORY_CACHE_STATS
61
62 enum UpdateReason { 59 enum UpdateReason {
63 UpdateForAccess, 60 UpdateForAccess,
64 UpdateForPropertyChange 61 UpdateForPropertyChange
65 }; 62 };
66 63
67 // MemoryCacheEntry class is used only in MemoryCache class, but we don't make 64 // MemoryCacheEntry class is used only in MemoryCache class, but we don't make
68 // MemoryCacheEntry class an inner class of MemoryCache because of dependency 65 // MemoryCacheEntry class an inner class of MemoryCache because of dependency
69 // from MemoryCacheLRUList. 66 // from MemoryCacheLRUList.
70 class MemoryCacheEntry final : public GarbageCollected<MemoryCacheEntry> { 67 class MemoryCacheEntry final : public GarbageCollected<MemoryCacheEntry> {
71 public: 68 public:
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // Automatically decide how much to prune. 222 // Automatically decide how much to prune.
226 AutomaticPrune, 223 AutomaticPrune,
227 // Maximally prune resources. 224 // Maximally prune resources.
228 MaximalPrune 225 MaximalPrune
229 }; 226 };
230 227
231 MemoryCache(); 228 MemoryCache();
232 229
233 MemoryCacheLRUList* lruListFor(unsigned accessCount, size_t); 230 MemoryCacheLRUList* lruListFor(unsigned accessCount, size_t);
234 231
235 #ifdef MEMORY_CACHE_STATS
236 void dumpStats(TimerBase*);
237 void dumpLRULists(bool includeLive) const;
238 #endif
239
240 // Calls to put the cached resource into and out of LRU lists. 232 // Calls to put the cached resource into and out of LRU lists.
241 void insertInLRUList(MemoryCacheEntry*, MemoryCacheLRUList*); 233 void insertInLRUList(MemoryCacheEntry*, MemoryCacheLRUList*);
242 void removeFromLRUList(MemoryCacheEntry*, MemoryCacheLRUList*); 234 void removeFromLRUList(MemoryCacheEntry*, MemoryCacheLRUList*);
243 bool containedInLRUList(MemoryCacheEntry*, MemoryCacheLRUList*); 235 bool containedInLRUList(MemoryCacheEntry*, MemoryCacheLRUList*);
244 236
245 // Track decoded resources that are in the cache and referenced by a Web pag e. 237 // Track decoded resources that are in the cache and referenced by a Web pag e.
246 void insertInLiveDecodedResourcesList(MemoryCacheEntry*); 238 void insertInLiveDecodedResourcesList(MemoryCacheEntry*);
247 void removeFromLiveDecodedResourcesList(MemoryCacheEntry*); 239 void removeFromLiveDecodedResourcesList(MemoryCacheEntry*);
248 bool containedInLiveDecodedResourcesList(MemoryCacheEntry*); 240 bool containedInLiveDecodedResourcesList(MemoryCacheEntry*);
249 241
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 280
289 // A URL-based map of all resources that are in the cache (including the fre shest version of objects that are currently being 281 // A URL-based map of all resources that are in the cache (including the fre shest version of objects that are currently being
290 // referenced by a Web page). 282 // referenced by a Web page).
291 // removeFragmentIdentifierIfNeeded() should be called for the url before us ing it as a key for the map. 283 // removeFragmentIdentifierIfNeeded() should be called for the url before us ing it as a key for the map.
292 using ResourceMap = HeapHashMap<String, Member<MemoryCacheEntry>>; 284 using ResourceMap = HeapHashMap<String, Member<MemoryCacheEntry>>;
293 using ResourceMapIndex = HeapHashMap<String, Member<ResourceMap>>; 285 using ResourceMapIndex = HeapHashMap<String, Member<ResourceMap>>;
294 ResourceMap* ensureResourceMap(const String& cacheIdentifier); 286 ResourceMap* ensureResourceMap(const String& cacheIdentifier);
295 ResourceMapIndex m_resourceMaps; 287 ResourceMapIndex m_resourceMaps;
296 288
297 friend class MemoryCacheTest; 289 friend class MemoryCacheTest;
298 #ifdef MEMORY_CACHE_STATS
299 Timer<MemoryCache> m_statsTimer;
300 #endif
301 }; 290 };
302 291
303 // Returns the global cache. 292 // Returns the global cache.
304 CORE_EXPORT MemoryCache* memoryCache(); 293 CORE_EXPORT MemoryCache* memoryCache();
305 294
306 // Sets the global cache, used to swap in a test instance. Returns the old 295 // Sets the global cache, used to swap in a test instance. Returns the old
307 // MemoryCache object. 296 // MemoryCache object.
308 CORE_EXPORT MemoryCache* replaceMemoryCacheForTesting(MemoryCache*); 297 CORE_EXPORT MemoryCache* replaceMemoryCacheForTesting(MemoryCache*);
309 298
310 } // namespace blink 299 } // namespace blink
311 300
312 #endif 301 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/MemoryCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698