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

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

Issue 2252743002: Revert of Add MemoryCoordinatorClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 , m_maxDeadCapacity(cDefaultCacheCapacity) 97 , m_maxDeadCapacity(cDefaultCacheCapacity)
98 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault CacheCapacity) 98 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault CacheCapacity)
99 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune) 99 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune)
100 , m_liveSize(0) 100 , m_liveSize(0)
101 , m_deadSize(0) 101 , m_deadSize(0)
102 #ifdef MEMORY_CACHE_STATS 102 #ifdef MEMORY_CACHE_STATS
103 , m_statsTimer(this, &MemoryCache::dumpStats) 103 , m_statsTimer(this, &MemoryCache::dumpStats)
104 #endif 104 #endif
105 { 105 {
106 MemoryCacheDumpProvider::instance()->setMemoryCache(this); 106 MemoryCacheDumpProvider::instance()->setMemoryCache(this);
107 if (ProcessHeap::isLowEndDevice())
108 MemoryCoordinator::instance().registerClient(this);
109 #ifdef MEMORY_CACHE_STATS 107 #ifdef MEMORY_CACHE_STATS
110 const double statsIntervalInSeconds = 15; 108 const double statsIntervalInSeconds = 15;
111 m_statsTimer.startRepeating(statsIntervalInSeconds, BLINK_FROM_HERE); 109 m_statsTimer.startRepeating(statsIntervalInSeconds, BLINK_FROM_HERE);
112 #endif 110 #endif
113 } 111 }
114 112
115 MemoryCache* MemoryCache::create() 113 MemoryCache* MemoryCache::create()
116 { 114 {
117 return new MemoryCache; 115 return new MemoryCache;
118 } 116 }
119 117
120 MemoryCache::~MemoryCache() 118 MemoryCache::~MemoryCache()
121 { 119 {
122 if (m_prunePending) 120 if (m_prunePending)
123 Platform::current()->currentThread()->removeTaskObserver(this); 121 Platform::current()->currentThread()->removeTaskObserver(this);
124 } 122 }
125 123
126 DEFINE_TRACE(MemoryCache) 124 DEFINE_TRACE(MemoryCache)
127 { 125 {
128 visitor->trace(m_allResources); 126 visitor->trace(m_allResources);
129 visitor->trace(m_liveDecodedResources); 127 visitor->trace(m_liveDecodedResources);
130 visitor->trace(m_resourceMaps); 128 visitor->trace(m_resourceMaps);
131 MemoryCacheDumpClient::trace(visitor); 129 MemoryCacheDumpClient::trace(visitor);
132 MemoryCoordinatorClient::trace(visitor);
133 } 130 }
134 131
135 KURL MemoryCache::removeFragmentIdentifierIfNeeded(const KURL& originalURL) 132 KURL MemoryCache::removeFragmentIdentifierIfNeeded(const KURL& originalURL)
136 { 133 {
137 if (!originalURL.hasFragmentIdentifier()) 134 if (!originalURL.hasFragmentIdentifier())
138 return originalURL; 135 return originalURL;
139 // Strip away fragment identifier from HTTP URLs. 136 // Strip away fragment identifier from HTTP URLs.
140 // 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
141 // 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.
142 if (!originalURL.protocolIsInHTTPFamily()) 139 if (!originalURL.protocolIsInHTTPFamily())
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 { 728 {
732 for (const auto& resourceMapIter : m_resourceMaps) { 729 for (const auto& resourceMapIter : m_resourceMaps) {
733 for (const auto& resourceIter : *resourceMapIter.value) { 730 for (const auto& resourceIter : *resourceMapIter.value) {
734 Resource* resource = resourceIter.value->resource(); 731 Resource* resource = resourceIter.value->resource();
735 resource->onMemoryDump(levelOfDetail, memoryDump); 732 resource->onMemoryDump(levelOfDetail, memoryDump);
736 } 733 }
737 } 734 }
738 return true; 735 return true;
739 } 736 }
740 737
741 void MemoryCache::onMemoryPressure(WebMemoryPressureLevel level)
742 {
743 pruneAll();
744 }
745
746 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y) 738 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y)
747 { 739 {
748 MemoryCacheEntry* ex = getEntryForResource(x); 740 MemoryCacheEntry* ex = getEntryForResource(x);
749 MemoryCacheEntry* ey = getEntryForResource(y); 741 MemoryCacheEntry* ey = getEntryForResource(y);
750 ASSERT(ex); 742 ASSERT(ex);
751 ASSERT(ey); 743 ASSERT(ey);
752 return lruListFor(ex->m_accessCount, x->size()) == lruListFor(ey->m_accessCo unt, y->size()); 744 return lruListFor(ex->m_accessCount, x->size()) == lruListFor(ey->m_accessCo unt, y->size());
753 } 745 }
754 746
755 #ifdef MEMORY_CACHE_STATS 747 #ifdef MEMORY_CACHE_STATS
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 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()); 782 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());
791 783
792 current = current->m_previousInAllResourcesList; 784 current = current->m_previousInAllResourcesList;
793 } 785 }
794 } 786 }
795 } 787 }
796 788
797 #endif // MEMORY_CACHE_STATS 789 #endif // MEMORY_CACHE_STATS
798 790
799 } // namespace blink 791 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/MemoryCache.h ('k') | third_party/WebKit/Source/platform/MemoryCoordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698