Title: [171749] trunk/Source
Revision
171749
Author
beid...@apple.com
Date
2014-07-29 10:37:58 -0700 (Tue, 29 Jul 2014)

Log Message

Make WKOriginDataManager actually operate on IndexedDatabases.
https://bugs.webkit.org/show_bug.cgi?id=135346

Reviewed by Sam Weinig (and David Kilzer and Alex Christensen)

Source/WebCore:
* WebCore.exp.in:

Source/WebKit2:
* DatabaseProcess/DatabaseProcess.cpp:
(WebKit::DatabaseProcess::DatabaseProcess):
(WebKit::DatabaseProcess::getIndexedDatabaseOrigins):
(WebKit::DatabaseProcess::doGetIndexedDatabaseOrigins):
(WebKit::removeAllDatabasesForOriginPath): Utility to delete all database files for the given origin path
    that have been modified between the given dates.
(WebKit::DatabaseProcess::deleteIndexedDatabaseEntriesForOrigin):
(WebKit::DatabaseProcess::doDeleteIndexedDatabaseEntriesForOrigin):
(WebKit::DatabaseProcess::deleteIndexedDatabaseEntriesModifiedBetweenDates):
(WebKit::DatabaseProcess::doDeleteIndexedDatabaseEntriesModifiedBetweenDates):
(WebKit::DatabaseProcess::deleteAllIndexedDatabaseEntries):
(WebKit::DatabaseProcess::doDeleteAllIndexedDatabaseEntries):
* DatabaseProcess/DatabaseProcess.h:

* Shared/WebCrossThreadCopier.cpp:
(WebCore::SecurityOriginData>::copy):
* Shared/WebCrossThreadCopier.h:

* UIProcess/WebOriginDataManagerProxy.cpp:
(WebKit::WebOriginDataManagerProxy::getOrigins):
(WebKit::WebOriginDataManagerProxy::didGetOrigins):
(WebKit::WebOriginDataManagerProxy::deleteEntriesForOrigin):
(WebKit::WebOriginDataManagerProxy::deleteEntriesModifiedBetweenDates):
(WebKit::WebOriginDataManagerProxy::deleteAllEntries):

* WebProcess/OriginData/WebOriginDataManager.cpp:
(WebKit::WebOriginDataManager::getOrigins): Pipe IDB requests through to the DatabaseProcess.
(WebKit::WebOriginDataManager::deleteEntriesForOrigin): Ditto.
(WebKit::WebOriginDataManager::deleteEntriesModifiedBetweenDates): Ditto.
(WebKit::WebOriginDataManager::deleteAllEntries): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (171748 => 171749)


--- trunk/Source/WebCore/ChangeLog	2014-07-29 17:23:47 UTC (rev 171748)
+++ trunk/Source/WebCore/ChangeLog	2014-07-29 17:37:58 UTC (rev 171749)
@@ -1,3 +1,12 @@
+2014-07-29  Brady Eidson  <beid...@apple.com>
+
+        Make WKOriginDataManager actually operate on IndexedDatabases.
+        https://bugs.webkit.org/show_bug.cgi?id=135346
+
+        Reviewed by Sam Weinig (and David Kilzer and Alex Christensen)
+
+        * WebCore.exp.in:
+
 2014-07-29  Dan Bernstein  <m...@apple.com>
 
         Moved the Cocoa-specific parts of CredentialBase into a Cocoa-specific Credential class.

Modified: trunk/Source/WebCore/WebCore.exp.in (171748 => 171749)


--- trunk/Source/WebCore/WebCore.exp.in	2014-07-29 17:23:47 UTC (rev 171748)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-07-29 17:37:58 UTC (rev 171749)
@@ -1066,6 +1066,8 @@
 __ZN7WebCore37WidgetHierarchyUpdatesSuspensionScope11moveWidgetsEv
 __ZN7WebCore37WidgetHierarchyUpdatesSuspensionScope35s_widgetHierarchyUpdateSuspendCountE
 __ZN7WebCore3URL10invalidateEv
