OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 window.indexedDB = window.indexedDB || window.webkitIndexedDB || | 5 window.indexedDB = window.indexedDB || window.webkitIndexedDB || |
6 window.mozIndexedDB || window.msIndexedDB; | 6 window.mozIndexedDB || window.msIndexedDB; |
7 window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange; | 7 window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange; |
8 | 8 |
9 var automation = { | 9 var automation = { |
10 results: {} | 10 results: {} |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 } | 325 } |
326 var oos; | 326 var oos; |
327 if (outputObjectStoreName) | 327 if (outputObjectStoreName) |
328 oos = transaction.objectStore(outputObjectStoreName); | 328 oos = transaction.objectStore(outputObjectStoreName); |
329 var numReadsLeft = numReads; | 329 var numReadsLeft = numReads; |
330 request.onsuccess = function(event) { | 330 request.onsuccess = function(event) { |
331 var cursor = event.target.result; | 331 var cursor = event.target.result; |
332 if (cursor) { | 332 if (cursor) { |
333 assert(numReadsLeft); | 333 assert(numReadsLeft); |
334 --numReadsLeft; | 334 --numReadsLeft; |
335 if (oos) // Put in random order for maximum difficulty. | 335 if (oos) |
336 oos.put(cursor.value, Math.random()); | 336 // Put in random order for maximum difficulty. We add in numKeys just |
| 337 // in case we're writing back to the same store; this way we won't |
| 338 // affect the number of keys available to the cursor, since we're always |
| 339 // outside its range. |
| 340 oos.put(cursor.value, numKeys + Math.random()); |
337 values.push({key: cursor.key, value: cursor.value}); | 341 values.push({key: cursor.key, value: cursor.value}); |
338 cursor.continue(); | 342 cursor.continue(); |
339 } else { | 343 } else { |
340 assert(!numReadsLeft); | 344 assert(!numReadsLeft); |
341 } | 345 } |
342 } | 346 } |
343 request.onerror = onError; | 347 request.onerror = onError; |
344 } | 348 } |
OLD | NEW |