<!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>[150304] 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/150304">150304</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2013-05-17 15:59:28 -0700 (Fri, 17 May 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use the UI process storage manager for deleting local storage data
https://bugs.webkit.org/show_bug.cgi?id=116358
&lt;rdar://problem/13852829&gt;

Reviewed by Andreas Kling.

* Shared/WebSecurityOrigin.h:
(WebKit::WebSecurityOrigin::protocol):
(WebKit::WebSecurityOrigin::host):
(WebKit::WebSecurityOrigin::databaseIdentifier):
(WebKit::WebSecurityOrigin::toString):
Remove unneeded consts.

(WebKit::WebSecurityOrigin::securityOrigin):
Add getter.

* UIProcess/Storage/LocalStorageDatabase.cpp:
(WebKit::LocalStorageDatabase::close):
deleteEmptyDatabaseWithOrigin has been renamed to deleteDatabaseWithOrigin.

* UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
(WebKit::LocalStorageDatabaseTracker::deleteDatabaseWithOrigin):
Rename since this is no longer used only for empty databases.

(WebKit::LocalStorageDatabaseTracker::deleteAllDatabases):
Loop over the tracker database and delete all database files.

* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::StorageArea::clear):
Clear the map, close the database and tell all event listeners to reset their caches.

(WebKit::StorageManager::LocalStorageNamespace::clearStorageAreasMatchingOrigin):
Loop over all storage areas and call clear on those matching the security origin.

(WebKit::StorageManager::LocalStorageNamespace::clearAllStorageAreas):
Loop over all storage areas and call clear on them.

(WebKit::StorageManager::deleteEntriesForOrigin):
Dispatch deleteEntriesForOriginInternal on the work queue.

(WebKit::StorageManager::deleteAllEntries):
Dispatch deleteAllEntriesInternal on the work queue.

(WebKit::StorageManager::deleteEntriesForOriginInternal):
Call clearStorageAreasMatchingOrigin on all local storage namespaces and then delete the database.

(WebKit::StorageManager::deleteAllEntriesInternal):
Call clearAllStorageAreas on all local storage namespaces and then delete all databases.

* UIProcess/WebKeyValueStorageManagerProxy.cpp:
(WebKit::WebKeyValueStorageManagerProxy::deleteEntriesForOrigin):
Call out to the storage manager.

(WebKit::WebKeyValueStorageManagerProxy::deleteAllEntries):
Ditto.

* WebProcess/Storage/StorageAreaMap.cpp:
(WebKit::StorageAreaMap::clearCache):
Call resetValues which will null out the storage map.

