Title: [228905] trunk/Source
Revision
228905
Author
[email protected]
Date
2018-02-21 16:10:25 -0800 (Wed, 21 Feb 2018)

Log Message

[Curl] Curl Cookie Database File should be configurable using NetworkProcessCreationParameters
https://bugs.webkit.org/show_bug.cgi?id=182751

Patch by Christopher Reid <[email protected]> on 2018-02-21
Reviewed by Youenn Fablet.

Source/WebCore:

No change in behavior.

Adding support to set a custom CookieJar Database.
Took CookieJarDB::open() out of its constructor because both the Network and Web process
were trying to open the journal files but one process was failing due to a lack of permission.
Now the database file is lazily opened and only the Network process will try to open the database.
Some cleanup was done to CookieJarDB too.

* platform/network/NetworkStorageSession.h:
* platform/network/curl/CookieJarDB.cpp:
* platform/network/curl/CookieJarDB.h:
* platform/network/curl/NetworkStorageSessionCurl.cpp:

Source/WebKit:

Adding a cookiePersistentStorageFile parameter to Curl's NetworkProcessCreationParameters.
This parameter is based on Soup's cookiePersistentStoragePath.
This parameter is not used yet, it is added to prepare for WinCairo WebKit support.

* NetworkProcess/NetworkProcessCreationParameters.cpp:
* NetworkProcess/NetworkProcessCreationParameters.h:
* NetworkProcess/curl/NetworkProcessCurl.cpp:
* WebProcess/Cookies/WebCookieManager.h:
* WebProcess/Cookies/curl/WebCookieManagerCurl.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228904 => 228905)


--- trunk/Source/WebCore/ChangeLog	2018-02-22 00:07:33 UTC (rev 228904)
+++ trunk/Source/WebCore/ChangeLog	2018-02-22 00:10:25 UTC (rev 228905)
@@ -1,3 +1,23 @@
+2018-02-21  Christopher Reid  <[email protected]>
+
+        [Curl] Curl Cookie Database File should be configurable using NetworkProcessCreationParameters
+        https://bugs.webkit.org/show_bug.cgi?id=182751
+
+        Reviewed by Youenn Fablet.
+
+        No change in behavior.
+
+        Adding support to set a custom CookieJar Database.
+        Took CookieJarDB::open() out of its constructor because both the Network and Web process
+        were trying to open the journal files but one process was failing due to a lack of permission.
+        Now the database file is lazily opened and only the Network process will try to open the database.
+        Some cleanup was done to CookieJarDB too.
+
+        * platform/network/NetworkStorageSession.h:
+        * platform/network/curl/CookieJarDB.cpp:
+        * platform/network/curl/CookieJarDB.h:
+        * platform/network/curl/NetworkStorageSessionCurl.cpp:
+
 2018-02-21  Chris Dumez  <[email protected]>
 
         Regression(r228708): Crash under WebCore::MediaResource::responseReceived(WebCore::CachedResource&, WebCore::ResourceResponse const&)

Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (228904 => 228905)


--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h	2018-02-22 00:07:33 UTC (rev 228904)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h	2018-02-22 00:10:25 UTC (rev 228905)
@@ -127,7 +127,8 @@
     ~NetworkStorageSession();
 
     const CookieJarCurl& cookieStorage() const { return m_cookieStorage; };
-    CookieJarDB& cookieDatabase() const { return m_cookieDatabase; };
+    CookieJarDB& cookieDatabase() const;
+    void setCookieDatabase(UniqueRef<CookieJarDB>&&) const;
 
     NetworkingContext* context() const;
 #else
@@ -165,7 +166,7 @@
     RefPtr<NetworkingContext> m_context;
 
     UniqueRef<CookieJarCurl> m_cookieStorage;
-    mutable CookieJarDB m_cookieDatabase;
+    mutable UniqueRef<CookieJarDB> m_cookieDatabase;
 #else
     RefPtr<NetworkingContext> m_context;
 #endif

Modified: trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp (228904 => 228905)


--- trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp	2018-02-22 00:07:33 UTC (rev 228904)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp	2018-02-22 00:10:25 UTC (rev 228905)
@@ -26,6 +26,8 @@
 #include "CookieJarDB.h"
 
 #include "CookieUtil.h"
+#include "FileSystem.h"
+#include "Logging.h"
 #include "SQLiteFileSystem.h"
 #include "URL.h"
 
@@ -69,16 +71,12 @@
 
 void CookieJarDB::setEnabled(bool enable)
 {
-    CookieJarDB::m_cookieEnable = enable;
+    m_isEnabled = enable;
 }
 
 CookieJarDB::CookieJarDB(const String& databasePath)
     : m_databasePath(databasePath)
 {
-    checkDatabaseCorruptionAndRemoveIfNeeded();
-
-    if (!openDatabase())
-        return;
 }
 
 CookieJarDB::~CookieJarDB()
