Title: [143009] trunk/Source/WebCore
Revision
143009
Author
[email protected]
Date
2013-02-15 09:09:46 -0800 (Fri, 15 Feb 2013)

Log Message

[Soup] Leverage new soup_cookie_jar_get_cookie_list() API
https://bugs.webkit.org/show_bug.cgi?id=109931

Reviewed by Kenneth Rohde Christiansen.

In several cases, the CookieJarSoup implementation was retrieving / copying ALL the
cookies using soup_cookie_jar_all_cookies() and then using soup_cookie_applies_to_uri()
to filter out cookies it is not interested in. This was inefficient.

In libsoup 2.40, soup_cookie_jar_get_cookie_list() was introduced to retrieve only the
cookies that apply to a given URI. This patch leverages this new API in CookieJarSoup's
getRawCookies() and deleteCookie(). This way, only the cookies we are interested in
are retrieved and copied. Libsoup does not need to iterate over all the cookies itself
because it keeps the cookies in a hash table using the host names as key.

No new tests, no behavior change.

* platform/network/soup/CookieJarSoup.cpp:
(WebCore::getRawCookies):
(WebCore::deleteCookie):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143008 => 143009)


--- trunk/Source/WebCore/ChangeLog	2013-02-15 17:09:32 UTC (rev 143008)
+++ trunk/Source/WebCore/ChangeLog	2013-02-15 17:09:46 UTC (rev 143009)
@@ -1,3 +1,26 @@
+2013-02-15  Christophe Dumez  <[email protected]>
+
+        [Soup] Leverage new soup_cookie_jar_get_cookie_list() API
+        https://bugs.webkit.org/show_bug.cgi?id=109931
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        In several cases, the CookieJarSoup implementation was retrieving / copying ALL the
+        cookies using soup_cookie_jar_all_cookies() and then using soup_cookie_applies_to_uri()
+        to filter out cookies it is not interested in. This was inefficient.
+
+        In libsoup 2.40, soup_cookie_jar_get_cookie_list() was introduced to retrieve only the
+        cookies that apply to a given URI. This patch leverages this new API in CookieJarSoup's
+        getRawCookies() and deleteCookie(). This way, only the cookies we are interested in
+        are retrieved and copied. Libsoup does not need to iterate over all the cookies itself
+        because it keeps the cookies in a hash table using the host names as key.
+
+        No new tests, no behavior change.
+
+        * platform/network/soup/CookieJarSoup.cpp:
+        (WebCore::getRawCookies):
+        (WebCore::deleteCookie):
+
 2013-02-15  Vladislav Kaznacheev  <[email protected]>
 
         Web Inspector: Added an option to split Elements and Sources sidebars in two panes.

Modified: trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp (143008 => 143009)


--- trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp	2013-02-15 17:09:32 UTC (rev 143008)
+++ trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp	2013-02-15 17:09:46 UTC (rev 143009)
@@ -142,15 +142,13 @@
     if (!jar)
         return false;
 
-    GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(jar));
+    GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data()));
+    GOwnPtr<GSList> cookies(soup_cookie_jar_get_cookie_list(jar, uri.get(), TRUE));
     if (!cookies)
         return false;
 
-    GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data()));
     for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) {
         GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(iter->data));
-        if (!soup_cookie_applies_to_uri(cookie.get(), uri.get()))
-            continue;
         rawCookies.append(Cookie(String::fromUTF8(cookie->name), String::fromUTF8(cookie->value), String::fromUTF8(cookie->domain),
                                  String::fromUTF8(cookie->path), static_cast<double>(soup_date_to_time_t(cookie->expires)) * 1000,
                                  cookie->http_only, cookie->secure, soup_cookie_jar_is_persistent(jar)));
@@ -165,16 +163,14 @@
     if (!jar)
         return;
 
-    GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(jar));
+    GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data()));
+    GOwnPtr<GSList> cookies(soup_cookie_jar_get_cookie_list(jar, uri.get(), TRUE));
     if (!cookies)
         return;
 
     CString cookieName = name.utf8();
-    GOwnPtr<SoupURI> uri(soup_uri_new(url.string().utf8().data()));
     for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) {
         GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(iter->data));
-        if (!soup_cookie_applies_to_uri(cookie.get(), uri.get()))
-            continue;
         if (cookieName == cookie->name)
             soup_cookie_jar_delete_cookie(jar, cookie.get());
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to