<!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>[191877] trunk</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/191877">191877</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2015-11-01 22:52:50 -0800 (Sun, 01 Nov 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Modern IDB: IBDObjectStore.count() support.
https://bugs.webkit.org/show_bug.cgi?id=150785
Reviewed by Darin Adler.
Source/WebCore:
Tests: storage/indexeddb/modern/idbobjectstore-count-1.html
storage/indexeddb/modern/idbobjectstore-count-failures.html
* Modules/indexeddb/client/IDBConnectionToServer.cpp:
(WebCore::IDBClient::IDBConnectionToServer::getCount):
(WebCore::IDBClient::IDBConnectionToServer::didGetCount):
* Modules/indexeddb/client/IDBConnectionToServer.h:
* Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
* Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
(WebCore::IDBClient::IDBObjectStore::count):
(WebCore::IDBClient::IDBObjectStore::doCount):
* Modules/indexeddb/client/IDBObjectStoreImpl.h:
* Modules/indexeddb/client/IDBRequestImpl.cpp:
(WebCore::IDBClient::IDBRequest::setResult):
* Modules/indexeddb/client/IDBRequestImpl.h:
* Modules/indexeddb/client/IDBTransactionImpl.cpp:
(WebCore::IDBClient::IDBTransaction::requestCount):
(WebCore::IDBClient::IDBTransaction::getCountOnServer):
(WebCore::IDBClient::IDBTransaction::didGetCountOnServer):
* Modules/indexeddb/client/IDBTransactionImpl.h:
* Modules/indexeddb/server/IDBBackingStore.h:
* Modules/indexeddb/server/IDBConnectionToClient.cpp:
(WebCore::IDBServer::IDBConnectionToClient::didGetCount):
* Modules/indexeddb/server/IDBConnectionToClient.h:
* Modules/indexeddb/server/IDBConnectionToClientDelegate.h:
* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::getCount):
* Modules/indexeddb/server/IDBServer.h:
* Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
(WebCore::IDBServer::MemoryIDBBackingStore::getCount):
* Modules/indexeddb/server/MemoryIDBBackingStore.h:
* Modules/indexeddb/server/MemoryObjectStore.cpp:
(WebCore::IDBServer::MemoryObjectStore::countForKeyRange):
(WebCore::IDBServer::MemoryObjectStore::valueForKeyRange):
(WebCore::IDBServer::MemoryObjectStore::lowestKeyWithRecordInRange):
* Modules/indexeddb/server/MemoryObjectStore.h:
* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::storeCallback):
(WebCore::IDBServer::UniqueIDBDatabase::getCount):
(WebCore::IDBServer::UniqueIDBDatabase::performGetCount):
(WebCore::IDBServer::UniqueIDBDatabase::didPerformGetCount):
(WebCore::IDBServer::UniqueIDBDatabase::performCountCallback):
* Modules/indexeddb/server/UniqueIDBDatabase.h:
* Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::getRecord):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::getCount):
* Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
* Modules/indexeddb/shared/IDBResultData.cpp:
(WebCore::IDBResultData::IDBResultData):
(WebCore::IDBResultData::getCountSuccess):
* Modules/indexeddb/shared/IDBResultData.h:
(WebCore::IDBResultData::resultInteger):
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::InProcessIDBServer::didGetCount):
(WebCore::InProcessIDBServer::getCount):
* Modules/indexeddb/shared/InProcessIDBServer.h:
LayoutTests:
* storage/indexeddb/modern/idbobjectstore-count-1-expected.txt: Added.
* storage/indexeddb/modern/idbobjectstore-count-1.html: Added.
* storage/indexeddb/modern/idbobjectstore-count-failures-expected.txt: Added.
* storage/indexeddb/modern/idbobjectstore-count-failures.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBConnectionToServercpp">trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBConnectionToServerh">trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBConnectionToServerDelegateh">trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBObjectStoreImplcpp">trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBObjectStoreImplh">trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBRequestImplcpp">trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBRequestImplh">trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBTransactionImplcpp">trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBTransactionImplh">trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIDBBackingStoreh">trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIDBConnectionToClientcpp">trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIDBConnectionToClienth">trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIDBConnectionToClientDelegateh">trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIDBServercpp">trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIDBServerh">trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStorecpp">trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStoreh">trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryObjectStorecpp">trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryObjectStoreh">trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp">trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabaseh">trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabaseTransactioncpp">trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabaseTransactionh">trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbsharedIDBResultDatacpp">trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbsharedIDBResultDatah">trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbsharedInProcessIDBServercpp">trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbsharedInProcessIDBServerh">trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsstorageindexeddbmodernidbobjectstorecount1expectedtxt">trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-1-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmodernidbobjectstorecount1html">trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-1.html</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmodernidbobjectstorecountfailuresexpectedtxt">trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-failures-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmodernidbobjectstorecountfailureshtml">trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-failures.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/LayoutTests/ChangeLog        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-11-01 Brady Eidson <beidson@apple.com>
+
+ Modern IDB: IBDObjectStore.count() support.
+ https://bugs.webkit.org/show_bug.cgi?id=150785
+
+ Reviewed by Darin Adler.
+
+ * storage/indexeddb/modern/idbobjectstore-count-1-expected.txt: Added.
+ * storage/indexeddb/modern/idbobjectstore-count-1.html: Added.
+ * storage/indexeddb/modern/idbobjectstore-count-failures-expected.txt: Added.
+ * storage/indexeddb/modern/idbobjectstore-count-failures.html: Added.
+
+
</ins><span class="cx"> 2015-11-01 Yusuke Suzuki <utatane.tea@gmail.com>
</span><span class="cx">
</span><span class="cx"> [ES6] Support Generator Syntax
</span></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmodernidbobjectstorecount1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-1-expected.txt (0 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-1-expected.txt         (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-1-expected.txt        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+ALERT: Initial upgrade needed: Old version - 0 New version - 1
+ALERT: Count is: 1
+ALERT: Count is: 0
+ALERT: Count is: 0
+ALERT: Count is: 0
+ALERT: Count is: 0
+ALERT: Count is: 2
+ALERT: Count is: 0
+ALERT: Count is: 0
+ALERT: Count is: 0
+ALERT: Count is: 0
+ALERT: Count is: 3
+ALERT: Count is: 1
+ALERT: Count is: 0
+ALERT: Count is: 1
+ALERT: Count is: 0
+ALERT: Count is: 4
+ALERT: Count is: 2
+ALERT: Count is: 1
+ALERT: Count is: 2
+ALERT: Count is: 0
+ALERT: Count is: 5
+ALERT: Count is: 3
+ALERT: Count is: 2
+ALERT: Count is: 3
+ALERT: Count is: 0
+ALERT: Count is: 6
+ALERT: Count is: 4
+ALERT: Count is: 3
+ALERT: Count is: 3
+ALERT: Count is: 0
+ALERT: Count is: 7
+ALERT: Count is: 4
+ALERT: Count is: 3
+ALERT: Count is: 3
+ALERT: Count is: 1
+ALERT: Count is: 8
+ALERT: Count is: 4
+ALERT: Count is: 3
+ALERT: Count is: 3
+ALERT: Count is: 1
+ALERT: Count is: 9
+ALERT: Count is: 4
+ALERT: Count is: 3
+ALERT: Count is: 3
+ALERT: Count is: 1
+ALERT: Count is: 10
+ALERT: Count is: 4
+ALERT: Count is: 3
+ALERT: Count is: 3
+ALERT: Count is: 1
+ALERT: Initial upgrade versionchange transaction complete
+ALERT: Done
+This test exercises various uses of IDBObjectStore.count()
</ins></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmodernidbobjectstorecount1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-1.html (0 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-1.html         (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-1.html        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -0,0 +1,92 @@
</span><ins>+This test exercises various uses of IDBObjectStore.count()
+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function done()
+{
+ alert("Done");
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+var createRequest = window.indexedDB.open("IDBObjectStoreCount1Database", 1);
+var database;
+var objectStore;
+
+function getCount(arg)
+{
+ var request;
+ if (arg == undefined)
+ request = objectStore.count();
+ else
+ request = objectStore.count(arg);
+
+ request.onsuccess = function() {
+ alert("Count is: " + request.result);
+ }
+ request.onerror = function(error) {
+ alert("Unexpected error getting count: " + error);
+ done();
+ }
+}
+
+function getCounts()
+{
+ getCount();
+ getCount(IDBKeyRange.bound(3, 6));
+ getCount(IDBKeyRange.bound(3, 6, true, false));
+ getCount(IDBKeyRange.bound(3, 6, false, true));
+ getCount(7);
+}
+
+createRequest.onupgradeneeded = function(event) {
+ alert("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+
+ var versionTransaction = createRequest.transaction;
+ database = event.target.result;
+ objectStore = database.createObjectStore("TestObjectStore");
+
+ objectStore.put(1, 1);
+ getCounts();
+ objectStore.put(2, 2);
+ getCounts();
+ objectStore.put(3, 3);
+ getCounts();
+ objectStore.put(4, 4);
+ getCounts();
+ objectStore.put(5, 5);
+ getCounts();
+ objectStore.put(6, 6);
+ getCounts();
+ objectStore.put(7, 7);
+ getCounts();
+ objectStore.put(8, 8);
+ getCounts();
+ objectStore.put(9, 9);
+ getCounts();
+ objectStore.put(10, 10);
+ getCounts();
+
+ // FIXME: Once objectStore.delete() is implemented, also test counts after deleting previous records.
+
+ versionTransaction.onabort = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected abort");
+ done();
+ }
+
+ versionTransaction.oncomplete = function(event) {
+ alert("Initial upgrade versionchange transaction complete");
+ done();
+ }
+
+ versionTransaction.onerror = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected error" + event);
+ done();
+ }
+}
+
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmodernidbobjectstorecountfailuresexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-failures-expected.txt (0 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-failures-expected.txt         (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-failures-expected.txt        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+ALERT: Initial upgrade needed: Old version - 0 New version - 1
+ALERT: Failed to count records in object store with an invalid key
+ALERT: Failed to count records in object store that's been deleted
+ALERT: Initial upgrade versionchange transaction complete
+ALERT: Failed to count records in object store while transaction is inactive
+ALERT: readonly transaction complete
+ALERT: Done
+This tests some obvious failures that can happen while calling IDBObjectStore.count().
</ins></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmodernidbobjectstorecountfailureshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-failures.html (0 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-failures.html         (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-count-failures.html        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -0,0 +1,98 @@
</span><ins>+This tests some obvious failures that can happen while calling IDBObjectStore.count().
+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function done()
+{
+ alert("Done");
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+var createRequest = window.indexedDB.open("IDBObjectStoreCountFailuresDatabase", 1);
+var database;
+
+createRequest.onupgradeneeded = function(event) {
+ alert("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+
+ var versionTransaction = createRequest.transaction;
+ database = event.target.result;
+ var objectStore = database.createObjectStore("TestObjectStore");
+ var request = objectStore.put("bar", "foo");
+
+ request.onsuccess = function() {
+ try {
+ objectStore.count(NaN);
+ } catch(e) {
+ alert("Failed to count records in object store with an invalid key");
+ }
+
+ database.deleteObjectStore("TestObjectStore");
+
+ try {
+ objectStore.count();
+ } catch(e) {
+ alert("Failed to count records in object store that's been deleted");
+ }
+
+ // Recreate the objectstore because we'll need it in phase 2.
+ var objectStore = database.createObjectStore("TestObjectStore");
+ objectStore.put("bar", "foo");
+ }
+
+ versionTransaction.onabort = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected aborted");
+ done();
+ }
+
+ versionTransaction.oncomplete = function(event) {
+ alert("Initial upgrade versionchange transaction complete");
+ continueTest1();
+ }
+
+ versionTransaction.onerror = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected error" + event);
+ done();
+ }
+}
+
+function continueTest1()
+{
+ var transaction = database.transaction("TestObjectStore", "readonly");
+ var objectStore = transaction.objectStore("TestObjectStore");
+
+ // Queue up a whole bunch of gets to keep the transaction alive for awhile
+ for (var i = 0; i < 10; ++i)
+ objectStore.get("foo");
+
+ var getWhileInactive = function() {
+ try {
+ objectStore.count();
+ } catch(e) {
+ alert("Failed to count records in object store while transaction is inactive");
+ }
+ }
+
+ setTimeout(getWhileInactive, 0);
+
+ transaction.onabort = function(event) {
+ alert("readonly transaction unexpected abort" + event);
+ done();
+ }
+
+ transaction.oncomplete = function(event) {
+ alert("readonly transaction complete");
+ done();
+ }
+
+ transaction.onerror = function(event) {
+ alert("readonly transaction unexpected error" + event);
+ done();
+ }
+}
+
+</script>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/ChangeLog        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -1,3 +1,79 @@
</span><ins>+2015-11-01 Brady Eidson <beidson@apple.com>
+
+ Modern IDB: IBDObjectStore.count() support.
+ https://bugs.webkit.org/show_bug.cgi?id=150785
+
+ Reviewed by Darin Adler.
+
+ Tests: storage/indexeddb/modern/idbobjectstore-count-1.html
+ storage/indexeddb/modern/idbobjectstore-count-failures.html
+
+ * Modules/indexeddb/client/IDBConnectionToServer.cpp:
+ (WebCore::IDBClient::IDBConnectionToServer::getCount):
+ (WebCore::IDBClient::IDBConnectionToServer::didGetCount):
+ * Modules/indexeddb/client/IDBConnectionToServer.h:
+ * Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
+
+ * Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
+ (WebCore::IDBClient::IDBObjectStore::count):
+ (WebCore::IDBClient::IDBObjectStore::doCount):
+ * Modules/indexeddb/client/IDBObjectStoreImpl.h:
+
+ * Modules/indexeddb/client/IDBRequestImpl.cpp:
+ (WebCore::IDBClient::IDBRequest::setResult):
+ * Modules/indexeddb/client/IDBRequestImpl.h:
+
+ * Modules/indexeddb/client/IDBTransactionImpl.cpp:
+ (WebCore::IDBClient::IDBTransaction::requestCount):
+ (WebCore::IDBClient::IDBTransaction::getCountOnServer):
+ (WebCore::IDBClient::IDBTransaction::didGetCountOnServer):
+ * Modules/indexeddb/client/IDBTransactionImpl.h:
+
+ * Modules/indexeddb/server/IDBBackingStore.h:
+
+ * Modules/indexeddb/server/IDBConnectionToClient.cpp:
+ (WebCore::IDBServer::IDBConnectionToClient::didGetCount):
+ * Modules/indexeddb/server/IDBConnectionToClient.h:
+ * Modules/indexeddb/server/IDBConnectionToClientDelegate.h:
+
+ * Modules/indexeddb/server/IDBServer.cpp:
+ (WebCore::IDBServer::IDBServer::getCount):
+ * Modules/indexeddb/server/IDBServer.h:
+
+ * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
+ (WebCore::IDBServer::MemoryIDBBackingStore::getCount):
+ * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+
+ * Modules/indexeddb/server/MemoryObjectStore.cpp:
+ (WebCore::IDBServer::MemoryObjectStore::countForKeyRange):
+ (WebCore::IDBServer::MemoryObjectStore::valueForKeyRange):
+ (WebCore::IDBServer::MemoryObjectStore::lowestKeyWithRecordInRange):
+ * Modules/indexeddb/server/MemoryObjectStore.h:
+
+ * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabase::storeCallback):
+ (WebCore::IDBServer::UniqueIDBDatabase::getCount):
+ (WebCore::IDBServer::UniqueIDBDatabase::performGetCount):
+ (WebCore::IDBServer::UniqueIDBDatabase::didPerformGetCount):
+ (WebCore::IDBServer::UniqueIDBDatabase::performCountCallback):
+ * Modules/indexeddb/server/UniqueIDBDatabase.h:
+
+ * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabaseTransaction::getRecord):
+ (WebCore::IDBServer::UniqueIDBDatabaseTransaction::getCount):
+ * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
+
+ * Modules/indexeddb/shared/IDBResultData.cpp:
+ (WebCore::IDBResultData::IDBResultData):
+ (WebCore::IDBResultData::getCountSuccess):
+ * Modules/indexeddb/shared/IDBResultData.h:
+ (WebCore::IDBResultData::resultInteger):
+
+ * Modules/indexeddb/shared/InProcessIDBServer.cpp:
+ (WebCore::InProcessIDBServer::didGetCount):
+ (WebCore::InProcessIDBServer::getCount):
+ * Modules/indexeddb/shared/InProcessIDBServer.h:
+
</ins><span class="cx"> 2015-11-01 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> Tidy handling of type=color in HTMLInputElement a bit
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBConnectionToServercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -170,6 +170,22 @@
</span><span class="cx"> completeOperation(resultData);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void IDBConnectionToServer::getCount(TransactionOperation& operation, const IDBKeyRangeData& keyRangeData)
+{
+ LOG(IndexedDB, "IDBConnectionToServer::getCount");
+
+ ASSERT(!keyRangeData.isNull);
+
+ saveOperation(operation);
+ m_delegate->getCount(IDBRequestData(operation), keyRangeData);
+}
+
+void IDBConnectionToServer::didGetCount(const IDBResultData& resultData)
+{
+ LOG(IndexedDB, "IDBConnectionToServer::didGetCount");
+ completeOperation(resultData);
+}
+
</ins><span class="cx"> void IDBConnectionToServer::establishTransaction(IDBTransaction& transaction)
</span><span class="cx"> {
</span><span class="cx"> LOG(IndexedDB, "IDBConnectionToServer::establishTransaction");
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBConnectionToServerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -76,6 +76,9 @@
</span><span class="cx"> void getRecord(TransactionOperation&, const IDBKeyRangeData&);
</span><span class="cx"> void didGetRecord(const IDBResultData&);
</span><span class="cx">
</span><ins>+ void getCount(TransactionOperation&, const IDBKeyRangeData&);
+ void didGetCount(const IDBResultData&);
+
</ins><span class="cx"> void commitTransaction(IDBTransaction&);
</span><span class="cx"> void didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBConnectionToServerDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> virtual void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier) = 0;
</span><span class="cx"> virtual void putOrAdd(const IDBRequestData&, IDBKey*, SerializedScriptValue&, const IndexedDB::ObjectStoreOverwriteMode) = 0;
</span><span class="cx"> virtual void getRecord(const IDBRequestData&, const IDBKeyRangeData&) = 0;
</span><ins>+ virtual void getCount(const IDBRequestData&, const IDBKeyRangeData&) = 0;
</ins><span class="cx"> virtual void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&) = 0;
</span><span class="cx">
</span><span class="cx"> virtual void databaseConnectionClosed(uint64_t databaseConnectionIdentifier) = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBObjectStoreImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -325,21 +325,71 @@
</span><span class="cx"> RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext*, ExceptionCode&)
</del><ins>+RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext* context, ExceptionCode& ec)
</ins><span class="cx"> {
</span><del>- RELEASE_ASSERT_NOT_REACHED();
</del><ins>+ LOG(IndexedDB, "IDBObjectStore::count");
+
+ if (!context) {
+ ec = INVALID_STATE_ERR;
+ return nullptr;
+ }
+
+ IDBKeyRangeData range;
+ range.isNull = false;
+ return doCount(*context, range, ec);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&)
</del><ins>+RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, ExceptionCode& ec)
</ins><span class="cx"> {
</span><del>- RELEASE_ASSERT_NOT_REACHED();
</del><ins>+ LOG(IndexedDB, "IDBObjectStore::count");
+
+ if (!context) {
+ ec = INVALID_STATE_ERR;
+ return nullptr;
+ }
+
+ DOMRequestState requestState(context);
+ RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+ if (!idbKey || idbKey->type() == KeyType::Invalid) {
+ ec = static_cast<ExceptionCode>(IDBExceptionCode::DataError);
+ return nullptr;
+ }
+
+ return doCount(*context, IDBKeyRangeData(idbKey.get()), ec);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext*, const Deprecated::ScriptValue&, ExceptionCode&)
</del><ins>+RefPtr<WebCore::IDBRequest> IDBObjectStore::count(ScriptExecutionContext* context, IDBKeyRange* range, ExceptionCode& ec)
</ins><span class="cx"> {
</span><del>- RELEASE_ASSERT_NOT_REACHED();
</del><ins>+ LOG(IndexedDB, "IDBObjectStore::count");
+
+ if (!context) {
+ ec = INVALID_STATE_ERR;
+ return nullptr;
+ }
+
+ return doCount(*context, IDBKeyRangeData(range), ec);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+RefPtr<WebCore::IDBRequest> IDBObjectStore::doCount(ScriptExecutionContext& context, const IDBKeyRangeData& range, ExceptionCode& ec)
+{
+ if (!m_transaction->isActive()) {
+ ec = static_cast<ExceptionCode>(IDBExceptionCode::TransactionInactiveError);
+ return nullptr;
+ }
+
+ if (m_deleted) {
+ ec = INVALID_STATE_ERR;
+ return nullptr;
+ }
+
+ if (range.isNull) {
+ ec = static_cast<ExceptionCode>(IDBExceptionCode::DataError);
+ return nullptr;
+ }
+
+ return m_transaction->requestCount(context, *this, range);
+}
+
</ins><span class="cx"> void IDBObjectStore::markAsDeleted()
</span><span class="cx"> {
</span><span class="cx"> m_deleted = true;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBObjectStoreImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -36,6 +36,8 @@
</span><span class="cx">
</span><span class="cx"> class IDBKey;
</span><span class="cx">
</span><ins>+struct IDBKeyRangeData;
+
</ins><span class="cx"> namespace IDBClient {
</span><span class="cx">
</span><span class="cx"> class IDBTransaction;
</span><span class="lines">@@ -83,6 +85,7 @@
</span><span class="cx"> IDBObjectStore(const IDBObjectStoreInfo&, IDBTransaction&);
</span><span class="cx">
</span><span class="cx"> RefPtr<WebCore::IDBRequest> putOrAdd(JSC::ExecState&, JSC::JSValue, RefPtr<IDBKey>, IndexedDB::ObjectStoreOverwriteMode, ExceptionCode&);
</span><ins>+ RefPtr<WebCore::IDBRequest> doCount(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCode&);
</ins><span class="cx">
</span><span class="cx"> IDBObjectStoreInfo m_info;
</span><span class="cx"> Ref<IDBTransaction> m_transaction;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBRequestImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -184,6 +184,12 @@
</span><span class="cx"> m_result = IDBAny::create(WTF::move(value));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void IDBRequest::setResult(uint64_t number)
+{
+ ASSERT(scriptExecutionContext());
+ m_result = IDBAny::create(Deprecated::ScriptValue(scriptExecutionContext()->vm(), JSC::JSValue(number)));
+}
+
</ins><span class="cx"> void IDBRequest::setResultToStructuredClone(const ThreadSafeDataBuffer& valueData)
</span><span class="cx"> {
</span><span class="cx"> LOG(IndexedDB, "IDBRequest::setResultToStructuredClone");
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBRequestImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -78,6 +78,7 @@
</span><span class="cx"> void requestCompleted(const IDBResultData&);
</span><span class="cx">
</span><span class="cx"> void setResult(const IDBKeyData*);
</span><ins>+ void setResult(uint64_t);
</ins><span class="cx"> void setResultToStructuredClone(const ThreadSafeDataBuffer&);
</span><span class="cx"> void setResultToUndefined();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBTransactionImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -431,6 +431,35 @@
</span><span class="cx"> request.requestCompleted(resultData);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Ref<IDBRequest> IDBTransaction::requestCount(ScriptExecutionContext& context, IDBObjectStore& objectStore, const IDBKeyRangeData& range)
+{
+ LOG(IndexedDB, "IDBTransaction::requestCount");
+ ASSERT(isActive());
+ ASSERT(!range.isNull);
+
+ Ref<IDBRequest> request = IDBRequest::create(context, objectStore, *this);
+ addRequest(request.get());
+
+ scheduleOperation(createTransactionOperation(*this, request.get(), &IDBTransaction::didGetCountOnServer, &IDBTransaction::getCountOnServer, range));
+
+ return request;
+}
+
+void IDBTransaction::getCountOnServer(TransactionOperation& operation, const IDBKeyRangeData& keyRange)
+{
+ LOG(IndexedDB, "IDBTransaction::getCountOnServer");
+
+ serverConnection().getCount(operation, keyRange);
+}
+
+void IDBTransaction::didGetCountOnServer(IDBRequest& request, const IDBResultData& resultData)
+{
+ LOG(IndexedDB, "IDBTransaction::didGetCountOnServer");
+
+ request.setResult(resultData.resultInteger());
+ request.requestCompleted(resultData);
+}
+
</ins><span class="cx"> Ref<IDBRequest> IDBTransaction::requestClearObjectStore(ScriptExecutionContext& context, IDBObjectStore& objectStore)
</span><span class="cx"> {
</span><span class="cx"> LOG(IndexedDB, "IDBTransaction::requestClearObjectStore");
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBTransactionImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -92,6 +92,7 @@
</span><span class="cx"> Ref<IDBRequest> requestPutOrAdd(ScriptExecutionContext&, IDBObjectStore&, IDBKey*, SerializedScriptValue&, IndexedDB::ObjectStoreOverwriteMode);
</span><span class="cx"> Ref<IDBRequest> requestGetRecord(ScriptExecutionContext&, IDBObjectStore&, const IDBKeyRangeData&);
</span><span class="cx"> Ref<IDBRequest> requestClearObjectStore(ScriptExecutionContext&, IDBObjectStore&);
</span><ins>+ Ref<IDBRequest> requestCount(ScriptExecutionContext&, IDBObjectStore&, const IDBKeyRangeData&);
</ins><span class="cx">
</span><span class="cx"> void deleteObjectStore(const String& objectStoreName);
</span><span class="cx">
</span><span class="lines">@@ -136,6 +137,9 @@
</span><span class="cx"> void getRecordOnServer(TransactionOperation&, const IDBKeyRangeData&);
</span><span class="cx"> void didGetRecordOnServer(IDBRequest&, const IDBResultData&);
</span><span class="cx">
</span><ins>+ void getCountOnServer(TransactionOperation&, const IDBKeyRangeData&);
+ void didGetCountOnServer(IDBRequest&, const IDBResultData&);
+
</ins><span class="cx"> void deleteObjectStoreOnServer(TransactionOperation&, const String& objectStoreName);
</span><span class="cx"> void didDeleteObjectStoreOnServer(const IDBResultData&);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIDBBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -60,6 +60,7 @@
</span><span class="cx"> virtual IDBError deleteRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&) = 0;
</span><span class="cx"> virtual IDBError putRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) = 0;
</span><span class="cx"> virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) = 0;
</span><ins>+ virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, uint64_t& outCount) = 0;
</ins><span class="cx"> virtual IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) = 0;
</span><span class="cx">
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIDBConnectionToClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -88,6 +88,11 @@
</span><span class="cx"> m_delegate->didGetRecord(result);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void IDBConnectionToClient::didGetCount(const IDBResultData& result)
+{
+ m_delegate->didGetCount(result);
+}
+
</ins><span class="cx"> void IDBConnectionToClient::didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError& error)
</span><span class="cx"> {
</span><span class="cx"> m_delegate->didCommitTransaction(transactionIdentifier, error);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIDBConnectionToClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> void didClearObjectStore(const IDBResultData&);
</span><span class="cx"> void didPutOrAdd(const IDBResultData&);
</span><span class="cx"> void didGetRecord(const IDBResultData&);
</span><ins>+ void didGetCount(const IDBResultData&);
</ins><span class="cx">
</span><span class="cx"> void fireVersionChangeEvent(UniqueIDBDatabaseConnection&, uint64_t requestedVersion);
</span><span class="cx"> void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIDBConnectionToClientDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> virtual void didClearObjectStore(const IDBResultData&) = 0;
</span><span class="cx"> virtual void didPutOrAdd(const IDBResultData&) = 0;
</span><span class="cx"> virtual void didGetRecord(const IDBResultData&) = 0;
</span><ins>+ virtual void didGetCount(const IDBResultData&) = 0;
</ins><span class="cx">
</span><span class="cx"> virtual void fireVersionChangeEvent(UniqueIDBDatabaseConnection&, uint64_t requestedVersion) = 0;
</span><span class="cx"> virtual void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIDBServercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -213,6 +213,17 @@
</span><span class="cx"> transaction->getRecord(requestData, keyRangeData);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void IDBServer::getCount(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData)
+{
+ LOG(IndexedDB, "IDBServer::getCount");
+
+ auto transaction = m_transactions.get(requestData.transactionIdentifier());
+ if (!transaction)
+ return;
+
+ transaction->getCount(requestData, keyRangeData);
+}
+
</ins><span class="cx"> void IDBServer::establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo& info)
</span><span class="cx"> {
</span><span class="cx"> LOG(IndexedDB, "IDBServer::establishTransaction");
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIDBServerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -64,6 +64,7 @@
</span><span class="cx"> void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier);
</span><span class="cx"> void putOrAdd(const IDBRequestData&, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode);
</span><span class="cx"> void getRecord(const IDBRequestData&, const IDBKeyRangeData&);
</span><ins>+ void getCount(const IDBRequestData&, const IDBKeyRangeData&);
</ins><span class="cx"> void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&);
</span><span class="cx"> void databaseConnectionClosed(uint64_t databaseConnectionIdentifier);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -259,6 +259,23 @@
</span><span class="cx"> return IDBError();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+IDBError MemoryIDBBackingStore::getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range, uint64_t& outCount)
+{
+ LOG(IndexedDB, "MemoryIDBBackingStore::getCount");
+
+ ASSERT(objectStoreIdentifier);
+
+ if (!m_transactions.contains(transactionIdentifier))
+ return IDBError(IDBExceptionCode::Unknown, WTF::ASCIILiteral("No backing store transaction found to get count"));
+
+ MemoryObjectStore* objectStore = m_objectStoresByIdentifier.get(objectStoreIdentifier);
+ if (!objectStore)
+ return IDBError(IDBExceptionCode::Unknown, WTF::ASCIILiteral("No backing store object store found"));
+
+ outCount = objectStore->countForKeyRange(range);
+ return IDBError();
+}
+
</ins><span class="cx"> IDBError MemoryIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber)
</span><span class="cx"> {
</span><span class="cx"> LOG(IndexedDB, "MemoryIDBBackingStore::generateKeyNumber");
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx"> virtual IDBError deleteRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&) override final;
</span><span class="cx"> virtual IDBError putRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) override final;
</span><span class="cx"> virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) override final;
</span><ins>+ virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, uint64_t& outCount) override final;
</ins><span class="cx"> virtual IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) override final;
</span><span class="cx">
</span><span class="cx"> void removeObjectStoreForVersionChangeAbort(MemoryObjectStore&);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryObjectStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -131,37 +131,69 @@
</span><span class="cx"> m_orderedKeys->insert(keyData);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+uint64_t MemoryObjectStore::countForKeyRange(const IDBKeyRangeData& inRange) const
+{
+ LOG(IndexedDB, "MemoryObjectStore::countForKeyRange");
+
+ if (!m_keyValueStore)
+ return 0;
+
+ uint64_t count = 0;
+ IDBKeyRangeData range = inRange;
+ while (true) {
+ auto key = lowestKeyWithRecordInRange(range);
+ if (key.isNull())
+ break;
+
+ ++count;
+ range.lowerKey = key;
+ range.lowerOpen = true;
+ }
+
+ return count;
+}
+
</ins><span class="cx"> ThreadSafeDataBuffer MemoryObjectStore::valueForKeyRange(const IDBKeyRangeData& keyRangeData) const
</span><span class="cx"> {
</span><span class="cx"> LOG(IndexedDB, "MemoryObjectStore::valueForKey");
</span><span class="cx">
</span><del>- if (!m_keyValueStore)
</del><ins>+ IDBKeyData key = lowestKeyWithRecordInRange(keyRangeData);
+ if (key.isNull())
</ins><span class="cx"> return ThreadSafeDataBuffer();
</span><span class="cx">
</span><del>- if (keyRangeData.isExactlyOneKey())
- return m_keyValueStore->get(keyRangeData.lowerKey);
</del><ins>+ ASSERT(m_keyValueStore);
+ return m_keyValueStore->get(key);
+}
</ins><span class="cx">
</span><ins>+IDBKeyData MemoryObjectStore::lowestKeyWithRecordInRange(const IDBKeyRangeData& keyRangeData) const
+{
+ if (!m_keyValueStore)
+ return { };
+
+ if (keyRangeData.isExactlyOneKey() && m_keyValueStore->contains(keyRangeData.lowerKey))
+ return keyRangeData.lowerKey;
+
</ins><span class="cx"> ASSERT(m_orderedKeys);
</span><span class="cx">
</span><span class="cx"> auto lowestInRange = m_orderedKeys->lower_bound(keyRangeData.lowerKey);
</span><span class="cx">
</span><span class="cx"> if (lowestInRange == m_orderedKeys->end())
</span><del>- return ThreadSafeDataBuffer();
</del><ins>+ return { };
</ins><span class="cx">
</span><span class="cx"> if (keyRangeData.lowerOpen && *lowestInRange == keyRangeData.lowerKey)
</span><span class="cx"> ++lowestInRange;
</span><span class="cx">
</span><span class="cx"> if (lowestInRange == m_orderedKeys->end())
</span><del>- return ThreadSafeDataBuffer();
</del><ins>+ return { };
</ins><span class="cx">
</span><span class="cx"> if (!keyRangeData.upperKey.isNull()) {
</span><span class="cx"> if (lowestInRange->compare(keyRangeData.upperKey) > 0)
</span><del>- return ThreadSafeDataBuffer();
</del><ins>+ return { };
</ins><span class="cx"> if (keyRangeData.upperOpen && *lowestInRange == keyRangeData.upperKey)
</span><del>- return ThreadSafeDataBuffer();
</del><ins>+ return { };
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- return m_keyValueStore->get(*lowestInRange);
</del><ins>+ return *lowestInRange;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace IDBServer
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryObjectStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -69,12 +69,15 @@
</span><span class="cx"> void replaceKeyValueStore(std::unique_ptr<KeyValueMap>&&);
</span><span class="cx">
</span><span class="cx"> ThreadSafeDataBuffer valueForKeyRange(const IDBKeyRangeData&) const;
</span><ins>+ uint64_t countForKeyRange(const IDBKeyRangeData&) const;
</ins><span class="cx">
</span><span class="cx"> const IDBObjectStoreInfo& info() const { return m_info; }
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> MemoryObjectStore(const IDBObjectStoreInfo&);
</span><span class="cx">
</span><ins>+ IDBKeyData lowestKeyWithRecordInRange(const IDBKeyRangeData&) const;
+
</ins><span class="cx"> IDBObjectStoreInfo m_info;
</span><span class="cx">
</span><span class="cx"> MemoryBackingStoreTransaction* m_writeTransaction { nullptr };
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -136,24 +136,35 @@
</span><span class="cx"> uint64_t UniqueIDBDatabase::storeCallback(ErrorCallback callback)
</span><span class="cx"> {
</span><span class="cx"> uint64_t identifier = generateUniqueCallbackIdentifier();
</span><del>- m_errorCallbacks.set(identifier, callback);
</del><ins>+ ASSERT(!m_errorCallbacks.contains(identifier));
+ m_errorCallbacks.add(identifier, callback);
</ins><span class="cx"> return identifier;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> uint64_t UniqueIDBDatabase::storeCallback(KeyDataCallback callback)
</span><span class="cx"> {
</span><span class="cx"> uint64_t identifier = generateUniqueCallbackIdentifier();
</span><del>- m_keyDataCallbacks.set(identifier, callback);
</del><ins>+ ASSERT(!m_keyDataCallbacks.contains(identifier));
+ m_keyDataCallbacks.add(identifier, callback);
</ins><span class="cx"> return identifier;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> uint64_t UniqueIDBDatabase::storeCallback(ValueDataCallback callback)
</span><span class="cx"> {
</span><span class="cx"> uint64_t identifier = generateUniqueCallbackIdentifier();
</span><del>- m_valueDataCallbacks.set(identifier, callback);
</del><ins>+ ASSERT(!m_valueDataCallbacks.contains(identifier));
+ m_valueDataCallbacks.add(identifier, callback);
</ins><span class="cx"> return identifier;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+uint64_t UniqueIDBDatabase::storeCallback(CountCallback callback)
+{
+ uint64_t identifier = generateUniqueCallbackIdentifier();
+ ASSERT(!m_countCallbacks.contains(identifier));
+ m_countCallbacks.add(identifier, callback);
+ return identifier;
+}
+
</ins><span class="cx"> void UniqueIDBDatabase::startVersionChangeTransaction()
</span><span class="cx"> {
</span><span class="cx"> LOG(IndexedDB, "(main) UniqueIDBDatabase::startVersionChangeTransaction");
</span><span class="lines">@@ -431,6 +442,37 @@
</span><span class="cx"> performValueDataCallback(callbackIdentifier, error, resultData);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void UniqueIDBDatabase::getCount(const IDBRequestData& requestData, const IDBKeyRangeData& range, CountCallback callback)
+{
+ ASSERT(isMainThread());
+ LOG(IndexedDB, "(main) UniqueIDBDatabase::getCount");
+
+ uint64_t callbackID = storeCallback(callback);
+ m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performGetCount, callbackID, requestData.transactionIdentifier(), requestData.objectStoreIdentifier(), range));
+}
+
+void UniqueIDBDatabase::performGetCount(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& keyRangeData)
+{
+ ASSERT(!isMainThread());
+ LOG(IndexedDB, "(db) UniqueIDBDatabase::performGetCount");
+
+ ASSERT(m_backingStore);
+ ASSERT(objectStoreIdentifier);
+
+ uint64_t count;
+ IDBError error = m_backingStore->getCount(transactionIdentifier, objectStoreIdentifier, keyRangeData, count);
+
+ m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformGetCount, callbackIdentifier, error, count));
+}
+
+void UniqueIDBDatabase::didPerformGetCount(uint64_t callbackIdentifier, const IDBError& error, uint64_t count)
+{
+ ASSERT(isMainThread());
+ LOG(IndexedDB, "(main) UniqueIDBDatabase::didPerformGetCount");
+
+ performCountCallback(callbackIdentifier, error, count);
+}
+
</ins><span class="cx"> void UniqueIDBDatabase::commitTransaction(UniqueIDBDatabaseTransaction& transaction, ErrorCallback callback)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(isMainThread());
</span><span class="lines">@@ -701,6 +743,13 @@
</span><span class="cx"> callback(error, resultData);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void UniqueIDBDatabase::performCountCallback(uint64_t callbackIdentifier, const IDBError& error, uint64_t count)
+{
+ auto callback = m_countCallbacks.take(callbackIdentifier);
+ ASSERT(callback);
+ callback(error, count);
+}
+
</ins><span class="cx"> } // namespace IDBServer
</span><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> typedef std::function<void(const IDBError&)> ErrorCallback;
</span><span class="cx"> typedef std::function<void(const IDBError&, const IDBKeyData&)> KeyDataCallback;
</span><span class="cx"> typedef std::function<void(const IDBError&, const ThreadSafeDataBuffer&)> ValueDataCallback;
</span><ins>+typedef std::function<void(const IDBError&, uint64_t)> CountCallback;
</ins><span class="cx">
</span><span class="cx"> class UniqueIDBDatabase : public ThreadSafeRefCounted<UniqueIDBDatabase> {
</span><span class="cx"> public:
</span><span class="lines">@@ -74,6 +75,7 @@
</span><span class="cx"> void clearObjectStore(UniqueIDBDatabaseTransaction&, uint64_t objectStoreIdentifier, ErrorCallback);
</span><span class="cx"> void putOrAdd(const IDBRequestData&, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode, KeyDataCallback);
</span><span class="cx"> void getRecord(const IDBRequestData&, const IDBKeyRangeData&, ValueDataCallback);
</span><ins>+ void getCount(const IDBRequestData&, const IDBKeyRangeData&, CountCallback);
</ins><span class="cx"> void commitTransaction(UniqueIDBDatabaseTransaction&, ErrorCallback);
</span><span class="cx"> void abortTransaction(UniqueIDBDatabaseTransaction&, ErrorCallback);
</span><span class="cx"> void transactionDestroyed(UniqueIDBDatabaseTransaction&);
</span><span class="lines">@@ -104,6 +106,7 @@
</span><span class="cx"> void performClearObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier);
</span><span class="cx"> void performPutOrAdd(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode);
</span><span class="cx"> void performGetRecord(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&);
</span><ins>+ void performGetCount(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&);
</ins><span class="cx"> void performActivateTransactionInBackingStore(uint64_t callbackIdentifier, const IDBTransactionInfo&);
</span><span class="cx">
</span><span class="cx"> // Main thread callbacks
</span><span class="lines">@@ -113,6 +116,7 @@
</span><span class="cx"> void didPerformClearObjectStore(uint64_t callbackIdentifier, const IDBError&);
</span><span class="cx"> void didPerformPutOrAdd(uint64_t callbackIdentifier, const IDBError&, const IDBKeyData&);
</span><span class="cx"> void didPerformGetRecord(uint64_t callbackIdentifier, const IDBError&, const ThreadSafeDataBuffer&);
</span><ins>+ void didPerformGetCount(uint64_t callbackIdentifier, const IDBError&, uint64_t);
</ins><span class="cx"> void didPerformCommitTransaction(uint64_t callbackIdentifier, const IDBError&, const IDBResourceIdentifier& transactionIdentifier);
</span><span class="cx"> void didPerformAbortTransaction(uint64_t callbackIdentifier, const IDBError&, const IDBResourceIdentifier& transactionIdentifier);
</span><span class="cx"> void didPerformActivateTransactionInBackingStore(uint64_t callbackIdentifier, const IDBError&);
</span><span class="lines">@@ -120,10 +124,12 @@
</span><span class="cx"> uint64_t storeCallback(ErrorCallback);
</span><span class="cx"> uint64_t storeCallback(KeyDataCallback);
</span><span class="cx"> uint64_t storeCallback(ValueDataCallback);
</span><ins>+ uint64_t storeCallback(CountCallback);
</ins><span class="cx">
</span><span class="cx"> void performErrorCallback(uint64_t callbackIdentifier, const IDBError&);
</span><span class="cx"> void performKeyDataCallback(uint64_t callbackIdentifier, const IDBError&, const IDBKeyData&);
</span><span class="cx"> void performValueDataCallback(uint64_t callbackIdentifier, const IDBError&, const ThreadSafeDataBuffer&);
</span><ins>+ void performCountCallback(uint64_t callbackIdentifier, const IDBError&, uint64_t);
</ins><span class="cx">
</span><span class="cx"> void invokeTransactionScheduler();
</span><span class="cx"> void transactionSchedulingTimerFired();
</span><span class="lines">@@ -147,6 +153,7 @@
</span><span class="cx"> HashMap<uint64_t, ErrorCallback> m_errorCallbacks;
</span><span class="cx"> HashMap<uint64_t, KeyDataCallback> m_keyDataCallbacks;
</span><span class="cx"> HashMap<uint64_t, ValueDataCallback> m_valueDataCallbacks;
</span><ins>+ HashMap<uint64_t, CountCallback> m_countCallbacks;
</ins><span class="cx">
</span><span class="cx"> Timer m_transactionSchedulingTimer;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabaseTransactioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -181,6 +181,23 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void UniqueIDBDatabaseTransaction::getCount(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData)
+{
+ LOG(IndexedDB, "UniqueIDBDatabaseTransaction::getCount");
+
+ ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier());
+
+ RefPtr<UniqueIDBDatabaseTransaction> self(this);
+ m_databaseConnection->database().getCount(requestData, keyRangeData, [this, self, requestData](const IDBError& error, uint64_t count) {
+ LOG(IndexedDB, "UniqueIDBDatabaseTransaction::getCount (callback)");
+
+ if (error.isNull())
+ m_databaseConnection->connectionToClient().didGetCount(IDBResultData::getCountSuccess(requestData.requestIdentifier(), count));
+ else
+ m_databaseConnection->connectionToClient().didGetCount(IDBResultData::error(requestData.requestIdentifier(), error));
+ });
+}
+
</ins><span class="cx"> const Vector<uint64_t>& UniqueIDBDatabaseTransaction::objectStoreIdentifiers()
</span><span class="cx"> {
</span><span class="cx"> if (!m_objectStoreIdentifiers.isEmpty())
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabaseTransactionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -69,6 +69,7 @@
</span><span class="cx"> void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier);
</span><span class="cx"> void putOrAdd(const IDBRequestData&, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode);
</span><span class="cx"> void getRecord(const IDBRequestData&, const IDBKeyRangeData&);
</span><ins>+ void getCount(const IDBRequestData&, const IDBKeyRangeData&);
</ins><span class="cx">
</span><span class="cx"> void didActivateInBackingStore(const IDBError&);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbsharedIDBResultDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx"> , m_requestIdentifier(other.m_requestIdentifier)
</span><span class="cx"> , m_error(other.m_error)
</span><span class="cx"> , m_databaseConnectionIdentifier(other.m_databaseConnectionIdentifier)
</span><ins>+ , m_resultInteger(other.m_resultInteger)
</ins><span class="cx"> , m_resultData(other.m_resultData)
</span><span class="cx"> {
</span><span class="cx"> if (other.m_databaseInfo)
</span><span class="lines">@@ -117,6 +118,13 @@
</span><span class="cx"> return result;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+IDBResultData IDBResultData::getCountSuccess(const IDBResourceIdentifier& requestIdentifier, uint64_t count)
+{
+ IDBResultData result(IDBResultType::GetRecordSuccess, requestIdentifier);
+ result.m_resultInteger = count;
+ return result;
+}
+
</ins><span class="cx"> const IDBDatabaseInfo& IDBResultData::databaseInfo() const
</span><span class="cx"> {
</span><span class="cx"> RELEASE_ASSERT(m_databaseInfo);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbsharedIDBResultDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> ClearObjectStoreSuccess,
</span><span class="cx"> PutOrAddSuccess,
</span><span class="cx"> GetRecordSuccess,
</span><ins>+ GetCountSuccess,
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> namespace IDBServer {
</span><span class="lines">@@ -66,6 +67,7 @@
</span><span class="cx"> static IDBResultData clearObjectStoreSuccess(const IDBResourceIdentifier&);
</span><span class="cx"> static IDBResultData putOrAddSuccess(const IDBResourceIdentifier&, const IDBKeyData&);
</span><span class="cx"> static IDBResultData getRecordSuccess(const IDBResourceIdentifier&, const ThreadSafeDataBuffer& valueData);
</span><ins>+ static IDBResultData getCountSuccess(const IDBResourceIdentifier&, uint64_t count);
</ins><span class="cx">
</span><span class="cx"> IDBResultData(const IDBResultData&);
</span><span class="cx">
</span><span class="lines">@@ -80,6 +82,7 @@
</span><span class="cx">
</span><span class="cx"> const IDBKeyData* resultKey() const { return m_resultKey.get(); }
</span><span class="cx"> const ThreadSafeDataBuffer& resultData() const { return m_resultData; }
</span><ins>+ uint64_t resultInteger() const { return m_resultInteger; }
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> IDBResultData(const IDBResourceIdentifier&);
</span><span class="lines">@@ -93,6 +96,7 @@
</span><span class="cx"> std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
</span><span class="cx"> std::unique_ptr<IDBTransactionInfo> m_transactionInfo;
</span><span class="cx"> std::unique_ptr<IDBKeyData> m_resultKey;
</span><ins>+ uint64_t m_resultInteger { 0 };
</ins><span class="cx"> ThreadSafeDataBuffer m_resultData;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbsharedInProcessIDBServercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -159,6 +159,14 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void InProcessIDBServer::didGetCount(const IDBResultData& resultData)
+{
+ RefPtr<InProcessIDBServer> self(this);
+ RunLoop::current().dispatch([this, self, resultData] {
+ m_connectionToServer->didGetCount(resultData);
+ });
+}
+
</ins><span class="cx"> void InProcessIDBServer::abortTransaction(IDBResourceIdentifier& resourceIdentifier)
</span><span class="cx"> {
</span><span class="cx"> RefPtr<InProcessIDBServer> self(this);
</span><span class="lines">@@ -219,6 +227,13 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void InProcessIDBServer::getCount(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData)
+{
+ RefPtr<InProcessIDBServer> self(this);
+ RunLoop::current().dispatch([this, self, requestData, keyRangeData] {
+ m_server->getCount(requestData, keyRangeData);
+ });
+}
</ins><span class="cx"> void InProcessIDBServer::establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo& info)
</span><span class="cx"> {
</span><span class="cx"> RefPtr<InProcessIDBServer> self(this);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbsharedInProcessIDBServerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h (191876 => 191877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h        2015-11-02 06:01:37 UTC (rev 191876)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h        2015-11-02 06:52:50 UTC (rev 191877)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx"> virtual void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier) override final;
</span><span class="cx"> virtual void putOrAdd(const IDBRequestData&, IDBKey*, SerializedScriptValue&, const IndexedDB::ObjectStoreOverwriteMode) override final;
</span><span class="cx"> virtual void getRecord(const IDBRequestData&, const IDBKeyRangeData&) override final;
</span><ins>+ virtual void getCount(const IDBRequestData&, const IDBKeyRangeData&) override final;
</ins><span class="cx"> virtual void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&) override final;
</span><span class="cx"> virtual void databaseConnectionClosed(uint64_t databaseConnectionIdentifier) override final;
</span><span class="cx">
</span><span class="lines">@@ -77,6 +78,7 @@
</span><span class="cx"> virtual void didClearObjectStore(const IDBResultData&) override final;
</span><span class="cx"> virtual void didPutOrAdd(const IDBResultData&) override final;
</span><span class="cx"> virtual void didGetRecord(const IDBResultData&) override final;
</span><ins>+ virtual void didGetCount(const IDBResultData&) override final;
</ins><span class="cx"> virtual void fireVersionChangeEvent(IDBServer::UniqueIDBDatabaseConnection&, uint64_t requestedVersion) override final;
</span><span class="cx"> virtual void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) override final;
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>