@@ -86,6 +84,14 @@
     closeDatabase();
 }
 
+void CookieJarDB::open()
+{
+    if (!m_database.isOpen()) {
+        checkDatabaseCorruptionAndRemoveIfNeeded();
+        openDatabase();
+    }
+}
+
 bool CookieJarDB::openDatabase()
 {
     if (m_database.isOpen())
@@ -112,6 +118,9 @@
     }
 
     if (!existsDatabaseFile) {
+        if (!FileSystem::makeAllDirectories(FileSystem::directoryName(m_databasePath)))
+            LOG_ERROR("Unable to create the Cookie Database path %s", m_databasePath.utf8().data());
+
         if (m_database.open(m_databasePath, false)) {
             bool databaseValidity = true;
             databaseValidity &= (executeSimpleSql(CREATE_COOKIE_TABLE_SQL) == SQLITE_DONE);
@@ -230,7 +239,7 @@
     if (m_databasePath.isEmpty())
         return false;
 
-    return m_cookieEnable;
+    return m_isEnabled;
 }
 
 bool CookieJarDB::searchCookies(const String& requestUrl, const std::optional<bool>& httpOnly, const std::optional<bool>& secure, const std::optional<bool>& session, Vector<Cookie>& results)

Modified: trunk/Source/WebCore/platform/network/curl/CookieJarDB.h (228904 => 228905)


--- trunk/Source/WebCore/platform/network/curl/CookieJarDB.h	2018-02-22 00:07:33 UTC (rev 228904)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarDB.h	2018-02-22 00:10:25 UTC (rev 228905)
@@ -40,6 +40,7 @@
     WTF_MAKE_NONCOPYABLE(CookieJarDB);
 
 public:
+    void open();
     bool isEnabled();
     void setEnabled(bool);
 
@@ -56,7 +57,7 @@
 
 private:
 
-    bool m_cookieEnable {true};
+    bool m_isEnabled {true};
     String m_databasePath;
 
     bool m_detectedDatabaseCorruption {false};

Modified: trunk/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp (228904 => 228905)


--- trunk/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp	2018-02-22 00:07:33 UTC (rev 228904)
+++ trunk/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp	2018-02-22 00:10:25 UTC (rev 228905)
@@ -48,12 +48,7 @@
     if (cookieJarPath)
         return cookieJarPath;
 
-    String cookieJarDirectory = FileSystem::localUserSpecificStorageDirectory();
-
-    if (!FileSystem::makeAllDirectories(cookieJarDirectory))
-        return defaultFileName;
-
-    return FileSystem::pathByAppendingComponent(cookieJarDirectory, defaultFileName);
+    return FileSystem::pathByAppendingComponent(FileSystem::localUserSpecificStorageDirectory(), defaultFileName);
 }
 
 NetworkStorageSession::NetworkStorageSession(PAL::SessionID sessionID, NetworkingContext* context)
@@ -60,7 +55,7 @@
     : m_sessionID(sessionID)
     , m_context(context)
     , m_cookieStorage(makeUniqueRef<CookieJarCurlDatabase>())
-    , m_cookieDatabase(defaultCookieJarPath())
+    , m_cookieDatabase(makeUniqueRef<CookieJarDB>(defaultCookieJarPath()))
 {
 }
 
@@ -73,6 +68,17 @@
     return m_context.get();
 }
 
