<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>101272</bug_id>
          
          <creation_ts>2012-11-05 15:58:44 -0800</creation_ts>
          <short_desc>[Qt] Implement deleteCookie() for persistent storage</short_desc>
          <delta_ts>2012-11-07 09:39:49 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sergio Villar Senin">svillar</reporter>
          <assigned_to name="Sergio Villar Senin">svillar</assigned_to>
          <cc>hausmann</cc>
    
    <cc>jturcotte</cc>
    
    <cc>menard</cc>
    
    <cc>rwlbuis</cc>
    
    <cc>svillar</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>758979</commentid>
    <comment_count>0</comment_count>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2012-11-05 15:58:44 -0800</bug_when>
    <thetext>[Qt] Implement deleteCookie() for persistent storage</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>758983</commentid>
    <comment_count>1</comment_count>
      <attachid>172426</attachid>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2012-11-05 16:06:47 -0800</bug_when>
    <thetext>Created attachment 172426
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>759429</commentid>
    <comment_count>2</comment_count>
      <attachid>172426</attachid>
    <who name="Jocelyn Turcotte">jturcotte</who>
    <bug_when>2012-11-06 02:07:40 -0800</bug_when>
    <thetext>Comment on attachment 172426
Patch

Oh, nice catch!
There are some issues I could see related to this:
- Before we had one prepared statement in setCookiesFromUrl and would iterate on each added cookie with it. Now since setCookiesFromUrl calls deleteCookie for each cookie, we&apos;ll end up preparing and executing an additional query for every cookie add/update.
- Another thing is if we have both a valid and an expired cookie passed to setCookiesFromUrl. deleteCookie will be called for both, but since QNetworkCookieJar::setCookiesFromUrl will return true we&apos;ll end up re-adding the expired cookie to the DB in SharedCookieJarQt::setCookiesFromUrl.
- If we do it that way, we should use INSERT instead of INSERT OR REPLACE in SharedCookieJarQt::setCookiesFromUrl

Would it be possible to do the deletion after the insert/replace in SharedCookieJarQt::setCookiesFromUrl instead?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>759896</commentid>
    <comment_count>3</comment_count>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2012-11-06 11:12:22 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; (From update of attachment 172426 [details])
&gt; Oh, nice catch!
&gt; There are some issues I could see related to this:
&gt; - Before we had one prepared statement in setCookiesFromUrl and would iterate on each added cookie with it. Now since setCookiesFromUrl calls deleteCookie for each cookie, we&apos;ll end up preparing and executing an additional query for every cookie add/update.

That&apos;s true, but I think that&apos;s unavoidable due to the implementation of the QNetworkCookieJar. Anyway I don&apos;t see any performance penalty on that as cookies should be a negligible part of the total load time.

&gt; - Another thing is if we have both a valid and an expired cookie passed to setCookiesFromUrl. deleteCookie will be called for both, but since QNetworkCookieJar::setCookiesFromUrl will return true we&apos;ll end up re-adding the expired cookie to the DB in SharedCookieJarQt::setCookiesFromUrl.

Not really, note that in the loop that builds the cookie ids in SharedCookieJarQt::setCookiesFromUrl(), we check for isSessionCookie() which means that only the cookies added to the QtNetwokCookieJar will be stored in the database.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>760125</commentid>
    <comment_count>4</comment_count>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2012-11-06 15:44:12 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; &gt; - Another thing is if we have both a valid and an expired cookie passed to setCookiesFromUrl. deleteCookie will be called for both, but since QNetworkCookieJar::setCookiesFromUrl will return true we&apos;ll end up re-adding the expired cookie to the DB in SharedCookieJarQt::setCookiesFromUrl.
&gt; 
&gt; Not really, note that in the loop that builds the cookie ids in SharedCookieJarQt::setCookiesFromUrl(), we check for isSessionCookie() which means that only the cookies added to the QtNetwokCookieJar will be stored in the database.

Beh, forget about this last comment which is totally wrong (I got misled by the session thing). The case you mention (cookies rejected by the QNetworkCookieJar but added to the DB) cannot happen because the loop does not iterate over the original list but over the accepted cookies:

    foreach (const QNetworkCookie &amp;cookie, cookiesForUrl(url)) {

so we&apos;ll only store the ones accepted by the QNetworkCookieJar anyway.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>760510</commentid>
    <comment_count>5</comment_count>
    <who name="Jocelyn Turcotte">jturcotte</who>
    <bug_when>2012-11-07 03:47:47 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; That&apos;s true, but I think that&apos;s unavoidable due to the implementation of the QNetworkCookieJar. Anyway I don&apos;t see any performance penalty on that as cookies should be a negligible part of the total load time.

I&apos;m being a bit paranoiac but this is disk IO and can easily become a bottleneck when the data grows bigger. I did some tests with a cookies.db containing 20000 cookies and our INSERT OR REPLACE statement already take 10ms on my desktop for every call to setCookiesFromUrl. It&apos;s going to be even slower on cheaper embedded devices so it could add half a second to the load time in some circumstances.

I tried and the delete seems to be pretty quick even if the database is full so it&apos;s fine.

(In reply to comment #4)
&gt; Beh, forget about this last comment which is totally wrong (I got misled by the session thing). The case you mention (cookies rejected by the QNetworkCookieJar but added to the DB) cannot happen because the loop does not iterate over the original list but over the accepted cookies:
&gt; 
&gt;     foreach (const QNetworkCookie &amp;cookie, cookiesForUrl(url)) {
&gt; 
&gt; so we&apos;ll only store the ones accepted by the QNetworkCookieJar anyway.

Ahh yep you&apos;re right, I didn&apos;t see that cookiesForUrl(url), sorry for spreading my wrong assumptions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>760781</commentid>
    <comment_count>6</comment_count>
      <attachid>172426</attachid>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2012-11-07 09:39:46 -0800</bug_when>
    <thetext>Comment on attachment 172426
Patch

Clearing flags on attachment: 172426

Committed r133770: &lt;http://trac.webkit.org/changeset/133770&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>760782</commentid>
    <comment_count>7</comment_count>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2012-11-07 09:39:49 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>172426</attachid>
            <date>2012-11-05 16:06:47 -0800</date>
            <delta_ts>2012-11-07 09:39:46 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-101272-20121105160501.patch</filename>
            <type>text/plain</type>
            <size>2734</size>
            <attacher name="Sergio Villar Senin">svillar</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTMzNDk3CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggNmZkMTE5NjhjM2U0OTky
ZDRlN2FmNjRhNTYwNTFlN2U0NTk0NGJmYy4uYjMxZThiYjE1NTE2OTAxOWQxYTVhY2QxODY4MTQ4
OTk1OGJmZGZhYiAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDIyIEBACisyMDEyLTExL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