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

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

Issue 1999613002: Move WebCacheMemoryDumpProvider to platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix link error on win 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) 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.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. 20 Boston, MA 02110-1301, USA.
21 */ 21 */
22 22
23 #include "core/fetch/MemoryCache.h" 23 #include "core/fetch/MemoryCache.h"
24 24
25 #include "core/fetch/WebCacheMemoryDumpProvider.h"
26 #include "platform/Logging.h" 25 #include "platform/Logging.h"
27 #include "platform/TraceEvent.h" 26 #include "platform/TraceEvent.h"
28 #include "platform/weborigin/SecurityOrigin.h" 27 #include "platform/weborigin/SecurityOrigin.h"
29 #include "platform/weborigin/SecurityOriginHash.h" 28 #include "platform/weborigin/SecurityOriginHash.h"
30 #include "public/platform/Platform.h" 29 #include "public/platform/Platform.h"
31 #include "wtf/Assertions.h" 30 #include "wtf/Assertions.h"
32 #include "wtf/CurrentTime.h" 31 #include "wtf/CurrentTime.h"
33 #include "wtf/MathExtras.h" 32 #include "wtf/MathExtras.h"
34 #include "wtf/TemporaryChange.h" 33 #include "wtf/TemporaryChange.h"
35 #include "wtf/text/CString.h" 34 #include "wtf/text/CString.h"
(...skipping 14 matching lines...) Expand all
50 if (!gMemoryCache) 49 if (!gMemoryCache)
51 gMemoryCache = new Persistent<MemoryCache>(MemoryCache::create()); 50 gMemoryCache = new Persistent<MemoryCache>(MemoryCache::create());
52 return gMemoryCache->get(); 51 return gMemoryCache->get();
53 } 52 }
54 53
55 MemoryCache* replaceMemoryCacheForTesting(MemoryCache* cache) 54 MemoryCache* replaceMemoryCacheForTesting(MemoryCache* cache)
56 { 55 {
57 memoryCache(); 56 memoryCache();
58 MemoryCache* oldCache = gMemoryCache->release(); 57 MemoryCache* oldCache = gMemoryCache->release();
59 *gMemoryCache = cache; 58 *gMemoryCache = cache;
60 WebCacheMemoryDumpProvider::instance()->setMemoryCache(cache); 59 MemoryCacheDumpProvider::instance()->setMemoryCache(cache);
61 return oldCache; 60 return oldCache;
62 } 61 }
63 62
64 DEFINE_TRACE(MemoryCacheEntry) 63 DEFINE_TRACE(MemoryCacheEntry)
65 { 64 {
66 visitor->trace(m_resource); 65 visitor->trace(m_resource);
67 visitor->trace(m_previousInLiveResourcesList); 66 visitor->trace(m_previousInLiveResourcesList);
68 visitor->trace(m_nextInLiveResourcesList); 67 visitor->trace(m_nextInLiveResourcesList);
69 visitor->trace(m_previousInAllResourcesList); 68 visitor->trace(m_previousInAllResourcesList);
70 visitor->trace(m_nextInAllResourcesList); 69 visitor->trace(m_nextInAllResourcesList);
(...skipping 26 matching lines...) Expand all
97 , m_minDeadCapacity(0) 96 , m_minDeadCapacity(0)
98 , m_maxDeadCapacity(cDefaultCacheCapacity) 97 , m_maxDeadCapacity(cDefaultCacheCapacity)
99 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault CacheCapacity) 98 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault CacheCapacity)
100 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune) 99 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune)
101 , m_liveSize(0) 100 , m_liveSize(0)
102 , m_deadSize(0) 101 , m_deadSize(0)
103 #ifdef MEMORY_CACHE_STATS 102 #ifdef MEMORY_CACHE_STATS
104 , m_statsTimer(this, &MemoryCache::dumpStats) 103 , m_statsTimer(this, &MemoryCache::dumpStats)
105 #endif 104 #endif
106 { 105 {
107 WebCacheMemoryDumpProvider::instance()->setMemoryCache(this); 106 MemoryCacheDumpProvider::instance()->setMemoryCache(this);
108 #ifdef MEMORY_CACHE_STATS 107 #ifdef MEMORY_CACHE_STATS
109 const double statsIntervalInSeconds = 15; 108 const double statsIntervalInSeconds = 15;
110 m_statsTimer.startRepeating(statsIntervalInSeconds, BLINK_FROM_HERE); 109 m_statsTimer.startRepeating(statsIntervalInSeconds, BLINK_FROM_HERE);
111 #endif 110 #endif
112 } 111 }
113 112
114 MemoryCache* MemoryCache::create() 113 MemoryCache* MemoryCache::create()
115 { 114 {
116 return new MemoryCache; 115 return new MemoryCache;
117 } 116 }
118 117
119 MemoryCache::~MemoryCache() 118 MemoryCache::~MemoryCache()
120 { 119 {
121 if (m_prunePending) 120 if (m_prunePending)
122 Platform::current()->currentThread()->removeTaskObserver(this); 121 Platform::current()->currentThread()->removeTaskObserver(this);
123 } 122 }
124 123
125 DEFINE_TRACE(MemoryCache) 124 DEFINE_TRACE(MemoryCache)
126 { 125 {
127 visitor->trace(m_allResources); 126 visitor->trace(m_allResources);
128 visitor->trace(m_liveDecodedResources); 127 visitor->trace(m_liveDecodedResources);
129 visitor->trace(m_resourceMaps); 128 visitor->trace(m_resourceMaps);
129 MemoryCacheDumpClient::trace(visitor);
130 } 130 }
131 131
132 KURL MemoryCache::removeFragmentIdentifierIfNeeded(const KURL& originalURL) 132 KURL MemoryCache::removeFragmentIdentifierIfNeeded(const KURL& originalURL)
133 { 133 {
134 if (!originalURL.hasFragmentIdentifier()) 134 if (!originalURL.hasFragmentIdentifier())
135 return originalURL; 135 return originalURL;
136 // Strip away fragment identifier from HTTP URLs. 136 // Strip away fragment identifier from HTTP URLs.
137 // Data URLs must be unmodified. For file and custom URLs clients may expect resources 137 // Data URLs must be unmodified. For file and custom URLs clients may expect resources
138 // to be unique even when they differ by the fragment identifier only. 138 // to be unique even when they differ by the fragment identifier only.
139 if (!originalURL.protocolIsInHTTPFamily()) 139 if (!originalURL.protocolIsInHTTPFamily())
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 pruneLiveResources(strategy); 716 pruneLiveResources(strategy);
717 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp; 717 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp;
718 m_pruneTimeStamp = currentTime; 718 m_pruneTimeStamp = currentTime;
719 } 719 }
720 720
721 void MemoryCache::updateFramePaintTimestamp() 721 void MemoryCache::updateFramePaintTimestamp()
722 { 722 {
723 m_lastFramePaintTimeStamp = currentTime(); 723 m_lastFramePaintTimeStamp = currentTime();
724 } 724 }
725 725
726 void MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProc essMemoryDump* memoryDump) 726 bool MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProc essMemoryDump* memoryDump)
727 { 727 {
728 for (const auto& resourceMapIter : m_resourceMaps) { 728 for (const auto& resourceMapIter : m_resourceMaps) {
729 for (const auto& resourceIter : *resourceMapIter.value) { 729 for (const auto& resourceIter : *resourceMapIter.value) {
730 Resource* resource = resourceIter.value->resource(); 730 Resource* resource = resourceIter.value->resource();
731 resource->onMemoryDump(levelOfDetail, memoryDump); 731 resource->onMemoryDump(levelOfDetail, memoryDump);
732 } 732 }
733 } 733 }
734 return true;
734 } 735 }
735 736
736 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y) 737 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y)
737 { 738 {
738 MemoryCacheEntry* ex = getEntryForResource(x); 739 MemoryCacheEntry* ex = getEntryForResource(x);
739 MemoryCacheEntry* ey = getEntryForResource(y); 740 MemoryCacheEntry* ey = getEntryForResource(y);
740 ASSERT(ex); 741 ASSERT(ex);
741 ASSERT(ey); 742 ASSERT(ey);
742 return lruListFor(ex->m_accessCount, x->size()) == lruListFor(ey->m_accessCo unt, y->size()); 743 return lruListFor(ex->m_accessCount, x->size()) == lruListFor(ey->m_accessCo unt, y->size());
743 } 744 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decode dSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSi ze()) / 1024.0f, current->m_accessCount, currentResource->hasClientsOrObservers( ), currentResource->isPurgeable()); 781 printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decode dSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSi ze()) / 1024.0f, current->m_accessCount, currentResource->hasClientsOrObservers( ), currentResource->isPurgeable());
781 782
782 current = current->m_previousInAllResourcesList; 783 current = current->m_previousInAllResourcesList;
783 } 784 }
784 } 785 }
785 } 786 }
786 787
787 #endif // MEMORY_CACHE_STATS 788 #endif // MEMORY_CACHE_STATS
788 789
789 } // namespace blink 790 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/MemoryCache.h ('k') | third_party/WebKit/Source/core/fetch/WebCacheMemoryDumpProvider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698