Title: [220351] trunk/Source/WebCore
Revision
220351
Author
commit-qu...@webkit.org
Date
2017-08-07 13:58:50 -0700 (Mon, 07 Aug 2017)

Log Message

[Curl] Add abstraction layer of cookie jar implementation for Curl port
https://bugs.webkit.org/show_bug.cgi?id=174943

Patch by Basuke Suzuki <basuke.suz...@sony.com> on 2017-08-07
Reviewed by Brent Fulgham.

* platform/network/curl/CookieJarCurl.cpp:
(WebCore::CookieJarCurlFileSystem::setCookiesFromDOM):
(WebCore::CookieJarCurlFileSystem::cookiesForDOM):
(WebCore::CookieJarCurlFileSystem::cookieRequestHeaderFieldValue):
(WebCore::CookieJarCurlFileSystem::cookiesEnabled):
(WebCore::CookieJarCurlFileSystem::getRawCookies):
(WebCore::CookieJarCurlFileSystem::deleteCookie):
(WebCore::CookieJarCurlFileSystem::getHostnamesWithCookies):
(WebCore::CookieJarCurlFileSystem::deleteCookiesForHostnames):
(WebCore::CookieJarCurlFileSystem::deleteAllCookies):
(WebCore::CookieJarCurlFileSystem::deleteAllCookiesModifiedSince):
(WebCore::cookiesForDOM):
(WebCore::setCookiesFromDOM):
(WebCore::cookieRequestHeaderFieldValue):
(WebCore::cookiesEnabled):
(WebCore::getRawCookies):
(WebCore::deleteCookie):
(WebCore::getHostnamesWithCookies):
(WebCore::deleteCookiesForHostnames):
(WebCore::deleteAllCookies):
(WebCore::deleteAllCookiesModifiedSince):
* platform/network/curl/CookieJarCurl.h: Added.
* platform/network/curl/CurlContext.cpp:
* platform/network/curl/CurlContext.h:
(WebCore::CurlContext::cookieJar):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (220350 => 220351)


--- trunk/Source/WebCore/ChangeLog	2017-08-07 20:30:24 UTC (rev 220350)
+++ trunk/Source/WebCore/ChangeLog	2017-08-07 20:58:50 UTC (rev 220351)
@@ -1,3 +1,36 @@
+2017-08-07  Basuke Suzuki  <basuke.suz...@sony.com>
+
+        [Curl] Add abstraction layer of cookie jar implementation for Curl port
+        https://bugs.webkit.org/show_bug.cgi?id=174943
+
+        Reviewed by Brent Fulgham.
+
+        * platform/network/curl/CookieJarCurl.cpp:
+        (WebCore::CookieJarCurlFileSystem::setCookiesFromDOM):
+        (WebCore::CookieJarCurlFileSystem::cookiesForDOM):
+        (WebCore::CookieJarCurlFileSystem::cookieRequestHeaderFieldValue):
+        (WebCore::CookieJarCurlFileSystem::cookiesEnabled):
+        (WebCore::CookieJarCurlFileSystem::getRawCookies):
+        (WebCore::CookieJarCurlFileSystem::deleteCookie):
+        (WebCore::CookieJarCurlFileSystem::getHostnamesWithCookies):
+        (WebCore::CookieJarCurlFileSystem::deleteCookiesForHostnames):
+        (WebCore::CookieJarCurlFileSystem::deleteAllCookies):
+        (WebCore::CookieJarCurlFileSystem::deleteAllCookiesModifiedSince):
+        (WebCore::cookiesForDOM):
+        (WebCore::setCookiesFromDOM):
+        (WebCore::cookieRequestHeaderFieldValue):
+        (WebCore::cookiesEnabled):
+        (WebCore::getRawCookies):
+        (WebCore::deleteCookie):
+        (WebCore::getHostnamesWithCookies):
+        (WebCore::deleteCookiesForHostnames):
+        (WebCore::deleteAllCookies):
+        (WebCore::deleteAllCookiesModifiedSince):
+        * platform/network/curl/CookieJarCurl.h: Added.
+        * platform/network/curl/CurlContext.cpp:
+        * platform/network/curl/CurlContext.h:
+        (WebCore::CurlContext::cookieJar):
+
 2017-08-07  Brady Eidson  <beid...@apple.com>
 
         Implement most of ServiceWorkerContainer::addRegistration.

Modified: trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp (220350 => 220351)


--- trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp	2017-08-07 20:30:24 UTC (rev 220350)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp	2017-08-07 20:58:50 UTC (rev 220351)
@@ -17,10 +17,9 @@
  */
 
 #include "config.h"
-#include "PlatformCookieJar.h"
+#include "CookieJarCurl.h"
 
 #if USE(CURL)
