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

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

Issue 1369253002: Add Web Resources usage to chrome://tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web_cache2_base
Patch Set: Use singleton provider. Created 5 years, 2 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 "config.h" 23 #include "config.h"
24 #include "core/fetch/MemoryCache.h" 24 #include "core/fetch/MemoryCache.h"
25 25
26 #include "core/fetch/ResourcePtr.h" 26 #include "core/fetch/ResourcePtr.h"
27 #include "core/fetch/WebCacheMemoryDumpProvider.h"
27 #include "platform/Logging.h" 28 #include "platform/Logging.h"
28 #include "platform/TraceEvent.h" 29 #include "platform/TraceEvent.h"
29 #include "platform/weborigin/SecurityOrigin.h" 30 #include "platform/weborigin/SecurityOrigin.h"
30 #include "platform/weborigin/SecurityOriginHash.h" 31 #include "platform/weborigin/SecurityOriginHash.h"
31 #include "public/platform/Platform.h" 32 #include "public/platform/Platform.h"
32 #include "wtf/Assertions.h" 33 #include "wtf/Assertions.h"
33 #include "wtf/CurrentTime.h" 34 #include "wtf/CurrentTime.h"
34 #include "wtf/MainThread.h" 35 #include "wtf/MainThread.h"
35 #include "wtf/MathExtras.h" 36 #include "wtf/MathExtras.h"
36 #include "wtf/TemporaryChange.h" 37 #include "wtf/TemporaryChange.h"
(...skipping 20 matching lines...) Expand all
57 MemoryCache* replaceMemoryCacheForTesting(MemoryCache* cache) 58 MemoryCache* replaceMemoryCacheForTesting(MemoryCache* cache)
58 { 59 {
59 #if ENABLE(OILPAN) 60 #if ENABLE(OILPAN)
60 // Move m_liveResources content to keep Resource objects alive. 61 // Move m_liveResources content to keep Resource objects alive.
61 for (const auto& resource : memoryCache()->m_liveResources) 62 for (const auto& resource : memoryCache()->m_liveResources)
62 cache->m_liveResources.add(resource); 63 cache->m_liveResources.add(resource);
63 memoryCache()->m_liveResources.clear(); 64 memoryCache()->m_liveResources.clear();
64 #endif 65 #endif
65 memoryCache(); 66 memoryCache();
66 MemoryCache* oldCache = gMemoryCache->release(); 67 MemoryCache* oldCache = gMemoryCache->release();
67 *gMemoryCache = cache; 68 *gMemoryCache = cache;
haraken 2015/10/14 09:04:07 You need to call setMemoryCache here as well.
ssid 2015/10/14 12:06:40 Done.
68 return oldCache; 69 return oldCache;
69 } 70 }
70 71
71 DEFINE_TRACE(MemoryCacheEntry) 72 DEFINE_TRACE(MemoryCacheEntry)
72 { 73 {
73 visitor->trace(m_previousInLiveResourcesList); 74 visitor->trace(m_previousInLiveResourcesList);
74 visitor->trace(m_nextInLiveResourcesList); 75 visitor->trace(m_nextInLiveResourcesList);
75 visitor->trace(m_previousInAllResourcesList); 76 visitor->trace(m_previousInAllResourcesList);
76 visitor->trace(m_nextInAllResourcesList); 77 visitor->trace(m_nextInAllResourcesList);
77 } 78 }
(...skipping 20 matching lines...) Expand all
98 , m_minDeadCapacity(0) 99 , m_minDeadCapacity(0)
99 , m_maxDeadCapacity(cDefaultCacheCapacity) 100 , m_maxDeadCapacity(cDefaultCacheCapacity)
100 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault CacheCapacity) 101 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault CacheCapacity)
101 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune) 102 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune)
102 , m_liveSize(0) 103 , m_liveSize(0)
103 , m_deadSize(0) 104 , m_deadSize(0)
104 #ifdef MEMORY_CACHE_STATS 105 #ifdef MEMORY_CACHE_STATS
105 , m_statsTimer(this, &MemoryCache::dumpStats) 106 , m_statsTimer(this, &MemoryCache::dumpStats)
106 #endif 107 #endif
107 { 108 {
109 WebCacheMemoryDumpProvider::instance()->setMemoryCache(this);
108 #ifdef MEMORY_CACHE_STATS 110 #ifdef MEMORY_CACHE_STATS
109 const double statsIntervalInSeconds = 15; 111 const double statsIntervalInSeconds = 15;
110 m_statsTimer.startRepeating(statsIntervalInSeconds, FROM_HERE); 112 m_statsTimer.startRepeating(statsIntervalInSeconds, FROM_HERE);
111 #endif 113 #endif
112 } 114 }
113 115
114 MemoryCache* MemoryCache::create() 116 MemoryCache* MemoryCache::create()
115 { 117 {
116 return new MemoryCache; 118 return new MemoryCache;
117 } 119 }
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 pruneLiveResources(strategy); 775 pruneLiveResources(strategy);
774 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp; 776 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp;
775 m_pruneTimeStamp = currentTime; 777 m_pruneTimeStamp = currentTime;
776 } 778 }
777 779
778 void MemoryCache::updateFramePaintTimestamp() 780 void MemoryCache::updateFramePaintTimestamp()
779 { 781 {
780 m_lastFramePaintTimeStamp = currentTime(); 782 m_lastFramePaintTimeStamp = currentTime();
781 } 783 }
782 784
785 void MemoryCache::onMemoryDump(WebProcessMemoryDump* memoryDump)
786 {
787 for (const auto& resourceMapIter : m_resourceMaps) {
788 for (const auto& resourceIter : *resourceMapIter.value) {
789 Resource* resource = resourceIter.value->m_resource.get();
790 resource->onMemoryDump(memoryDump);
791 }
792 }
793 }
794
783 void MemoryCache::registerLiveResource(Resource& resource) 795 void MemoryCache::registerLiveResource(Resource& resource)
784 { 796 {
785 #if ENABLE(OILPAN) 797 #if ENABLE(OILPAN)
786 ASSERT(!m_liveResources.contains(&resource)); 798 ASSERT(!m_liveResources.contains(&resource));
787 m_liveResources.add(&resource); 799 m_liveResources.add(&resource);
788 #endif 800 #endif
789 } 801 }
790 802
791 void MemoryCache::unregisterLiveResource(Resource& resource) 803 void MemoryCache::unregisterLiveResource(Resource& resource)
792 { 804 {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", currentResource->de codedSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overhe adSize()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), curr entResource->isPurgeable(), currentResource->wasPurged()); 846 printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", currentResource->de codedSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overhe adSize()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), curr entResource->isPurgeable(), currentResource->wasPurged());
835 847
836 current = current->m_previousInAllResourcesList; 848 current = current->m_previousInAllResourcesList;
837 } 849 }
838 } 850 }
839 } 851 }
840 852
841 #endif // MEMORY_CACHE_STATS 853 #endif // MEMORY_CACHE_STATS
842 854
843 } // namespace blink 855 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698