<!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>[163266] trunk/Source</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/163266">163266</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2014-02-02 11:55:25 -0800 (Sun, 02 Feb 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>IDB: Support IDBFactory.deleteDatabase()
https://bugs.webkit.org/show_bug.cgi?id=128060
Reviewed by Filip Pizlo and Maciej Stachowiak (filesystem parts also Tim Hatcher and Simon Fraser)
Source/WebCore:
* Modules/indexeddb/IDBDatabaseBackend.cpp:
(WebCore::IDBDatabaseBackend::deleteDatabaseAsync):
* Modules/indexeddb/IDBFactory.cpp:
(WebCore::IDBFactory::deleteDatabase):
Change factory-level deleteDatabase to take opening and main frame origins:
* Modules/indexeddb/IDBFactoryBackendInterface.h:
* Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp:
(WebCore::IDBFactoryBackendLevelDB::deleteDatabase):
* Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h:
* Modules/indexeddb/IDBServerConnection.h:
* Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h:
* WebCore.exp.in:
Source/WebKit2:
* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp:
(WebKit::DatabaseProcessIDBConnection::deleteDatabase):
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
(WebKit::UniqueIDBDatabase::calculateAbsoluteDatabaseFilename): Central place to
calculate the database filename.
(WebKit::UniqueIDBDatabase::unregisterConnection):
(WebKit::UniqueIDBDatabase::shutdown): Pass shutdown type along.
(WebKit::UniqueIDBDatabase::shutdownBackingStore): If this is a delete shutdown, delete the DB.
(WebKit::UniqueIDBDatabase::didShutdownBackingStore):
(WebKit::UniqueIDBDatabase::deleteDatabase):
(WebKit::UniqueIDBDatabase::postMainThreadTask): All some tasks to bypass the no-more-request restriction.
(WebKit::UniqueIDBDatabase::postDatabaseTask): Ditto.
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::~UniqueIDBDatabaseBackingStoreSQLite):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::getOrEstablishMetadata): Use
calculateAbsoluteDatabaseFilename from UniqueIDBDatabase.
* WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp:
(WebKit::WebIDBFactoryBackend::open): Update logging channel.
(WebKit::WebIDBFactoryBackend::deleteDatabase): Implement.
* WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h:
* Shared/WebCrossThreadCopier.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBDatabaseBackendcpp">trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackend.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBFactorycpp">trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBFactoryBackendInterfaceh">trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBServerConnectionh">trunk/Source/WebCore/Modules/indexeddb/IDBServerConnection.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbleveldbIDBFactoryBackendLevelDBcpp">trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbleveldbIDBFactoryBackendLevelDBh">trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbleveldbIDBServerConnectionLevelDBh">trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessIndexedDBDatabaseProcessIDBConnectioncpp">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessIndexedDBUniqueIDBDatabasecpp">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessIndexedDBUniqueIDBDatabaseh">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessIndexedDBsqliteUniqueIDBDatabaseBackingStoreSQLitecpp">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedWebCrossThreadCopierh">trunk/Source/WebKit2/Shared/WebCrossThreadCopier.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessDatabasesIndexedDBWebIDBFactoryBackendcpp">trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessDatabasesIndexedDBWebIDBFactoryBackendh">trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebCore/ChangeLog        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2014-02-02 Brady Eidson <beidson@apple.com>
+
+ IDB: Support IDBFactory.deleteDatabase()
+ https://bugs.webkit.org/show_bug.cgi?id=128060
+
+ Reviewed by Filip Pizlo and Maciej Stachowiak (filesystem parts also Tim Hatcher and Simon Fraser)
+
+ * Modules/indexeddb/IDBDatabaseBackend.cpp:
+ (WebCore::IDBDatabaseBackend::deleteDatabaseAsync):
+
+ * Modules/indexeddb/IDBFactory.cpp:
+ (WebCore::IDBFactory::deleteDatabase):
+
+ Change factory-level deleteDatabase to take opening and main frame origins:
+ * Modules/indexeddb/IDBFactoryBackendInterface.h:
+ * Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp:
+ (WebCore::IDBFactoryBackendLevelDB::deleteDatabase):
+ * Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h:
+
+ * Modules/indexeddb/IDBServerConnection.h:
+ * Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h:
+
+ * WebCore.exp.in:
+
</ins><span class="cx"> 2014-02-02 Zalan Bujtas <zalan@apple.com>
</span><span class="cx">
</span><span class="cx"> Subpixel rendering: Introduce device pixel snapping helper functions.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBDatabaseBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackend.cpp (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackend.cpp        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackend.cpp        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -555,13 +555,13 @@
</span><span class="cx"> return connectionCount();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void IDBDatabaseBackend::deleteDatabaseAsync(PassRefPtr<IDBCallbacks> callbacks)
</del><ins>+void IDBDatabaseBackend::deleteDatabaseAsync(PassRefPtr<IDBCallbacks> prpCallbacks)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(!isDeleteDatabaseBlocked());
</span><span class="cx">
</span><span class="cx"> RefPtr<IDBDatabaseBackend> self(this);
</span><ins>+ RefPtr<IDBCallbacks> callbacks = prpCallbacks;
</ins><span class="cx"> m_serverConnection->deleteDatabase(m_metadata.name, [self, callbacks](bool success) {
</span><del>- ASSERT(self->m_deleteCallbacksWaitingCompletion.contains(callbacks));
</del><span class="cx"> self->m_deleteCallbacksWaitingCompletion.remove(callbacks);
</span><span class="cx">
</span><span class="cx"> // If this IDBDatabaseBackend was closed while waiting for deleteDatabase to complete, no point in performing any callbacks.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBFactorycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -161,7 +161,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, 0, IndexedDB::VersionNullness::Null);
</span><del>- m_backend->deleteDatabase(name, request, context->securityOrigin(), context, getIndexedDBDatabasePath(context));
</del><ins>+ m_backend->deleteDatabase(name, *context->securityOrigin(), *context->topOrigin(), request, context, getIndexedDBDatabasePath(context));
</ins><span class="cx"> return request;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBFactoryBackendInterfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx">
</span><span class="cx"> virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) = 0;
</span><span class="cx"> virtual void open(const String& name, uint64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin) = 0;
</span><del>- virtual void deleteDatabase(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) = 0;
</del><ins>+ virtual void deleteDatabase(const String& name, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin, PassRefPtr<IDBCallbacks>, ScriptExecutionContext*, const String& dataDir) = 0;
</ins><span class="cx">
</span><span class="cx"> virtual void removeIDBDatabaseBackend(const String& uniqueIdentifier) = 0;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBServerConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBServerConnection.h (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBServerConnection.h        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBServerConnection.h        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -59,13 +59,11 @@
</span><span class="cx">
</span><span class="cx"> typedef std::function<void (bool success)> BoolCallbackFunction;
</span><span class="cx">
</span><del>- // Factory-level operations
- virtual void deleteDatabase(const String& name, BoolCallbackFunction successCallback) = 0;
-
</del><span class="cx"> // Database-level operations
</span><span class="cx"> typedef std::function<void (const IDBDatabaseMetadata&, bool success)> GetIDBDatabaseMetadataFunction;
</span><span class="cx"> virtual void getOrEstablishIDBDatabaseMetadata(GetIDBDatabaseMetadataFunction) = 0;
</span><span class="cx"> virtual void close() = 0;
</span><ins>+ virtual void deleteDatabase(const String& name, BoolCallbackFunction successCallback) = 0;
</ins><span class="cx">
</span><span class="cx"> // Transaction-level operations
</span><span class="cx"> virtual void openTransaction(int64_t transactionID, const HashSet<int64_t>& objectStoreIds, IndexedDB::TransactionMode, BoolCallbackFunction successCallback) = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbleveldbIDBFactoryBackendLevelDBcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -103,10 +103,10 @@
</span><span class="cx"> callbacks->onSuccess(databaseNames.release());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void IDBFactoryBackendLevelDB::deleteDatabase(const String& name, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, ScriptExecutionContext*, const String& dataDirectory)
</del><ins>+void IDBFactoryBackendLevelDB::deleteDatabase(const String& name, const SecurityOrigin& openingOrigin, const SecurityOrigin&, PassRefPtr<IDBCallbacks> callbacks, ScriptExecutionContext*, const String& dataDirectory)
</ins><span class="cx"> {
</span><span class="cx"> LOG(StorageAPI, "IDBFactoryBackendLevelDB::deleteDatabase");
</span><del>- const String uniqueIdentifier = computeUniqueIdentifier(name, *securityOrigin);
</del><ins>+ const String uniqueIdentifier = computeUniqueIdentifier(name, openingOrigin);
</ins><span class="cx">
</span><span class="cx"> IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentifier);
</span><span class="cx"> if (it != m_databaseBackendMap.end()) {
</span><span class="lines">@@ -117,7 +117,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // FIXME: Everything from now on should be done on another thread.
</span><del>- RefPtr<IDBBackingStoreLevelDB> backingStore = openBackingStore(*securityOrigin, dataDirectory);
</del><ins>+ RefPtr<IDBBackingStoreLevelDB> backingStore = openBackingStore(openingOrigin, dataDirectory);
</ins><span class="cx"> if (!backingStore) {
</span><span class="cx"> callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Internal error opening backing store for indexedDB.deleteDatabase."));
</span><span class="cx"> return;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbleveldbIDBFactoryBackendLevelDBh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx"> virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) override final;
</span><span class="cx"> virtual void open(const String& name, uint64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin) override final;
</span><span class="cx">
</span><del>- virtual void deleteDatabase(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) override final;
</del><ins>+ virtual void deleteDatabase(const String& name, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin, PassRefPtr<IDBCallbacks>, ScriptExecutionContext*, const String& dataDir) override final;
</ins><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> virtual PassRefPtr<IDBBackingStoreLevelDB> openBackingStore(const SecurityOrigin&, const String& dataDir);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbleveldbIDBServerConnectionLevelDBh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -48,12 +48,10 @@
</span><span class="cx">
</span><span class="cx"> virtual bool isClosed() override;
</span><span class="cx">
</span><del>- // Factory-level operations
- virtual void deleteDatabase(const String& name, BoolCallbackFunction successCallback) override;
-
</del><span class="cx"> // Database-level operations
</span><span class="cx"> virtual void getOrEstablishIDBDatabaseMetadata(GetIDBDatabaseMetadataFunction) override;
</span><span class="cx"> virtual void close() override;
</span><ins>+ virtual void deleteDatabase(const String& name, BoolCallbackFunction successCallback) override;
</ins><span class="cx">
</span><span class="cx"> // Transaction-level operations
</span><span class="cx"> virtual void openTransaction(int64_t transactionID, const HashSet<int64_t>& objectStoreIds, IndexedDB::TransactionMode, BoolCallbackFunction successCallback) override;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -3103,6 +3103,7 @@
</span><span class="cx"> __ZN7WebCore10IDBKeyPathC1ERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore10IDBKeyPathC1ERKN3WTF6VectorINS1_6StringELm0ENS1_15CrashOnOverflowEEE
</span><span class="cx"> __ZN7WebCore10IDBKeyPath6decodeERNS_12KeyedDecoderERS0_
</span><ins>+__ZN7WebCore18IDBDatabaseBackend14deleteDatabaseEN3WTF10PassRefPtrINS_12IDBCallbacksEEE
</ins><span class="cx"> __ZN7WebCore18IDBDatabaseBackend14openConnectionEN3WTF10PassRefPtrINS_12IDBCallbacksEEENS2_INS_20IDBDatabaseCallbacksEEExy
</span><span class="cx"> __ZN7WebCore18IDBDatabaseBackend6createERKN3WTF6StringES4_PNS_26IDBFactoryBackendInterfaceERNS_19IDBServerConnectionE
</span><span class="cx"> __ZN7WebCore18IDBDatabaseBackendD1Ev
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebKit2/ChangeLog        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2014-02-02 Brady Eidson <beidson@apple.com>
+
+ IDB: Support IDBFactory.deleteDatabase()
+ https://bugs.webkit.org/show_bug.cgi?id=128060
+
+ Reviewed by Filip Pizlo and Maciej Stachowiak (filesystem parts also Tim Hatcher and Simon Fraser)
+
+ * DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp:
+ (WebKit::DatabaseProcessIDBConnection::deleteDatabase):
+
+ * DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
+ (WebKit::UniqueIDBDatabase::calculateAbsoluteDatabaseFilename): Central place to
+ calculate the database filename.
+ (WebKit::UniqueIDBDatabase::unregisterConnection):
+ (WebKit::UniqueIDBDatabase::shutdown): Pass shutdown type along.
+ (WebKit::UniqueIDBDatabase::shutdownBackingStore): If this is a delete shutdown, delete the DB.
+ (WebKit::UniqueIDBDatabase::didShutdownBackingStore):
+ (WebKit::UniqueIDBDatabase::deleteDatabase):
+ (WebKit::UniqueIDBDatabase::postMainThreadTask): All some tasks to bypass the no-more-request restriction.
+ (WebKit::UniqueIDBDatabase::postDatabaseTask): Ditto.
+ * DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:
+
+ * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
+ (WebKit::UniqueIDBDatabaseBackingStoreSQLite::~UniqueIDBDatabaseBackingStoreSQLite):
+ (WebKit::UniqueIDBDatabaseBackingStoreSQLite::getOrEstablishMetadata): Use
+ calculateAbsoluteDatabaseFilename from UniqueIDBDatabase.
+
+ * WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp:
+ (WebKit::WebIDBFactoryBackend::open): Update logging channel.
+ (WebKit::WebIDBFactoryBackend::deleteDatabase): Implement.
+ * WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h:
+
+ * Shared/WebCrossThreadCopier.h:
+
</ins><span class="cx"> 2014-02-01 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> More characters -> deprecatedCharacters (based on more EWS complaints)
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBDatabaseProcessIDBConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -81,10 +81,19 @@
</span><span class="cx">
</span><span class="cx"> void DatabaseProcessIDBConnection::deleteDatabase(uint64_t requestID, const String& databaseName)
</span><span class="cx"> {
</span><ins>+ ASSERT(m_uniqueIDBDatabase);
+
</ins><span class="cx"> LOG(IDB, "DatabaseProcess deleteDatabase request ID %llu", requestID);
</span><span class="cx">
</span><del>- // FIXME: Implement
- send(Messages::WebIDBServerConnection::DidDeleteDatabase(requestID, false));
</del><ins>+ if (databaseName != m_uniqueIDBDatabase->identifier().databaseName()) {
+ LOG_ERROR("Request to delete database name that doesn't match with this database connection's database name");
+ send(Messages::WebIDBServerConnection::DidDeleteDatabase(requestID, false));
+ }
+
+ RefPtr<DatabaseProcessIDBConnection> connection(this);
+ m_uniqueIDBDatabase->deleteDatabase([connection, requestID](bool success) {
+ connection->send(Messages::WebIDBServerConnection::DidDeleteDatabase(requestID, success));
+ });
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void DatabaseProcessIDBConnection::openTransaction(uint64_t requestID, int64_t transactionID, const Vector<int64_t>& objectStoreIDs, uint64_t intMode)
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBUniqueIDBDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include "DataReference.h"
</span><span class="cx"> #include "DatabaseProcess.h"
</span><span class="cx"> #include "DatabaseProcessIDBConnection.h"
</span><ins>+#include "Logging.h"
</ins><span class="cx"> #include "UniqueIDBDatabaseBackingStoreSQLite.h"
</span><span class="cx"> #include "WebCrossThreadCopier.h"
</span><span class="cx"> #include <WebCore/FileSystem.h>
</span><span class="lines">@@ -47,6 +48,11 @@
</span><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><ins>+String UniqueIDBDatabase::calculateAbsoluteDatabaseFilename(const String& absoluteDatabaseDirectory)
+{
+ return pathByAppendingComponent(absoluteDatabaseDirectory, "IndexedDB.sqlite3");
+}
+
</ins><span class="cx"> UniqueIDBDatabase::UniqueIDBDatabase(const UniqueIDBDatabaseIdentifier& identifier)
</span><span class="cx"> : m_identifier(identifier)
</span><span class="cx"> , m_acceptingNewRequests(true)
</span><span class="lines">@@ -106,15 +112,18 @@
</span><span class="cx"> m_connections.remove(&connection);
</span><span class="cx">
</span><span class="cx"> if (m_connections.isEmpty()) {
</span><del>- shutdown();
</del><ins>+ shutdown(UniqueIDBDatabaseShutdownType::NormalShutdown);
</ins><span class="cx"> DatabaseProcess::shared().removeUniqueIDBDatabase(*this);
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void UniqueIDBDatabase::shutdown()
</del><ins>+void UniqueIDBDatabase::shutdown(UniqueIDBDatabaseShutdownType type)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(isMainThread());
</span><span class="cx">
</span><ins>+ if (!m_acceptingNewRequests)
+ return;
+
</ins><span class="cx"> m_acceptingNewRequests = false;
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -135,30 +144,68 @@
</span><span class="cx">
</span><span class="cx"> for (const auto& it : m_pendingDatabaseTasks)
</span><span class="cx"> it.value->requestAborted();
</span><ins>+
+ m_pendingMetadataRequests.clear();
+ m_pendingTransactionRequests.clear();
+ m_pendingDatabaseTasks.clear();
</ins><span class="cx">
</span><span class="cx"> // Balanced by an adoptRef in ::didShutdownBackingStore()
</span><span class="cx"> ref();
</span><span class="cx">
</span><del>- DatabaseProcess::shared().queue().dispatch(bind(&UniqueIDBDatabase::shutdownBackingStore, this));
</del><ins>+ postDatabaseTask(createAsyncTask(*this, &UniqueIDBDatabase::shutdownBackingStore, type, absoluteDatabaseDirectory()), DatabaseTaskType::Shutdown);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void UniqueIDBDatabase::shutdownBackingStore()
</del><ins>+void UniqueIDBDatabase::shutdownBackingStore(UniqueIDBDatabaseShutdownType type, const String& databaseDirectory)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(!isMainThread());
</span><del>- if (m_backingStore)
- m_backingStore.clear();
</del><span class="cx">
</span><del>- RunLoop::main()->dispatch(bind(&UniqueIDBDatabase::didShutdownBackingStore, this));
</del><ins>+ m_backingStore.clear();
+
+ if (type == UniqueIDBDatabaseShutdownType::DeleteShutdown) {
+ String dbFilename = UniqueIDBDatabase::calculateAbsoluteDatabaseFilename(databaseDirectory);
+ LOG(IDB, "UniqueIDBDatabase::shutdownBackingStore deleting file '%s' on disk", dbFilename.utf8().data());
+ deleteFile(dbFilename);
+ deleteEmptyDirectory(databaseDirectory);
+ }
+
+ postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didShutdownBackingStore, type), DatabaseTaskType::Shutdown);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void UniqueIDBDatabase::didShutdownBackingStore()
</del><ins>+void UniqueIDBDatabase::didShutdownBackingStore(UniqueIDBDatabaseShutdownType type)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(isMainThread());
</span><span class="cx">
</span><span class="cx"> // Balanced by a ref in ::shutdown()
</span><span class="cx"> RefPtr<UniqueIDBDatabase> protector(adoptRef(this));
</span><ins>+
+ if (m_pendingShutdownTask)
+ m_pendingShutdownTask->completeRequest(type);
+
+ m_pendingShutdownTask = nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void UniqueIDBDatabase::deleteDatabase(std::function<void(bool)> successCallback)
+{
+ if (!m_acceptingNewRequests) {
+ // Someone else has already shutdown this database, so we can't request a delete.
+ callOnMainThread([successCallback]() {
+ successCallback(false);
+ });
+ return;
+ }
+
+ RefPtr<UniqueIDBDatabase> protector(this);
+ m_pendingShutdownTask = AsyncRequestImpl<UniqueIDBDatabaseShutdownType>::create([this, protector, successCallback](UniqueIDBDatabaseShutdownType type) {
+ // If the shutdown just completed was a Delete shutdown then we succeeded.
+ // If not report failure instead of trying again.
+ successCallback(type == UniqueIDBDatabaseShutdownType::DeleteShutdown);
+ }, [this, protector, successCallback]() {
+ successCallback(false);
+ });
+
+ shutdown(UniqueIDBDatabaseShutdownType::DeleteShutdown);
+}
+
</ins><span class="cx"> void UniqueIDBDatabase::getOrEstablishIDBDatabaseMetadata(std::function<void(bool, const IDBDatabaseMetadata&)> completionCallback)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isMainThread());
</span><span class="lines">@@ -1013,11 +1060,11 @@
</span><span class="cx"> return DatabaseProcess::shared().absoluteIndexedDatabasePathFromDatabaseRelativePath(m_databaseRelativeDirectory);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void UniqueIDBDatabase::postMainThreadTask(std::unique_ptr<AsyncTask> task)
</del><ins>+void UniqueIDBDatabase::postMainThreadTask(std::unique_ptr<AsyncTask> task, DatabaseTaskType taskType)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(!isMainThread());
</span><span class="cx">
</span><del>- if (!m_acceptingNewRequests)
</del><ins>+ if (!m_acceptingNewRequests && taskType == DatabaseTaskType::Normal)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> MutexLocker locker(m_mainThreadTaskMutex);
</span><span class="lines">@@ -1050,11 +1097,11 @@
</span><span class="cx"> task->performTask();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void UniqueIDBDatabase::postDatabaseTask(std::unique_ptr<AsyncTask> task)
</del><ins>+void UniqueIDBDatabase::postDatabaseTask(std::unique_ptr<AsyncTask> task, DatabaseTaskType taskType)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(isMainThread());
</span><span class="cx">
</span><del>- if (!m_acceptingNewRequests)
</del><ins>+ if (!m_acceptingNewRequests && taskType == DatabaseTaskType::Normal)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> MutexLocker locker(m_databaseTaskMutex);
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBUniqueIDBDatabaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -55,6 +55,11 @@
</span><span class="cx">
</span><span class="cx"> struct SecurityOriginData;
</span><span class="cx">
</span><ins>+enum class UniqueIDBDatabaseShutdownType {
+ NormalShutdown,
+ DeleteShutdown
+};
+
</ins><span class="cx"> class UniqueIDBDatabase : public ThreadSafeRefCounted<UniqueIDBDatabase> {
</span><span class="cx"> public:
</span><span class="cx"> static PassRefPtr<UniqueIDBDatabase> create(const UniqueIDBDatabaseIdentifier& identifier)
</span><span class="lines">@@ -64,11 +69,15 @@
</span><span class="cx">
</span><span class="cx"> ~UniqueIDBDatabase();
</span><span class="cx">
</span><ins>+ static String calculateAbsoluteDatabaseFilename(const String& absoluteDatabaseDirectory);
+
</ins><span class="cx"> const UniqueIDBDatabaseIdentifier& identifier() const { return m_identifier; }
</span><span class="cx">
</span><span class="cx"> void registerConnection(DatabaseProcessIDBConnection&);
</span><span class="cx"> void unregisterConnection(DatabaseProcessIDBConnection&);
</span><span class="cx">
</span><ins>+ void deleteDatabase(std::function<void(bool)> successCallback);
+
</ins><span class="cx"> void getOrEstablishIDBDatabaseMetadata(std::function<void(bool, const WebCore::IDBDatabaseMetadata&)> completionCallback);
</span><span class="cx">
</span><span class="cx"> void openTransaction(const IDBIdentifier& transactionIdentifier, const Vector<int64_t>& objectStoreIDs, WebCore::IndexedDB::TransactionMode, std::function<void(bool)> successCallback);
</span><span class="lines">@@ -107,9 +116,14 @@
</span><span class="cx">
</span><span class="cx"> String absoluteDatabaseDirectory() const;
</span><span class="cx">
</span><del>- void postDatabaseTask(std::unique_ptr<AsyncTask>);
- void shutdown();
</del><ins>+ enum class DatabaseTaskType {
+ Normal,
+ Shutdown
+ };
+ void postDatabaseTask(std::unique_ptr<AsyncTask>, DatabaseTaskType = DatabaseTaskType::Normal);
</ins><span class="cx">
</span><ins>+ void shutdown(UniqueIDBDatabaseShutdownType);
+
</ins><span class="cx"> // Method that attempts to make legal filenames from all legal database names
</span><span class="cx"> String filenameForDatabaseName() const;
</span><span class="cx">
</span><span class="lines">@@ -123,7 +137,7 @@
</span><span class="cx">
</span><span class="cx"> // To be called from the database workqueue thread only
</span><span class="cx"> void performNextDatabaseTask();
</span><del>- void postMainThreadTask(std::unique_ptr<AsyncTask>);
</del><ins>+ void postMainThreadTask(std::unique_ptr<AsyncTask>, DatabaseTaskType = DatabaseTaskType::Normal);
</ins><span class="cx"> void openBackingStoreAndReadMetadata(const UniqueIDBDatabaseIdentifier&, const String& databaseDirectory);
</span><span class="cx"> void openBackingStoreTransaction(const IDBIdentifier& transactionIdentifier, const Vector<int64_t>& objectStoreIDs, WebCore::IndexedDB::TransactionMode);
</span><span class="cx"> void beginBackingStoreTransaction(const IDBIdentifier&);
</span><span class="lines">@@ -145,7 +159,7 @@
</span><span class="cx"> void countInBackingStore(uint64_t requestID, const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyRangeData&);
</span><span class="cx"> void deleteRangeInBackingStore(uint64_t requestID, const IDBIdentifier& transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKeyRangeData&);
</span><span class="cx">
</span><del>- void shutdownBackingStore();
</del><ins>+ void shutdownBackingStore(UniqueIDBDatabaseShutdownType, const String& databaseDirectory);
</ins><span class="cx">
</span><span class="cx"> // Callbacks from the database workqueue thread, to be performed on the main thread only
</span><span class="cx"> void performNextMainThreadTask();
</span><span class="lines">@@ -165,7 +179,7 @@
</span><span class="cx"> void didCountInBackingStore(uint64_t requestID, int64_t count, uint32_t errorCode, const String& errorMessage);
</span><span class="cx"> void didDeleteRangeInBackingStore(uint64_t requestID, uint32_t errorCode, const String& errorMessage);
</span><span class="cx">
</span><del>- void didShutdownBackingStore();
</del><ins>+ void didShutdownBackingStore(UniqueIDBDatabaseShutdownType);
</ins><span class="cx"> void didCompleteBoolRequest(uint64_t requestID, bool success);
</span><span class="cx">
</span><span class="cx"> bool m_acceptingNewRequests;
</span><span class="lines">@@ -173,6 +187,7 @@
</span><span class="cx"> Deque<RefPtr<AsyncRequest>> m_pendingMetadataRequests;
</span><span class="cx"> HashMap<IDBIdentifier, RefPtr<AsyncRequest>> m_pendingTransactionRequests;
</span><span class="cx"> HashMap<uint64_t, RefPtr<AsyncRequest>> m_pendingDatabaseTasks;
</span><ins>+ RefPtr<AsyncRequest> m_pendingShutdownTask;
</ins><span class="cx">
</span><span class="cx"> std::unique_ptr<WebCore::IDBDatabaseMetadata> m_metadata;
</span><span class="cx"> bool m_didGetMetadataFromBackingStore;
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBsqliteUniqueIDBDatabaseBackingStoreSQLitecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx">
</span><span class="cx"> #include "ArgumentDecoder.h"
</span><span class="cx"> #include "IDBSerialization.h"
</span><ins>+#include "Logging.h"
</ins><span class="cx"> #include "SQLiteIDBCursor.h"
</span><span class="cx"> #include "SQLiteIDBTransaction.h"
</span><span class="cx"> #include <WebCore/FileSystem.h>
</span><span class="lines">@@ -67,6 +68,9 @@
</span><span class="cx"> UniqueIDBDatabaseBackingStoreSQLite::~UniqueIDBDatabaseBackingStoreSQLite()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!isMainThread());
</span><ins>+
+ m_transactions.clear();
+ m_sqliteDB = nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<IDBDatabaseMetadata> UniqueIDBDatabaseBackingStoreSQLite::createAndPopulateInitialMetadata()
</span><span class="lines">@@ -294,7 +298,8 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!isMainThread());
</span><span class="cx">
</span><del>- String dbFilename = pathByAppendingComponent(m_absoluteDatabaseDirectory, "IndexedDB.sqlite3");
</del><ins>+ String dbFilename = UniqueIDBDatabase::calculateAbsoluteDatabaseFilename(m_absoluteDatabaseDirectory);
+
</ins><span class="cx"> m_sqliteDB = openSQLiteDatabaseAtPath(dbFilename);
</span><span class="cx"> if (!m_sqliteDB)
</span><span class="cx"> return nullptr;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebCrossThreadCopierh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebCrossThreadCopier.h (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebCrossThreadCopier.h        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebKit2/Shared/WebCrossThreadCopier.h        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -34,6 +34,8 @@
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> class IDBIdentifier;
</span><span class="cx"> class UniqueIDBDatabaseIdentifier;
</span><ins>+
+enum class UniqueIDBDatabaseShutdownType;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> namespace WTF {
</span><span class="lines">@@ -50,6 +52,14 @@
</span><span class="cx"> static WebKit::IDBIdentifier copy(const WebKit::IDBIdentifier&);
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+
+template<> struct CrossThreadCopierBase<false, false, WebKit::UniqueIDBDatabaseShutdownType> {
+ static WebKit::UniqueIDBDatabaseShutdownType copy(const WebKit::UniqueIDBDatabaseShutdownType& type)
+ {
+ return type;
+ }
+};
+
</ins><span class="cx"> template<> struct CrossThreadCopierBase<false, false, Vector<char>> {
</span><span class="cx"> static Vector<char> copy(const Vector<char>&);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessDatabasesIndexedDBWebIDBFactoryBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx"> void WebIDBFactoryBackend::open(const String& databaseName, uint64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBDatabaseCallbacks> databaseCallbacks, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isMainThread());
</span><del>- LOG(StorageAPI, "WebIDBFactoryBackend::open");
</del><ins>+ LOG(IDB, "WebIDBFactoryBackend::open");
</ins><span class="cx">
</span><span class="cx"> String databaseIdentifier = uniqueDatabaseIdentifier(databaseName, openingOrigin, mainFrameOrigin);
</span><span class="cx"> if (databaseIdentifier.isNull()) {
</span><span class="lines">@@ -95,9 +95,30 @@
</span><span class="cx"> databaseBackend->openConnection(callbacks, databaseCallbacks, transactionId, version);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebIDBFactoryBackend::deleteDatabase(const String&, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String&)
</del><ins>+void WebIDBFactoryBackend::deleteDatabase(const String& databaseName, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin, PassRefPtr<IDBCallbacks> callbacks, ScriptExecutionContext*, const String&)
</ins><span class="cx"> {
</span><del>- notImplemented();
</del><ins>+ ASSERT(isMainThread());
+ LOG(IDB, "WebIDBFactoryBackend::deleteDatabase");
+
+ String databaseIdentifier = uniqueDatabaseIdentifier(databaseName, openingOrigin, mainFrameOrigin);
+ if (databaseIdentifier.isNull()) {
+ callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::InvalidAccessError, "Document is not allowed to use Indexed Databases"));
+ return;
+ }
+
+ // If there's already a connection to the database, delete it directly.
+ IDBDatabaseBackendMap::iterator it = sharedDatabaseBackendMap().find(databaseIdentifier);
+ if (it != sharedDatabaseBackendMap().end()) {
+ it->value->deleteDatabase(callbacks);
+ return;
+ }
+
+ RefPtr<IDBServerConnection> serverConnection = WebIDBServerConnection::create(databaseName, openingOrigin, mainFrameOrigin);
+ RefPtr<IDBDatabaseBackend> databaseBackend = IDBDatabaseBackend::create(databaseName, databaseIdentifier, this, *serverConnection);
+
+ sharedDatabaseBackendMap().set(databaseIdentifier, databaseBackend.get());
+ databaseBackend->deleteDatabase(callbacks);
+ sharedDatabaseBackendMap().remove(databaseIdentifier);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebIDBFactoryBackend::removeIDBDatabaseBackend(const String& identifier)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessDatabasesIndexedDBWebIDBFactoryBackendh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h (163265 => 163266)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h        2014-02-02 18:38:45 UTC (rev 163265)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h        2014-02-02 19:55:25 UTC (rev 163266)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx">
</span><span class="cx"> virtual void getDatabaseNames(PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::ScriptExecutionContext*, const String& dataDir) override;
</span><span class="cx"> virtual void open(const String& name, uint64_t version, int64_t transactionId, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::IDBDatabaseCallbacks>, const WebCore::SecurityOrigin& openingOrigin, const WebCore::SecurityOrigin& mainFrameOrigin) override;
</span><del>- virtual void deleteDatabase(const String& name, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::ScriptExecutionContext*, const String& dataDir) override;
</del><ins>+ virtual void deleteDatabase(const String& name, const WebCore::SecurityOrigin& openingOrigin, const WebCore::SecurityOrigin& mainFrameOrigin, PassRefPtr<WebCore::IDBCallbacks>, WebCore::ScriptExecutionContext*, const String& dataDir) override;
</ins><span class="cx">
</span><span class="cx"> virtual void removeIDBDatabaseBackend(const String& uniqueIdentifier) override;
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>