Changeset 203857 in webkit
- Timestamp:
- Jul 28, 2016 10:22:14 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r203855 r203857 1 2016-07-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Split calculateCacheSizes in two methods 4 https://bugs.webkit.org/show_bug.cgi?id=160237 5 6 Reviewed by Darin Adler. 7 8 Rename getVolumeFreeSizeForPath as volumeFreeSizeForPath and make it available to all platforms adding an 9 implementation for mac. 10 11 * platform/FileSystem.h: 12 * platform/efl/FileSystemEfl.cpp: 13 (WebCore::volumeFreeSizeForPath): 14 (WebCore::getVolumeFreeSizeForPath): Deleted. 15 * platform/glib/FileSystemGlib.cpp: 16 (WebCore::volumeFreeSizeForPath): 17 (WebCore::getVolumeFreeSizeForPath): Deleted. 18 * platform/mac/FileSystemMac.mm: 19 (WebCore::volumeFreeSizeForPath): 20 * platform/win/FileSystemWin.cpp: 21 (WebCore::volumeFreeSizeForPath): 22 1 23 2016-07-28 Myles C. Maxfield <mmaxfield@apple.com> 2 24 -
trunk/Source/WebCore/platform/FileSystem.h
r202190 r203857 146 146 WEBCORE_EXPORT String pathGetFileName(const String&); 147 147 WEBCORE_EXPORT String directoryName(const String&); 148 WEBCORE_EXPORT bool getVolumeFreeSpace(const String&, uint64_t&); 148 149 149 150 WEBCORE_EXPORT void setMetadataURL(String& URLString, const String& referrer, const String& path); … … 203 204 CString sharedResourcesPath(); 204 205 #endif 205 #if USE(SOUP)206 uint64_t getVolumeFreeSizeForPath(const char*);207 #endif208 206 209 207 #if PLATFORM(WIN) -
trunk/Source/WebCore/platform/efl/FileSystemEfl.cpp
r200168 r203857 89 89 } 90 90 91 uint64_t getVolumeFreeSizeForPath(const char* path)91 bool getVolumeFreeSpace(const String& path, uint64_t& freeSpace) 92 92 { 93 CString fsRep = fileSystemRepresentation(path); 94 if (!fsRep.data() || fsRep.data()[0] == '\0') 95 return false; 96 93 97 struct statvfs buf; 94 if (statvfs( path, &buf) < 0)95 return 0;98 if (statvfs(fsRep.data(), &buf) < 0) 99 return false; 96 100 97 return static_cast<uint64_t>(buf.f_bavail) * buf.f_bsize; 101 freeSpace = static_cast<uint64_t>(buf.f_bavail) * buf.f_bsize; 102 return true; 98 103 } 99 104 -
trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp
r201796 r203857 233 233 } 234 234 235 uint64_t getVolumeFreeSizeForPath(const char* path) 236 { 237 GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(path)); 235 bool getVolumeFreeSpace(const String& path, uint64_t& freeSpace) 236 { 237 GUniquePtr<gchar> filename = unescapedFilename(path); 238 if (!filename) 239 return false; 240 241 GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(filename.get())); 238 242 GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_filesystem_info(file.get(), G_FILE_ATTRIBUTE_FILESYSTEM_FREE, 0, 0)); 239 243 if (!fileInfo) 240 return 0; 241 242 return g_file_info_get_attribute_uint64(fileInfo.get(), G_FILE_ATTRIBUTE_FILESYSTEM_FREE); 244 return false; 245 246 freeSpace = g_file_info_get_attribute_uint64(fileInfo.get(), G_FILE_ATTRIBUTE_FILESYSTEM_FREE); 247 return !!freeSpace; 243 248 } 244 249 -
trunk/Source/WebCore/platform/mac/FileSystemMac.mm
r192583 r203857 99 99 } 100 100 101 bool getVolumeFreeSpace(const String& path, uint64_t& freeSpace) 102 { 103 NSDictionary *fileSystemAttributesDictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:(NSString *)path error:NULL]; 104 if (!fileSystemAttributesDictionary) 105 return false; 106 freeSpace = [[fileSystemAttributesDictionary objectForKey:NSFileSystemFreeSize] unsignedLongLongValue]; 107 return true; 108 } 109 101 110 #if !PLATFORM(IOS) 102 111 bool deleteEmptyDirectory(const String& path) -
trunk/Source/WebCore/platform/win/FileSystemWin.cpp
r200036 r203857 448 448 } 449 449 450 bool getVolumeFreeSpace(const String&, uint64_t&) 451 { 452 notImplemented(); 453 return false; 454 } 455 450 456 } // namespace WebCore -
trunk/Source/WebKit2/ChangeLog
r203856 r203857 1 2016-07-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Split calculateCacheSizes in two methods 4 https://bugs.webkit.org/show_bug.cgi?id=160237 5 6 Reviewed by Darin Adler. 7 8 It's used to calculate memory and disk cache sizes, but only the web process is interested in memory caches, and 9 the network process in disk cache. We can also avoid a lot of duplicated code between ports to set the cache model. 10 11 * NetworkProcess/NetworkProcess.cpp: 12 (WebKit::NetworkProcess::setCacheModel): Use calculateURLCacheSizes to set the disk cache size and call 13 platformSetURLCacheSize if not set to allow ports to setup platform specific cache. 14 * NetworkProcess/NetworkProcess.h: 15 * NetworkProcess/cocoa/NetworkProcessCocoa.mm: 16 (WebKit::NetworkProcess::platformSetURLCacheSize): Remove common code that is now in cross-platform file. 17 (WebKit::volumeFreeSize): Deleted. 18 (WebKit::NetworkProcess::platformSetCacheModel): Renamed to platformSetURLCacheSize(). 19 * NetworkProcess/soup/NetworkProcessSoup.cpp: 20 (WebKit::NetworkProcess::platformSetURLCacheSize): Remove common code that is now in cross-platform file. 21 (WebKit::getCacheDiskFreeSize): Deleted. 22 (WebKit::NetworkProcess::platformSetCacheModel): Renamed to platformSetURLCacheSize(). 23 * Shared/CacheModel.cpp: 24 (WebKit::calculateMemoryCacheSizes): Calculate the memory and page cache sizes. 25 (WebKit::calculateURLCacheSizes): Calculate the disk cache size. 26 (WebKit::calculateCacheSizes): Deleted. 27 * Shared/CacheModel.h: 28 * WebProcess/WebProcess.cpp: 29 (WebKit::WebProcess): Tell the page cache to clear backing stores for GTK+ port too. This was done before when 30 setting the cache model. 31 (WebKit::WebProcess::setCacheModel): Use calculateMemoryCacheSizes to setup memory caches and call 32 platformSetCacheModel to allow ports do more setup according to the cache model. 33 (WebKit::WebProcess::clearResourceCaches): Deleted. 34 * WebProcess/WebProcess.h: 35 * WebProcess/cocoa/WebProcessCocoa.mm: 36 (WebKit::WebProcess::platformSetCacheModel): Remove common code that is now in cross-platform file. 37 (WebKit::volumeFreeSize): Deleted. 38 (WebKit::WebProcess::platformClearResourceCaches): Deleted. 39 * WebProcess/soup/WebProcessSoup.cpp: 40 (WebKit::WebProcess::platformSetCacheModel): Remove common code that is now in cross-platform file. 41 (WebKit::WebProcess::platformInitializeWebProcess): 42 (WebKit::WebProcess::platformClearResourceCaches): Deleted. 43 1 44 2016-07-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 45 -
trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp
r203749 r203857 539 539 CacheModel cacheModel = static_cast<CacheModel>(cm); 540 540 541 if (!m_hasSetCacheModel || cacheModel != m_cacheModel) { 542 m_hasSetCacheModel = true; 543 m_cacheModel = cacheModel; 544 platformSetCacheModel(cacheModel); 545 } 541 if (m_hasSetCacheModel && (cacheModel == m_cacheModel)) 542 return; 543 544 m_hasSetCacheModel = true; 545 m_cacheModel = cacheModel; 546 547 unsigned urlCacheMemoryCapacity = 0; 548 uint64_t urlCacheDiskCapacity = 0; 549 uint64_t diskFreeSize = 0; 550 if (WebCore::getVolumeFreeSpace(m_diskCacheDirectory, diskFreeSize)) { 551 // As a fudge factor, use 1000 instead of 1024, in case the reported byte 552 // count doesn't align exactly to a megabyte boundary. 553 diskFreeSize /= KB * 1000; 554 calculateURLCacheSizes(cacheModel, diskFreeSize, urlCacheMemoryCapacity, urlCacheDiskCapacity); 555 } 556 557 if (m_diskCacheSizeOverride >= 0) 558 urlCacheDiskCapacity = m_diskCacheSizeOverride; 559 560 #if ENABLE(NETWORK_CACHE) 561 auto& networkCache = NetworkCache::singleton(); 562 if (networkCache.isEnabled()) { 563 networkCache.setCapacity(urlCacheDiskCapacity); 564 return; 565 } 566 #endif 567 568 platformSetURLCacheSize(urlCacheMemoryCapacity, urlCacheDiskCapacity); 546 569 } 547 570 -
trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h
r203342 r203857 198 198 199 199 // Platform Helpers 200 void platformSet CacheModel(CacheModel);200 void platformSetURLCacheSize(unsigned urlCacheMemoryCapacity, uint64_t urlCacheDiskCapacity); 201 201 202 202 // Connections to WebProcesses. -
trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm
r198457 r203857 39 39 #import <WebCore/SecurityOriginData.h> 40 40 #import <WebKitSystemInterface.h> 41 #import <wtf/RAMSize.h>42 41 43 42 namespace WebKit { … … 125 124 } 126 125 127 static uint64_t volumeFreeSize(const String& path) 128 { 129 NSDictionary *fileSystemAttributesDictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:(NSString *)path error:NULL]; 130 return [[fileSystemAttributesDictionary objectForKey:NSFileSystemFreeSize] unsignedLongLongValue]; 131 } 132 133 void NetworkProcess::platformSetCacheModel(CacheModel cacheModel) 134 { 135 uint64_t memSize = ramSize() / 1024 / 1024; 136 137 // As a fudge factor, use 1000 instead of 1024, in case the reported byte 138 // count doesn't align exactly to a megabyte boundary. 139 uint64_t diskFreeSize = volumeFreeSize(m_diskCacheDirectory) / 1024 / 1000; 140 141 unsigned cacheTotalCapacity = 0; 142 unsigned cacheMinDeadCapacity = 0; 143 unsigned cacheMaxDeadCapacity = 0; 144 auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 }; 145 unsigned pageCacheCapacity = 0; 146 unsigned long urlCacheMemoryCapacity = 0; 147 unsigned long urlCacheDiskCapacity = 0; 148 149 calculateCacheSizes(cacheModel, memSize, diskFreeSize, 150 cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, 151 pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity); 152 153 if (m_diskCacheSizeOverride >= 0) 154 urlCacheDiskCapacity = m_diskCacheSizeOverride; 155 156 #if ENABLE(NETWORK_CACHE) 157 auto& networkCache = NetworkCache::singleton(); 158 if (networkCache.isEnabled()) { 159 networkCache.setCapacity(urlCacheDiskCapacity); 160 return; 161 } 162 #endif 126 void NetworkProcess::platformSetURLCacheSize(unsigned urlCacheMemoryCapacity, uint64_t urlCacheDiskCapacity) 127 { 163 128 NSURLCache *nsurlCache = [NSURLCache sharedURLCache]; 164 129 [nsurlCache setMemoryCapacity:urlCacheMemoryCapacity]; 165 130 if (!m_diskCacheIsDisabledForTesting) 166 [nsurlCache setDiskCapacity:std::max<u nsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.131 [nsurlCache setDiskCapacity:std::max<uint64_t>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn. 167 132 } 168 133 -
trunk/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp
r201267 r203857 45 45 46 46 namespace WebKit { 47 48 #if !ENABLE(NETWORK_CACHE)49 static uint64_t getCacheDiskFreeSize(SoupCache* cache)50 {51 ASSERT(cache);52 53 GUniqueOutPtr<char> cacheDir;54 g_object_get(G_OBJECT(cache), "cache-dir", &cacheDir.outPtr(), NULL);55 if (!cacheDir)56 return 0;57 58 return WebCore::getVolumeFreeSizeForPath(cacheDir.get());59 }60 #endif61 47 62 48 void NetworkProcess::userPreferredLanguagesChanged(const Vector<String>& languages) … … 108 94 } 109 95 110 void NetworkProcess::platformSet CacheModel(CacheModel cacheModel)96 void NetworkProcess::platformSetURLCacheSize(unsigned /*urlCacheMemoryCapacity*/, uint64_t urlCacheDiskCapacity) 111 97 { 112 unsigned cacheTotalCapacity = 0; 113 unsigned cacheMinDeadCapacity = 0; 114 unsigned cacheMaxDeadCapacity = 0; 115 auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 }; 116 unsigned pageCacheCapacity = 0; 117 118 unsigned long urlCacheMemoryCapacity = 0; 119 unsigned long urlCacheDiskCapacity = 0; 120 121 #if ENABLE(NETWORK_CACHE) 122 uint64_t diskFreeSize = WebCore::getVolumeFreeSizeForPath(m_diskCacheDirectory.utf8().data()) / WTF::MB; 123 #else 98 #if !ENABLE(NETWORK_CACHE) 124 99 SoupCache* cache = SoupNetworkSession::defaultSession().cache(); 125 uint64_t diskFreeSize = getCacheDiskFreeSize(cache) / WTF::MB;126 #endif127 128 uint64_t memSize = WTF::ramSize() / WTF::MB;129 calculateCacheSizes(cacheModel, memSize, diskFreeSize,130 cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval,131 pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity);132 133 #if ENABLE(NETWORK_CACHE)134 auto& networkCache = NetworkCache::singleton();135 if (networkCache.isEnabled())136 networkCache.setCapacity(urlCacheDiskCapacity);137 #else138 100 if (urlCacheDiskCapacity > soup_cache_get_max_size(cache)) 139 101 soup_cache_set_max_size(cache, urlCacheDiskCapacity); 102 #else 103 UNUSED_PARAM(urlCacheDiskCapacity); 140 104 #endif 141 105 } -
trunk/Source/WebKit2/Shared/CacheModel.cpp
r201857 r203857 28 28 29 29 #include <algorithm> 30 #include <wtf/RAMSize.h> 31 #include <wtf/StdLibExtras.h> 30 32 31 33 namespace WebKit { 32 34 33 void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize, 34 unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, std::chrono::seconds& deadDecodedDataDeletionInterval, 35 unsigned& pageCacheCapacity, unsigned long& urlCacheMemoryCapacity, unsigned long& urlCacheDiskCapacity) 35 void calculateMemoryCacheSizes(CacheModel cacheModel, unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, std::chrono::seconds& deadDecodedDataDeletionInterval, unsigned& pageCacheCapacity) 36 36 { 37 uint64_t memorySize = ramSize() / MB; 38 37 39 switch (cacheModel) { 38 40 case CacheModelDocumentViewer: { … … 42 44 // Object cache capacities (in bytes) 43 45 if (memorySize >= 2048) 44 cacheTotalCapacity = 96 * 1024 * 1024;46 cacheTotalCapacity = 96 * MB; 45 47 else if (memorySize >= 1536) 46 cacheTotalCapacity = 64 * 1024 * 1024;47 else if (memorySize >= 1024) 48 cacheTotalCapacity = 32 * 1024 * 1024;49 else if (memorySize >= 512) 50 cacheTotalCapacity = 16 * 1024 * 1024;48 cacheTotalCapacity = 64 * MB; 49 else if (memorySize >= 1024) 50 cacheTotalCapacity = 32 * MB; 51 else if (memorySize >= 512) 52 cacheTotalCapacity = 16 * MB; 51 53 52 54 cacheMinDeadCapacity = 0; 53 55 cacheMaxDeadCapacity = 0; 54 55 // Foundation memory cache capacity (in bytes)56 urlCacheMemoryCapacity = 0;57 58 // Disk cache capacity (in bytes)59 urlCacheDiskCapacity = 0;60 56 61 57 break; … … 72 68 // Object cache capacities (in bytes) 73 69 if (memorySize >= 2048) 74 cacheTotalCapacity = 96 * 1024 * 1024;70 cacheTotalCapacity = 96 * MB; 75 71 else if (memorySize >= 1536) 76 cacheTotalCapacity = 64 * 1024 * 1024;77 else if (memorySize >= 1024) 78 cacheTotalCapacity = 32 * 1024 * 1024;79 else if (memorySize >= 512) 80 cacheTotalCapacity = 16 * 1024 * 1024;72 cacheTotalCapacity = 64 * MB; 73 else if (memorySize >= 1024) 74 cacheTotalCapacity = 32 * MB; 75 else if (memorySize >= 512) 76 cacheTotalCapacity = 16 * MB; 81 77 82 78 cacheMinDeadCapacity = cacheTotalCapacity / 8; 83 79 cacheMaxDeadCapacity = cacheTotalCapacity / 4; 84 85 // Foundation memory cache capacity (in bytes)86 if (memorySize >= 2048)87 urlCacheMemoryCapacity = 4 * 1024 * 1024;88 else if (memorySize >= 1024)89 urlCacheMemoryCapacity = 2 * 1024 * 1024;90 else if (memorySize >= 512)91 urlCacheMemoryCapacity = 1 * 1024 * 1024;92 else93 urlCacheMemoryCapacity = 512 * 1024;94 95 // Disk cache capacity (in bytes)96 if (diskFreeSize >= 16384)97 urlCacheDiskCapacity = 75 * 1024 * 1024;98 else if (diskFreeSize >= 8192)99 urlCacheDiskCapacity = 40 * 1024 * 1024;100 else if (diskFreeSize >= 4096)101 urlCacheDiskCapacity = 30 * 1024 * 1024;102 else103 urlCacheDiskCapacity = 20 * 1024 * 1024;104 80 105 81 break; … … 116 92 // Object cache capacities (in bytes) 117 93 // (Testing indicates that value / MB depends heavily on content and 118 // browsing pattern. Even growth above 128MB can have substantial 94 // browsing pattern. Even growth above 128MB can have substantial 119 95 // value / MB for some content / browsing patterns.) 120 96 if (memorySize >= 2048) 121 cacheTotalCapacity = 128 * 1024 * 1024;97 cacheTotalCapacity = 128 * MB; 122 98 else if (memorySize >= 1536) 123 cacheTotalCapacity = 96 * 1024 * 1024;124 else if (memorySize >= 1024) 125 cacheTotalCapacity = 64 * 1024 * 1024;126 else if (memorySize >= 512) 127 cacheTotalCapacity = 32 * 1024 * 1024;99 cacheTotalCapacity = 96 * MB; 100 else if (memorySize >= 1024) 101 cacheTotalCapacity = 64 * MB; 102 else if (memorySize >= 512) 103 cacheTotalCapacity = 32 * MB; 128 104 129 105 cacheMinDeadCapacity = cacheTotalCapacity / 4; … … 136 112 deadDecodedDataDeletionInterval = std::chrono::seconds { 60 }; 137 113 114 break; 115 } 116 default: 117 ASSERT_NOT_REACHED(); 118 }; 119 } 120 121 void calculateURLCacheSizes(CacheModel cacheModel, uint64_t diskFreeSize, unsigned& urlCacheMemoryCapacity, uint64_t& urlCacheDiskCapacity) 122 { 123 switch (cacheModel) { 124 case CacheModelDocumentViewer: { 125 // Foundation memory cache capacity (in bytes) 126 urlCacheMemoryCapacity = 0; 127 128 // Disk cache capacity (in bytes) 129 urlCacheDiskCapacity = 0; 130 131 break; 132 } 133 case CacheModelDocumentBrowser: { 134 uint64_t memorySize = ramSize() / MB; 135 136 // Foundation memory cache capacity (in bytes) 137 if (memorySize >= 2048) 138 urlCacheMemoryCapacity = 4 * MB; 139 else if (memorySize >= 1024) 140 urlCacheMemoryCapacity = 2 * MB; 141 else if (memorySize >= 512) 142 urlCacheMemoryCapacity = 1 * MB; 143 else 144 urlCacheMemoryCapacity = 512 * KB; 145 146 // Disk cache capacity (in bytes) 147 if (diskFreeSize >= 16384) 148 urlCacheDiskCapacity = 75 * MB; 149 else if (diskFreeSize >= 8192) 150 urlCacheDiskCapacity = 40 * MB; 151 else if (diskFreeSize >= 4096) 152 urlCacheDiskCapacity = 30 * MB; 153 else 154 urlCacheDiskCapacity = 20 * MB; 155 156 break; 157 } 158 case CacheModelPrimaryWebBrowser: { 159 uint64_t memorySize = ramSize() / MB; 160 138 161 #if PLATFORM(IOS) 139 162 if (memorySize >= 1024) 140 urlCacheMemoryCapacity = 16 * 1024 * 1024;141 else 142 urlCacheMemoryCapacity = 8 * 1024 * 1024;163 urlCacheMemoryCapacity = 16 * MB; 164 else 165 urlCacheMemoryCapacity = 8 * MB; 143 166 #else 144 167 // Foundation memory cache capacity (in bytes) 145 168 // (These values are small because WebCore does most caching itself.) 146 169 if (memorySize >= 1024) 147 urlCacheMemoryCapacity = 4 * 1024 * 1024;148 else if (memorySize >= 512) 149 urlCacheMemoryCapacity = 2 * 1024 * 1024;170 urlCacheMemoryCapacity = 4 * MB; 171 else if (memorySize >= 512) 172 urlCacheMemoryCapacity = 2 * MB; 150 173 else if (memorySize >= 256) 151 urlCacheMemoryCapacity = 1 * 1024 * 1024;152 else 153 urlCacheMemoryCapacity = 512 * 1024;174 urlCacheMemoryCapacity = 1 * MB; 175 else 176 urlCacheMemoryCapacity = 512 * KB; 154 177 #endif 155 178 156 179 // Disk cache capacity (in bytes) 157 180 if (diskFreeSize >= 16384) 158 urlCacheDiskCapacity = 500 * 1024 * 1024;181 urlCacheDiskCapacity = 500 * MB; 159 182 else if (diskFreeSize >= 8192) 160 urlCacheDiskCapacity = 250 * 1024 * 1024;183 urlCacheDiskCapacity = 250 * MB; 161 184 else if (diskFreeSize >= 4096) 162 urlCacheDiskCapacity = 125 * 1024 * 1024;185 urlCacheDiskCapacity = 125 * MB; 163 186 else if (diskFreeSize >= 2048) 164 urlCacheDiskCapacity = 100 * 1024 * 1024;187 urlCacheDiskCapacity = 100 * MB; 165 188 else if (diskFreeSize >= 1024) 166 urlCacheDiskCapacity = 75 * 1024 * 1024;167 else 168 urlCacheDiskCapacity = 50 * 1024 * 1024;189 urlCacheDiskCapacity = 75 * MB; 190 else 191 urlCacheDiskCapacity = 50 * MB; 169 192 170 193 break; -
trunk/Source/WebKit2/Shared/CacheModel.h
r169550 r203857 38 38 }; 39 39 40 void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize, 41 unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, std::chrono::seconds& deadDecodedDataDeletionInterval, 42 unsigned& pageCacheCapacity, unsigned long& urlCacheMemoryCapacity, unsigned long& urlCacheDiskCapacity); 40 void calculateMemoryCacheSizes(CacheModel, unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, std::chrono::seconds& deadDecodedDataDeletionInterval, unsigned& pageCacheCapacity); 41 void calculateURLCacheSizes(CacheModel, uint64_t diskFreeSize, unsigned& urlCacheMemoryCapacity, uint64_t& urlCacheDiskCapacity); 43 42 44 43 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebProcess.cpp
r203342 r203857 206 206 #endif 207 207 208 #if PLATFORM(IOS) 208 #if PLATFORM(IOS) || PLATFORM(GTK) 209 209 PageCache::singleton().setShouldClearBackingStores(true); 210 210 #endif … … 530 530 CacheModel cacheModel = static_cast<CacheModel>(cm); 531 531 532 if (!m_hasSetCacheModel || cacheModel != m_cacheModel) { 533 m_hasSetCacheModel = true; 534 m_cacheModel = cacheModel; 535 platformSetCacheModel(cacheModel); 536 } 532 if (m_hasSetCacheModel && (cacheModel == m_cacheModel)) 533 return; 534 535 m_hasSetCacheModel = true; 536 m_cacheModel = cacheModel; 537 538 unsigned cacheTotalCapacity = 0; 539 unsigned cacheMinDeadCapacity = 0; 540 unsigned cacheMaxDeadCapacity = 0; 541 auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 }; 542 unsigned pageCacheSize = 0; 543 calculateMemoryCacheSizes(cacheModel, cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, pageCacheSize); 544 545 auto& memoryCache = MemoryCache::singleton(); 546 memoryCache.setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); 547 memoryCache.setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); 548 PageCache::singleton().setMaxSize(pageCacheSize); 549 550 platformSetCacheModel(cacheModel); 537 551 } 538 552 … … 752 766 void WebProcess::clearResourceCaches(ResourceCachesToClear resourceCachesToClear) 753 767 { 754 platformClearResourceCaches(resourceCachesToClear);755 756 768 // Toggling the cache model like this forces the cache to evict all its in-memory resources. 757 769 // FIXME: We need a better way to do this. -
trunk/Source/WebKit2/WebProcess/WebProcess.h
r203338 r203857 262 262 263 263 void platformSetCacheModel(CacheModel); 264 void platformClearResourceCaches(ResourceCachesToClear);265 264 266 265 void setEnhancedAccessibility(bool); -
trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm
r201612 r203857 49 49 #import <WebCore/FontCascade.h> 50 50 #import <WebCore/LocalizedStrings.h> 51 #import <WebCore/MemoryCache.h>52 51 #import <WebCore/MemoryPressureHandler.h> 53 52 #import <WebCore/NSAccessibilitySPI.h> 54 #import <WebCore/PageCache.h>55 53 #import <WebCore/RuntimeApplicationChecks.h> 56 54 #import <WebCore/pthreadSPI.h> … … 62 60 #import <objc/runtime.h> 63 61 #import <stdio.h> 64 #import <wtf/RAMSize.h>65 62 66 63 #if PLATFORM(IOS) … … 76 73 namespace WebKit { 77 74 78 static uint64_t volumeFreeSize(NSString *path) 79 { 80 NSDictionary *fileSystemAttributesDictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:path error:NULL]; 81 return [[fileSystemAttributesDictionary objectForKey:NSFileSystemFreeSize] unsignedLongLongValue]; 82 } 83 84 void WebProcess::platformSetCacheModel(CacheModel cacheModel) 85 { 86 RetainPtr<NSString> nsurlCacheDirectory = adoptNS((NSString *)WKCopyFoundationCacheDirectory()); 87 if (!nsurlCacheDirectory) 88 nsurlCacheDirectory = NSHomeDirectory(); 89 90 uint64_t memSize = ramSize() / 1024 / 1024; 91 92 // As a fudge factor, use 1000 instead of 1024, in case the reported byte 93 // count doesn't align exactly to a megabyte boundary. 94 uint64_t diskFreeSize = volumeFreeSize(nsurlCacheDirectory.get()) / 1024 / 1000; 95 96 unsigned cacheTotalCapacity = 0; 97 unsigned cacheMinDeadCapacity = 0; 98 unsigned cacheMaxDeadCapacity = 0; 99 auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 }; 100 unsigned pageCacheSize = 0; 101 unsigned long urlCacheMemoryCapacity = 0; 102 unsigned long urlCacheDiskCapacity = 0; 103 104 calculateCacheSizes(cacheModel, memSize, diskFreeSize, 105 cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, 106 pageCacheSize, urlCacheMemoryCapacity, urlCacheDiskCapacity); 107 108 auto& memoryCache = MemoryCache::singleton(); 109 memoryCache.setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); 110 memoryCache.setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); 111 PageCache::singleton().setMaxSize(pageCacheSize); 112 } 113 114 void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear) 115 { 116 // FIXME: Remove this. 75 void WebProcess::platformSetCacheModel(CacheModel) 76 { 117 77 } 118 78 -
trunk/Source/WebKit2/WebProcess/soup/WebProcessSoup.cpp
r200621 r203857 28 28 #include "WebProcess.h" 29 29 30 #include "CertificateInfo.h"31 #include "WebCookieManager.h"32 30 #include "WebProcessCreationParameters.h" 33 #include <WebCore/FileSystem.h>34 #include <WebCore/Language.h>35 31 #include <WebCore/MemoryCache.h> 36 #include <WebCore/PageCache.h>37 #include <WebCore/ResourceHandle.h>38 #include <WebCore/SoupNetworkSession.h>39 #include <libsoup/soup.h>40 #include <wtf/RAMSize.h>41 #include <wtf/glib/GRefPtr.h>42 #include <wtf/glib/GUniquePtr.h>43 32 44 33 namespace WebKit { … … 46 35 void WebProcess::platformSetCacheModel(CacheModel cacheModel) 47 36 { 48 unsigned cacheTotalCapacity = 0; 49 unsigned cacheMinDeadCapacity = 0; 50 unsigned cacheMaxDeadCapacity = 0; 51 auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 }; 52 unsigned pageCacheSize = 0; 53 54 unsigned long urlCacheMemoryCapacity = 0; 55 unsigned long urlCacheDiskCapacity = 0; 56 57 uint64_t diskFreeSize = 0; 58 59 uint64_t memSize = WTF::ramSize() / WTF::MB; 60 calculateCacheSizes(cacheModel, memSize, diskFreeSize, 61 cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, 62 pageCacheSize, urlCacheMemoryCapacity, urlCacheDiskCapacity); 63 64 auto& memoryCache = WebCore::MemoryCache::singleton(); 65 memoryCache.setDisabled(cacheModel == CacheModelDocumentViewer); 66 memoryCache.setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); 67 memoryCache.setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); 68 WebCore::PageCache::singleton().setMaxSize(pageCacheSize); 69 70 #if PLATFORM(GTK) 71 WebCore::PageCache::singleton().setShouldClearBackingStores(true); 72 #endif 37 // FIXME: this is no longer soup specific, this file should be renamed. 38 WebCore::MemoryCache::singleton().setDisabled(cacheModel == CacheModelDocumentViewer); 73 39 } 74 40 75 void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear) 76 { 77 } 78 79 void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& parameters) 41 void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&&) 80 42 { 81 43 }
Note: See TracChangeset
for help on using the changeset viewer.