-
 #include "Cookie.h"
 #include "CurlContext.h"
 #include "NotImplemented.h"
@@ -240,7 +239,7 @@
     return cookieStr.toString();
 }
 
-void setCookiesFromDOM(const NetworkStorageSession&, const URL&, const URL& url, const String& value)
+void CookieJarCurlFileSystem::setCookiesFromDOM(const NetworkStorageSession&, const URL& firstParty, const URL& url, const String& value)
 {
     CurlHandle curlHandle;
 
@@ -288,22 +287,22 @@
     return cookies;
 }
 
-String cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+String CookieJarCurlFileSystem::cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
 {
     return cookiesForSession(session, firstParty, url, false);
 }
 
-String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+String CookieJarCurlFileSystem::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
 {
     return cookiesForSession(session, firstParty, url, true);
 }
 
-bool cookiesEnabled(const NetworkStorageSession&, const URL& /*firstParty*/, const URL& /*url*/)
+bool CookieJarCurlFileSystem::cookiesEnabled(const NetworkStorageSession&, const URL& firstParty, const URL&)
 {
     return true;
 }
 
-bool getRawCookies(const NetworkStorageSession&, const URL& /*firstParty*/, const URL& /*url*/, Vector<Cookie>& rawCookies)
+bool CookieJarCurlFileSystem::getRawCookies(const NetworkStorageSession&, const URL& firstParty, const URL&, Vector<Cookie>& rawCookies)
 {
     // FIXME: Not yet implemented
     rawCookies.clear();
@@ -310,31 +309,83 @@
     return false; // return true when implemented
 }
 
-void deleteCookie(const NetworkStorageSession&, const URL&, const String&)
+void CookieJarCurlFileSystem::deleteCookie(const NetworkStorageSession&, const URL&, const String&)
 {
     // FIXME: Not yet implemented
 }
 
-void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>&)
+void CookieJarCurlFileSystem::getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteCookiesForHostnames(const NetworkStorageSession&, const Vector<String>&)
+void CookieJarCurlFileSystem::deleteCookiesForHostnames(const NetworkStorageSession&, const Vector<String>& cookieHostNames)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteAllCookies(const NetworkStorageSession&)
+void CookieJarCurlFileSystem::deleteAllCookies(const NetworkStorageSession&)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteAllCookiesModifiedSince(const NetworkStorageSession&, std::chrono::system_clock::time_point)
+void CookieJarCurlFileSystem::deleteAllCookiesModifiedSince(const NetworkStorageSession&, std::chrono::system_clock::time_point)
 {
     // FIXME: Not yet implemented
 }
 
+// dispatcher functions
+
+String cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+{
+    return CurlContext::singleton().cookieJar().cookiesForDOM(session, firstParty, url);
 }
 
+void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url, const String& value)
+{
+    CurlContext::singleton().cookieJar().setCookiesFromDOM(session, firstParty, url, value);
+}
+
+String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+{
+    return CurlContext::singleton().cookieJar().cookieRequestHeaderFieldValue(session, firstParty, url);
+}
+
+bool cookiesEnabled(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+{
+    return CurlContext::singleton().cookieJar().cookiesEnabled(session, firstParty, url);
+}
+
+bool getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const URL& url, Vector<Cookie>& rawCookies)
+{
+    return CurlContext::singleton().cookieJar().getRawCookies(session, firstParty, url, rawCookies);
+}
+
+void deleteCookie(const NetworkStorageSession& session, const URL& url, const String& cookie)
+{
+    CurlContext::singleton().cookieJar().deleteCookie(session, url, cookie);
+}
+
+void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
+{
+    CurlContext::singleton().cookieJar().getHostnamesWithCookies(session, hostnames);
+}
+
+void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vector<String>& cookieHostNames)
+{
+    CurlContext::singleton().cookieJar().deleteCookiesForHostnames(session, cookieHostNames);
+}
+
+void deleteAllCookies(const NetworkStorageSession& session)
+{
+    CurlContext::singleton().cookieJar().deleteAllCookies(session);
+}
+
+void deleteAllCookiesModifiedSince(const NetworkStorageSession& session, std::chrono::system_clock::time_point since)
+{
+    CurlContext::singleton().cookieJar().deleteAllCookiesModifiedSince(session, since);
+}
+
+}
+
 #endif

Added: trunk/Source/WebCore/platform/network/curl/CookieJarCurl.h (0 => 220351)


