<!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>[163249] 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/163249">163249</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2014-02-01 13:00:30 -0800 (Sat, 01 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>IDB: Implement IDBObjectStore.delete()
https://bugs.webkit.org/show_bug.cgi?id=127880

Reviewed by Sam Weinig.

Source/WebCore:

* Modules/indexeddb/IDBKeyData.cpp:
(WebCore::IDBKeyData::compare): Make this const.
* Modules/indexeddb/IDBKeyData.h:

* Modules/indexeddb/IDBKeyRangeData.cpp:
(WebCore::IDBKeyRangeData::isExactlyOneKey): Returns whether or not
  the key range is known to represent precisely one key.
* Modules/indexeddb/IDBKeyRangeData.h:

* WebCore.exp.in:

Source/WebKit2:

Implementing IDBObjectStore.delete() involves filling in the already-stubbed deleteRange() method.

* DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
(WebKit::UniqueIDBDatabase::deleteRangeInBackingStore): Call through to the backing store.

* DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::deleteRange): Call deleteRecord on each key represented
  by the passed-in keyRange. This involves collecting each key using a cursor.
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::deleteRecord): Delete an individual record from the
  object store and all associated indexes.
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:

Teach the SQLiteIDBCursor to remember if it ended in an error condition:
* DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp:
(WebKit::SQLiteIDBCursor::SQLiteIDBCursor):
(WebKit::SQLiteIDBCursor::advanceOnce):
* DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.h:
(WebKit::SQLiteIDBCursor::didError):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBKeyDatacpp">trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBKeyDatah">trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBKeyRangeDatacpp">trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBKeyRangeDatah">trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.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="#trunkSourceWebKit2DatabaseProcessIndexedDBUniqueIDBDatabasecpp">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessIndexedDBUniqueIDBDatabaseBackingStoreh">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessIndexedDBsqliteSQLiteIDBCursorcpp">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessIndexedDBsqliteSQLiteIDBCursorh">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.h</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessIndexedDBsqliteUniqueIDBDatabaseBackingStoreSQLitecpp">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessIndexedDBsqliteUniqueIDBDatabaseBackingStoreSQLiteh">trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebCore/ChangeLog        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2014-02-01  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        IDB: Implement IDBObjectStore.delete()
+        https://bugs.webkit.org/show_bug.cgi?id=127880
+
+        Reviewed by Sam Weinig.
+
+        * Modules/indexeddb/IDBKeyData.cpp:
+        (WebCore::IDBKeyData::compare): Make this const.
+        * Modules/indexeddb/IDBKeyData.h:
+
+        * Modules/indexeddb/IDBKeyRangeData.cpp:
+        (WebCore::IDBKeyRangeData::isExactlyOneKey): Returns whether or not
+          the key range is known to represent precisely one key.
+        * Modules/indexeddb/IDBKeyRangeData.h:
+
+        * WebCore.exp.in:
+
</ins><span class="cx"> 2014-02-01  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         SVGTextLayoutAttributesBuilder shouldn't use RenderText::deprecatedCharacters()
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBKeyDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -200,7 +200,7 @@
</span><span class="cx">     return decoder.decodeObjects(&quot;array&quot;, result.arrayValue, arrayFunction);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int IDBKeyData::compare(const IDBKeyData&amp; other)
</del><ins>+int IDBKeyData::compare(const IDBKeyData&amp; other) const
</ins><span class="cx"> {
</span><span class="cx">     if (type == IDBKey::InvalidType) {
</span><span class="cx">         if (other.type != IDBKey::InvalidType)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBKeyDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx">     //   - Returns negative if this IDBKeyData is less than other.
</span><span class="cx">     //   - Returns positive if this IDBKeyData is greater than other.
</span><span class="cx">     //   - Returns zero if this IDBKeyData is equal to other.
</span><del>-    int compare(const IDBKeyData&amp; other);
</del><ins>+    int compare(const IDBKeyData&amp; other) const;
</ins><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     String loggingString() const;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBKeyRangeDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.cpp (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.cpp        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.cpp        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -51,6 +51,14 @@
</span><span class="cx">     return IDBKeyRange::create(lowerKey.maybeCreateIDBKey(), upperKey.maybeCreateIDBKey(), lowerOpen ? IDBKeyRange::LowerBoundOpen : IDBKeyRange::LowerBoundClosed, upperOpen ? IDBKeyRange::UpperBoundOpen : IDBKeyRange::UpperBoundClosed);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool IDBKeyRangeData::isExactlyOneKey() const
+{
+    if (isNull || lowerOpen || upperOpen)
+        return false;
+
+    return !lowerKey.compare(upperKey);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(INDEXED_DATABASE)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBKeyRangeDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.h (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.h        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.h        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -59,6 +59,8 @@
</span><span class="cx"> 
</span><span class="cx">     PassRefPtr&lt;IDBKeyRange&gt; maybeCreateIDBKeyRange() const;
</span><span class="cx"> 
</span><ins>+    bool isExactlyOneKey() const;
+
</ins><span class="cx">     bool isNull;
</span><span class="cx"> 
</span><span class="cx">     IDBKeyData lowerKey;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -3092,12 +3092,13 @@
</span><span class="cx"> #endif
</span><span class="cx"> __ZNK7WebCore10IDBKeyData17maybeCreateIDBKeyEv
</span><span class="cx"> __ZNK7WebCore10IDBKeyData6encodeERNS_12KeyedEncoderE
</span><ins>+__ZNK7WebCore10IDBKeyData7compareERKS0_
</ins><span class="cx"> __ZNK7WebCore10IDBKeyPath6encodeERNS_12KeyedEncoderE
</span><span class="cx"> __ZNK7WebCore11IDBKeyRange9isOnlyKeyEv
</span><ins>+__ZNK7WebCore15IDBKeyRangeData15isExactlyOneKeyEv
</ins><span class="cx"> __ZNK7WebCore15IDBKeyRangeData22maybeCreateIDBKeyRangeEv
</span><span class="cx"> __ZNK7WebCore6IDBKey7isValidEv
</span><span class="cx"> __ZN7WebCore10IDBKeyData6decodeERNS_12KeyedDecoderERS0_
</span><del>-__ZN7WebCore10IDBKeyData7compareERKS0_
</del><span class="cx"> __ZN7WebCore10IDBKeyDataC1EPKNS_6IDBKeyE
</span><span class="cx"> __ZN7WebCore10IDBKeyPathC1ERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore10IDBKeyPathC1ERKN3WTF6VectorINS1_6StringELm0ENS1_15CrashOnOverflowEEE
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebKit2/ChangeLog        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -1,5 +1,32 @@
</span><span class="cx"> 2014-02-01  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        IDB: Implement IDBObjectStore.delete()
+        https://bugs.webkit.org/show_bug.cgi?id=127880
+
+        Reviewed by Sam Weinig.
+
+        Implementing IDBObjectStore.delete() involves filling in the already-stubbed deleteRange() method.
+
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
+        (WebKit::UniqueIDBDatabase::deleteRangeInBackingStore): Call through to the backing store.
+
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
+        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
+        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::deleteRange): Call deleteRecord on each key represented
+          by the passed-in keyRange. This involves collecting each key using a cursor.
+        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::deleteRecord): Delete an individual record from the
+          object store and all associated indexes.
+        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:
+
+        Teach the SQLiteIDBCursor to remember if it ended in an error condition:
+        * DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp:
+        (WebKit::SQLiteIDBCursor::SQLiteIDBCursor):
+        (WebKit::SQLiteIDBCursor::advanceOnce):
+        * DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.h:
+        (WebKit::SQLiteIDBCursor::didError):
+
+2014-02-01  Brady Eidson  &lt;beidson@apple.com&gt;
+
</ins><span class="cx">         IDB: Index reading
</span><span class="cx">         &lt;rdar://problem/15899973&gt; and https://bugs.webkit.org/show_bug.cgi?id=127868
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBUniqueIDBDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -989,11 +989,14 @@
</span><span class="cx">     request-&gt;completeRequest(count, errorCode, errorMessage);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void UniqueIDBDatabase::deleteRangeInBackingStore(uint64_t requestID, const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const IDBKeyRangeData&amp;)
</del><ins>+void UniqueIDBDatabase::deleteRangeInBackingStore(uint64_t requestID, const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const IDBKeyRangeData&amp; keyRangeData)
</ins><span class="cx"> {
</span><del>-    // FIXME: Implement
</del><ins>+    if (!m_backingStore-&gt;deleteRange(transactionIdentifier, objectStoreID, keyRangeData)) {
+        LOG_ERROR(&quot;Failed to delete range from backing store.&quot;);
+        postMainThreadTask(createAsyncTask(*this, &amp;UniqueIDBDatabase::didDeleteRangeInBackingStore, requestID, IDBDatabaseException::UnknownError, ASCIILiteral(&quot;Failed to get count from backing store&quot;)));
+    }
</ins><span class="cx"> 
</span><del>-    postMainThreadTask(createAsyncTask(*this, &amp;UniqueIDBDatabase::didDeleteRangeInBackingStore, requestID, IDBDatabaseException::UnknownError, ASCIILiteral(&quot;deleteRange in backing store not supported yet&quot;)));
</del><ins>+    postMainThreadTask(createAsyncTask(*this, &amp;UniqueIDBDatabase::didDeleteRangeInBackingStore, requestID, 0, String(StringImpl::empty())));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void UniqueIDBDatabase::didDeleteRangeInBackingStore(uint64_t requestID, uint32_t errorCode, const String&amp; errorMessage)
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBUniqueIDBDatabaseBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -70,6 +70,7 @@
</span><span class="cx">     virtual bool putRecord(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKey&amp;, const uint8_t* valueBuffer, size_t valueSize) = 0;
</span><span class="cx">     virtual bool putIndexRecord(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyData&amp;, const WebCore::IDBKeyData&amp; indexKey) = 0;
</span><span class="cx">     virtual bool getIndexRecord(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyRangeData&amp;, RefPtr&lt;WebCore::SharedBuffer&gt;&amp; result) = 0;
</span><ins>+    virtual bool deleteRange(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKeyRangeData&amp;) = 0;
</ins><span class="cx"> 
</span><span class="cx">     virtual bool getKeyRecordFromObjectStore(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKey&amp;, RefPtr&lt;WebCore::SharedBuffer&gt;&amp; result) = 0;
</span><span class="cx">     virtual bool getKeyRangeRecordFromObjectStore(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKeyRange&amp;, RefPtr&lt;WebCore::SharedBuffer&gt;&amp; result, RefPtr&lt;WebCore::IDBKey&gt;&amp; resultKey) = 0;
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBsqliteSQLiteIDBCursorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx">     , m_cursorDirection(cursorDirection)
</span><span class="cx">     , m_keyRange(keyRange)
</span><span class="cx">     , m_completed(false)
</span><ins>+    , m_errored(false)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(m_objectStoreID);
</span><span class="cx"> }
</span><span class="lines">@@ -262,6 +263,7 @@
</span><span class="cx">     if (result != SQLResultRow) {
</span><span class="cx">         LOG_ERROR(&quot;Error advancing cursor - (%i) %s&quot;, result, m_transaction-&gt;sqliteTransaction()-&gt;database().lastErrorMsg());
</span><span class="cx">         m_completed = true;
</span><ins>+        m_errored = true;
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -272,6 +274,7 @@
</span><span class="cx">     if (!deserializeIDBKeyData(reinterpret_cast&lt;const uint8_t*&gt;(keyData.data()), keyData.size(), key)) {
</span><span class="cx">         LOG_ERROR(&quot;Unable to deserialize key data from database while advancing cursor&quot;);
</span><span class="cx">         m_completed = true;
</span><ins>+        m_errored = true;
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -285,6 +288,7 @@
</span><span class="cx">         if (!deserializeIDBKeyData(reinterpret_cast&lt;const uint8_t*&gt;(keyData.data()), keyData.size(), m_currentValueKey)) {
</span><span class="cx">             LOG_ERROR(&quot;Unable to deserialize value data from database while advancing index cursor&quot;);
</span><span class="cx">             m_completed = true;
</span><ins>+            m_errored = true;
</ins><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -295,6 +299,8 @@
</span><span class="cx">             || objectStoreStatement.bindInt64(2, m_objectStoreID) != SQLResultOk
</span><span class="cx">             || objectStoreStatement.step() != SQLResultRow) {
</span><span class="cx">             LOG_ERROR(&quot;Could not create index cursor statement into object store records&quot;);
</span><ins>+            m_completed = true;
+            m_errored = true;
</ins><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBsqliteSQLiteIDBCursorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.h (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.h        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.h        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -64,6 +64,8 @@
</span><span class="cx">     bool advance(uint64_t count);
</span><span class="cx">     bool iterate(const WebCore::IDBKeyData&amp; targetKey);
</span><span class="cx"> 
</span><ins>+    bool didError() const { return m_errored; }
+
</ins><span class="cx"> private:
</span><span class="cx">     SQLiteIDBCursor(SQLiteIDBTransaction*, const IDBIdentifier&amp; cursorIdentifier, int64_t objectStoreID, int64_t indexID, WebCore::IndexedDB::CursorDirection, WebCore::IndexedDB::CursorType, WebCore::IDBDatabaseBackend::TaskType, const WebCore::IDBKeyRangeData&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -88,6 +90,7 @@
</span><span class="cx">     std::unique_ptr&lt;WebCore::SQLiteStatement&gt; m_statement;
</span><span class="cx"> 
</span><span class="cx">     bool m_completed;
</span><ins>+    bool m_errored;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBsqliteUniqueIDBDatabaseBackingStoreSQLitecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -838,6 +838,108 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool UniqueIDBDatabaseBackingStoreSQLite::deleteRange(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const IDBKeyRangeData&amp; keyRangeData)
+{
+    ASSERT(!isMainThread());
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB-&gt;isOpen());
+
+    SQLiteIDBTransaction* transaction = m_transactions.get(transactionIdentifier);
+    if (!transaction || !transaction-&gt;inProgress()) {
+        LOG_ERROR(&quot;Attempt to get count from database without an established, in-progress transaction&quot;);
+        return false;
+    }
+
+    if (transaction-&gt;mode() == IndexedDB::TransactionMode::ReadOnly) {
+        LOG_ERROR(&quot;Attempt to delete range from a read-only transaction&quot;);
+        return false;
+    }
+
+    // If the range to delete is exactly one key we can delete it right now.
+    if (keyRangeData.isExactlyOneKey()) {
+        if (!deleteRecord(*transaction, objectStoreID, keyRangeData.lowerKey)) {
+            LOG_ERROR(&quot;Failed to delete record for key '%s'&quot;, keyRangeData.lowerKey.loggingString().utf8().data());
+            return false;
+        }
+        return true;
+    }
+
+    // Otherwise the range might span multiple keys so we collect them with a cursor.
+    SQLiteIDBCursor* cursor = transaction-&gt;openCursor(objectStoreID, IDBIndexMetadata::InvalidId, IndexedDB::CursorDirection::Next, IndexedDB::CursorType::KeyAndValue, IDBDatabaseBackend::NormalTask, keyRangeData);
+
+    if (!cursor) {
+        LOG_ERROR(&quot;Cannot open cursor to perform index get in database&quot;);
+        return false;
+    }
+
+    m_cursors.set(cursor-&gt;identifier(), cursor);
+
+    Vector&lt;IDBKeyData&gt; keys;
+    do
+        keys.append(cursor-&gt;currentKey());
+    while (cursor-&gt;advance(1));
+
+    bool cursorDidError = cursor-&gt;didError();
+
+    // closeCursor() will remove the cursor from m_cursors and delete the cursor object
+    transaction-&gt;closeCursor(*cursor);
+
+    if (cursorDidError) {
+        LOG_ERROR(&quot;Unable to iterate over object store to deleteRange in database&quot;);
+        return false;
+    }
+
+    for (auto&amp; key : keys) {
+        if (!deleteRecord(*transaction, objectStoreID, key)) {
+            LOG_ERROR(&quot;Failed to delete record for key '%s'&quot;, key.loggingString().utf8().data());
+            return false;
+        }
+    }
+
+    return true;
+}
+
+bool UniqueIDBDatabaseBackingStoreSQLite::deleteRecord(SQLiteIDBTransaction&amp; transaction, int64_t objectStoreID, const WebCore::IDBKeyData&amp; key)
+{
+    ASSERT(!isMainThread());
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB-&gt;isOpen());
+
+    RefPtr&lt;SharedBuffer&gt; keyBuffer = serializeIDBKeyData(key);
+    if (!keyBuffer) {
+        LOG_ERROR(&quot;Unable to serialize IDBKeyData to be removed from the database&quot;);
+        return false;
+    }
+
+    // Delete record from object store
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral(&quot;DELETE FROM Records WHERE objectStoreID = ? AND key = CAST(? AS TEXT);&quot;));
+
+        if (sql.prepare() != SQLResultOk
+            || sql.bindInt64(1, objectStoreID) != SQLResultOk
+            || sql.bindBlob(2, keyBuffer-&gt;data(), keyBuffer-&gt;size()) != SQLResultOk
+            || sql.step() != SQLResultDone) {
+            LOG_ERROR(&quot;Could not delete record from object store %lli (%i) - %s&quot;, objectStoreID, m_sqliteDB-&gt;lastError(), m_sqliteDB-&gt;lastErrorMsg());
+            return false;
+        }
+    }
+
+    // Delete record from indexes store
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral(&quot;DELETE FROM IndexRecords WHERE objectStoreID = ? AND value = CAST(? AS TEXT);&quot;));
+
+        if (sql.prepare() != SQLResultOk
+            || sql.bindInt64(1, objectStoreID) != SQLResultOk
+            || sql.bindBlob(2, keyBuffer-&gt;data(), keyBuffer-&gt;size()) != SQLResultOk
+            || sql.step() != SQLResultDone) {
+            LOG_ERROR(&quot;Could not delete record from indexes for object store %lli (%i) - %s&quot;, objectStoreID, m_sqliteDB-&gt;lastError(), m_sqliteDB-&gt;lastErrorMsg());
+            return false;
+        }
+    }
+
+    return true;
+}
+
</ins><span class="cx"> bool UniqueIDBDatabaseBackingStoreSQLite::getKeyRecordFromObjectStore(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const IDBKey&amp; key, RefPtr&lt;SharedBuffer&gt;&amp; result)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!isMainThread());
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessIndexedDBsqliteUniqueIDBDatabaseBackingStoreSQLiteh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h (163248 => 163249)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h        2014-02-01 20:37:15 UTC (rev 163248)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h        2014-02-01 21:00:30 UTC (rev 163249)
</span><span class="lines">@@ -75,6 +75,7 @@
</span><span class="cx">     virtual bool putRecord(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKey&amp;, const uint8_t* valueBuffer, size_t valueSize) override;
</span><span class="cx">     virtual bool putIndexRecord(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyData&amp; keyValue, const WebCore::IDBKeyData&amp; indexKey) override;
</span><span class="cx">     virtual bool getIndexRecord(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyRangeData&amp;, RefPtr&lt;WebCore::SharedBuffer&gt;&amp; result) override;
</span><ins>+    virtual bool deleteRange(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKeyRangeData&amp;) override;
</ins><span class="cx"> 
</span><span class="cx">     virtual bool getKeyRecordFromObjectStore(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKey&amp;, RefPtr&lt;WebCore::SharedBuffer&gt;&amp; result) override;
</span><span class="cx">     virtual bool getKeyRangeRecordFromObjectStore(const IDBIdentifier&amp; transactionIdentifier, int64_t objectStoreID, const WebCore::IDBKeyRange&amp;, RefPtr&lt;WebCore::SharedBuffer&gt;&amp; result, RefPtr&lt;WebCore::IDBKey&gt;&amp; resultKey) override;
</span><span class="lines">@@ -93,6 +94,8 @@
</span><span class="cx">     std::unique_ptr&lt;WebCore::IDBDatabaseMetadata&gt; extractExistingMetadata();
</span><span class="cx">     std::unique_ptr&lt;WebCore::IDBDatabaseMetadata&gt; createAndPopulateInitialMetadata();
</span><span class="cx"> 
</span><ins>+    bool deleteRecord(SQLiteIDBTransaction&amp;, int64_t objectStoreID, const WebCore::IDBKeyData&amp;);
+
</ins><span class="cx">     int idbKeyCollate(int aLength, const void* a, int bLength, const void* b);
</span><span class="cx"> 
</span><span class="cx">     UniqueIDBDatabaseIdentifier m_identifier;
</span></span></pre>
</div>
</div>

</body>
</html>