<!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>[199499] trunk/Source/WebCore</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/199499">199499</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2016-04-13 09:28:40 -0700 (Wed, 13 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Modern IDB (Blob support): Support deleting stored blob files.
https://bugs.webkit.org/show_bug.cgi?id=156523

Reviewed by Alex Christensen.

No new tests (No testable change in behavior yet, current tests pass).

There's 3 points in time when we need to delete blob files (and records of them):
1 - When deleting a specific object store record.
2 - When deleting an entire object store.
3 - When deleting a whole database.

This patch does those three things.

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteObjectStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteUnusedBlobFileRecords):
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::getRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteBackingStore):
* Modules/indexeddb/server/SQLiteIDBBackingStore.h:

* Modules/indexeddb/server/SQLiteIDBTransaction.cpp:
(WebCore::IDBServer::SQLiteIDBTransaction::commit):
(WebCore::IDBServer::SQLiteIDBTransaction::deleteBlobFilesIfNecessary):
(WebCore::IDBServer::SQLiteIDBTransaction::addRemovedBlobFile):
* Modules/indexeddb/server/SQLiteIDBTransaction.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverSQLiteIDBBackingStorecpp">trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverSQLiteIDBBackingStoreh">trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverSQLiteIDBTransactioncpp">trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverSQLiteIDBTransactionh">trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (199498 => 199499)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-13 16:25:13 UTC (rev 199498)
+++ trunk/Source/WebCore/ChangeLog        2016-04-13 16:28:40 UTC (rev 199499)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2016-04-13  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB (Blob support): Support deleting stored blob files.
+        https://bugs.webkit.org/show_bug.cgi?id=156523
+
+        Reviewed by Alex Christensen.
+
+        No new tests (No testable change in behavior yet, current tests pass).
+
+        There's 3 points in time when we need to delete blob files (and records of them):
+        1 - When deleting a specific object store record.
+        2 - When deleting an entire object store.
+        3 - When deleting a whole database.
+        
+        This patch does those three things.
+
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteObjectStore):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteUnusedBlobFileRecords):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteRecord):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::getRecord):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteBackingStore):
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+
+        * Modules/indexeddb/server/SQLiteIDBTransaction.cpp:
+        (WebCore::IDBServer::SQLiteIDBTransaction::commit):
+        (WebCore::IDBServer::SQLiteIDBTransaction::deleteBlobFilesIfNecessary):
+        (WebCore::IDBServer::SQLiteIDBTransaction::addRemovedBlobFile):
+        * Modules/indexeddb/server/SQLiteIDBTransaction.h:
+
</ins><span class="cx"> 2016-04-13  Frederic Wang  &lt;fwang@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix two coding mistakes in MathMLInlineContainerElement::childrenChanged
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverSQLiteIDBBackingStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (199498 => 199499)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp        2016-04-13 16:25:13 UTC (rev 199498)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp        2016-04-13 16:28:40 UTC (rev 199499)
</span><span class="lines">@@ -941,9 +941,24 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // Delete all unused Blob URL records.
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral(&quot;DELETE FROM BlobRecords WHERE objectStoreRow NOT IN (SELECT recordID FROM Records)&quot;));
+        if (sql.prepare() != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR(&quot;Could not delete Blob URL records(%i) - %s&quot;, m_sqliteDB-&gt;lastError(), m_sqliteDB-&gt;lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Could not delete stored blob records for deleted object store&quot;) };
+        }
+    }
+
+    // Delete all unused Blob File records.
+    auto error = deleteUnusedBlobFileRecords(*transaction);
+    if (!error.isNull())
+        return error;
+
</ins><span class="cx">     m_databaseInfo-&gt;deleteObjectStore(objectStoreIdentifier);
</span><span class="cx"> 
</span><del>-    return true;
</del><ins>+    return { };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IDBError SQLiteIDBBackingStore::clearObjectStore(const IDBResourceIdentifier&amp; transactionIdentifier, uint64_t objectStoreID)
</span><span class="lines">@@ -1251,6 +1266,47 @@
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+IDBError SQLiteIDBBackingStore::deleteUnusedBlobFileRecords(SQLiteIDBTransaction&amp; transaction)
+{
+    LOG(IndexedDB, &quot;SQLiteIDBBackingStore::deleteUnusedBlobFileRecords&quot;);
+
+    // Gather the set of blob URLs and filenames that are no longer in use.
+    HashSet&lt;String&gt; removedBlobFilenames;
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral(&quot;SELECT fileName FROM BlobFiles WHERE blobURL NOT IN (SELECT blobURL FROM BlobRecords)&quot;));
+
+        if (sql.prepare() != SQLITE_OK) {
+            LOG_ERROR(&quot;Error deleting stored blobs (%i) (Could not gather unused blobURLs) - %s&quot;, m_sqliteDB-&gt;lastError(), m_sqliteDB-&gt;lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Error deleting stored blobs&quot;) };
+        }
+
+        int result = sql.step();
+        while (result == SQLITE_ROW)
+            removedBlobFilenames.add(sql.getColumnText(1));
+
+        if (result != SQLITE_DONE) {
+            LOG_ERROR(&quot;Error deleting stored blobs (%i) (Could not gather unused blobURLs) - %s&quot;, m_sqliteDB-&gt;lastError(), m_sqliteDB-&gt;lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Error deleting stored blobs&quot;) };
+        }
+    }
+
+    // Remove the blob records that are no longer in use.
+    if (!removedBlobFilenames.isEmpty()) {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral(&quot;DELETE FROM BlobFiles WHERE blobURL NOT IN (SELECT blobURL FROM BlobRecords)&quot;));
+
+        if (sql.prepare() != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR(&quot;Error deleting stored blobs (%i) (Could not delete blobFile records) - %s&quot;, m_sqliteDB-&gt;lastError(), m_sqliteDB-&gt;lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Error deleting stored blobs&quot;) };
+        }
+    }
+
+    for (auto&amp; file : removedBlobFilenames)
+        transaction.addRemovedBlobFile(file);
+
+    return { };
+}
+
</ins><span class="cx"> IDBError SQLiteIDBBackingStore::deleteRecord(SQLiteIDBTransaction&amp; transaction, int64_t objectStoreID, const IDBKeyData&amp; keyData)
</span><span class="cx"> {
</span><span class="cx">     LOG(IndexedDB, &quot;SQLiteIDBBackingStore::deleteRecord - key %s, object store %&quot; PRIu64, keyData.loggingString().utf8().data(), objectStoreID);
</span><span class="lines">@@ -1267,6 +1323,53 @@
</span><span class="cx">         return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Unable to serialize IDBKeyData to be removed from the database&quot;) };
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // Get the record ID
+    int64_t recordID;
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral(&quot;SELECT recordID FROM Records WHERE objectStoreID = ? AND key = CAST(? AS TEXT);&quot;));
+
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindInt64(1, objectStoreID) != SQLITE_OK
+            || sql.bindBlob(2, keyBuffer-&gt;data(), keyBuffer-&gt;size()) != SQLITE_OK) {
+            LOG_ERROR(&quot;Could not delete record from object store %&quot; PRIi64 &quot; (%i) - %s&quot;, objectStoreID, m_sqliteDB-&gt;lastError(), m_sqliteDB-&gt;lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Failed to delete record from object store&quot;) };
+        }
+
+        int result = sql.step();
+
+        // If there's no record ID, there's no record to delete.
+        if (result == SQLITE_DONE)
+            return { };
+
+        if (result != SQLITE_ROW) {
+            LOG_ERROR(&quot;Could not delete record from object store %&quot; PRIi64 &quot; (%i) (unable to fetch record ID) - %s&quot;, objectStoreID, m_sqliteDB-&gt;lastError(), m_sqliteDB-&gt;lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Failed to delete record from object store&quot;) };
+        }
+
+        recordID = sql.getColumnInt64(0);
+    }
+
+    if (recordID &lt; 1) {
+        LOG_ERROR(&quot;Could not delete record from object store %&quot; PRIi64 &quot; (%i) (record ID is invalid) - %s&quot;, objectStoreID, m_sqliteDB-&gt;lastError(), m_sqliteDB-&gt;lastErrorMsg());
+        return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Failed to delete record from object store&quot;) };
+    }
+
+    // Delete the blob records for this object store record.
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral(&quot;DELETE FROM BlobRecords WHERE objectStoreRow = ?;&quot;));
+
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindInt64(1, recordID) != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR(&quot;Could not delete record from object store %&quot; PRIi64 &quot; (%i) (Could not delete BlobRecords records) - %s&quot;, objectStoreID, m_sqliteDB-&gt;lastError(), m_sqliteDB-&gt;lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Failed to delete record from object store&quot;) };
+        }
+    }
+
+    auto error = deleteUnusedBlobFileRecords(transaction);
+    if (!error.isNull())
+        return error;
+
</ins><span class="cx">     // Delete record from object store
</span><span class="cx">     {
</span><span class="cx">         SQLiteStatement sql(*m_sqliteDB, ASCIILiteral(&quot;DELETE FROM Records WHERE objectStoreID = ? AND key = CAST(? AS TEXT);&quot;));
</span><span class="lines">@@ -1464,6 +1567,8 @@
</span><span class="cx">             LOG_ERROR(&quot;Indexing new object store record failed, but unable to remove the object store record itself&quot;);
</span><span class="cx">             return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Indexing new object store record failed, but unable to remove the object store record itself&quot;) };
</span><span class="cx">         }
</span><ins>+
+        return error;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     const Vector&lt;String&gt;&amp; blobURLs = value.blobURLs();
</span><span class="lines">@@ -1862,6 +1967,32 @@
</span><span class="cx"> 
</span><span class="cx">     LOG(IndexedDB, &quot;SQLiteIDBBackingStore::deleteBackingStore deleting file '%s' on disk&quot;, dbFilename.utf8().data());
</span><span class="cx"> 
</span><ins>+    Vector&lt;String&gt; blobFiles;
+    {
+        bool errored = true;
+
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral(&quot;SELECT fileName FROM BlobFiles;&quot;));
+        if (sql.prepare() == SQLITE_OK) {
+            int result = sql.step();
+            while (result == SQLITE_ROW) {
+                blobFiles.append(sql.getColumnText(0));
+                result = sql.step();
+            }
+
+            if (result == SQLITE_DONE)
+                errored = false;
+        }
+
+        if (errored)
+            LOG_ERROR(&quot;Error getting all blob filenames to be deleted&quot;);
+    }
+
+    String databaseDirectory = fullDatabaseDirectory();
+    for (auto&amp; file : blobFiles) {
+        String fullPath = pathByAppendingComponent(databaseDirectory, file);
+        deleteFile(fullPath);
+    }
+
</ins><span class="cx">     if (m_sqliteDB) {
</span><span class="cx">         m_sqliteDB-&gt;close();
</span><span class="cx">         m_sqliteDB = nullptr;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverSQLiteIDBBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h (199498 => 199499)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h        2016-04-13 16:25:13 UTC (rev 199498)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h        2016-04-13 16:28:40 UTC (rev 199499)
</span><span class="lines">@@ -105,6 +105,8 @@
</span><span class="cx">     IDBError uncheckedPutIndexRecord(int64_t objectStoreID, int64_t indexID, const IDBKeyData&amp; keyValue, const IDBKeyData&amp; indexKey);
</span><span class="cx">     IDBError uncheckedHasIndexRecord(const IDBIndexInfo&amp;, const IDBKeyData&amp;, bool&amp; hasRecord);
</span><span class="cx"> 
</span><ins>+    IDBError deleteUnusedBlobFileRecords(SQLiteIDBTransaction&amp;);
+
</ins><span class="cx">     JSC::VM&amp; vm();
</span><span class="cx">     JSC::JSGlobalObject&amp; globalObject();
</span><span class="cx">     void initializeVM();
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverSQLiteIDBTransactioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp (199498 => 199499)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp        2016-04-13 16:25:13 UTC (rev 199498)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp        2016-04-13 16:28:40 UTC (rev 199499)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include &quot;FileSystem.h&quot;
</span><span class="cx"> #include &quot;IDBCursorInfo.h&quot;
</span><span class="cx"> #include &quot;IndexedDB.h&quot;
</span><ins>+#include &quot;Logging.h&quot;
</ins><span class="cx"> #include &quot;SQLiteIDBBackingStore.h&quot;
</span><span class="cx"> #include &quot;SQLiteIDBCursor.h&quot;
</span><span class="cx"> #include &quot;SQLiteTransaction.h&quot;
</span><span class="lines">@@ -68,6 +69,7 @@
</span><span class="cx"> 
</span><span class="cx"> IDBError SQLiteIDBTransaction::commit()
</span><span class="cx"> {
</span><ins>+    LOG(IndexedDB, &quot;SQLiteIDBTransaction::commit&quot;);
</ins><span class="cx">     if (!m_sqliteTransaction || !m_sqliteTransaction-&gt;inProgress())
</span><span class="cx">         return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;No SQLite transaction in progress to commit&quot;) };
</span><span class="cx"> 
</span><span class="lines">@@ -76,6 +78,7 @@
</span><span class="cx">     if (m_sqliteTransaction-&gt;inProgress())
</span><span class="cx">         return { IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Unable to commit SQLite transaction in database backend&quot;) };
</span><span class="cx"> 
</span><ins>+    deleteBlobFilesIfNecessary();
</ins><span class="cx">     moveBlobFilesIfNecessary();
</span><span class="cx"> 
</span><span class="cx">     reset();
</span><span class="lines">@@ -97,6 +100,18 @@
</span><span class="cx">     m_blobTemporaryAndStoredFilenames.clear();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SQLiteIDBTransaction::deleteBlobFilesIfNecessary()
+{
+    String databaseDirectory = m_backingStore.fullDatabaseDirectory();
+    for (auto&amp; entry : m_blobRemovedFilenames) {
+        String fullPath = pathByAppendingComponent(databaseDirectory, entry);
+        m_backingStore.temporaryFileHandler().prepareForAccessToTemporaryFile(entry);
+        m_backingStore.temporaryFileHandler().accessToTemporaryFileComplete(entry);
+    }
+
+    m_blobRemovedFilenames.clear();
+}
+
</ins><span class="cx"> IDBError SQLiteIDBTransaction::abort()
</span><span class="cx"> {
</span><span class="cx">     for (auto&amp; entry : m_blobTemporaryAndStoredFilenames) {
</span><span class="lines">@@ -202,6 +217,13 @@
</span><span class="cx">     m_blobTemporaryAndStoredFilenames.append({ temporaryPath, storedFilename });
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SQLiteIDBTransaction::addRemovedBlobFile(const String&amp; removedFilename)
+{
+    ASSERT(!m_blobRemovedFilenames.contains(removedFilename));
+    m_blobRemovedFilenames.add(removedFilename);
+}
+
+
</ins><span class="cx"> } // namespace IDBServer
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverSQLiteIDBTransactionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h (199498 => 199499)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h        2016-04-13 16:25:13 UTC (rev 199498)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h        2016-04-13 16:28:40 UTC (rev 199499)
</span><span class="lines">@@ -72,12 +72,14 @@
</span><span class="cx">     SQLiteTransaction* sqliteTransaction() const { return m_sqliteTransaction.get(); }
</span><span class="cx"> 
</span><span class="cx">     void addBlobFile(const String&amp; temporaryPath, const String&amp; storedFilename);
</span><ins>+    void addRemovedBlobFile(const String&amp; removedFilename);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void clearCursors();
</span><span class="cx">     void reset();
</span><span class="cx"> 
</span><span class="cx">     void moveBlobFilesIfNecessary();
</span><ins>+    void deleteBlobFilesIfNecessary();
</ins><span class="cx"> 
</span><span class="cx">     IDBTransactionInfo m_info;
</span><span class="cx"> 
</span><span class="lines">@@ -86,6 +88,7 @@
</span><span class="cx">     HashMap&lt;IDBResourceIdentifier, std::unique_ptr&lt;SQLiteIDBCursor&gt;&gt; m_cursors;
</span><span class="cx">     HashSet&lt;SQLiteIDBCursor*&gt; m_backingStoreCursors;
</span><span class="cx">     Vector&lt;std::pair&lt;String, String&gt;&gt; m_blobTemporaryAndStoredFilenames;
</span><ins>+    HashSet&lt;String&gt; m_blobRemovedFilenames;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace IDBServer
</span></span></pre>
</div>
</div>

</body>
</html>