+__ZN7WebCore3URL11setProtocolERKN3WTF6StringE
+__ZN7WebCore3URL7setPathERKN3WTF6StringE
 __ZN7WebCore3URLC1ENS_18ParsedURLStringTagERKN3WTF6StringE
 __ZN7WebCore3URLC1EP5NSURL
 __ZN7WebCore3URLC1EPK7__CFURL

Modified: trunk/Source/WebKit2/ChangeLog (171748 => 171749)


--- trunk/Source/WebKit2/ChangeLog	2014-07-29 17:23:47 UTC (rev 171748)
+++ trunk/Source/WebKit2/ChangeLog	2014-07-29 17:37:58 UTC (rev 171749)
@@ -1,3 +1,41 @@
+2014-07-29  Brady Eidson  <beid...@apple.com>
+
+        Make WKOriginDataManager actually operate on IndexedDatabases.
+        https://bugs.webkit.org/show_bug.cgi?id=135346
+
+        Reviewed by Sam Weinig (and David Kilzer and Alex Christensen)
+
+        * DatabaseProcess/DatabaseProcess.cpp:
+        (WebKit::DatabaseProcess::DatabaseProcess):
+        (WebKit::DatabaseProcess::getIndexedDatabaseOrigins): 
+        (WebKit::DatabaseProcess::doGetIndexedDatabaseOrigins):
+        (WebKit::removeAllDatabasesForOriginPath): Utility to delete all database files for the given origin path
+            that have been modified between the given dates.
+        (WebKit::DatabaseProcess::deleteIndexedDatabaseEntriesForOrigin):
+        (WebKit::DatabaseProcess::doDeleteIndexedDatabaseEntriesForOrigin):
+        (WebKit::DatabaseProcess::deleteIndexedDatabaseEntriesModifiedBetweenDates):
+        (WebKit::DatabaseProcess::doDeleteIndexedDatabaseEntriesModifiedBetweenDates):
+        (WebKit::DatabaseProcess::deleteAllIndexedDatabaseEntries):
+        (WebKit::DatabaseProcess::doDeleteAllIndexedDatabaseEntries):
+        * DatabaseProcess/DatabaseProcess.h:
+
+        * Shared/WebCrossThreadCopier.cpp:
+        (WebCore::SecurityOriginData>::copy):
+        * Shared/WebCrossThreadCopier.h:
+
+        * UIProcess/WebOriginDataManagerProxy.cpp:
+        (WebKit::WebOriginDataManagerProxy::getOrigins):
+        (WebKit::WebOriginDataManagerProxy::didGetOrigins):
+        (WebKit::WebOriginDataManagerProxy::deleteEntriesForOrigin):
+        (WebKit::WebOriginDataManagerProxy::deleteEntriesModifiedBetweenDates):
+        (WebKit::WebOriginDataManagerProxy::deleteAllEntries):
+
+        * WebProcess/OriginData/WebOriginDataManager.cpp:
+        (WebKit::WebOriginDataManager::getOrigins): Pipe IDB requests through to the DatabaseProcess.
+        (WebKit::WebOriginDataManager::deleteEntriesForOrigin): Ditto.
+        (WebKit::WebOriginDataManager::deleteEntriesModifiedBetweenDates): Ditto.
+        (WebKit::WebOriginDataManager::deleteAllEntries): Ditto.
+
 2014-07-29  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r171704.

Modified: trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp (171748 => 171749)


--- trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp	2014-07-29 17:23:47 UTC (rev 171748)
+++ trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp	2014-07-29 17:37:58 UTC (rev 171749)
@@ -34,9 +34,12 @@
 #include "DatabaseProcessProxyMessages.h"
 #include "DatabaseToWebProcessConnection.h"
 #include "UniqueIDBDatabase.h"
+#include "WebCrossThreadCopier.h"
 #include "WebOriginDataManager.h"
 #include "WebOriginDataManagerMessages.h"
