Changeset 106920 in webkit
- Timestamp:
- Feb 7, 2012 3:42:39 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106917 r106920 1 2012-02-07 Michael Brüning <michael.bruning@nokia.com> 2 3 [Qt][WK2] Compute and set cache capacities using the current CacheModel 4 https://bugs.webkit.org/show_bug.cgi?id=73918 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 No new tests. (Not applicable) 9 10 Added OS-specific implementation for retrieving the free disk space. 11 12 * platform/FileSystem.h: 13 (WebCore): 14 * platform/qt/FileSystemQt.cpp: 15 (WebCore::getVolumeFreeSizeForPath): 16 (WebCore): 17 1 18 2012-02-07 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 19 -
trunk/Source/WebCore/platform/FileSystem.h
r96829 r106920 199 199 String filenameForDisplay(const String&); 200 200 CString applicationDirectoryPath(); 201 #endif 202 #if PLATFORM(GTK) || PLATFORM(QT) 201 203 uint64_t getVolumeFreeSizeForPath(const char*); 202 204 #endif -
trunk/Source/WebCore/platform/qt/FileSystemQt.cpp
r82193 r106920 40 40 #include <QFileInfo> 41 41 #include <QTemporaryFile> 42 #include <sys/statvfs.h> 42 43 #include <wtf/text/CString.h> 43 44 … … 191 192 } 192 193 194 uint64_t getVolumeFreeSizeForPath(const char* path) 195 { 196 #if defined(Q_OS_WIN) 197 ULARGE_INTEGER freeBytesToCaller; 198 BOOL result = GetDiskFreeSpaceExW((LPCWSTR)path, &freeBytesToCaller, 0, 0); 199 if (!result) 200 return 0; 201 return static_cast<uint64_t>freeBytesToCaller.QuadPart; 202 #else 203 struct statvfs volumeInfo; 204 if (statvfs(path, &volumeInfo)) 205 return 0; 206 207 return static_cast<uint64_t>(volumeInfo.f_bavail) * static_cast<uint64_t>(volumeInfo.f_frsize); 208 #endif 209 } 210 193 211 int writeToFile(PlatformFileHandle handle, const char* data, int length) 194 212 { -
trunk/Source/WebKit2/ChangeLog
r106907 r106920 1 2012-02-07 Michael Brüning <michael.bruning@nokia.com> 2 3 [Qt][WK2] Compute and set cache capacities using the current CacheModel 4 https://bugs.webkit.org/show_bug.cgi?id=73918 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 First part of the implementation. The next steps are the implementation 9 of the API for the Qt WebKit 2 port and the hybrid memory and disk cache. 10 11 * Shared/WebProcessCreationParameters.cpp: 12 (WebKit::WebProcessCreationParameters::encode): 13 (WebKit::WebProcessCreationParameters::decode): 14 * Shared/WebProcessCreationParameters.h: 15 (WebProcessCreationParameters): 16 * UIProcess/qt/WebContextQt.cpp: 17 (WebKit::defaultDiskCacheDirectory): 18 (WebKit): 19 (WebKit::WebContext::platformInitializeWebProcess): 20 * WebProcess/qt/WebProcessQt.cpp: 21 (WebKit::physicalMemorySizeInBytes): 22 (WebKit): 23 (WebKit::WebProcess::platformSetCacheModel): 24 (WebKit::WebProcess::platformInitializeWebProcess): 25 1 26 2012-02-06 Shinya Kawanaka <shinyak@google.com> 2 27 -
trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp
r105364 r106920 99 99 #if PLATFORM(QT) 100 100 encoder->encode(cookieStorageDirectory); 101 encoder->encode(diskCacheDirectory); 101 102 #endif 102 103 … … 196 197 if (!decoder->decode(parameters.cookieStorageDirectory)) 197 198 return false; 199 if (!decoder->decode(parameters.diskCacheDirectory)) 200 return false; 198 201 #endif 199 202 -
trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h
r105364 r106920 122 122 #if PLATFORM(QT) 123 123 String cookieStorageDirectory; 124 String diskCacheDirectory; 124 125 #endif 125 126 -
trunk/Source/WebKit2/UIProcess/qt/WebContextQt.cpp
r98721 r106920 58 58 } 59 59 60 static String defaultDiskCacheDirectory() 61 { 62 static String s_defaultDiskCacheDirectory; 63 64 if (!s_defaultDiskCacheDirectory.isEmpty()) 65 return s_defaultDiskCacheDirectory; 66 67 s_defaultDiskCacheDirectory = WebCore::pathByAppendingComponent(defaultDataLocation(), "cache/"); 68 WebCore::makeAllDirectories(s_defaultDiskCacheDirectory); 69 return s_defaultDiskCacheDirectory; 70 } 71 60 72 static QString s_defaultDatabaseDirectory; 61 73 static QString s_defaultLocalStorageDirectory; … … 70 82 qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); 71 83 parameters.cookieStorageDirectory = defaultDataLocation(); 84 parameters.diskCacheDirectory = defaultDiskCacheDirectory(); 85 72 86 #if ENABLE(GEOLOCATION) 73 87 static WebGeolocationProviderQt* location = WebGeolocationProviderQt::create(toAPI(geolocationManagerProxy())); -
trunk/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp
r104193 r106920 1 1 /* 2 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2011, 2012 Nokia Corporation and/or its subsidiary(-ies) 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 36 37 #include <QNetworkAccessManager> 37 38 #include <QNetworkCookieJar> 39 #include <QNetworkDiskCache> 38 40 #include <WebCore/CookieJarQt.h> 41 #include <WebCore/FileSystem.h> 42 #include <WebCore/MemoryCache.h> 39 43 #include <WebCore/PageCache.h> 40 44 #include <WebCore/RuntimeEnabledFeatures.h> … … 42 46 #if defined(Q_OS_MACX) 43 47 #include <dispatch/dispatch.h> 48 #include <mach/host_info.h> 49 #include <mach/mach.h> 50 #include <mach/mach_error.h> 51 #elif defined(Q_OS_WIN) 52 53 #else 54 #include <unistd.h> 44 55 #endif 45 56 … … 48 59 namespace WebKit { 49 60 50 static const int DefaultPageCacheCapacity = 20; 61 static uint64_t physicalMemorySizeInBytes() 62 { 63 static uint64_t physicalMemorySize = 0; 51 64 52 void WebProcess::platformSetCacheModel(CacheModel) 65 if (!physicalMemorySize) { 66 #if defined(Q_OS_MACX) 67 host_basic_info_data_t hostInfo; 68 mach_port_t host = mach_host_self(); 69 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; 70 kern_return_t r = host_info(host, HOST_BASIC_INFO, (host_info_t)&hostInfo, &count); 71 mach_port_deallocate(mach_task_self(), host); 72 73 if (r == KERN_SUCCESS) 74 physicalMemorySize = hostInfo.max_mem; 75 76 #elif defined(Q_OS_WIN) 77 MEMORYSTATUSEX statex; 78 statex.dwLength = sizeof(statex); 79 GlobalMemoryStatusEx(&statex); 80 physicalMemorySize = static_cast<uint64_t>(statex.ullTotalPhys); 81 82 #else 83 long pageSize = sysconf(_SC_PAGESIZE); 84 long numberOfPages = sysconf(_SC_PHYS_PAGES); 85 86 if (pageSize > 0 && numberOfPages > 0) 87 physicalMemorySize = static_cast<uint64_t>(pageSize) * static_cast<uint64_t>(numberOfPages); 88 89 #endif 90 } 91 return physicalMemorySize; 92 } 93 94 void WebProcess::platformSetCacheModel(CacheModel cacheModel) 53 95 { 54 // FIXME: see bug 73918 55 pageCache()->setCapacity(DefaultPageCacheCapacity); 96 QNetworkDiskCache* diskCache = qobject_cast<QNetworkDiskCache*>(m_networkAccessManager->cache()); 97 ASSERT(diskCache); 98 99 ASSERT(WebCore::platformInfo()); 100 uint64_t physicalMemorySizeInMegabytes = physicalMemorySizeInBytes() / 1024 / 1024; 101 102 // The Mac port of WebKit2 uses a fudge factor of 1000 here to account for misalignment, however, 103 // that tends to overestimate the memory quite a bit (1 byte misalignment ~ 48 MiB misestimation). 104 // We use 1024 * 1023 for now to keep the estimation error down to +/- ~1 MiB. 105 uint64_t freeVolumeSpace = WebCore::getVolumeFreeSizeForPath(diskCache->cacheDirectory().toAscii().constData()) / 1024 / 1023; 106 107 // The following variables are initialised to 0 because WebProcess::calculateCacheSizes might not 108 // set them in some rare cases. 109 unsigned cacheTotalCapacity = 0; 110 unsigned cacheMinDeadCapacity = 0; 111 unsigned cacheMaxDeadCapacity = 0; 112 double deadDecodedDataDeletionInterval = 0; 113 unsigned pageCacheCapacity = 0; 114 unsigned long urlCacheMemoryCapacity = 0; 115 unsigned long urlCacheDiskCapacity = 0; 116 117 calculateCacheSizes(cacheModel, physicalMemorySizeInMegabytes, freeVolumeSpace, 118 cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, 119 pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity); 120 121 memoryCache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); 122 memoryCache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); 123 pageCache()->setCapacity(pageCacheCapacity); 124 125 // FIXME: Implement hybrid in-memory- and disk-caching as e.g. the Mac port does. 126 diskCache->setMaximumCacheSize(static_cast<qint64>(urlCacheDiskCapacity)); 56 127 } 57 128 … … 70 141 { 71 142 m_networkAccessManager = new QtNetworkAccessManager(this); 143 144 ASSERT(!parameters.diskCacheDirectory.isEmpty() && !parameters.diskCacheDirectory.isNull()); 145 QNetworkDiskCache* diskCache = new QNetworkDiskCache(); 146 diskCache->setCacheDirectory(parameters.diskCacheDirectory); 147 // The m_networkAccessManager takes ownership of the diskCache object upon the following call. 148 m_networkAccessManager->setCache(diskCache); 149 72 150 ASSERT(!parameters.cookieStorageDirectory.isEmpty() && !parameters.cookieStorageDirectory.isNull()); 73 151 WebCore::SharedCookieJarQt* jar = WebCore::SharedCookieJarQt::create(parameters.cookieStorageDirectory);
Note: See TracChangeset
for help on using the changeset viewer.