* WebProcess/Storage/StorageAreaMap.messages.in:
Add ClearCache message.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebSecurityOriginh">trunk/Source/WebKit2/Shared/WebSecurityOrigin.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessStorageLocalStorageDatabasecpp">trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessStorageLocalStorageDatabaseTrackercpp">trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessStorageLocalStorageDatabaseTrackerh">trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessStorageStorageManagercpp">trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessStorageStorageManagerh">trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebKeyValueStorageManagerProxycpp">trunk/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessStorageStorageAreaMapcpp">trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessStorageStorageAreaMaph">trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessStorageStorageAreaMapmessagesin">trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (150303 => 150304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2013-05-17 22:06:08 UTC (rev 150303)
+++ trunk/Source/WebKit2/ChangeLog        2013-05-17 22:59:28 UTC (rev 150304)
</span><span class="lines">@@ -1,5 +1,70 @@
</span><span class="cx"> 2013-05-17  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Use the UI process storage manager for deleting local storage data
+        https://bugs.webkit.org/show_bug.cgi?id=116358
+        &lt;rdar://problem/13852829&gt;
+
+        Reviewed by Andreas Kling.
+
+        * Shared/WebSecurityOrigin.h:
+        (WebKit::WebSecurityOrigin::protocol):
+        (WebKit::WebSecurityOrigin::host):
+        (WebKit::WebSecurityOrigin::databaseIdentifier):
+        (WebKit::WebSecurityOrigin::toString):
+        Remove unneeded consts.
+
+        (WebKit::WebSecurityOrigin::securityOrigin):
+        Add getter.
+
+        * UIProcess/Storage/LocalStorageDatabase.cpp:
+        (WebKit::LocalStorageDatabase::close):
+        deleteEmptyDatabaseWithOrigin has been renamed to deleteDatabaseWithOrigin.
+
+        * UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
+        (WebKit::LocalStorageDatabaseTracker::deleteDatabaseWithOrigin):
+        Rename since this is no longer used only for empty databases.
+
+        (WebKit::LocalStorageDatabaseTracker::deleteAllDatabases):
+        Loop over the tracker database and delete all database files.
+
+        * UIProcess/Storage/StorageManager.cpp:
+        (WebKit::StorageManager::StorageArea::clear):
+        Clear the map, close the database and tell all event listeners to reset their caches.
+
+        (WebKit::StorageManager::LocalStorageNamespace::clearStorageAreasMatchingOrigin):
+        Loop over all storage areas and call clear on those matching the security origin.
+
+        (WebKit::StorageManager::LocalStorageNamespace::clearAllStorageAreas):
+        Loop over all storage areas and call clear on them.
+        
+        (WebKit::StorageManager::deleteEntriesForOrigin):
+        Dispatch deleteEntriesForOriginInternal on the work queue.
+
+        (WebKit::StorageManager::deleteAllEntries):
+        Dispatch deleteAllEntriesInternal on the work queue.
+
+        (WebKit::StorageManager::deleteEntriesForOriginInternal):
+        Call clearStorageAreasMatchingOrigin on all local storage namespaces and then delete the database.
+
+        (WebKit::StorageManager::deleteAllEntriesInternal):
+        Call clearAllStorageAreas on all local storage namespaces and then delete all databases.
+
+        * UIProcess/WebKeyValueStorageManagerProxy.cpp:
+        (WebKit::WebKeyValueStorageManagerProxy::deleteEntriesForOrigin):
+        Call out to the storage manager.
+
+        (WebKit::WebKeyValueStorageManagerProxy::deleteAllEntries):
+        Ditto.
+
+        * WebProcess/Storage/StorageAreaMap.cpp:
+        (WebKit::StorageAreaMap::clearCache):
+        Call resetValues which will null out the storage map.
+
+        * WebProcess/Storage/StorageAreaMap.messages.in:
+        Add ClearCache message.
+
+2013-05-17  Anders Carlsson  &lt;andersca@apple.com&gt;
+
</ins><span class="cx">         Only import local storage items from the database once
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=116354
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebSecurityOriginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebSecurityOrigin.h (150303 => 150304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebSecurityOrigin.h        2013-05-17 22:06:08 UTC (rev 150303)
+++ trunk/Source/WebKit2/Shared/WebSecurityOrigin.h        2013-05-17 22:59:28 UTC (rev 150304)
</span><span class="lines">@@ -56,13 +56,15 @@
</span><span class="cx">         return adoptRef(new WebSecurityOrigin(securityOrigin));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    const String protocol() const { return m_securityOrigin-&gt;protocol(); }
-    const String host() const { return m_securityOrigin-&gt;host(); }
</del><ins>+    String protocol() const { return m_securityOrigin-&gt;protocol(); }
+    String host() const { return m_securityOrigin-&gt;host(); }
</ins><span class="cx">     unsigned short port() const { return m_securityOrigin-&gt;port(); }
</span><span class="cx"> 
</span><del>-    const String databaseIdentifier() const { return m_securityOrigin-&gt;databaseIdentifier(); }
-    const String toString() const { return m_securityOrigin-&gt;toString(); }
</del><ins>+    String databaseIdentifier() const { return m_securityOrigin-&gt;databaseIdentifier(); }
+    String toString() const { return m_securityOrigin-&gt;toString(); }
</ins><span class="cx"> 
</span><ins>+    WebCore::SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
+
</ins><span class="cx"> private:
</span><span class="cx">     WebSecurityOrigin(PassRefPtr&lt;WebCore::SecurityOrigin&gt; securityOrigin)
</span><span class="cx">         : m_securityOrigin(securityOrigin)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessStorageLocalStorageDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp (150303 => 150304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp        2013-05-17 22:06:08 UTC (rev 150303)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp        2013-05-17 22:59:28 UTC (rev 150304)
</span><span class="lines">@@ -226,7 +226,7 @@
</span><span class="cx">         m_database.close();
</span><span class="cx"> 
</span><span class="cx">     if (isEmpty)
</span><del>-        m_tracker-&gt;deleteEmptyDatabaseWithOrigin(m_securityOrigin.get());
</del><ins>+        m_tracker-&gt;deleteDatabaseWithOrigin(m_securityOrigin.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void LocalStorageDatabase::itemDidChange(const String&amp; key, const String&amp; value)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessStorageLocalStorageDatabaseTrackercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp (150303 => 150304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp        2013-05-17 22:06:08 UTC (rev 150303)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp        2013-05-17 22:59:28 UTC (rev 150304)
</span><span class="lines">@@ -65,11 +65,59 @@
</span><span class="cx">     addDatabaseWithOriginIdentifier(securityOrigin-&gt;databaseIdentifier(), databasePath(securityOrigin));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void LocalStorageDatabaseTracker::deleteEmptyDatabaseWithOrigin(SecurityOrigin* securityOrigin)
</del><ins>+void LocalStorageDatabaseTracker::deleteDatabaseWithOrigin(SecurityOrigin* securityOrigin)
</ins><span class="cx"> {
</span><span class="cx">     removeDatabaseWithOriginIdentifier(securityOrigin-&gt;databaseIdentifier());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void LocalStorageDatabaseTracker::deleteAllDatabases()
+{
+    m_origins.clear();
+
+    openTrackerDatabase(SkipIfNonExistent);
+    if (!m_database.isOpen())
+        return;
+
+    SQLiteStatement statement(m_database, &quot;SELECT origin, path FROM Origins&quot;);
+    if (statement.prepare() != SQLResultOk) {
+        LOG_ERROR(&quot;Failed to prepare statement.&quot;);
+        return;
+    }
+
+    int result;
+    while ((result = statement.step()) == SQLResultRow) {
+        deleteFile(statement.getColumnText(1));
+
+        // FIXME: Call out to the client.
+    }
+
+    if (result != SQLResultDone)
+        LOG_ERROR(&quot;Failed to read in all origins from the database.&quot;);
+
+    if (m_database.isOpen())
+        m_database.close();
+
+    if (!deleteFile(trackerDatabasePath())) {
+        // In the case where it is not possible to delete the database file (e.g some other program
+        // like a virus scanner is accessing it), make sure to remove all entries.
+        openTrackerDatabase(SkipIfNonExistent);
+        if (!m_database.isOpen())
+            return;
+
+        SQLiteStatement deleteStatement(m_database, &quot;DELETE FROM Origins&quot;);
+        if (deleteStatement.prepare() != SQLResultOk) {
+            LOG_ERROR(&quot;Unable to prepare deletion of all origins&quot;);
+            return;
+        }
+        if (!deleteStatement.executeCommand()) {
+            LOG_ERROR(&quot;Unable to execute deletion of all origins&quot;);
+            return;
+        }
+    }
+
+    deleteEmptyDirectory(m_localStorageDirectory);
+}
+
</ins><span class="cx"> Vector&lt;RefPtr&lt;WebCore::SecurityOrigin&gt;&gt; LocalStorageDatabaseTracker::origins() const
</span><span class="cx"> {
</span><span class="cx">     Vector&lt;RefPtr&lt;SecurityOrigin&gt;&gt; origins;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessStorageLocalStorageDatabaseTrackerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.h (150303 => 150304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.h        2013-05-17 22:06:08 UTC (rev 150303)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.h        2013-05-17 22:59:28 UTC (rev 150304)
</span><span class="lines">@@ -51,7 +51,8 @@
</span><span class="cx">     String databasePath(WebCore::SecurityOrigin*) const;
</span><span class="cx"> 
</span><span class="cx">     void didOpenDatabaseWithOrigin(WebCore::SecurityOrigin*);
</span><del>-    void deleteEmptyDatabaseWithOrigin(WebCore::SecurityOrigin*);
</del><ins>+    void deleteDatabaseWithOrigin(WebCore::SecurityOrigin*);
+    void deleteAllDatabases();
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;RefPtr&lt;WebCore::SecurityOrigin&gt;&gt; origins() const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessStorageStorageManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp (150303 => 150304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp        2013-05-17 22:06:08 UTC (rev 150303)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp        2013-05-17 22:59:28 UTC (rev 150304)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx">     void clear(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String&amp; urlString);
</span><span class="cx"> 
</span><span class="cx">     const HashMap&lt;String, String&gt;&amp; items();
</span><ins>+    void clear();
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     explicit StorageArea(LocalStorageNamespace*, PassRefPtr&lt;SecurityOrigin&gt;, unsigned quotaInBytes);
</span><span class="lines">@@ -88,6 +89,9 @@
</span><span class="cx">     PassRefPtr&lt;StorageArea&gt; getOrCreateStorageArea(PassRefPtr&lt;SecurityOrigin&gt;);
</span><span class="cx">     void didDestroyStorageArea(StorageArea*);
</span><span class="cx"> 
</span><ins>+    void clearStorageAreasMatchingOrigin(SecurityOrigin*);
+    void clearAllStorageAreas();
+
</ins><span class="cx"> private:
</span><span class="cx">     explicit LocalStorageNamespace(StorageManager*, uint64_t storageManagerID);
</span><span class="cx"> 
</span><span class="lines">@@ -205,6 +209,19 @@
</span><span class="cx">     return m_storageMap-&gt;items();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void StorageManager::StorageArea::clear()
+{
+    m_storageMap = StorageMap::create(m_quotaInBytes);
+
+    if (m_localStorageDatabase) {
+        m_localStorageDatabase-&gt;close();
+        m_localStorageDatabase = nullptr;
+    }
+
+    for (auto it = m_eventListeners.begin(), end = m_eventListeners.end(); it != end; ++it)
+        it-&gt;first-&gt;send(Messages::StorageAreaMap::ClearCache(), it-&gt;second);
+}
+
</ins><span class="cx"> void StorageManager::StorageArea::openDatabaseAndImportItemsIfNeeded()
</span><span class="cx"> {
</span><span class="cx">     if (!m_localStorageNamespace)
</span><span class="lines">@@ -273,6 +290,20 @@
</span><span class="cx">     m_storageManager-&gt;m_localStorageNamespaces.remove(m_storageNamespaceID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void StorageManager::LocalStorageNamespace::clearStorageAreasMatchingOrigin(SecurityOrigin* securityOrigin)
+{
+    for (auto it = m_storageAreaMap.begin(), end = m_storageAreaMap.end(); it != end; ++it) {
+        if (it-&gt;key-&gt;equal(securityOrigin))
+            it-&gt;value-&gt;clear();
+    }
+}
+
+void StorageManager::LocalStorageNamespace::clearAllStorageAreas()
+{
+    for (auto it = m_storageAreaMap.begin(), end = m_storageAreaMap.end(); it != end; ++it)
+        it-&gt;value-&gt;clear();
+}
+
</ins><span class="cx"> class StorageManager::SessionStorageNamespace : public ThreadSafeRefCounted&lt;SessionStorageNamespace&gt; {
</span><span class="cx"> public:
</span><span class="cx">     static PassRefPtr&lt;SessionStorageNamespace&gt; create(CoreIPC::Connection* allowedConnection, unsigned quotaInBytes);
</span><span class="lines">@@ -394,6 +425,16 @@
</span><span class="cx">     m_queue-&gt;dispatch(bind(&amp;StorageManager::getOriginsInternal, this, RefPtr&lt;FunctionDispatcher&gt;(callbackDispatcher), context, callback));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void StorageManager::deleteEntriesForOrigin(SecurityOrigin* securityOrigin)
+{
+    m_queue-&gt;dispatch(bind(&amp;StorageManager::deleteEntriesForOriginInternal, this, RefPtr&lt;SecurityOrigin&gt;(securityOrigin)));
+}
+
+void StorageManager::deleteAllEntries()
+{
+    m_queue-&gt;dispatch(bind(&amp;StorageManager::deleteAllEntriesInternal, this));
+}
+
</ins><span class="cx"> void StorageManager::createLocalStorageMap(CoreIPC::Connection* connection, uint64_t storageMapID, uint64_t storageNamespaceID, const SecurityOriginData&amp; securityOriginData)
</span><span class="cx"> {
</span><span class="cx">     std::pair&lt;RefPtr&lt;CoreIPC::Connection&gt;, uint64_t&gt; connectionAndStorageMapIDPair(connection, storageMapID);
</span><span class="lines">@@ -467,7 +508,6 @@
</span><span class="cx">     ASSERT(storageArea);
</span><span class="cx"> 
</span><span class="cx">     values = storageArea-&gt;items();
</span><del>-
</del><span class="cx">     connection-&gt;send(Messages::StorageAreaMap::DidGetValues(storageMapSeed), storageMapID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -586,4 +626,21 @@
</span><span class="cx">     dispatcher-&gt;dispatch(bind(callCallbackFunction, context, callbackFunction, securityOrigins.leakPtr()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void StorageManager::deleteEntriesForOriginInternal(SecurityOrigin* securityOrigin)
+{
+    for (auto it = m_localStorageNamespaces.begin(), end = m_localStorageNamespaces.end(); it != end; ++it)
+        it-&gt;value-&gt;clearStorageAreasMatchingOrigin(securityOrigin);
+
+    m_localStorageDatabaseTracker-&gt;deleteDatabaseWithOrigin(securityOrigin);
+}
+
+void StorageManager::deleteAllEntriesInternal()
+{
+    for (auto it = m_localStorageNamespaces.begin(), end = m_localStorageNamespaces.end(); it != end; ++it)
+        it-&gt;value-&gt;clearAllStorageAreas();
+
+    m_localStorageDatabaseTracker-&gt;deleteAllDatabases();
+}
+
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessStorageStorageManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h (150303 => 150304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h        2013-05-17 22:06:08 UTC (rev 150303)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h        2013-05-17 22:59:28 UTC (rev 150304)
</span><span class="lines">@@ -62,6 +62,8 @@
</span><span class="cx">     // FIXME: Instead of a context + C function, this should take a WTF::Function, but we currently don't
</span><span class="cx">     // support arguments in functions.
</span><span class="cx">     void getOrigins(FunctionDispatcher* callbackDispatcher, void* context, void (*callback)(const Vector&lt;RefPtr&lt;WebCore::SecurityOrigin&gt;&gt;&amp; securityOrigins, void* context));
</span><ins>+    void deleteEntriesForOrigin(WebCore::SecurityOrigin*);
+    void deleteAllEntries();
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     StorageManager();
</span><span class="lines">@@ -94,6 +96,8 @@
</span><span class="cx">     LocalStorageNamespace* getOrCreateLocalStorageNamespace(uint64_t storageNamespaceID);
</span><span class="cx"> 
</span><span class="cx">     void getOriginsInternal(FunctionDispatcher* callbackDispatcher, void* context, void (*callback)(const Vector&lt;RefPtr&lt;WebCore::SecurityOrigin&gt;&gt;&amp; securityOrigins, void* context));
</span><ins>+    void deleteEntriesForOriginInternal(WebCore::SecurityOrigin*);
+    void deleteAllEntriesInternal();
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;WorkQueue&gt; m_queue;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebKeyValueStorageManagerProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp (150303 => 150304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp        2013-05-17 22:06:08 UTC (rev 150303)
+++ trunk/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp        2013-05-17 22:59:28 UTC (rev 150304)
</span><span class="lines">@@ -109,19 +109,12 @@
</span><span class="cx"> 
</span><span class="cx"> void WebKeyValueStorageManagerProxy::deleteEntriesForOrigin(WebSecurityOrigin* origin)
</span><span class="cx"> {
</span><del>-    SecurityOriginData securityOriginData;
-    securityOriginData.protocol = origin-&gt;protocol();
-    securityOriginData.host = origin-&gt;host();
-    securityOriginData.port = origin-&gt;port();
-
-    // FIXME (Multi-WebProcess): &lt;rdar://problem/12239765&gt; Should key-value storage be handled in the web process?
-    context()-&gt;sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebKeyValueStorageManager::DeleteEntriesForOrigin(securityOriginData));
</del><ins>+    context()-&gt;storageManager().deleteEntriesForOrigin(origin-&gt;securityOrigin());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebKeyValueStorageManagerProxy::deleteAllEntries()
</span><span class="cx"> {
</span><del>-    // FIXME (Multi-WebProcess): &lt;rdar://problem/12239765&gt; Should key-value storage be handled in the web process?
-    context()-&gt;sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebKeyValueStorageManager::DeleteAllEntries());
</del><ins>+    context()-&gt;storageManager().deleteAllEntries();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessStorageStorageAreaMapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp (150303 => 150304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp        2013-05-17 22:06:08 UTC (rev 150303)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp        2013-05-17 22:59:28 UTC (rev 150304)
</span><span class="lines">@@ -293,6 +293,11 @@
</span><span class="cx">         dispatchLocalStorageEvent(sourceStorageAreaID, key, oldValue, newValue, urlString);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void StorageAreaMap::clearCache()
+{
+    resetValues();
+}
+
</ins><span class="cx"> void StorageAreaMap::dispatchSessionStorageEvent(uint64_t sourceStorageAreaID, const String&amp; key, const String&amp; oldValue, const String&amp; newValue, const String&amp; urlString)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(storageType() == SessionStorage);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessStorageStorageAreaMaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h (150303 => 150304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h        2013-05-17 22:06:08 UTC (rev 150303)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h        2013-05-17 22:59:28 UTC (rev 150304)
</span><span class="lines">@@ -70,14 +70,15 @@
</span><span class="cx">     void didRemoveItem(uint64_t storageMapSeed, const String&amp; key);
</span><span class="cx">     void didClear(uint64_t storageMapSeed);
</span><span class="cx"> 
</span><ins>+    void dispatchStorageEvent(uint64_t sourceStorageAreaID, const String&amp; key, const String&amp; oldValue, const String&amp; newValue, const String&amp; urlString);
+    void clearCache();
+
</ins><span class="cx">     void resetValues();
</span><span class="cx">     void loadValuesIfNeeded();
</span><span class="cx"> 
</span><span class="cx">     bool shouldApplyChangeForKey(const String&amp; key) const;
</span><span class="cx">     void applyChange(const String&amp; key, const String&amp; newValue);
</span><span class="cx"> 
</span><del>-    void dispatchStorageEvent(uint64_t sourceStorageAreaID, const String&amp; key, const String&amp; oldValue, const String&amp; newValue, const String&amp; urlString);
-
</del><span class="cx">     void dispatchSessionStorageEvent(uint64_t sourceStorageAreaID, const String&amp; key, const String&amp; oldValue, const String&amp; newValue, const String&amp; urlString);
</span><span class="cx">     void dispatchLocalStorageEvent(uint64_t sourceStorageAreaID, const String&amp; key, const String&amp; oldValue, const String&amp; newValue, const String&amp; urlString);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessStorageStorageAreaMapmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in (150303 => 150304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in        2013-05-17 22:06:08 UTC (rev 150303)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in        2013-05-17 22:59:28 UTC (rev 150304)
</span><span class="lines">@@ -27,4 +27,5 @@
</span><span class="cx">     DidClear(uint64_t storageMapSeed)
</span><span class="cx"> 
</span><span class="cx">     DispatchStorageEvent(uint64_t sourceStorageAreaID, WTF::String key, WTF::String oldValue, WTF::String newValue, WTF::String urlString)
</span><ins>+    ClearCache()
</ins><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>