<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:mcatanzaro&#64;igalia.com" title="Michael Catanzaro &lt;mcatanzaro&#64;igalia.com&gt;"> <span class="fn">Michael Catanzaro</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK] Update cookie manager API to properly work with ephemeral sessions"
   href="https://bugs.webkit.org/show_bug.cgi?id=168230">bug 168230</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #301345 Flags</td>
           <td>review?
           </td>
           <td>review-
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK] Update cookie manager API to properly work with ephemeral sessions"
   href="https://bugs.webkit.org/show_bug.cgi?id=168230#c2">Comment # 2</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK] Update cookie manager API to properly work with ephemeral sessions"
   href="https://bugs.webkit.org/show_bug.cgi?id=168230">bug 168230</a>
              from <span class="vcard"><a class="email" href="mailto:mcatanzaro&#64;igalia.com" title="Michael Catanzaro &lt;mcatanzaro&#64;igalia.com&gt;"> <span class="fn">Michael Catanzaro</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=301345&amp;action=diff" name="attach_301345" title="Patch">attachment 301345</a> <a href="attachment.cgi?id=301345&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=301345&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=301345&amp;action=review</a>

It looks mostly good, but I'd like to review this one again after you answer my questions about why you used the weak pointer, which I hope was just a mistake.

<span class="quote">&gt; Source/WebCore/platform/network/soup/CookieJarSoup.cpp:217
&gt; +    // FIXME: Add support for deleting cookies modified since the given timestamp. It should probably be added to libsoup.
&gt; +    if (timestamp == std::chrono::system_clock::from_time_t(0))
&gt; +        deleteAllCookies(session);</span >

Are you planning to fix this soon? I don't think we should proceed with these API changes if the API does not work properly. At least add a runtime warning using g_warning().

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp:40
&gt; + * The WebKitCookieManager defines how to setup and handle cookies.</span >

setup (noun) -&gt; set up (verb)

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp:43
&gt;   * store cookies, with webkit_cookie_manager_set_persistent_storage(),</span >

Remove the comma

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp:144
&gt; +    g_object_add_weak_pointer(G_OBJECT(dataManager), reinterpret_cast&lt;void**&gt;(&amp;manager-&gt;priv-&gt;dataManager));</span >

Why is the weak pointer needed? I would expect WebKitCookieManager to be owned by the WebKitWebsiteDataManager, so WebKitWebsiteDataManager would keep a ref to ensure the WebKitCookieManager is never destroyed first. Is there some really good reason you don't do that? I think it should be a normal raw pointer instead.

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp:165
&gt;   * By default, &#64;cookie_manager doesn't store the cookies persistenly, so you need to call this</span >

Preexisting problem, but let's fix it now: persistenly -&gt; persistently

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp:176
&gt; +    for (auto* processPool : webkitWebsiteDataManagerGetProcessPools(manager-&gt;priv-&gt;dataManager)) {</span >

This is a big problem. Either manager-&gt;priv-&gt;dataManager can be legitimately null here, or you should not have used a weak pointer.

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp:197
&gt; +    g_return_if_fail(WEBKIT_IS_WEBSITE_DATA_MANAGER(manager-&gt;priv-&gt;dataManager));</span >

Ditto. If you're going to use the weak pointer, then the entire class needs to be prepared to deal with the WebKitWebsiteDataManager being null. There's no point to the weak pointer otherwise.

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp:82
&gt;   * webkit_web_context_get_security_manager() for that.</span >

Remove &quot;for that&quot;: the sentence works better without them.

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp:698
&gt;  WebKitCookieManager* webkit_web_context_get_cookie_manager(WebKitWebContext* context)</span >

I think you should document that this function returns the WebKitCookieManager of this context's WebKitWebsiteDataManager. I know it's an implementation detail, but otherwise I think it's kind of confusing why both WebKitWebContext and WebKitWebsiteDataManager have a WebKitCookieManager.

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp:2286
&gt; + * Get the #WebKitWebsiteDataManager associated to &#64;web_view. If &#64;web_view is not ephemeral</span >

Add a comma after &quot;ephemeral&quot;

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp:2287
&gt; + * the returned #WebKitWebsiteDataManager will be the same as the #WebKitWebView:web-context one.</span >

&quot;the #WebKitWebView:web-context one&quot; doesn't sound great. I would write: &quot;will be the same as the #WebKitWebsiteDataManager of &#64;web_view's #WebKitWebContext.&quot;

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitWebsiteDataManager.cpp:103
&gt; +    GRefPtr&lt;WebKitCookieManager&gt; cookieManager;</span >

Aha, so you do keep a ref! Good! Then you don't need the weak pointer in WebKitCookieManager, right? Surely the WebKitCookieManager cannot outlive the WebKitWebsiteDataManager due to this ref.

<span class="quote">&gt; Source/WebKit2/UIProcess/API/gtk/WebKitWebsiteDataManager.cpp:104
&gt; +    Vector&lt;WebProcessPool*&gt; processPools;</span >

Is it possible to use Vector&lt;WebProcessPool&amp;&gt; to clarify that the process pools are not null?

<span class="quote">&gt; Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.cpp:54
&gt; +#if PLATFORM(GTK)
&gt; +    if (hostName == &quot;localhost&quot;)
&gt; +        return hostName;
&gt; +#endif</span >

I think this should be an #else condition, not a GTK-specific condition.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>