OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |