Skip to content
Permalink
Browse files
Remove unused memory capacity output value in calculateURLCacheSizes
https://bugs.webkit.org/show_bug.cgi?id=240577

Patch by Olivier Blin <olivier.blin@softathome.com> on 2022-05-19
Reviewed by Darin Adler.

Source/WebKit:

calculateURLCacheSizes() had a urlCacheMemoryCapacity output value
since its creation in r203857, which was passed to platformSetURLCacheSize().

But the implementation has been removed for the soup platform in
r205556 when switching to the WebKit network cache, and for the Cocoa
platform in r232201 when dropping NSURLCache support.

urlCacheMemoryCapacity is now unused.

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::computeCapacity):
* Shared/CacheModel.cpp:
(WebKit::calculateURLCacheSizes):
* Shared/CacheModel.h:

Canonical link: https://commits.webkit.org/250782@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294527 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
blino authored and webkit-commit-queue committed May 20, 2022
1 parent 834b53d commit 12009214f89a47f79cb44d9b13985af841972f61
Showing 3 changed files with 8 additions and 41 deletions.
@@ -64,15 +64,13 @@ static const AtomString& resourceType()

static size_t computeCapacity(CacheModel cacheModel, const String& cachePath)
{
unsigned urlCacheMemoryCapacity = 0;
uint64_t urlCacheDiskCapacity = 0;
if (auto diskFreeSize = FileSystem::volumeFreeSpace(cachePath)) {
// As a fudge factor, use 1000 instead of 1024, in case the reported byte
// count doesn't align exactly to a megabyte boundary.
*diskFreeSize /= KB * 1000;
calculateURLCacheSizes(cacheModel, *diskFreeSize, urlCacheMemoryCapacity, urlCacheDiskCapacity);
return calculateURLCacheDiskCapacity(cacheModel, *diskFreeSize);
}
return urlCacheDiskCapacity;
return 0;
}

RefPtr<Cache> Cache::open(NetworkProcess& networkProcess, const String& cachePath, OptionSet<CacheOption> options, PAL::SessionID sessionID)
@@ -125,31 +125,18 @@ void calculateMemoryCacheSizes(CacheModel cacheModel, unsigned& cacheTotalCapaci
};
}

void calculateURLCacheSizes(CacheModel cacheModel, uint64_t diskFreeSize, unsigned& urlCacheMemoryCapacity, uint64_t& urlCacheDiskCapacity)
uint64_t calculateURLCacheDiskCapacity(CacheModel cacheModel, uint64_t diskFreeSize)
{
uint64_t urlCacheDiskCapacity;

switch (cacheModel) {
case CacheModel::DocumentViewer: {
// Foundation memory cache capacity (in bytes)
urlCacheMemoryCapacity = 0;

// Disk cache capacity (in bytes)
urlCacheDiskCapacity = 0;

break;
}
case CacheModel::DocumentBrowser: {
uint64_t memorySize = ramSize() / MB;

// Foundation memory cache capacity (in bytes)
if (memorySize >= 2048)
urlCacheMemoryCapacity = 4 * MB;
else if (memorySize >= 1024)
urlCacheMemoryCapacity = 2 * MB;
else if (memorySize >= 512)
urlCacheMemoryCapacity = 1 * MB;
else
urlCacheMemoryCapacity = 512 * KB;

// Disk cache capacity (in bytes)
if (diskFreeSize >= 16384)
urlCacheDiskCapacity = 75 * MB;
@@ -163,26 +150,6 @@ void calculateURLCacheSizes(CacheModel cacheModel, uint64_t diskFreeSize, unsign
break;
}
case CacheModel::PrimaryWebBrowser: {
uint64_t memorySize = ramSize() / MB;

#if PLATFORM(IOS_FAMILY)
if (memorySize >= 1024)
urlCacheMemoryCapacity = 16 * MB;
else
urlCacheMemoryCapacity = 8 * MB;
#else
// Foundation memory cache capacity (in bytes)
// (These values are small because WebCore does most caching itself.)
if (memorySize >= 1024)
urlCacheMemoryCapacity = 4 * MB;
else if (memorySize >= 512)
urlCacheMemoryCapacity = 2 * MB;
else if (memorySize >= 256)
urlCacheMemoryCapacity = 1 * MB;
else
urlCacheMemoryCapacity = 512 * KB;
#endif

// Disk cache capacity (in bytes)
if (diskFreeSize >= 16384)
urlCacheDiskCapacity = 1 * GB;
@@ -202,6 +169,8 @@ void calculateURLCacheSizes(CacheModel cacheModel, uint64_t diskFreeSize, unsign
default:
ASSERT_NOT_REACHED();
};

return urlCacheDiskCapacity;
}

} // namespace WebKit
@@ -39,7 +39,7 @@ enum class CacheModel : uint8_t {
};

void calculateMemoryCacheSizes(CacheModel, unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, Seconds& deadDecodedDataDeletionInterval, unsigned& backForwardCacheCapacity);
void calculateURLCacheSizes(CacheModel, uint64_t diskFreeSize, unsigned& urlCacheMemoryCapacity, uint64_t& urlCacheDiskCapacity);
uint64_t calculateURLCacheDiskCapacity(CacheModel, uint64_t diskFreeSize);

} // namespace WebKit

0 comments on commit 1200921

Please sign in to comment.