WK_EXPORT int NetworkProcessMain(int argc, char* argv[]) { if (argc != 2) return 1; #if PLATFORM(EFL) if (!ecore_init()) return 1; if (!ecore_main_loop_glib_integrate()) return 1; #endif InitializeWebKit2(); #if USE(SOUP) SoupSession* session = ResourceHandle::defaultSession(); #if PLATFORM(EFL) // Only for EFL because GTK port uses the default resolver, which uses GIO's proxy resolver. const char* httpProxy = getenv("http_proxy"); if (httpProxy) { const char* noProxy = getenv("no_proxy"); GRefPtr<SoupProxyURIResolver> resolver = adoptGRef(soupProxyResolverWkNew(httpProxy, noProxy)); soup_session_add_feature(session, SOUP_SESSION_FEATURE(resolver.get())); } #endif #endif int socket = atoi(argv[1]); WebKit::ChildProcessInitializationParameters parameters; parameters.connectionIdentifier = int(socket); NetworkProcess::shared().initialize(parameters); #if USE(SOUP) // Despite using system CAs to validate certificates we're // accepting invalid certificates by default. New API will be // added later to let client accept/discard invalid certificates. g_object_set(session, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE, SOUP_SESSION_SSL_STRICT, FALSE, NULL); #endif RunLoop::run(); #if USE(SOUP) if (SoupSessionFeature* soupCache = soup_session_get_feature(session, SOUP_TYPE_CACHE)) { soup_cache_flush(SOUP_CACHE(soupCache)); soup_cache_dump(SOUP_CACHE(soupCache)); } #endif return 0; }
static void cache_down (GrlNetWc *self) { GFile *cache_dir_file; GrlNetWcPrivate *priv = self->priv; SoupSessionFeature *cache = soup_session_get_feature (priv->session, SOUP_TYPE_CACHE); gchar *cache_dir; GRL_DEBUG ("cache down"); if (!cache) { return; } soup_cache_clear (SOUP_CACHE (cache)); g_object_get (cache, "cache-dir", &cache_dir, NULL); cache_dir_file = g_file_new_for_path (cache_dir); g_free (cache_dir); g_file_delete (cache_dir_file, NULL, NULL); g_object_unref (G_OBJECT (cache_dir_file)); soup_session_remove_feature (priv->session, cache); }
void WebProcess::platformSetCacheModel(CacheModel cacheModel) { unsigned cacheTotalCapacity = 0; unsigned cacheMinDeadCapacity = 0; unsigned cacheMaxDeadCapacity = 0; double deadDecodedDataDeletionInterval = 0; unsigned pageCacheCapacity = 0; unsigned long urlCacheMemoryCapacity = 0; unsigned long urlCacheDiskCapacity = 0; SoupSession* session = WebCore::ResourceHandle::defaultSession(); SoupCache* cache = SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE)); uint64_t diskFreeSize = getCacheDiskFreeSize(cache) / 1024 / 1024; uint64_t memSize = getMemorySize(); calculateCacheSizes(cacheModel, memSize, diskFreeSize, cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity); WebCore::memoryCache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); WebCore::memoryCache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); WebCore::pageCache()->setCapacity(pageCacheCapacity); if (urlCacheDiskCapacity > soup_cache_get_max_size(cache)) soup_cache_set_max_size(cache, urlCacheDiskCapacity); }
void WebProcess::platformTerminate() { SoupSession* session = WebCore::ResourceHandle::defaultSession(); SoupCache* cache = SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE)); soup_cache_flush(cache); soup_cache_dump(cache); }
void NetworkProcess::clearCacheForAllOrigins(uint32_t cachesToClear) { if (cachesToClear == InMemoryResourceCachesOnly) return; SoupSession* session = ResourceHandle::defaultSession(); soup_cache_clear(SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE))); }
void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear) { if (cachesToClear == InMemoryResourceCachesOnly) return; SoupSession* session = WebCore::ResourceHandle::defaultSession(); soup_cache_clear(SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE))); }
WK_EXPORT int WebProcessMainNix(int argc, char* argv[]) { // WebProcess should be launched with an option. if (argc != 2) return 1; #ifdef WTF_USE_SOUP #if !GLIB_CHECK_VERSION(2, 35, 0) g_type_init(); #endif #endif InitializeWebKit2(); #ifdef WTF_USE_SOUP SoupSession* session = WebCore::ResourceHandle::defaultSession(); g_object_set(G_OBJECT(session), "ssl-use-system-ca-file", true, NULL); const char* httpProxy = getenv("http_proxy"); if (httpProxy) { const char* noProxy = getenv("no_proxy"); SoupProxyURIResolver* resolverNix = soupProxyResolverWkNew(httpProxy, noProxy); soup_session_add_feature(session, SOUP_SESSION_FEATURE(resolverNix)); g_object_unref(resolverNix); } #endif int socket = atoi(argv[1]); ChildProcessInitializationParameters parameters; parameters.connectionIdentifier = socket; WebProcess::shared().initialize(parameters); RunLoop::run(); #ifdef WTF_USE_SOUP if (SoupSessionFeature* soupCache = soup_session_get_feature(session, SOUP_TYPE_CACHE)) { soup_cache_flush(SOUP_CACHE(soupCache)); soup_cache_dump(SOUP_CACHE(soupCache)); } #endif return 0; }
void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear) { if (cachesToClear == InMemoryResourceCachesOnly) return; // If we're using the network process then it is the only one that needs to clear the disk cache. if (usesNetworkProcess()) return; soup_cache_clear(SOUP_CACHE(soup_session_get_feature(WebCore::ResourceHandle::defaultSession(), SOUP_TYPE_CACHE))); }
WK_EXPORT int WebProcessMainGtk(int argc, char* argv[]) { ASSERT(argc == 2); #ifndef NDEBUG if (g_getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH")) sleep(30); #endif gtk_init(&argc, &argv); bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); InitializeWebKit2(); int socket = atoi(argv[1]); ChildProcessInitializationParameters parameters; parameters.connectionIdentifier = socket; WebProcess::shared().initialize(parameters); // Despite using system CAs to validate certificates we're // accepting invalid certificates by default. New API will be // added later to let client accept/discard invalid certificates. SoupSession* session = WebCore::ResourceHandle::defaultSession(); g_object_set(session, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE, SOUP_SESSION_SSL_STRICT, FALSE, NULL); RunLoop::run(); if (SoupSessionFeature* soupCache = soup_session_get_feature(session, SOUP_TYPE_CACHE)) { soup_cache_flush(SOUP_CACHE(soupCache)); soup_cache_dump(SOUP_CACHE(soupCache)); } return 0; }
/** * grl_net_wc_set_cache_size: * @self: a #GrlNetWc instance * @cache_size: size of cache (in Mb) * * Sets the new maximum size of cache, in Megabytes. Default value is 10. Using * 0 means no cache will be done. * * Since: 0.1.12 **/ void grl_net_wc_set_cache_size (GrlNetWc *self, guint size) { g_return_if_fail (GRL_IS_NET_WC (self)); if (self->priv->cache_size == size) return; self->priv->cache_size = size; SoupSessionFeature *cache = soup_session_get_feature (self->priv->session, SOUP_TYPE_CACHE); if (!cache) return; soup_cache_set_max_size (SOUP_CACHE (cache), size * 1024 * 1024); }
SoupCache* SoupNetworkSession::cache() const { SoupSessionFeature* soupCache = soup_session_get_feature(m_soupSession.get(), SOUP_TYPE_CACHE); return soupCache ? SOUP_CACHE(soupCache) : nullptr; }
WK_EXPORT int WebProcessMainEfl(int argc, char* argv[]) { // WebProcess should be launched with an option. if (argc != 2) return 1; if (!eina_init()) return 1; if (!ecore_init()) { // Could not init ecore. eina_shutdown(); return 1; } #ifdef HAVE_ECORE_X XSetExtensionErrorHandler(dummyExtensionErrorHandler); if (!ecore_x_init(0)) { // Could not init ecore_x. // PlatformScreenEfl and systemBeep() functions // depend on ecore_x functionality. ecore_shutdown(); eina_shutdown(); return 1; } #endif if (!ecore_evas_init()) { #ifdef HAVE_ECORE_X ecore_x_shutdown(); #endif ecore_shutdown(); eina_shutdown(); return 1; } if (!edje_init()) { ecore_evas_shutdown(); #ifdef HAVE_ECORE_X ecore_x_shutdown(); #endif ecore_shutdown(); eina_shutdown(); return 1; } #if !GLIB_CHECK_VERSION(2, 35, 0) g_type_init(); #endif if (!ecore_main_loop_glib_integrate()) return 1; InitializeWebKit2(); SoupSession* session = WebCore::ResourceHandle::defaultSession(); const char* httpProxy = getenv("http_proxy"); if (httpProxy) { const char* noProxy = getenv("no_proxy"); SoupProxyURIResolver* resolverEfl = soupProxyResolverWkNew(httpProxy, noProxy); soup_session_add_feature(session, SOUP_SESSION_FEATURE(resolverEfl)); g_object_unref(resolverEfl); } int socket = atoi(argv[1]); ChildProcessInitializationParameters parameters; parameters.connectionIdentifier = socket; WebProcess::shared().initialize(parameters); RunLoop::run(); if (SoupSessionFeature* soupCache = soup_session_get_feature(session, SOUP_TYPE_CACHE)) { soup_cache_flush(SOUP_CACHE(soupCache)); soup_cache_dump(SOUP_CACHE(soupCache)); } edje_shutdown(); ecore_evas_shutdown(); #ifdef HAVE_ECORE_X ecore_x_shutdown(); #endif ecore_shutdown(); eina_shutdown(); return 0; }