+void NetworkStorageSession::setCookieDatabase(UniqueRef<CookieJarDB>&& cookieDatabase) const
+{
+    m_cookieDatabase = WTFMove(cookieDatabase);
+}
+
+CookieJarDB& NetworkStorageSession::cookieDatabase() const
+{
+    m_cookieDatabase->open();
+    return m_cookieDatabase;
+}
+
 static std::unique_ptr<NetworkStorageSession>& defaultSession()
 {
     ASSERT(isMainThread());

Modified: trunk/Source/WebKit/ChangeLog (228904 => 228905)


--- trunk/Source/WebKit/ChangeLog	2018-02-22 00:07:33 UTC (rev 228904)
+++ trunk/Source/WebKit/ChangeLog	2018-02-22 00:10:25 UTC (rev 228905)
@@ -1,3 +1,20 @@
+2018-02-21  Christopher Reid  <[email protected]>
+
+        [Curl] Curl Cookie Database File should be configurable using NetworkProcessCreationParameters
+        https://bugs.webkit.org/show_bug.cgi?id=182751
+
+        Reviewed by Youenn Fablet.
+
+        Adding a cookiePersistentStorageFile parameter to Curl's NetworkProcessCreationParameters.
+        This parameter is based on Soup's cookiePersistentStoragePath.
+        This parameter is not used yet, it is added to prepare for WinCairo WebKit support.
+
+        * NetworkProcess/NetworkProcessCreationParameters.cpp:
+        * NetworkProcess/NetworkProcessCreationParameters.h:
+        * NetworkProcess/curl/NetworkProcessCurl.cpp:
+        * WebProcess/Cookies/WebCookieManager.h:
+        * WebProcess/Cookies/curl/WebCookieManagerCurl.cpp:
+
 2018-02-21  Brian Burg  <[email protected]>
 
         [Cocoa] Web Automation: provide a way to ask clients the type of a _javascript_ dialog

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp (228904 => 228905)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp	2018-02-22 00:07:33 UTC (rev 228904)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp	2018-02-22 00:10:25 UTC (rev 228905)
@@ -94,6 +94,8 @@
     encoder << ignoreTLSErrors;
     encoder << languages;
     encoder << proxySettings;
+#elif USE(CURL)
+    encoder << cookiePersistentStorageFile;
 #endif
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
     encoder << logCookieInformation;
@@ -228,6 +230,9 @@
         return false;
     if (!decoder.decode(result.proxySettings))
         return false;
+#elif USE(CURL)
+    if (!decoder.decode(result.cookiePersistentStorageFile))
+        return false;
 #endif
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h (228904 => 228905)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h	2018-02-22 00:07:33 UTC (rev 228904)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h	2018-02-22 00:10:25 UTC (rev 228905)
@@ -108,6 +108,8 @@
     bool ignoreTLSErrors { false };
     Vector<String> languages;
     WebCore::SoupNetworkProxySettings proxySettings;
+#elif USE(CURL)
+    String cookiePersistentStorageFile;
 #endif
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED

Modified: trunk/Source/WebKit/NetworkProcess/curl/NetworkProcessCurl.cpp (228904 => 228905)


--- trunk/Source/WebKit/NetworkProcess/curl/NetworkProcessCurl.cpp	2018-02-22 00:07:33 UTC (rev 228904)
+++ trunk/Source/WebKit/NetworkProcess/curl/NetworkProcessCurl.cpp	2018-02-22 00:10:25 UTC (rev 228905)
@@ -45,7 +45,8 @@
 
 void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters& parameters)
 {
-    notImplemented();
+    if (!parameters.cookiePersistentStorageFile.isEmpty())
+        supplement<WebCookieManager>()->setCookiePersistentStorage(parameters.cookiePersistentStorageFile);
 }
 
 void NetworkProcess::platformSetURLCacheSize(unsigned, uint64_t)

Modified: trunk/Source/WebKit/WebProcess/Cookies/WebCookieManager.h (228904 => 228905)


--- trunk/Source/WebKit/WebProcess/Cookies/WebCookieManager.h	2018-02-22 00:07:33 UTC (rev 228904)
+++ trunk/Source/WebKit/WebProcess/Cookies/WebCookieManager.h	2018-02-22 00:10:25 UTC (rev 228905)
@@ -60,6 +60,8 @@
 
 #if USE(SOUP)
     void setCookiePersistentStorage(const String& storagePath, uint32_t storageType);
+#elif USE(CURL)
+    void setCookiePersistentStorage(const String& storagePath);
 #endif
 
     void notifyCookiesDidChange(PAL::SessionID);

Modified: trunk/Source/WebKit/WebProcess/Cookies/curl/WebCookieManagerCurl.cpp (228904 => 228905)


--- trunk/Source/WebKit/WebProcess/Cookies/curl/WebCookieManagerCurl.cpp	2018-02-22 00:07:33 UTC (rev 228904)
+++ trunk/Source/WebKit/WebProcess/Cookies/curl/WebCookieManagerCurl.cpp	2018-02-22 00:10:25 UTC (rev 228905)
@@ -27,6 +27,7 @@
 #include "WebCookieManager.h"
 
 #include "ChildProcess.h"
+#include <WebCore/CookieJarDB.h>
 #include <WebCore/NetworkStorageSession.h>
 #include <wtf/text/CString.h>
 
@@ -43,4 +44,10 @@
     return HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
 }
 
+void WebCookieManager::setCookiePersistentStorage(const String& storagePath)
+{
+    auto& storageSession = NetworkStorageSession::defaultStorageSession();
+    storageSession.setCookieDatabase(makeUniqueRef<CookieJarDB>(storagePath));
+}
+
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to