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) 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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |