<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[177032] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/177032">177032</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2014-12-09 12:29:59 -0800 (Tue, 09 Dec 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement clearing of cookies
https://bugs.webkit.org/show_bug.cgi?id=139455

Reviewed by Andreas Kling.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::deleteWebsiteData):
Handle deleting cookies by finding the right network storage session and deleting the cookies from it.
Then, send a DidDeleteWebsiteData message back.

* NetworkProcess/NetworkProcess.h:
Add new members.

* NetworkProcess/NetworkProcess.messages.in:
Add new DeleteWebsiteData message.

* Shared/WebsiteData/WebsiteDataTypes.h:
Move the website data types enum to its own file so it can be shared.

* UIProcess/API/Cocoa/_WKWebsiteDataStore.mm:
(toWebsiteDataTypes):
Update now that WebsiteDataTypes is its own enum.

(-[_WKWebsiteDataStore removeDataOfTypes:modifiedSince:completionHandler:]):
removeDataModifiedSince was renamed to removeData.

* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::generateCallbackID):
Helper function to create a callback ID.

(WebKit::NetworkProcessProxy::~NetworkProcessProxy):
Assert that we have no pending callbacks.

(WebKit::NetworkProcessProxy::deleteWebsiteData):
Put the completion handler in our map and message the network process.

(WebKit::NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch):
Call all completion handlers.

(WebKit::NetworkProcessProxy::didDeleteWebsiteData):
Grab the completion handler and call it.

* UIProcess/Network/NetworkProcessProxy.h:
Add new members.

* UIProcess/Network/NetworkProcessProxy.messages.in:
Add DidDeleteWebsiteData callback.

* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::computeNetworkProcessAccessType):
Helper function that computes the type of process access we'd need for the given mask of
website data types.

(WebKit::WebsiteDataStore::removeData):
Gather all the network processes and message them. Use a callback aggregator object to track callbacks
so we'll call the completion handler once all callbacks have been invoked.

* UIProcess/WebsiteData/WebsiteDataStore.h:
Move WebsiteDataTypes to its own file.

* WebKit2.xcodeproj/project.pbxproj:
Add new files.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkProcesscpp">trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkProcessh">trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkProcessmessagesin">trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKWebsiteDataStoremm">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStore.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessNetworkNetworkProcessProxycpp">trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessNetworkNetworkProcessProxyh">trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessNetworkNetworkProcessProxymessagesin">trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp">trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh">trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/Source/WebKit2/Shared/WebsiteData/</li>
<li><a href="#trunkSourceWebKit2SharedWebsiteDataWebsiteDataTypesh">trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (177031 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-12-09 20:06:57 UTC (rev 177031)
+++ trunk/Source/WebKit2/ChangeLog        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -1,5 +1,70 @@
</span><span class="cx"> 2014-12-09  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Implement clearing of cookies
+        https://bugs.webkit.org/show_bug.cgi?id=139455
+
+        Reviewed by Andreas Kling.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::deleteWebsiteData):
+        Handle deleting cookies by finding the right network storage session and deleting the cookies from it.
+        Then, send a DidDeleteWebsiteData message back.
+
+        * NetworkProcess/NetworkProcess.h:
+        Add new members.
+
+        * NetworkProcess/NetworkProcess.messages.in:
+        Add new DeleteWebsiteData message.
+
+        * Shared/WebsiteData/WebsiteDataTypes.h:
+        Move the website data types enum to its own file so it can be shared.
+
+        * UIProcess/API/Cocoa/_WKWebsiteDataStore.mm:
+        (toWebsiteDataTypes):
+        Update now that WebsiteDataTypes is its own enum.
+
+        (-[_WKWebsiteDataStore removeDataOfTypes:modifiedSince:completionHandler:]):
+        removeDataModifiedSince was renamed to removeData.
+
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::generateCallbackID):
+        Helper function to create a callback ID.
+
+        (WebKit::NetworkProcessProxy::~NetworkProcessProxy):
+        Assert that we have no pending callbacks.
+
+        (WebKit::NetworkProcessProxy::deleteWebsiteData):
+        Put the completion handler in our map and message the network process.
+
+        (WebKit::NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch):
+        Call all completion handlers.
+
+        (WebKit::NetworkProcessProxy::didDeleteWebsiteData):
+        Grab the completion handler and call it.
+
+        * UIProcess/Network/NetworkProcessProxy.h:
+        Add new members.
+
+        * UIProcess/Network/NetworkProcessProxy.messages.in:
+        Add DidDeleteWebsiteData callback.
+
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::computeNetworkProcessAccessType):
+        Helper function that computes the type of process access we'd need for the given mask of
+        website data types.
+
+        (WebKit::WebsiteDataStore::removeData):
+        Gather all the network processes and message them. Use a callback aggregator object to track callbacks
+        so we'll call the completion handler once all callbacks have been invoked.
+
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        Move WebsiteDataTypes to its own file.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add new files.
+
+2014-12-09  Anders Carlsson  &lt;andersca@apple.com&gt;
+
</ins><span class="cx">         Give WebsiteDataStore a unique ID
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=139448
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (177031 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp        2014-12-09 20:06:57 UTC (rev 177031)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -43,8 +43,10 @@
</span><span class="cx"> #include &quot;StatisticsData.h&quot;
</span><span class="cx"> #include &quot;WebContextMessages.h&quot;
</span><span class="cx"> #include &quot;WebCookieManager.h&quot;
</span><ins>+#include &quot;WebsiteDataTypes.h&quot;
</ins><span class="cx"> #include &lt;WebCore/Logging.h&gt;
</span><span class="cx"> #include &lt;WebCore/MemoryPressureHandler.h&gt;
</span><ins>+#include &lt;WebCore/PlatformCookieJar.h&gt;
</ins><span class="cx"> #include &lt;WebCore/ResourceRequest.h&gt;
</span><span class="cx"> #include &lt;WebCore/SessionID.h&gt;
</span><span class="cx"> #include &lt;wtf/RunLoop.h&gt;
</span><span class="lines">@@ -234,6 +236,16 @@
</span><span class="cx">     SessionTracker::destroySession(sessionID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkProcess::deleteWebsiteData(WebCore::SessionID sessionID, uint64_t websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID)
+{
+    if (websiteDataTypes &amp; WebsiteDataTypeCookies) {
+        if (auto* networkStorageSession = SessionTracker::session(sessionID))
+            deleteAllCookiesModifiedSince(*networkStorageSession, modifiedSince);
+    }
+
+    parentProcessConnection()-&gt;send(Messages::NetworkProcessProxy::DidDeleteWebsiteData(callbackID), 0);
+}
+
</ins><span class="cx"> void NetworkProcess::downloadRequest(uint64_t downloadID, const ResourceRequest&amp; request)
</span><span class="cx"> {
</span><span class="cx">     downloadManager().startDownload(downloadID, request);
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (177031 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h        2014-12-09 20:06:57 UTC (rev 177031)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -112,6 +112,9 @@
</span><span class="cx">     void createNetworkConnectionToWebProcess();
</span><span class="cx">     void ensurePrivateBrowsingSession(WebCore::SessionID);
</span><span class="cx">     void destroyPrivateBrowsingSession(WebCore::SessionID);
</span><ins>+
+    void deleteWebsiteData(WebCore::SessionID, uint64_t websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID);
+
</ins><span class="cx">     void downloadRequest(uint64_t downloadID, const WebCore::ResourceRequest&amp;);
</span><span class="cx">     void resumeDownload(uint64_t downloadID, const IPC::DataReference&amp; resumeData, const String&amp; path, const SandboxExtension::Handle&amp;);
</span><span class="cx">     void cancelDownload(uint64_t downloadID);
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkProcessmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in (177031 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in        2014-12-09 20:06:57 UTC (rev 177031)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -37,6 +37,8 @@
</span><span class="cx">     EnsurePrivateBrowsingSession(WebCore::SessionID sessionID)
</span><span class="cx">     DestroyPrivateBrowsingSession(WebCore::SessionID sessionID)
</span><span class="cx"> 
</span><ins>+    DeleteWebsiteData(WebCore::SessionID sessionID, uint64_t websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID)
+
</ins><span class="cx">     DownloadRequest(uint64_t downloadID, WebCore::ResourceRequest request)
</span><span class="cx">     ResumeDownload(uint64_t downloadID, IPC::DataReference resumeData, String path, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
</span><span class="cx">     CancelDownload(uint64_t downloadID)
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebsiteDataWebsiteDataTypeshfromrev177020trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h (from rev 177020, trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h) (0 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h                                (rev 0)
+++ trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebsiteDataTypes_h
+#define WebsiteDataTypes_h
+
+namespace WebKit {
+
+enum WebsiteDataTypes {
+    WebsiteDataTypeCookies = 1 &lt;&lt; 0,
+};
+
+};
+
+#endif // WebsiteDataTypes_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKWebsiteDataStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStore.mm (177031 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStore.mm        2014-12-09 20:06:57 UTC (rev 177031)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStore.mm        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -52,9 +52,9 @@
</span><span class="cx">     return _websiteDataStore-&gt;isNonPersistent();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static WebKit::WebsiteDataStore::WebsiteDataTypes toWebsiteDataTypes(WKWebsiteDataTypes wkWebsiteDataTypes)
</del><ins>+static WebKit::WebsiteDataTypes toWebsiteDataTypes(WKWebsiteDataTypes wkWebsiteDataTypes)
</ins><span class="cx"> {
</span><del>-    using WebsiteDataTypes = WebKit::WebsiteDataStore::WebsiteDataTypes;
</del><ins>+    using WebsiteDataTypes = WebKit::WebsiteDataTypes;
</ins><span class="cx"> 
</span><span class="cx">     int websiteDataTypes = 0;
</span><span class="cx"> 
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx"> - (void)removeDataOfTypes:(WKWebsiteDataTypes)websiteDataTypes modifiedSince:(NSDate *)date completionHandler:(void (^)())completionHandler
</span><span class="cx"> {
</span><span class="cx">     auto completionHandlerCopy = Block_copy(completionHandler);
</span><del>-    _websiteDataStore-&gt;websiteDataStore().removeDataModifiedSince(toWebsiteDataTypes(websiteDataTypes), toSystemClockTime(date ? date : [NSDate distantPast]), [completionHandlerCopy] {
</del><ins>+    _websiteDataStore-&gt;websiteDataStore().removeData(toWebsiteDataTypes(websiteDataTypes), toSystemClockTime(date ? date : [NSDate distantPast]), [completionHandlerCopy] {
</ins><span class="cx">         completionHandlerCopy();
</span><span class="cx">         Block_release(completionHandlerCopy);
</span><span class="cx">     });
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessNetworkNetworkProcessProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp (177031 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp        2014-12-09 20:06:57 UTC (rev 177031)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -51,6 +51,13 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><ins>+static uint64_t generateCallbackID()
+{
+    static uint64_t callbackID;
+
+    return ++callbackID;
+}
+
</ins><span class="cx"> PassRefPtr&lt;NetworkProcessProxy&gt; NetworkProcessProxy::create(WebContext&amp; webContext)
</span><span class="cx"> {
</span><span class="cx">     return adoptRef(new NetworkProcessProxy(webContext));
</span><span class="lines">@@ -66,6 +73,7 @@
</span><span class="cx"> 
</span><span class="cx"> NetworkProcessProxy::~NetworkProcessProxy()
</span><span class="cx"> {
</span><ins>+    ASSERT(m_pendingDeleteWebsiteDataCallbacks.isEmpty());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void NetworkProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions&amp; launchOptions)
</span><span class="lines">@@ -107,6 +115,14 @@
</span><span class="cx">     return m_downloadProxyMap-&gt;createDownloadProxy(m_webContext, resourceRequest);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkProcessProxy::deleteWebsiteData(WebCore::SessionID sessionID, WebsiteDataTypes dataTypes, std::chrono::system_clock::time_point modifiedSince,  std::function&lt;void ()&gt; completionHandler)
+{
+    auto callbackID = generateCallbackID();
+
+    m_pendingDeleteWebsiteDataCallbacks.add(callbackID, WTF::move(completionHandler));
+    send(Messages::NetworkProcess::DeleteWebsiteData(sessionID, dataTypes, modifiedSince, callbackID), 0);
+}
+
</ins><span class="cx"> void NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch()
</span><span class="cx"> {
</span><span class="cx">     // The network process must have crashed or exited, send any pending sync replies we might have.
</span><span class="lines">@@ -122,6 +138,10 @@
</span><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    for (const auto&amp; callback : m_pendingDeleteWebsiteDataCallbacks.values())
+        callback();
+    m_pendingDeleteWebsiteDataCallbacks.clear();
+
</ins><span class="cx">     // Tell the network process manager to forget about this network process proxy. This may cause us to be deleted.
</span><span class="cx">     m_webContext.networkProcessCrashed(this);
</span><span class="cx"> }
</span><span class="lines">@@ -183,6 +203,12 @@
</span><span class="cx">     page-&gt;didReceiveAuthenticationChallengeProxy(frameID, authenticationChallenge.release());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkProcessProxy::didDeleteWebsiteData(uint64_t callbackID)
+{
+    auto callback = m_pendingDeleteWebsiteDataCallbacks.take(callbackID);
+    callback();
+}
+
</ins><span class="cx"> void NetworkProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connection::Identifier connectionIdentifier)
</span><span class="cx"> {
</span><span class="cx">     ChildProcessProxy::didFinishLaunching(launcher, connectionIdentifier);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessNetworkNetworkProcessProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h (177031 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h        2014-12-09 20:06:57 UTC (rev 177031)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include &quot;CustomProtocolManagerProxy.h&quot;
</span><span class="cx"> #include &quot;ProcessLauncher.h&quot;
</span><span class="cx"> #include &quot;WebProcessProxyMessages.h&quot;
</span><ins>+#include &quot;WebsiteDataTypes.h&quot;
</ins><span class="cx"> #include &lt;memory&gt;
</span><span class="cx"> #include &lt;wtf/Deque.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -42,6 +43,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class AuthenticationChallenge;
</span><span class="cx"> class ResourceRequest;
</span><ins>+class SessionID;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -60,6 +62,8 @@
</span><span class="cx"> 
</span><span class="cx">     DownloadProxy* createDownloadProxy(const WebCore::ResourceRequest&amp;);
</span><span class="cx"> 
</span><ins>+    void deleteWebsiteData(WebCore::SessionID, WebsiteDataTypes, std::chrono::system_clock::time_point modifiedSince, std::function&lt;void ()&gt; completionHandler);
+
</ins><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     void setProcessSuppressionEnabled(bool);
</span><span class="cx"> #endif
</span><span class="lines">@@ -85,6 +89,7 @@
</span><span class="cx">     void didReceiveNetworkProcessProxyMessage(IPC::Connection*, IPC::MessageDecoder&amp;);
</span><span class="cx">     void didCreateNetworkConnectionToWebProcess(const IPC::Attachment&amp;);
</span><span class="cx">     void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&amp;, uint64_t challengeID);
</span><ins>+    void didDeleteWebsiteData(uint64_t callbackID);
</ins><span class="cx"> 
</span><span class="cx">     // ProcessLauncher::Client
</span><span class="cx">     virtual void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
</span><span class="lines">@@ -94,9 +99,10 @@
</span><span class="cx">     unsigned m_numPendingConnectionRequests;
</span><span class="cx">     Deque&lt;RefPtr&lt;Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply&gt;&gt; m_pendingConnectionReplies;
</span><span class="cx"> 
</span><ins>+    HashMap&lt;uint64_t, std::function&lt;void ()&gt;&gt; m_pendingDeleteWebsiteDataCallbacks;
+
</ins><span class="cx">     std::unique_ptr&lt;DownloadProxyMap&gt; m_downloadProxyMap;
</span><span class="cx">     CustomProtocolManagerProxy m_customProtocolManagerProxy;
</span><del>-    
</del><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     std::unique_ptr&lt;ProcessAssertion&gt; m_assertion;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessNetworkNetworkProcessProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in (177031 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in        2014-12-09 20:06:57 UTC (rev 177031)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -26,6 +26,8 @@
</span><span class="cx">     DidCreateNetworkConnectionToWebProcess(IPC::Attachment connectionIdentifier)
</span><span class="cx"> 
</span><span class="cx">     DidReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID)
</span><ins>+
+    DidDeleteWebsiteData(uint64_t callbackID)
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(NETWORK_PROCESS)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (177031 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2014-12-09 20:06:57 UTC (rev 177031)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;WebsiteDataStore.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;WebContext.h&quot;
</ins><span class="cx"> #include &lt;wtf/RunLoop.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -86,10 +87,91 @@
</span><span class="cx">     m_webPages.remove(&amp;webPageProxy);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebsiteDataStore::removeDataModifiedSince(WebsiteDataTypes dataTypes, std::chrono::system_clock::time_point, std::function&lt;void ()&gt; completionHandler)
</del><ins>+enum class ProcessAccessType {
+    None,
+    OnlyIfLaunched,
+    Launch,
+};
+
+static ProcessAccessType computeNetworkProcessAccessType(WebsiteDataTypes dataTypes, bool isNonPersistantStore)
</ins><span class="cx"> {
</span><del>-    // FIXME: Actually remove data.
-    RunLoop::main().dispatch(WTF::move(completionHandler));
</del><ins>+    ProcessAccessType processAccessType = ProcessAccessType::None;
+
+    if (dataTypes &amp; WebsiteDataTypeCookies) {
+        if (isNonPersistantStore)
+            processAccessType = std::max(processAccessType, ProcessAccessType::OnlyIfLaunched);
+        else
+            processAccessType = std::max(processAccessType, ProcessAccessType::Launch);
+    }
+
+    // FIXME: Handle caches here too.
+
+    return processAccessType;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebsiteDataStore::removeData(WebsiteDataTypes dataTypes, std::chrono::system_clock::time_point modifiedSince, std::function&lt;void ()&gt; completionHandler)
+{
+    struct CallbackAggregator : public RefCounted&lt;CallbackAggregator&gt; {
+        explicit CallbackAggregator (std::function&lt;void ()&gt; completionHandler)
+            : completionHandler(WTF::move(completionHandler))
+        {
+        }
+
+        void addPendingCallback()
+        {
+            pendingCallbacks++;
+        }
+
+        void removePendingCallback()
+        {
+            ASSERT(pendingCallbacks);
+            --pendingCallbacks;
+
+            callIfNeeded();
+        }
+
+        void callIfNeeded()
+        {
+            if (!pendingCallbacks)
+                RunLoop::main().dispatch(WTF::move(completionHandler));
+        }
+
+        unsigned pendingCallbacks = 0;
+        std::function&lt;void ()&gt; completionHandler;
+    };
+
+    RefPtr&lt;CallbackAggregator&gt; callbackAggregator = adoptRef(new CallbackAggregator(WTF::move(completionHandler)));
+
+    auto networkProcessAccessType = computeNetworkProcessAccessType(dataTypes, isNonPersistent());
+    if (networkProcessAccessType != ProcessAccessType::None) {
+        HashSet&lt;WebContext*&gt; contexts;
+        for (auto&amp; webPage : m_webPages)
+            contexts.add(&amp;webPage-&gt;process().context());
+
+        for (auto&amp; context : contexts) {
+            switch (networkProcessAccessType) {
+            case ProcessAccessType::OnlyIfLaunched:
+                if (!context-&gt;networkProcess())
+                    continue;
+                break;
+
+            case ProcessAccessType::Launch:
+                context-&gt;ensureNetworkProcess();
+                break;
+
+            case ProcessAccessType::None:
+                ASSERT_NOT_REACHED();
+            }
+
+            callbackAggregator-&gt;addPendingCallback();
+            context-&gt;networkProcess()-&gt;deleteWebsiteData(m_sessionID, dataTypes, modifiedSince, [callbackAggregator] {
+                callbackAggregator-&gt;removePendingCallback();
+            });
+        }
+    }
+
+    // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
+    callbackAggregator-&gt;callIfNeeded();
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h (177031 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h        2014-12-09 20:06:57 UTC (rev 177031)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #ifndef WebsiteDataStore_h
</span><span class="cx"> #define WebsiteDataStore_h
</span><span class="cx"> 
</span><ins>+#include &quot;WebsiteDataTypes.h&quot;
</ins><span class="cx"> #include &lt;WebCore/SessionID.h&gt;
</span><span class="cx"> #include &lt;functional&gt;
</span><span class="cx"> #include &lt;wtf/HashSet.h&gt;
</span><span class="lines">@@ -38,10 +39,6 @@
</span><span class="cx"> 
</span><span class="cx"> class WebsiteDataStore : public RefCounted&lt;WebsiteDataStore&gt; {
</span><span class="cx"> public:
</span><del>-    enum WebsiteDataTypes {
-        WebsiteDataTypeCookies = 1 &lt;&lt; 0,
-    };
-
</del><span class="cx">     struct Configuration {
</span><span class="cx">     };
</span><span class="cx">     static RefPtr&lt;WebsiteDataStore&gt; createNonPersistent();
</span><span class="lines">@@ -56,7 +53,7 @@
</span><span class="cx">     bool isNonPersistent() const { return m_sessionID.isEphemeral(); }
</span><span class="cx">     WebCore::SessionID sessionID() const { return m_sessionID; }
</span><span class="cx"> 
</span><del>-    void removeDataModifiedSince(WebsiteDataTypes, std::chrono::system_clock::time_point, std::function&lt;void ()&gt; completionHandler);
</del><ins>+    void removeData(WebsiteDataTypes, std::chrono::system_clock::time_point modifiedSince, std::function&lt;void ()&gt; completionHandler);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     explicit WebsiteDataStore(WebCore::SessionID);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (177031 => 177032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-12-09 20:06:57 UTC (rev 177031)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-12-09 20:29:59 UTC (rev 177032)
</span><span class="lines">@@ -2398,6 +2398,7 @@
</span><span class="cx">                 1ABC3DF31899E437004F0626 /* NavigationState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NavigationState.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1ABC3DF41899E437004F0626 /* NavigationState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationState.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1ABC3DFB1899F51C004F0626 /* WKNavigationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationDelegate.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                1ABF43791A368050003FB0E6 /* WebsiteDataTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebsiteDataTypes.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 1AC0273E196622D600C12B75 /* WebPageProxyCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPageProxyCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AC1336518565B5700F3EC05 /* UserData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserData.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AC1336618565B5700F3EC05 /* UserData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserData.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4423,6 +4424,7 @@
</span><span class="cx">                                 1AAE058C1279DCD400852418 /* Plugins */,
</span><span class="cx">                                 3709504918A9FAD20087AE5D /* posix */,
</span><span class="cx">                                 0F5947A0187B3B7100437857 /* Scrolling */,
</span><ins>+                                1ABF43781A368035003FB0E6 /* WebsiteData */,
</ins><span class="cx">                                 BC64696D11DBE603006455B0 /* APIArray.cpp */,
</span><span class="cx">                                 BC64696E11DBE603006455B0 /* APIArray.h */,
</span><span class="cx">                                 1A3DD205125E5A2F004515E6 /* APIClient.h */,
</span><span class="lines">@@ -4694,6 +4696,14 @@
</span><span class="cx">                         path = Cocoa;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="cx">                 };
</span><ins>+                1ABF43781A368035003FB0E6 /* WebsiteData */ = {
+                        isa = PBXGroup;
+                        children = (
+                                1ABF43791A368050003FB0E6 /* WebsiteDataTypes.h */,
+                        );
+                        path = WebsiteData;
+                        sourceTree = &quot;&lt;group&gt;&quot;;
+                };
</ins><span class="cx">                 1AE00D6818327C1200087DD7 /* IPC */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span></span></pre>
</div>
</div>

</body>
</html>