+#include "WebOriginDataManagerProxyMessages.h"
 #include <WebCore/FileSystem.h>
+#include <WebCore/TextEncoding.h>
 #include <wtf/MainThread.h>
 
 using namespace WebCore;
@@ -53,6 +56,9 @@
     : m_queue(adoptRef(*WorkQueue::create("com.apple.WebKit.DatabaseProcess").leakRef()))
     , m_webOriginDataManager(std::make_unique<WebOriginDataManager>(this))
 {
+    // Make sure the UTF8Encoding encoding and the text encoding maps have been built on the main thread before a background thread needs it.
+    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=135365 - Need a more explicit way of doing this besides accessing the UTF8Encoding.
+    UTF8Encoding();
 }
 
 DatabaseProcess::~DatabaseProcess()
@@ -185,6 +191,126 @@
 #endif
 }
 
+void DatabaseProcess::getIndexedDatabaseOrigins(uint64_t callbackID)
+{
+    postDatabaseTask(createAsyncTask(*this, &DatabaseProcess::doGetIndexedDatabaseOrigins, callbackID));
+}
+
+void DatabaseProcess::doGetIndexedDatabaseOrigins(uint64_t callbackID)
+{
+    Vector<SecurityOriginData> results;
+
+    if (m_indexedDatabaseDirectory.isEmpty()) {
+        send(Messages::WebOriginDataManagerProxy::DidGetOrigins(results, callbackID), 0);
+        return;
+    }
+
+    Vector<String> originPaths = listDirectory(m_indexedDatabaseDirectory, "*");
+    for (auto& originPath : originPaths) {
+        URL url;
+        url.setProtocol(ASCIILiteral("file"));
+        url.setPath(originPath);
+
+        String databaseIdentifier = url.lastPathComponent();
+
+        RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::maybeCreateFromDatabaseIdentifier(databaseIdentifier);
+        if (!securityOrigin)
+            continue;
+
+        results.append(SecurityOriginData::fromSecurityOrigin(securityOrigin.get()));
+    }
+
+    send(Messages::WebOriginDataManagerProxy::DidGetOrigins(results, callbackID), 0);
+}
+
+static void removeAllDatabasesForOriginPath(const String& originPath, double startDate, double endDate)
+{
+    // FIXME: We should also close/invalidate any live handles to the database files we are about to delete.
+    // Right now:
+    //     - For read-only operations, they will continue functioning as normal on the unlinked file.
+    //     - For write operations, they will start producing errors as SQLite notices the missing backing store.
+    // This is tracked by https://bugs.webkit.org/show_bug.cgi?id=135347
+
+    Vector<String> databasePaths = listDirectory(originPath, "*");
+
+    for (auto& databasePath : databasePaths) {
+        String databaseFile = pathByAppendingComponent(databasePath, "IndexedDB.sqlite3");
+
+        if (!fileExists(databaseFile))
+            continue;
+
+        time_t modTime;
+        getFileModificationTime(databaseFile, modTime);
+
+        if (modTime < startDate || modTime > endDate)
+            continue;
+
+        deleteFile(databaseFile);
+        deleteEmptyDirectory(databasePath);
+    }
+
+    deleteEmptyDirectory(originPath);
+}
+
+void DatabaseProcess::deleteIndexedDatabaseEntriesForOrigin(const SecurityOriginData& origin, uint64_t callbackID)
+{
+    postDatabaseTask(createAsyncTask(*this, &DatabaseProcess::doDeleteIndexedDatabaseEntriesForOrigin, origin, callbackID));
+}
+
+void DatabaseProcess::doDeleteIndexedDatabaseEntriesForOrigin(const SecurityOriginData& originData, uint64_t callbackID)
+{
+    if (m_indexedDatabaseDirectory.isEmpty()) {
+        send(Messages::WebOriginDataManagerProxy::DidDeleteEntries(callbackID), 0);
+        return;
+    }
+
+    RefPtr<SecurityOrigin> origin = originData.securityOrigin();
+    String databaseIdentifier = origin->databaseIdentifier();
+    String originPath = pathByAppendingComponent(m_indexedDatabaseDirectory, databaseIdentifier);
+
+    removeAllDatabasesForOriginPath(originPath, std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max());
+
+    send(Messages::WebOriginDataManagerProxy::DidDeleteEntries(callbackID), 0);
+}
+
+void DatabaseProcess::deleteIndexedDatabaseEntriesModifiedBetweenDates(double startDate, double endDate, uint64_t callbackID)
+{
+    postDatabaseTask(createAsyncTask(*this, &DatabaseProcess::doDeleteIndexedDatabaseEntriesModifiedBetweenDates, startDate, endDate, callbackID));
+}
+
+void DatabaseProcess::doDeleteIndexedDatabaseEntriesModifiedBetweenDates(double startDate, double endDate, uint64_t callbackID)
+{
+    if (m_indexedDatabaseDirectory.isEmpty()) {
+        send(Messages::WebOriginDataManagerProxy::DidDeleteEntries(callbackID), 0);
+        return;
+    }
+
+    Vector<String> originPaths = listDirectory(m_indexedDatabaseDirectory, "*");
+    for (auto& originPath : originPaths)
+        removeAllDatabasesForOriginPath(originPath, startDate, endDate);
+
+    send(Messages::WebOriginDataManagerProxy::DidDeleteEntries(callbackID), 0);
+}
+
+void DatabaseProcess::deleteAllIndexedDatabaseEntries(uint64_t callbackID)
+{
+    postDatabaseTask(createAsyncTask(*this, &DatabaseProcess::doDeleteAllIndexedDatabaseEntries, callbackID));
+}
+
+void DatabaseProcess::doDeleteAllIndexedDatabaseEntries(uint64_t callbackID)
+{
+    if (m_indexedDatabaseDirectory.isEmpty()) {
+        send(Messages::WebOriginDataManagerProxy::DidDeleteAllEntries(callbackID), 0);
+        return;
+    }
+
+    Vector<String> originPaths = listDirectory(m_indexedDatabaseDirectory, "*");
+    for (auto& originPath : originPaths)
+        removeAllDatabasesForOriginPath(originPath, std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max());
+
+    send(Messages::WebOriginDataManagerProxy::DidDeleteAllEntries(callbackID), 0);
+}
+
 #if !PLATFORM(COCOA)
 void DatabaseProcess::initializeProcess(const ChildProcessInitializationParameters&)
 {

Modified: trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.h (171748 => 171749)


--- trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.h	2014-07-29 17:23:47 UTC (rev 171748)
+++ trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.h	2014-07-29 17:37:58 UTC (rev 171749)
@@ -60,6 +60,11 @@
 
     WorkQueue& queue() { return m_queue.get(); }
 
+    void getIndexedDatabaseOrigins(uint64_t callbackID);
+    void deleteIndexedDatabaseEntriesForOrigin(const SecurityOriginData&, uint64_t callbackID);
+    void deleteIndexedDatabaseEntriesModifiedBetweenDates(double startDate, double endDate, uint64_t callbackID);
+    void deleteAllIndexedDatabaseEntries(uint64_t callbackID);
+
 private:
     DatabaseProcess();
 
@@ -85,6 +90,10 @@
     // For execution on work queue thread only
     void performNextDatabaseTask();
     void ensurePathExists(const String&);
+    void doGetIndexedDatabaseOrigins(uint64_t callbackID);
+    void doDeleteIndexedDatabaseEntriesForOrigin(const SecurityOriginData&, uint64_t callbackID);
+    void doDeleteIndexedDatabaseEntriesModifiedBetweenDates(double startDate, double endDate, uint64_t callbackID);
+    void doDeleteAllIndexedDatabaseEntries(uint64_t callbackID);
 
     Vector<RefPtr<DatabaseToWebProcessConnection>> m_databaseToWebProcessConnections;
 

Modified: trunk/Source/WebKit2/Shared/WebCrossThreadCopier.cpp (171748 => 171749)


--- trunk/Source/WebKit2/Shared/WebCrossThreadCopier.cpp	2014-07-29 17:23:47 UTC (rev 171748)
+++ trunk/Source/WebKit2/Shared/WebCrossThreadCopier.cpp	2014-07-29 17:37:58 UTC (rev 171749)
@@ -28,6 +28,7 @@
 #if ENABLE(INDEXED_DATABASE)
 
 #include "IDBIdentifier.h"
+#include "SecurityOriginData.h"
 #include "UniqueIDBDatabaseIdentifier.h"
 #include <WebCore/IDBKeyData.h>
 
@@ -79,6 +80,11 @@
     return result;
 }
 
