Changeset 160307 in webkit
- Timestamp:
- Dec 9, 2013 4:06:40 AM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r160304 r160307 1 2013-12-09 Kwang Yul Seo <skyul@company100.net> 2 3 [WK2][Soup] Support cache model in NetworkProcess 4 https://bugs.webkit.org/show_bug.cgi?id=118343 5 6 Reviewed by Carlos Garcia Campos. 7 8 Original patch by Kwang Yul Seo <skyul@company100.net> and Csaba Osztrogonác <ossy@webkit.org>. 9 10 Copied cache model code from WebProcess. 11 NetworkProcess is configured not to use the WebCore memory cache. 12 13 * NetworkProcess/soup/NetworkProcessSoup.cpp: 14 (WebKit::getCacheDiskFreeSize): 15 (WebKit::getMemorySize): 16 (WebKit::NetworkProcess::platformInitializeNetworkProcess): 17 Initialize soup cache. 18 (WebKit::NetworkProcess::platformSetCacheModel): 19 Copied code from WebProcess::platformSetCacheModel but removed 20 WebCore memory cache initialization because NetworkProcess does not use 21 the WebCore memory cache. 22 (WebKit::NetworkProcess::clearCacheForAllOrigins): 23 Copied code from WebProcess::clearCacheForAllOrigins. 24 * NetworkProcess/unix/NetworkProcessMainUnix.cpp: 25 Copied initialization code from WebProcessMainGtk.cpp. 26 (WebKit::NetworkProcessMain): 27 * WebProcess/soup/WebProcessSoup.cpp: 28 (WebKit::WebProcess::platformSetCacheModel): 29 Don't set the disk cache if NetworkProcess is used. 30 (WebKit::WebProcess::platformClearResourceCaches): 31 Don't clear the non-existing disk cache. (if NetworkProcess is used) 32 (WebKit::WebProcess::platformInitializeWebProcess): 33 Don't initialize the disk cache if NetworkProcess is used. 34 1 35 2013-12-09 Gustavo Noronha Silva <gns@gnome.org> 2 36 -
trunk/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp
r159647 r160307 30 30 31 31 #include "NetworkProcessCreationParameters.h" 32 #include "ResourceCachesToClear.h" 33 #include <WebCore/FileSystem.h> 32 34 #include <WebCore/NotImplemented.h> 35 #include <WebCore/ResourceHandle.h> 36 #include <libsoup/soup.h> 37 #include <wtf/gobject/GOwnPtr.h> 38 #include <wtf/gobject/GRefPtr.h> 33 39 34 40 using namespace WebCore; … … 36 42 namespace WebKit { 37 43 38 void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters&)44 static uint64_t getCacheDiskFreeSize(SoupCache* cache) 39 45 { 46 ASSERT(cache); 47 48 GOwnPtr<char> cacheDir; 49 g_object_get(G_OBJECT(cache), "cache-dir", &cacheDir.outPtr(), NULL); 50 if (!cacheDir) 51 return 0; 52 53 return WebCore::getVolumeFreeSizeForPath(cacheDir.get()); 40 54 } 41 55 42 void NetworkProcess::platformSetCacheModel(CacheModel)56 static uint64_t getMemorySize() 43 57 { 44 notImplemented(); 58 static uint64_t kDefaultMemorySize = 512; 59 #if !OS(WINDOWS) 60 long pageSize = sysconf(_SC_PAGESIZE); 61 if (pageSize == -1) 62 return kDefaultMemorySize; 63 64 long physPages = sysconf(_SC_PHYS_PAGES); 65 if (physPages == -1) 66 return kDefaultMemorySize; 67 68 return ((pageSize / 1024) * physPages) / 1024; 69 #else 70 // Fallback to default for other platforms. 71 return kDefaultMemorySize; 72 #endif 73 } 74 75 void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters& parameters) 76 { 77 ASSERT(!parameters.diskCacheDirectory.isEmpty()); 78 GRefPtr<SoupCache> soupCache = adoptGRef(soup_cache_new(parameters.diskCacheDirectory.utf8().data(), SOUP_CACHE_SINGLE_USER)); 79 soup_session_add_feature(WebCore::ResourceHandle::defaultSession(), SOUP_SESSION_FEATURE(soupCache.get())); 80 soup_cache_load(soupCache.get()); 81 } 82 83 void NetworkProcess::platformSetCacheModel(CacheModel cacheModel) 84 { 85 unsigned cacheTotalCapacity = 0; 86 unsigned cacheMinDeadCapacity = 0; 87 unsigned cacheMaxDeadCapacity = 0; 88 double deadDecodedDataDeletionInterval = 0; 89 unsigned pageCacheCapacity = 0; 90 91 unsigned long urlCacheMemoryCapacity = 0; 92 unsigned long urlCacheDiskCapacity = 0; 93 94 SoupSession* session = ResourceHandle::defaultSession(); 95 SoupCache* cache = SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE)); 96 uint64_t diskFreeSize = getCacheDiskFreeSize(cache) / 1024 / 1024; 97 98 uint64_t memSize = getMemorySize(); 99 calculateCacheSizes(cacheModel, memSize, diskFreeSize, 100 cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, 101 pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity); 102 103 if (urlCacheDiskCapacity > soup_cache_get_max_size(cache)) 104 soup_cache_set_max_size(cache, urlCacheDiskCapacity); 45 105 } 46 106 … … 52 112 void NetworkProcess::clearCacheForAllOrigins(uint32_t cachesToClear) 53 113 { 54 notImplemented(); 114 if (cachesToClear == InMemoryResourceCachesOnly) 115 return; 116 117 SoupSession* session = ResourceHandle::defaultSession(); 118 soup_cache_clear(SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE))); 55 119 } 56 120 -
trunk/Source/WebKit2/NetworkProcess/unix/NetworkProcessMainUnix.cpp
r160302 r160307 46 46 #endif 47 47 48 #if USE(SOUP) 49 #include <libsoup/soup.h> 50 #endif 51 48 52 using namespace WebCore; 49 53 … … 66 70 67 71 #if USE(SOUP) 68 SoupSession* session = WebCore::ResourceHandle::defaultSession();72 SoupSession* session = ResourceHandle::defaultSession(); 69 73 #if PLATFORM(EFL) 70 74 // Only for EFL because GTK port uses the default resolver, which uses GIO's proxy resolver. … … 85 89 NetworkProcess::shared().initialize(parameters); 86 90 91 #if USE(SOUP) 92 // Despite using system CAs to validate certificates we're 93 // accepting invalid certificates by default. New API will be 94 // added later to let client accept/discard invalid certificates. 95 g_object_set(session, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE, 96 SOUP_SESSION_SSL_STRICT, FALSE, NULL); 97 #endif 98 87 99 RunLoop::run(); 100 101 #if USE(SOUP) 102 if (SoupSessionFeature* soupCache = soup_session_get_feature(session, SOUP_TYPE_CACHE)) { 103 soup_cache_flush(SOUP_CACHE(soupCache)); 104 soup_cache_dump(SOUP_CACHE(soupCache)); 105 } 106 #endif 88 107 89 108 return 0; -
trunk/Source/WebKit2/WebProcess/soup/WebProcessSoup.cpp
r159647 r160307 91 91 unsigned long urlCacheDiskCapacity = 0; 92 92 93 SoupSession* session = WebCore::ResourceHandle::defaultSession(); 94 SoupCache* cache = SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE)); 95 uint64_t diskFreeSize = getCacheDiskFreeSize(cache) / 1024 / 1024; 96 93 uint64_t diskFreeSize = 0; 94 SoupCache* cache = nullptr; 95 96 #if ENABLE(NETWORK_PROCESS) 97 if (!m_usesNetworkProcess) { 98 #endif 99 SoupSession* session = WebCore::ResourceHandle::defaultSession(); 100 cache = SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE)); 101 diskFreeSize = getCacheDiskFreeSize(cache) / 1024 / 1024; 102 #if ENABLE(NETWORK_PROCESS) 103 } 104 #endif 97 105 uint64_t memSize = getMemorySize(); 98 106 calculateCacheSizes(cacheModel, memSize, diskFreeSize, … … 104 112 WebCore::pageCache()->setCapacity(pageCacheCapacity); 105 113 114 #if ENABLE(NETWORK_PROCESS) 115 if (!m_usesNetworkProcess) { 116 #endif 117 if (urlCacheDiskCapacity > soup_cache_get_max_size(cache)) 118 soup_cache_set_max_size(cache, urlCacheDiskCapacity); 119 #if ENABLE(NETWORK_PROCESS) 120 } 121 #endif 106 122 if (urlCacheDiskCapacity > soup_cache_get_max_size(cache)) 107 123 soup_cache_set_max_size(cache, urlCacheDiskCapacity); … … 113 129 return; 114 130 131 // If we're using the network process then it is the only one that needs to clear the disk cache. 132 #if ENABLE(NETWORK_PROCESS) 133 if (m_usesNetworkProcess) 134 return; 135 #endif 115 136 SoupSession* session = WebCore::ResourceHandle::defaultSession(); 116 137 soup_cache_clear(SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE))); … … 178 199 #endif 179 200 180 ASSERT(!parameters.diskCacheDirectory.isEmpty()); 181 GRefPtr<SoupCache> soupCache = adoptGRef(soup_cache_new(parameters.diskCacheDirectory.utf8().data(), SOUP_CACHE_SINGLE_USER)); 182 soup_session_add_feature(WebCore::ResourceHandle::defaultSession(), SOUP_SESSION_FEATURE(soupCache.get())); 183 soup_cache_load(soupCache.get()); 184 201 #if ENABLE(NETWORK_PROCESS) 202 if (!m_usesNetworkProcess) { 203 #endif 204 ASSERT(!parameters.diskCacheDirectory.isEmpty()); 205 GRefPtr<SoupCache> soupCache = adoptGRef(soup_cache_new(parameters.diskCacheDirectory.utf8().data(), SOUP_CACHE_SINGLE_USER)); 206 soup_session_add_feature(WebCore::ResourceHandle::defaultSession(), SOUP_SESSION_FEATURE(soupCache.get())); 207 soup_cache_load(soupCache.get()); 208 #if ENABLE(NETWORK_PROCESS) 209 } 210 #endif 185 211 if (!parameters.languages.isEmpty()) 186 212 setSoupSessionAcceptLanguage(parameters.languages);
Note: See TracChangeset
for help on using the changeset viewer.