[EFL] Switch to ENABLE_NETWORK_CACHE
authormcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Sep 2016 18:13:08 +0000 (18:13 +0000)
committermcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Sep 2016 18:13:08 +0000 (18:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152676

Reviewed by Alex Christensen.

.:

Build with -Wno-error=missing-field-initializers to avoid spurious build failures.

* Source/cmake/OptionsEfl.cmake:

Source/WebCore:

* PlatformEfl.cmake: Add GRefPtrSoup to build.
* platform/network/soup/SoupNetworkSession.cpp:
(WebCore::SoupNetworkSession::clearOldSoupCache): Renamed from clearCache.
(WebCore::SoupNetworkSession::setCache): Deleted.
(WebCore::SoupNetworkSession::cache): Deleted.
(WebCore::SoupNetworkSession::clearCache): Deleted.
* platform/network/soup/SoupNetworkSession.h:

Source/WebKit2:

Nowadays GTK+ always uses the network cache, and never the soup cache. Remove support for
using the soup cache, and switch the EFL port to use network cache.

* NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
(WebKit::NetworkCache::BlobStorage::add): Check return value of link to placate
-Werror=unused-result on EFL builder
* NetworkProcess/efl/NetworkProcessMainEfl.cpp:
* NetworkProcess/soup/NetworkProcessSoup.cpp:
(WebKit::getCacheDiskFreeSize):
(WebKit::NetworkProcess::platformInitializeNetworkProcess):
(WebKit::NetworkProcess::platformSetCacheModel):
(WebKit::NetworkProcess::clearDiskCache):
* PlatformEfl.cmake: Add files to build.
* UIProcess/API/efl/APIWebsiteDataStoreEfl.cpp:
(API::WebsiteDataStore::defaultNetworkCacheDirectory): Use a saner location.
* UIProcess/API/gtk/APIWebsiteDataStoreGtk.cpp:
(API::WebsiteDataStore::defaultNetworkCacheDirectory):
* UIProcess/API/gtk/WebKitPrivate.h:
* UIProcess/soup/WebProcessPoolSoup.cpp:
(WebKit::WebProcessPool::platformInitializeNetworkProcess):
* WebProcess/efl/WebProcessMainEfl.cpp:
* config.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205556 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/PlatformEfl.cmake
Source/WebCore/platform/network/soup/SoupNetworkSession.cpp
Source/WebCore/platform/network/soup/SoupNetworkSession.h
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCacheBlobStorage.cpp
Source/WebKit2/NetworkProcess/efl/NetworkProcessMainEfl.cpp
Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp
Source/WebKit2/PlatformEfl.cmake
Source/WebKit2/UIProcess/API/efl/APIWebsiteDataStoreEfl.cpp
Source/WebKit2/UIProcess/API/gtk/APIWebsiteDataStoreGtk.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
Source/WebKit2/UIProcess/soup/WebProcessPoolSoup.cpp
Source/WebKit2/WebProcess/efl/WebProcessMainEfl.cpp
Source/WebKit2/config.h
Source/cmake/OptionsEfl.cmake

index 1aaca2f..11ca7c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2016-09-07  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [EFL] Switch to ENABLE_NETWORK_CACHE
+        https://bugs.webkit.org/show_bug.cgi?id=152676
+
+        Reviewed by Alex Christensen.
+
+        Build with -Wno-error=missing-field-initializers to avoid spurious build failures.
+
+        * Source/cmake/OptionsEfl.cmake:
+
 2016-09-07  Youenn Fablet  <youenn@apple.com>
 
         [Streams API] Separate compile flag for ReadableStream and WritableStream
index 53b8be1..d54d0ac 100644 (file)
@@ -1,3 +1,18 @@
+2016-09-07  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [EFL] Switch to ENABLE_NETWORK_CACHE
+        https://bugs.webkit.org/show_bug.cgi?id=152676
+
+        Reviewed by Alex Christensen.
+
+        * PlatformEfl.cmake: Add GRefPtrSoup to build.
+        * platform/network/soup/SoupNetworkSession.cpp:
+        (WebCore::SoupNetworkSession::clearOldSoupCache): Renamed from clearCache.
+        (WebCore::SoupNetworkSession::setCache): Deleted.
+        (WebCore::SoupNetworkSession::cache): Deleted.
+        (WebCore::SoupNetworkSession::clearCache): Deleted.
+        * platform/network/soup/SoupNetworkSession.h:
+
 2016-09-07  Chris Dumez  <cdumez@apple.com>
 
         Drop legacy canvas.probablySupportsContext()
index 6089f2d..bd0ba40 100644 (file)
@@ -195,6 +195,7 @@ list(APPEND WebCore_SOURCES
     platform/network/soup/CookieStorageSoup.cpp
     platform/network/soup/CredentialStorageSoup.cpp
     platform/network/soup/DNSSoup.cpp
+    platform/network/soup/GRefPtrSoup.cpp
     platform/network/soup/NetworkStorageSessionSoup.cpp
     platform/network/soup/ProxyServerSoup.cpp
     platform/network/soup/ResourceErrorSoup.cpp
index 7686578..b7ecfde 100644 (file)
@@ -160,18 +160,6 @@ SoupCookieJar* SoupNetworkSession::cookieJar() const
     return SOUP_COOKIE_JAR(soup_session_get_feature(m_soupSession.get(), SOUP_TYPE_COOKIE_JAR));
 }
 
-void SoupNetworkSession::setCache(SoupCache* cache)
-{
-    ASSERT(!soup_session_get_feature(m_soupSession.get(), SOUP_TYPE_CACHE));
-    soup_session_add_feature(m_soupSession.get(), SOUP_SESSION_FEATURE(cache));
-}
-
-SoupCache* SoupNetworkSession::cache() const
-{
-    SoupSessionFeature* soupCache = soup_session_get_feature(m_soupSession.get(), SOUP_TYPE_CACHE);
-    return soupCache ? SOUP_CACHE(soupCache) : nullptr;
-}
-
 static inline bool stringIsNumeric(const char* str)
 {
     while (*str) {
@@ -182,7 +170,8 @@ static inline bool stringIsNumeric(const char* str)
     return true;
 }
 
-void SoupNetworkSession::clearCache(const String& cacheDirectory)
+// Old versions of WebKit created this cache.
+void SoupNetworkSession::clearOldSoupCache(const String& cacheDirectory)
 {
     CString cachePath = fileSystemRepresentation(cacheDirectory);
     GUniquePtr<char> cacheFile(g_build_filename(cachePath.data(), "soup.cache2", nullptr));
index afa4cde..7aa79e3 100644 (file)
@@ -58,9 +58,7 @@ public:
     void setCookieJar(SoupCookieJar*);
     SoupCookieJar* cookieJar() const;
 
-    void setCache(SoupCache*);
-    SoupCache* cache() const;
-    static void clearCache(const String& cacheDirectory);
+    static void clearOldSoupCache(const String& cacheDirectory);
 
     void setSSLPolicy(SSLPolicy);
     SSLPolicy sslPolicy() const;
index 8665507..cfac98d 100644 (file)
@@ -1,3 +1,33 @@
+2016-09-07  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [EFL] Switch to ENABLE_NETWORK_CACHE
+        https://bugs.webkit.org/show_bug.cgi?id=152676
+
+        Reviewed by Alex Christensen.
+
+        Nowadays GTK+ always uses the network cache, and never the soup cache. Remove support for
+        using the soup cache, and switch the EFL port to use network cache.
+
+        * NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
+        (WebKit::NetworkCache::BlobStorage::add): Check return value of link to placate
+        -Werror=unused-result on EFL builder
+        * NetworkProcess/efl/NetworkProcessMainEfl.cpp:
+        * NetworkProcess/soup/NetworkProcessSoup.cpp:
+        (WebKit::getCacheDiskFreeSize):
+        (WebKit::NetworkProcess::platformInitializeNetworkProcess):
+        (WebKit::NetworkProcess::platformSetCacheModel):
+        (WebKit::NetworkProcess::clearDiskCache):
+        * PlatformEfl.cmake: Add files to build.
+        * UIProcess/API/efl/APIWebsiteDataStoreEfl.cpp:
+        (API::WebsiteDataStore::defaultNetworkCacheDirectory): Use a saner location.
+        * UIProcess/API/gtk/APIWebsiteDataStoreGtk.cpp:
+        (API::WebsiteDataStore::defaultNetworkCacheDirectory):
+        * UIProcess/API/gtk/WebKitPrivate.h:
+        * UIProcess/soup/WebProcessPoolSoup.cpp:
+        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+        * WebProcess/efl/WebProcessMainEfl.cpp:
+        * config.h:
+
 2016-09-07  Youenn Fablet  <youenn@apple.com>
 
         [Streams API] Separate compile flag for ReadableStream and WritableStream
index 49644b5..619b8e7 100644 (file)
@@ -97,7 +97,8 @@ BlobStorage::Blob BlobStorage::add(const String& path, const Data& data)
     if (blobExists) {
         auto existingData = mapFile(blobPath.data());
         if (bytesEqual(existingData, data)) {
-            link(blobPath.data(), linkPath.data());
+            if (link(blobPath.data(), linkPath.data()) == -1)
+                WTFLogAlways("Failed to create hard link from %s to %s", blobPath.data(), linkPath.data());
             return { existingData, hash };
         }
         unlink(blobPath.data());
@@ -107,7 +108,8 @@ BlobStorage::Blob BlobStorage::add(const String& path, const Data& data)
     if (mappedData.isNull())
         return { };
 
-    link(blobPath.data(), linkPath.data());
+    if (link(blobPath.data(), linkPath.data()) == -1)
+        WTFLogAlways("Failed to create hard link from %s to %s", blobPath.data(), linkPath.data());
 
     m_approximateSize += mappedData.size();
 
index 432c12a..e41932f 100644 (file)
@@ -53,11 +53,6 @@ public:
 
     void platformFinalize() override
     {
-        if (SoupCache* soupCache = SoupNetworkSession::defaultSession().cache()) {
-            soup_cache_flush(soupCache);
-            soup_cache_dump(soupCache);
-        }
-
         ecore_shutdown();
     }
 };
index a3e14df..5f4a193 100644 (file)
@@ -55,9 +55,7 @@ void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreati
     ASSERT(!parameters.diskCacheDirectory.isEmpty());
     m_diskCacheDirectory = parameters.diskCacheDirectory;
 
-#if ENABLE(NETWORK_CACHE)
-    // Clear the old soup cache if it exists.
-    SoupNetworkSession::defaultSession().clearCache(WebCore::directoryName(m_diskCacheDirectory));
+    SoupNetworkSession::defaultSession().clearOldSoupCache(WebCore::directoryName(m_diskCacheDirectory));
 
     NetworkCache::Cache::Parameters cacheParameters {
         parameters.shouldEnableNetworkCacheEfficacyLogging
@@ -66,20 +64,6 @@ void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreati
 #endif
     };
     NetworkCache::singleton().initialize(m_diskCacheDirectory, cacheParameters);
-#else
-    // We used to use the given cache directory for the soup cache, but now we use a subdirectory to avoid
-    // conflicts with other cache files in the same directory. Remove the old cache files if they still exist.
-    SoupNetworkSession::defaultSession().clearCache(WebCore::directoryName(m_diskCacheDirectory));
-
-    GRefPtr<SoupCache> soupCache = adoptGRef(soup_cache_new(m_diskCacheDirectory.utf8().data(), SOUP_CACHE_SINGLE_USER));
-    SoupNetworkSession::defaultSession().setCache(soupCache.get());
-    // Set an initial huge max_size for the SoupCache so the call to soup_cache_load() won't evict any cached
-    // resource. The final size of the cache will be set by NetworkProcess::platformSetCacheModel().
-    unsigned initialMaxSize = soup_cache_get_max_size(soupCache.get());
-    soup_cache_set_max_size(soupCache.get(), G_MAXUINT);
-    soup_cache_load(soupCache.get());
-    soup_cache_set_max_size(soupCache.get(), initialMaxSize);
-#endif
 
     if (!parameters.cookiePersistentStoragePath.isEmpty()) {
         supplement<WebCookieManager>()->setCookiePersistentStorage(parameters.cookiePersistentStoragePath,
@@ -93,15 +77,8 @@ void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreati
     setIgnoreTLSErrors(parameters.ignoreTLSErrors);
 }
 
-void NetworkProcess::platformSetURLCacheSize(unsigned /*urlCacheMemoryCapacity*/, uint64_t urlCacheDiskCapacity)
+void NetworkProcess::platformSetURLCacheSize(unsigned, uint64_t)
 {
-#if !ENABLE(NETWORK_CACHE)
-    SoupCache* cache = SoupNetworkSession::defaultSession().cache();
-    if (urlCacheDiskCapacity > soup_cache_get_max_size(cache))
-        soup_cache_set_max_size(cache, urlCacheDiskCapacity);
-#else
-    UNUSED_PARAM(urlCacheDiskCapacity);
-#endif
 }
 
 void NetworkProcess::setIgnoreTLSErrors(bool ignoreTLSErrors)
@@ -124,13 +101,7 @@ void NetworkProcess::clearCacheForAllOrigins(uint32_t cachesToClear)
 
 void NetworkProcess::clearDiskCache(std::chrono::system_clock::time_point modifiedSince, std::function<void ()> completionHandler)
 {
-#if ENABLE(NETWORK_CACHE)
     NetworkCache::singleton().clear(modifiedSince, WTFMove(completionHandler));
-#else
-    UNUSED_PARAM(modifiedSince);
-    UNUSED_PARAM(completionHandler);
-    soup_cache_clear(SoupNetworkSession::defaultSession().cache());
-#endif
 }
 
 void NetworkProcess::platformTerminate()
index c17af03..5487dcb 100644 (file)
@@ -8,6 +8,10 @@ list(APPEND WebKit2_SOURCES
 
     NetworkProcess/Downloads/soup/DownloadSoup.cpp
 
+    NetworkProcess/cache/NetworkCacheCodersSoup.cpp
+    NetworkProcess/cache/NetworkCacheDataSoup.cpp
+    NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp
+
     NetworkProcess/efl/NetworkProcessMainEfl.cpp
 
     NetworkProcess/soup/NetworkProcessSoup.cpp
index 0ed7fc2..ce05239 100644 (file)
@@ -38,13 +38,7 @@ String WebsiteDataStore::defaultApplicationCacheDirectory()
 
 String WebsiteDataStore::defaultNetworkCacheDirectory()
 {
-#if ENABLE(NETWORK_CACHE)
-    static const char networkCacheSubdirectory[] = "WebKitCache";
-#else
-    static const char networkCacheSubdirectory[] = "webkit";
-#endif
-
-    return cacheDirectoryFileSystemRepresentation(networkCacheSubdirectory);
+    return cacheDirectoryFileSystemRepresentation("WebKitEfl" EINA_PATH_SEP_S "WebKitCache");
 }
 
 String WebsiteDataStore::defaultIndexedDBDatabaseDirectory()
index 55cc396..8badf95 100644 (file)
@@ -35,14 +35,11 @@ String WebsiteDataStore::defaultApplicationCacheDirectory()
     return cacheDirectoryFileSystemRepresentation("webkitgtk" G_DIR_SEPARATOR_S "applications");
 }
 
+// FIXME: The other directories in this file are shared between all applications using WebKitGTK+.
+// Why is only this directory namespaced to a particular application?
 String WebsiteDataStore::defaultNetworkCacheDirectory()
 {
-#if ENABLE(NETWORK_CACHE)
-    static const char networkCacheSubdirectory[] = "WebKitCache";
-#else
-    static const char networkCacheSubdirectory[] = "webkit";
-#endif
-    return cacheDirectoryFileSystemRepresentation(WebCore::pathByAppendingComponent(WebCore::filenameToString(g_get_prgname()), networkCacheSubdirectory));
+    return cacheDirectoryFileSystemRepresentation(WebCore::pathByAppendingComponent(WebCore::filenameToString(g_get_prgname()), "WebKitCache"));
 }
 
 String WebsiteDataStore::defaultIndexedDBDatabaseDirectory()
index c995cd5..75e8c9e 100644 (file)
@@ -127,10 +127,6 @@ enum SnapshotRegion {
     SnapshotRegionFullDocument
 };
 
-#if ENABLE(NETWORK_CACHE)
 static const char networkCacheSubdirectory[] = "WebKitCache";
-#else
-static const char networkCacheSubdirectory[] = "webkit";
-#endif
 
 #endif // WebKitPrivate_h
index fa81ca1..d5db244 100644 (file)
@@ -41,9 +41,7 @@ void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationPara
     parameters.ignoreTLSErrors = m_ignoreTLSErrors;
     parameters.languages = WebCore::userPreferredLanguages();
     parameters.urlSchemesRegisteredForCustomProtocols = supplement<WebSoupCustomProtocolRequestManager>()->registeredSchemesForCustomProtocols();
-#if ENABLE(NETWORK_CACHE)
     parameters.shouldEnableNetworkCacheEfficacyLogging = false;
-#endif
 }
 
 void WebProcessPool::setIgnoreTLSErrors(bool ignoreTLSErrors)
index 52d0acc..4611c6e 100644 (file)
@@ -104,11 +104,6 @@ public:
 
     void platformFinalize() override
     {
-        if (SoupCache* soupCache = SoupNetworkSession::defaultSession().cache()) {
-            soup_cache_flush(soupCache);
-            soup_cache_dump(soupCache);
-        }
-
         edje_shutdown();
         ecore_evas_shutdown();
 #ifdef HAVE_ECORE_X
index 61e5323..1d91fbd 100644 (file)
@@ -99,7 +99,7 @@
 #endif
 
 #ifndef ENABLE_NETWORK_CACHE
-#if PLATFORM(COCOA) || PLATFORM(GTK)
+#if PLATFORM(COCOA) || USE(SOUP)
 #define ENABLE_NETWORK_CACHE 1
 #else
 #define ENABLE_NETWORK_CACHE 0
index 00acbd0..4fa0b56 100644 (file)
@@ -8,7 +8,7 @@ set(ENABLE_WEBKIT2 ON)
 
 # FIXME: Disable WERROR in clang build because of many warnings.
 if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
-    set(ADDITIONAL_COMPILER_FLAGS ENABLE_WERROR)
+    set(ADDITIONAL_COMPILER_FLAGS ENABLE_WERROR "-Wno-error=missing-field-initializers")
 endif ()
 
 set(USE_SOUP 1)