+SecurityOriginData CrossThreadCopierBase<false, false, SecurityOriginData>::copy(const SecurityOriginData& securityOriginData)
+{
+    return securityOriginData.isolatedCopy();
+}
+
 ASCIILiteral CrossThreadCopierBase<false, false, ASCIILiteral>::copy(const ASCIILiteral& literal)
 {
     return literal;

Modified: trunk/Source/WebKit2/Shared/WebCrossThreadCopier.h (171748 => 171749)


--- trunk/Source/WebKit2/Shared/WebCrossThreadCopier.h	2014-07-29 17:23:47 UTC (rev 171748)
+++ trunk/Source/WebKit2/Shared/WebCrossThreadCopier.h	2014-07-29 17:37:58 UTC (rev 171749)
@@ -36,6 +36,8 @@
 class UniqueIDBDatabaseIdentifier;
 
 enum class UniqueIDBDatabaseShutdownType;
+
+struct SecurityOriginData;
 }
 
 namespace WTF {
@@ -60,6 +62,10 @@
     }
 };
 
+template<> struct CrossThreadCopierBase<false, false, WebKit::SecurityOriginData> {
+    static WebKit::SecurityOriginData copy(const WebKit::SecurityOriginData& type);
+};
+
 template<> struct CrossThreadCopierBase<false, false, Vector<char>> {
     static Vector<char> copy(const Vector<char>&);
 };

