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

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

Issue 2251853005: Reland: Add MemoryCoordinatorClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment 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);
107 #ifdef MEMORY_CACHE_STATS 109 #ifdef MEMORY_CACHE_STATS
108 const double statsIntervalInSeconds = 15; 110 const double statsIntervalInSeconds = 15;
109 m_statsTimer.startRepeating(statsIntervalInSeconds, BLINK_FROM_HERE); 111 m_statsTimer.startRepeating(statsIntervalInSeconds, BLINK_FROM_HERE);
110 #endif 112 #endif
111 } 113 }
112 114
113 MemoryCache* MemoryCache::create() 115 MemoryCache* MemoryCache::create()
114 { 116 {
115 return new MemoryCache; 117 return new MemoryCache;
116 } 118 }
117 119
118 MemoryCache::~MemoryCache() 120 MemoryCache::~MemoryCache()
119 { 121 {
120 if (m_prunePending) 122 if (m_prunePending)
121 Platform::current()->currentThread()->removeTaskObserver(this); 123 Platform::current()->currentThread()->removeTaskObserver(this);
122 } 124 }
123 125
124 DEFINE_TRACE(MemoryCache) 126 DEFINE_TRACE(MemoryCache)
125 { 127 {
126 visitor->trace(m_allResources); 128 visitor->trace(m_allResources);
127 visitor->trace(m_liveDecodedResources); 129 visitor->trace(m_liveDecodedResources);
128 visitor->trace(m_resourceMaps); 130 visitor->trace(m_resourceMaps);
129 MemoryCacheDumpClient::trace(visitor); 131 MemoryCacheDumpClient::trace(visitor);
132 MemoryCoordinatorClient::trace(visitor);
130 } 133 }
131 134
132 KURL MemoryCache::removeFragmentIdentifierIfNeeded(const KURL& originalURL) 135 KURL MemoryCache::removeFragmentIdentifierIfNeeded(const KURL& originalURL)
133 { 136 {
134 if (!originalURL.hasFragmentIdentifier()) 137 if (!originalURL.hasFragmentIdentifier())
135 return originalURL; 138 return originalURL;
136 // Strip away fragment identifier from HTTP URLs. 139 // Strip away fragment identifier from HTTP URLs.
137 // Data URLs must be unmodified. For file and custom URLs clients may expect resources 140 // 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. 141 // to be unique even when they differ by the fragment identifier only.
139 if (!originalURL.protocolIsInHTTPFamily()) 142 if (!originalURL.protocolIsInHTTPFamily())
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 { 731 {
729 for (const auto& resourceMapIter : m_resourceMaps) { 732 for (const auto& resourceMapIter : m_resourceMaps) {
730 for (const auto& resourceIter : *resourceMapIter.value) { 733 for (const auto& resourceIter : *resourceMapIter.value) {
731 Resource* resource = resourceIter.value->resource(); 734 Resource* resource = resourceIter.value->resource();
732 resource->onMemoryDump(levelOfDetail, memoryDump); 735 resource->onMemoryDump(levelOfDetail, memoryDump);
733 } 736 }
734 } 737 }
735 return true; 738 return true;
736 } 739 }
737 740
741 void MemoryCache::onMemoryPressure(WebMemoryPressureLevel level)
742 {
743 pruneAll();
744 }
745
738 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y) 746 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y)
739 { 747 {
740 MemoryCacheEntry* ex = getEntryForResource(x); 748 MemoryCacheEntry* ex = getEntryForResource(x);
741 MemoryCacheEntry* ey = getEntryForResource(y); 749 MemoryCacheEntry* ey = getEntryForResource(y);
742 ASSERT(ex); 750 ASSERT(ex);
743 ASSERT(ey); 751 ASSERT(ey);
744 return lruListFor(ex->m_accessCount, x->size()) == lruListFor(ey->m_accessCo unt, y->size()); 752 return lruListFor(ex->m_accessCount, x->size()) == lruListFor(ey->m_accessCo unt, y->size());
745 } 753 }
746 754
747 #ifdef MEMORY_CACHE_STATS 755 #ifdef MEMORY_CACHE_STATS
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()); 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());
783 791
784 current = current->m_previousInAllResourcesList; 792 current = current->m_previousInAllResourcesList;
785 } 793 }
786 } 794 }
787 } 795 }
788 796
789 #endif // MEMORY_CACHE_STATS 797 #endif // MEMORY_CACHE_STATS
790 798
791 } // namespace blink 799 } // 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