Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: chrome/test/data/indexeddb/perf_shared.js

Issue 10854046: Add cache test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rolled in code review feedback. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/indexeddb/perf_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/indexeddb/perf_shared.js
diff --git a/chrome/test/data/indexeddb/perf_shared.js b/chrome/test/data/indexeddb/perf_shared.js
index 0b1e2615591fda67be02b96b2bf6cbf23ae566c0..062da3eefac3f50eea9e5addc8819377bd786ea8 100644
--- a/chrome/test/data/indexeddb/perf_shared.js
+++ b/chrome/test/data/indexeddb/perf_shared.js
@@ -278,6 +278,10 @@ function putLinearValues(
}
}
+function verifyResultNonNull(result) {
+ assert(result != null);
+}
+
function getRandomValues(
transaction, objectStoreNames, numReads, numKeys, indexName, getKey) {
if (!getKey)
@@ -291,6 +295,7 @@ function getRandomValues(
var rand = Math.floor(Math.random() * numKeys);
var request = source.get(getKey(rand));
request.onerror = onError;
+ request.onsuccess = verifyResultNonNull;
}
}
}
@@ -311,6 +316,20 @@ function putRandomValues(
}
}
+function getSpecificValues(transaction, objectStoreNames, indexName, keys) {
+ for (var i in objectStoreNames) {
+ var os = transaction.objectStore(objectStoreNames[i]);
+ var source = os;
+ if (indexName)
+ source = source.index(indexName);
+ for (var j = 0; j < keys.length; ++j) {
+ var request = source.get(keys[j]);
+ request.onerror = onError;
+ request.onsuccess = verifyResultNonNull;
+ }
+ }
+}
+
// getKey should be deterministic, as we assume that a cursor that starts at
// getKey(X) and runs through getKey(X + K) has exactly K values available.
// This is annoying to guarantee generally when using an index, so we avoid both
@@ -360,3 +379,30 @@ function getValuesFromCursor(
}
request.onerror = onError;
}
+
+function runTransactionBatch(db, count, batchFunc, objectStoreNames, mode,
+ onComplete) {
+ var numTransactionsRunning = 0;
+
+ runOneBatch(db);
+
+ function runOneBatch(db) {
+ if (count <= 0) {
+ return;
+ }
+ --count;
+ ++numTransactionsRunning;
+ var transaction = getTransaction(db, objectStoreNames, mode,
+ function() {
+ assert(!--numTransactionsRunning);
+ if (count <= 0) {
+ onComplete();
+ } else {
+ runOneBatch(db);
+ }
+ });
+
+ batchFunc(transaction);
+ }
+}
+
« no previous file with comments | « no previous file | chrome/test/data/indexeddb/perf_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698