Modified: trunk/Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp (171748 => 171749)


--- trunk/Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp	2014-07-29 17:23:47 UTC (rev 171748)
+++ trunk/Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp	2014-07-29 17:37:58 UTC (rev 171749)
@@ -31,7 +31,11 @@
 #include "WebOriginDataManagerMessages.h"
 #include "WebOriginDataManagerProxyMessages.h"
 #include "WebSecurityOrigin.h"
+#include <WebCore/SecurityOrigin.h>
+#include <wtf/NeverDestroyed.h>
 
+using namespace WebCore;
+
 namespace WebKit {
 
 const char* WebOriginDataManagerProxy::supplementName()
@@ -82,6 +86,14 @@
 
 void WebOriginDataManagerProxy::getOrigins(WKOriginDataTypes types, std::function<void (API::Array*, CallbackBase::Error)> callbackFunction)
 {
+    // FIXME: Right now we only support IndexedDatabase data so we know that we're only sending this request to the DatabaseProcess.
+    // That's why having one single callback works.
+    // In the future when we message N-processes we'll have to wait for all N replies before responding to the client.
+    if (!(types & kWKIndexedDatabaseData)) {
+        callbackFunction(nullptr, CallbackBase::Error::None);
+        return;
+    }
+
     RefPtr<ArrayCallback> callback = ArrayCallback::create(WTF::move(callbackFunction));
 
     if (!context()) {
@@ -92,24 +104,32 @@
     uint64_t callbackID = callback->callbackID();
     m_arrayCallbacks.set(callbackID, callback.release());
 
-    // FIXME (Multi-WebProcess): <rdar://problem/12239765> Make manipulating cache information work with per-tab WebProcess.
-    context()->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebOriginDataManager::GetOrigins(types, callbackID));
+    context()->sendToDatabaseProcessRelaunchingIfNecessary(Messages::WebOriginDataManager::GetOrigins(types, callbackID));
 }
 
-void WebOriginDataManagerProxy::didGetOrigins(const Vector<SecurityOriginData>& originDatas, uint64_t callbackID)
+void WebOriginDataManagerProxy::didGetOrigins(IPC::Connection* connection, const Vector<SecurityOriginData>& originIdentifiers, uint64_t callbackID)
 {
     RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
-    performAPICallbackWithSecurityOriginDataVector(originDatas, callback.get());
+    MESSAGE_CHECK_BASE(callback, connection);
+
+    Vector<RefPtr<API::Object>> securityOrigins;
+    securityOrigins.reserveInitialCapacity(originIdentifiers.size());
+
+    for (const auto& originIdentifier : originIdentifiers)
+        securityOrigins.uncheckedAppend(WebSecurityOrigin::create(originIdentifier.securityOrigin()));
+
+    callback->performCallbackWithReturnValue(API::Array::create(WTF::move(securityOrigins)).get());
 }
 
 void WebOriginDataManagerProxy::deleteEntriesForOrigin(WKOriginDataTypes types, WebSecurityOrigin* origin, std::function<void (CallbackBase::Error)> callbackFunction)
 {
-    if (!(types & kWKIndexedDatabaseData))
-        return;
-
     // FIXME: Right now we only support IndexedDatabase data so we know that we're only sending this request to the DatabaseProcess.
     // That's why having one single callback works.
     // In the future when we message N-processes we'll have to wait for all N replies before responding to the client.
+    if (!(types & kWKIndexedDatabaseData)) {
+        callbackFunction(CallbackBase::Error::None);
+        return;
+    }
 
     RefPtr<VoidCallback> callback = VoidCallback::create(WTF::move(callbackFunction));
 
@@ -131,12 +151,13 @@
 
 void WebOriginDataManagerProxy::deleteEntriesModifiedBetweenDates(WKOriginDataTypes types, double startDate, double endDate, std::function<void (CallbackBase::Error)> callbackFunction)
 {
-    if (!(types & kWKIndexedDatabaseData))
-        return;
-
     // FIXME: Right now we only support IndexedDatabase data so we know that we're only sending this request to the DatabaseProcess.
     // That's why having one single callback works.
     // In the future when we message N-processes we'll have to wait for all N replies before responding to the client.
+    if (!(types & kWKIndexedDatabaseData)) {
+        callbackFunction(CallbackBase::Error::None);
+        return;
+    }
 
     RefPtr<VoidCallback> callback = VoidCallback::create(WTF::move(callbackFunction));
 
@@ -151,20 +172,22 @@
     context()->sendToDatabaseProcessRelaunchingIfNecessary(Messages::WebOriginDataManager::DeleteEntriesModifiedBetweenDates(types, startDate, endDate, callbackID));
 }
 
-void WebOriginDataManagerProxy::didDeleteEntries(uint64_t callbackID)
+void WebOriginDataManagerProxy::didDeleteEntries(IPC::Connection* connection, uint64_t callbackID)
 {
     RefPtr<VoidCallback> callback = m_voidCallbacks.take(callbackID);
+    MESSAGE_CHECK_BASE(callback, connection);
     callback->performCallback();
 }
 
 void WebOriginDataManagerProxy::deleteAllEntries(WKOriginDataTypes types, std::function<void (CallbackBase::Error)> callbackFunction)
 {
-    if (!(types & kWKIndexedDatabaseData))
-        return;
-
     // FIXME: Right now we only support IndexedDatabase data so we know that we're only sending this request to the DatabaseProcess.
     // That's why having one single callback works.
     // In the future when we message N-processes we'll have to wait for all N replies before responding to the client.
+    if (!(types & kWKIndexedDatabaseData)) {
+        callbackFunction(CallbackBase::Error::None);
+        return;
+    }
 
     RefPtr<VoidCallback> callback = VoidCallback::create(WTF::move(callbackFunction));
 
@@ -179,9 +202,10 @@
     context()->sendToDatabaseProcessRelaunchingIfNecessary(Messages::WebOriginDataManager::DeleteAllEntries(types, callbackID));
 }
 
-void WebOriginDataManagerProxy::didDeleteAllEntries(uint64_t callbackID)
+void WebOriginDataManagerProxy::didDeleteAllEntries(IPC::Connection* connection, uint64_t callbackID)
 {
     RefPtr<VoidCallback> callback = m_voidCallbacks.take(callbackID);
+    MESSAGE_CHECK_BASE(callback, connection);
     callback->performCallback();
 }
 

Modified: trunk/Source/WebKit2/UIProcess/WebOriginDataManagerProxy.h (171748 => 171749)


--- trunk/Source/WebKit2/UIProcess/WebOriginDataManagerProxy.h	2014-07-29 17:23:47 UTC (rev 171748)
+++ trunk/Source/WebKit2/UIProcess/WebOriginDataManagerProxy.h	2014-07-29 17:37:58 UTC (rev 171749)
@@ -67,9 +67,9 @@
 private:
     explicit WebOriginDataManagerProxy(WebContext*);
 
-    void didGetOrigins(const Vector<SecurityOriginData>&, uint64_t callbackID);
-    void didDeleteEntries(uint64_t callbackID);
-    void didDeleteAllEntries(uint64_t callbackID);
+    void didGetOrigins(IPC::Connection*, const Vector<SecurityOriginData>&, uint64_t callbackID);
+    void didDeleteEntries(IPC::Connection*, uint64_t callbackID);
+    void didDeleteAllEntries(IPC::Connection*, uint64_t callbackID);
 
     // WebContextSupplement
     virtual void contextDestroyed() override;

Modified: trunk/Source/WebKit2/UIProcess/WebOriginDataManagerProxy.messages.in (171748 => 171749)


--- trunk/Source/WebKit2/UIProcess/WebOriginDataManagerProxy.messages.in	2014-07-29 17:23:47 UTC (rev 171748)
+++ trunk/Source/WebKit2/UIProcess/WebOriginDataManagerProxy.messages.in	2014-07-29 17:37:58 UTC (rev 171749)
@@ -21,7 +21,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> WebOriginDataManagerProxy {
-    DidGetOrigins(Vector<WebKit::SecurityOriginData> originIdentifiers, uint64_t callbackID);
-    DidDeleteEntries(uint64_t callbackID);
-    DidDeleteAllEntries(uint64_t callbackID);
+    DidGetOrigins(Vector<WebKit::SecurityOriginData> originIdentifiers, uint64_t callbackID) WantsConnection
+    DidDeleteEntries(uint64_t callbackID) WantsConnection
+    DidDeleteAllEntries(uint64_t callbackID) WantsConnection
 }

Modified: trunk/Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.cpp (171748 => 171749)


--- trunk/Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.cpp	2014-07-29 17:23:47 UTC (rev 171748)
+++ trunk/Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.cpp	2014-07-29 17:37:58 UTC (rev 171749)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "WebOriginDataManager.h"
 
-#include "ChildProcess.h"
+#include "DatabaseProcess.h"
 #include "SecurityOriginData.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebOriginDataManagerMessages.h"
@@ -51,48 +51,54 @@
     m_childProcess->addMessageReceiver(Messages::WebOriginDataManager::messageReceiverName(), *this);
 }
 
-void WebOriginDataManager::getOrigins(WKOriginDataTypes, uint64_t callbackID)
+void WebOriginDataManager::getOrigins(WKOriginDataTypes types, uint64_t callbackID)
 {
-    HashSet<RefPtr<SecurityOrigin>> origins;
-
-    // FIXME: populate origins
-
-    Vector<SecurityOriginData> identifiers;
-    identifiers.reserveCapacity(origins.size());
-
-    HashSet<RefPtr<SecurityOrigin>>::iterator end = origins.end();
-    HashSet<RefPtr<SecurityOrigin>>::iterator i = origins.begin();
-    for (; i != end; ++i) {
-        RefPtr<SecurityOrigin> origin = *i;
-
-        SecurityOriginData originData;
-        originData.protocol = origin->protocol();
-        originData.host = origin->host();
-        originData.port = origin->port();
-
-        identifiers.uncheckedAppend(originData);
+    // FIXME: For now, the DatabaseProcess only handles IndexedDatabase origin data.
+    // If it ever starts handling other data types (e.g. WebSQL) then it will have to aggregrate requests
+    // for multiple types into the one callback.
+    if (types & kWKIndexedDatabaseData) {
+        DatabaseProcess::shared().getIndexedDatabaseOrigins(callbackID);
+        return;
     }
 
-    m_childProcess->send(Messages::WebOriginDataManagerProxy::DidGetOrigins(identifiers, callbackID), 0);
+    Vector<SecurityOriginData> results;
+    m_childProcess->send(Messages::WebOriginDataManagerProxy::DidGetOrigins(results, callbackID), 0);
 }
 
-void WebOriginDataManager::deleteEntriesForOrigin(WKOriginDataTypes, const SecurityOriginData& origindata, uint64_t callbackID)
+void WebOriginDataManager::deleteEntriesForOrigin(WKOriginDataTypes types, const SecurityOriginData& originData, uint64_t callbackID)
 {
-    // FIXME: delete entries for origin
+    // FIXME: For now, the DatabaseProcess only handles IndexedDatabase origin data.
+    // If it ever starts handling other data types (e.g. WebSQL) then it will have to aggregrate requests
+    // for multiple types into the one callback.
+    if (types & kWKIndexedDatabaseData) {
+        DatabaseProcess::shared().deleteIndexedDatabaseEntriesForOrigin(originData, callbackID);
+        return;
+    }
+
     m_childProcess->send(Messages::WebOriginDataManagerProxy::DidDeleteEntries(callbackID), 0);
 }
 
-void WebOriginDataManager::deleteEntriesModifiedBetweenDates(WKOriginDataTypes, double, double, uint64_t callbackID)
+void WebOriginDataManager::deleteEntriesModifiedBetweenDates(WKOriginDataTypes types, double startTime, double endTime, uint64_t callbackID)
 {
-    // FIXME: delete entries modified between the start and end date
-
+    // FIXME: For now, the DatabaseProcess only handles IndexedDatabase origin data.
+    // If it ever starts handling other data types (e.g. WebSQL) then it will have to aggregrate requests
+    // for multiple types into the one callback.
+    if (types & kWKIndexedDatabaseData) {
+        DatabaseProcess::shared().deleteIndexedDatabaseEntriesModifiedBetweenDates(startTime, endTime, callbackID);
+        return;
+    }
     m_childProcess->send(Messages::WebOriginDataManagerProxy::DidDeleteEntries(callbackID), 0);
 }
 
-void WebOriginDataManager::deleteAllEntries(WKOriginDataTypes, uint64_t callbackID)
+void WebOriginDataManager::deleteAllEntries(WKOriginDataTypes types, uint64_t callbackID)
 {
-    // FIXME: delete entries
-
+    // FIXME: For now, the DatabaseProcess only handles IndexedDatabase origin data.
+    // If it ever starts handling other data types (e.g. WebSQL) then it will have to aggregrate requests
+    // for multiple types into the one callback.
+    if (types & kWKIndexedDatabaseData) {
+        DatabaseProcess::shared().deleteAllIndexedDatabaseEntries(callbackID);
+        return;
+    }
     m_childProcess->send(Messages::WebOriginDataManagerProxy::DidDeleteAllEntries(callbackID), 0);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to