--- trunk/Source/WebCore/platform/network/curl/CookieJarCurl.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarCurl.h	2017-08-07 20:58:50 UTC (rev 220351)
@@ -0,0 +1,56 @@
+/*
+* Copyright (C) 2017 Sony Interactive Entertainment Inc.
+*
+*  This library is free software; you can redistribute it and/or
+*  modify it under the terms of the GNU Lesser General Public
+*  License as published by the Free Software Foundation; either
+*  version 2 of the License, or (at your option) any later version.
+*
+*  This library is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+*  Lesser General Public License for more details.
+*
+*  You should have received a copy of the GNU Lesser General Public
+*  License along with this library; if not, write to the Free Software
+*  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#pragma once
+
+#include "PlatformCookieJar.h"
+
+namespace WebCore {
+
+class Cookie;
+class NetworkStorageSession;
+class URL;
+
+class CookieJarCurl {
+public:
+    virtual String cookiesForDOM(const NetworkStorageSession&, const URL& firstParty, const URL&) = 0;
+    virtual void setCookiesFromDOM(const NetworkStorageSession&, const URL& firstParty, const URL&, const String&) = 0;
+    virtual bool cookiesEnabled(const NetworkStorageSession&, const URL& firstParty, const URL&) = 0;
+    virtual String cookieRequestHeaderFieldValue(const NetworkStorageSession&, const URL& firstParty, const URL&) = 0;
+    virtual bool getRawCookies(const NetworkStorageSession&, const URL& firstParty, const URL&, Vector<Cookie>&) = 0;
+    virtual void deleteCookie(const NetworkStorageSession&, const URL&, const String&) = 0;
+    virtual void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames) = 0;
+    virtual void deleteCookiesForHostnames(const NetworkStorageSession&, const Vector<String>& cookieHostNames) = 0;
+    virtual void deleteAllCookies(const NetworkStorageSession&) = 0;
+    virtual void deleteAllCookiesModifiedSince(const NetworkStorageSession&, std::chrono::system_clock::time_point) = 0;
+};
+
+class CookieJarCurlFileSystem : public CookieJarCurl {
+    String cookiesForDOM(const NetworkStorageSession&, const URL& firstParty, const URL&) override;
+    void setCookiesFromDOM(const NetworkStorageSession&, const URL& firstParty, const URL&, const String&) override;
+    bool cookiesEnabled(const NetworkStorageSession&, const URL& firstParty, const URL&) override;
+    String cookieRequestHeaderFieldValue(const NetworkStorageSession&, const URL& firstParty, const URL&) override;
+    bool getRawCookies(const NetworkStorageSession&, const URL& firstParty, const URL&, Vector<Cookie>&) override;
+    void deleteCookie(const NetworkStorageSession&, const URL&, const String&) override;
+    void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames) override;
+    void deleteCookiesForHostnames(const NetworkStorageSession&, const Vector<String>& cookieHostNames) override;
+    void deleteAllCookies(const NetworkStorageSession&) override;
+    void deleteAllCookiesModifiedSince(const NetworkStorageSession&, std::chrono::system_clock::time_point) override;
+};
+
+}

Modified: trunk/Source/WebCore/platform/network/curl/CurlContext.cpp (220350 => 220351)


--- trunk/Source/WebCore/platform/network/curl/CurlContext.cpp	2017-08-07 20:30:24 UTC (rev 220350)
+++ trunk/Source/WebCore/platform/network/curl/CurlContext.cpp	2017-08-07 20:58:50 UTC (rev 220351)
@@ -106,6 +106,7 @@
 CurlContext::CurlContext()
 : m_cookieJarFileName { cookieJarPath() }
 , m_certificatePath { certificatePath() }
+, m_cookieJar { std::make_unique<CookieJarCurlFileSystem>() }
 {
     initCookieSession();
 

Modified: trunk/Source/WebCore/platform/network/curl/CurlContext.h (220350 => 220351)


--- trunk/Source/WebCore/platform/network/curl/CurlContext.h	2017-08-07 20:30:24 UTC (rev 220350)
+++ trunk/Source/WebCore/platform/network/curl/CurlContext.h	2017-08-07 20:58:50 UTC (rev 220351)
@@ -26,6 +26,7 @@
 
 #pragma once
 
+#include "CookieJarCurl.h"
 #include "URL.h"
 
 #include <wtf/Lock.h>
@@ -117,6 +118,7 @@
     // Cookie
     const char* getCookieJarFileName() const { return m_cookieJarFileName.data(); }
     void setCookieJarFileName(const char* cookieJarFileName) { m_cookieJarFileName = CString(cookieJarFileName); }
+    CookieJarCurl& cookieJar() { return *m_cookieJar; }
 
     // Certificate
     const char* getCertificatePath() const { return m_certificatePath.data(); }
@@ -137,6 +139,7 @@
     CString m_cookieJarFileName;
     CString m_certificatePath;
     CurlShareHandle m_shareHandle;
+    std::unique_ptr<CookieJarCurl> m_cookieJar;
     bool m_ignoreSSLErrors { false };
 
     CurlContext();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to