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

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

Issue 1918093003: Encapsulate |MemoryCacheEntry::m_resource| and refactor pruneDead/LiveResources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@MemoryCache_1a
Patch Set: Created 4 years, 7 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) 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // MemoryCacheEntry class an inner class of MemoryCache because of dependency 67 // MemoryCacheEntry class an inner class of MemoryCache because of dependency
68 // from MemoryCacheLRUList. 68 // from MemoryCacheLRUList.
69 class MemoryCacheEntry final : public GarbageCollectedFinalized<MemoryCacheEntry > { 69 class MemoryCacheEntry final : public GarbageCollectedFinalized<MemoryCacheEntry > {
70 public: 70 public:
71 static MemoryCacheEntry* create(Resource* resource) 71 static MemoryCacheEntry* create(Resource* resource)
72 { 72 {
73 return new MemoryCacheEntry(resource); 73 return new MemoryCacheEntry(resource);
74 } 74 }
75 DECLARE_TRACE(); 75 DECLARE_TRACE();
76 void dispose(); 76 void dispose();
77 Resource* resource();
77 78
78 Member<Resource> m_resource;
79 bool m_inLiveDecodedResourcesList; 79 bool m_inLiveDecodedResourcesList;
80 unsigned m_accessCount; 80 unsigned m_accessCount;
81 double m_lastDecodedAccessTime; // Used as a thrash guard 81 double m_lastDecodedAccessTime; // Used as a thrash guard
82 82
83 Member<MemoryCacheEntry> m_previousInLiveResourcesList; 83 Member<MemoryCacheEntry> m_previousInLiveResourcesList;
84 Member<MemoryCacheEntry> m_nextInLiveResourcesList; 84 Member<MemoryCacheEntry> m_nextInLiveResourcesList;
85 Member<MemoryCacheEntry> m_previousInAllResourcesList; 85 Member<MemoryCacheEntry> m_previousInAllResourcesList;
86 Member<MemoryCacheEntry> m_nextInAllResourcesList; 86 Member<MemoryCacheEntry> m_nextInAllResourcesList;
87 87
88 private: 88 private:
89 Member<Resource> m_resource;
Nate Chapin 2016/04/26 17:34:36 Nit: I think it's an unwritten convention that pri
90
89 explicit MemoryCacheEntry(Resource* resource) 91 explicit MemoryCacheEntry(Resource* resource)
90 : m_resource(resource) 92 : m_inLiveDecodedResourcesList(false)
91 , m_inLiveDecodedResourcesList(false)
92 , m_accessCount(0) 93 , m_accessCount(0)
93 , m_lastDecodedAccessTime(0.0) 94 , m_lastDecodedAccessTime(0.0)
94 , m_previousInLiveResourcesList(nullptr) 95 , m_previousInLiveResourcesList(nullptr)
95 , m_nextInLiveResourcesList(nullptr) 96 , m_nextInLiveResourcesList(nullptr)
96 , m_previousInAllResourcesList(nullptr) 97 , m_previousInAllResourcesList(nullptr)
97 , m_nextInAllResourcesList(nullptr) 98 , m_nextInAllResourcesList(nullptr)
99 , m_resource(resource)
98 { 100 {
99 } 101 }
100 }; 102 };
101 103
102 WILL_NOT_BE_EAGERLY_TRACED_CLASS(MemoryCacheEntry); 104 WILL_NOT_BE_EAGERLY_TRACED_CLASS(MemoryCacheEntry);
103 105
104 // MemoryCacheLRUList is used only in MemoryCache class, but we don't make 106 // MemoryCacheLRUList is used only in MemoryCache class, but we don't make
105 // MemoryCacheLRUList an inner struct of MemoryCache because we can't define 107 // MemoryCacheLRUList an inner struct of MemoryCache because we can't define
106 // VectorTraits for inner structs. 108 // VectorTraits for inner structs.
107 struct MemoryCacheLRUList final { 109 struct MemoryCacheLRUList final {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // Returns the global cache. 308 // Returns the global cache.
307 CORE_EXPORT MemoryCache* memoryCache(); 309 CORE_EXPORT MemoryCache* memoryCache();
308 310
309 // Sets the global cache, used to swap in a test instance. Returns the old 311 // Sets the global cache, used to swap in a test instance. Returns the old
310 // MemoryCache object. 312 // MemoryCache object.
311 CORE_EXPORT MemoryCache* replaceMemoryCacheForTesting(MemoryCache*); 313 CORE_EXPORT MemoryCache* replaceMemoryCacheForTesting(MemoryCache*);
312 314
313 } // namespace blink 315 } // namespace blink
314 316
315 #endif 317 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698