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

Side by Side Diff: chrome/test/data/indexeddb/transaction_run_forever.js

Issue 6209005: Fix IndexedDB race condition during shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing Jeremy's comments Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 loopCount = 0; 5 loopCount = 0;
6 function endlessLoop() 6 function endlessLoop()
7 { 7 {
8 var request = objectStore.get(0); 8 var request = objectStore.get(0);
9 request.onsuccess = endlessLoop; 9 request.onsuccess = endlessLoop;
10 request.onerror = unexpectedErrorCallback; 10 request.onerror = unexpectedErrorCallback;
11 11
12 loopCount += 1; 12 loopCount += 1;
13 if (loopCount == 7) { 13 if (loopCount == 7) {
14 // If we've already looped 7 times, it's pretty safe to assume 14 // If we've already looped 7 times, it's pretty safe to assume
15 // we'll continue looping for some time... 15 // we'll continue looping for some time...
16 debug("Looping infinitely within a transaction."); 16 debug("Looping infinitely within a transaction.");
17 done(); 17 done();
18 } 18 }
19 } 19 }
20 20
21 function newTransactionComplete() 21 function newTransactionComplete()
22 { 22 {
23 debug('The transaction completed.'); 23 debug('The transaction completed.');
24 24
25 var finalTransaction = db.transaction([], IDBTransaction.READ_ONLY, 0); 25 var finalTransaction = db.transaction({objectStoreNames: [], mode: IDBTransact ion.READ_ONLY});
26 finalTransaction.oncomplete = unexpectedCompleteCallback; 26 finalTransaction.oncomplete = unexpectedCompleteCallback;
27 finalTransaction.onabort = unexpectedErrorCallback; 27 finalTransaction.onabort = unexpectedErrorCallback;
28 28
29 objectStore = finalTransaction.objectStore('employees'); 29 objectStore = finalTransaction.objectStore('employees');
30 endlessLoop(); 30 endlessLoop();
31 endlessLoop(); // Make sure at least one is in flight at any time. 31 endlessLoop(); // Make sure at least one is in flight at any time.
32 } 32 }
33 33
34 function onSetVersionComplete() 34 function onSetVersionComplete()
35 { 35 {
36 debug('Creating new transaction.'); 36 debug('Creating new transaction.');
37 var newTransaction = db.transaction([], IDBTransaction.READ_WRITE, 0); 37 var newTransaction = db.transaction({objectStoreNames: [], mode: IDBTransactio n.READ_WRITE});
38 newTransaction.oncomplete = newTransactionComplete; 38 newTransaction.oncomplete = newTransactionComplete;
39 newTransaction.onabort = unexpectedAbortCallback; 39 newTransaction.onabort = unexpectedAbortCallback;
40 40
41 var request = newTransaction.objectStore('employees').put( 41 var request = newTransaction.objectStore('employees').put(
42 {id: 0, name: 'John Doe', desk: 'LON-BEL-123'}); 42 {id: 0, name: 'John Doe', desk: 'LON-BEL-123'});
43 request.onerror = unexpectedErrorCallback; 43 request.onerror = unexpectedErrorCallback;
44 } 44 }
45 45
46 function onSetVersion() 46 function onSetVersion()
47 { 47 {
(...skipping 22 matching lines...) Expand all
70 IDBCursor = webkitIDBCursor; 70 IDBCursor = webkitIDBCursor;
71 IDBKeyRange = webkitIDBKeyRange; 71 IDBKeyRange = webkitIDBKeyRange;
72 IDBTransaction = webkitIDBTransaction; 72 IDBTransaction = webkitIDBTransaction;
73 } 73 }
74 74
75 debug('Connecting to indexedDB.'); 75 debug('Connecting to indexedDB.');
76 var result = indexedDB.open('name'); 76 var result = indexedDB.open('name');
77 result.onsuccess = setVersion; 77 result.onsuccess = setVersion;
78 result.onerror = unexpectedErrorCallback; 78 result.onerror = unexpectedErrorCallback;
79 } 79 }
OLDNEW
« no previous file with comments | « chrome/test/data/indexeddb/object_store_test.js ('k') | chrome/test/data/indexeddb/transaction_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698