Changeset 69121 in webkit
- Timestamp:
- Oct 5, 2010 10:10:39 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r69120 r69121 1 2010-10-04 Andrei Popescu <andreip@google.com> 2 3 Reviewed by Jeremy Orlow. 4 5 IDBDatabase::createObjectStore/removeObjectStore and IDBObjectStore::createIndex/removeIndex should be synchronous. 6 https://bugs.webkit.org/show_bug.cgi?id=46883 7 8 * storage/indexeddb/database-basics-expected.txt: 9 * storage/indexeddb/database-basics.html: 10 * storage/indexeddb/index-basics-expected.txt: 11 * storage/indexeddb/index-basics.html: 12 * storage/indexeddb/index-cursor-expected.txt: 13 * storage/indexeddb/index-cursor.html: 14 * storage/indexeddb/objectstore-basics-expected.txt: 15 * storage/indexeddb/objectstore-basics.html: 16 * storage/indexeddb/objectstore-cursor-expected.txt: 17 * storage/indexeddb/objectstore-cursor.html: 18 * storage/indexeddb/objectstore-removeobjectstore-expected.txt: 19 * storage/indexeddb/objectstore-removeobjectstore.html: 20 * storage/indexeddb/open-cursor-expected.txt: 21 * storage/indexeddb/open-cursor.html: 22 * storage/indexeddb/resources/shared.js: 23 (deleteAllObjectStores): 24 * storage/indexeddb/transaction-basics-expected.txt: 25 * storage/indexeddb/transaction-basics.html: 26 1 27 2010-10-05 Chris Fleizach <cfleizach@apple.com> 2 28 -
trunk/LayoutTests/storage/indexeddb/database-basics-expected.txt
r68795 r69121 42 42 trans = event.result 43 43 PASS trans !== null is true 44 Deleted all object stores. 44 45 Testing setVersion. 45 46 db.setVersion("version a") … … 83 84 PASS db.objectStores.contains('') is false 84 85 db.createObjectStore("test123") 85 PASS 'onsuccess' in result is true86 PASS 'onerror' in result is true87 PASS 'readyState' in result is true88 An event should fire shortly...89 90 Success event fired:91 PASS 'result' in event is true92 PASS 'code' in event is false93 PASS 'message' in event is false94 PASS 'source' in event is true95 PASS event.source != null is true96 PASS 'onsuccess' in event.target is true97 PASS 'onerror' in event.target is true98 PASS 'readyState' in event.target is true99 PASS event.target.readyState is event.target.DONE100 101 86 PASS db.objectStores is ['test123'] 102 87 PASS db.objectStores.length is 1 -
trunk/LayoutTests/storage/indexeddb/database-basics.html
r68795 r69121 51 51 verifyResult(result); 52 52 result.onsuccess = setVersionAgain; 53 result.on Error = unexpectedErrorCallback;53 result.onerror = unexpectedErrorCallback; 54 54 } 55 55 … … 61 61 verifyResult(result); 62 62 result.onsuccess = createObjectStore; 63 result.on Error = unexpectedErrorCallback;63 result.onerror = unexpectedErrorCallback; 64 64 } 65 65 … … 73 73 shouldBe("db.objectStores.contains('')", "false"); 74 74 75 result = evalAndLog('db.createObjectStore("test123")'); 76 verifyResult(result); 77 result.onsuccess = checkObjectStore; 78 result.onError = unexpectedErrorCallback; 75 objectStore = evalAndLog('db.createObjectStore("test123")'); 76 checkObjectStore(objectStore); 79 77 } 80 78 81 function checkObjectStore( )79 function checkObjectStore(objectStore) 82 80 { 83 verifySuccessEvent(event);84 81 shouldBe("db.objectStores", "['test123']"); 85 82 shouldBe("db.objectStores.length", "1"); -
trunk/LayoutTests/storage/indexeddb/index-basics-expected.txt
r68795 r69121 42 42 trans = event.result 43 43 PASS trans !== null is true 44 Deleted all object stores. 44 45 db.createObjectStore('storeName', null) 45 PASS 'onsuccess' in result is true 46 PASS 'onerror' in result is true 47 PASS 'readyState' in result is true 48 An event should fire shortly... 49 50 Success event fired: 51 PASS 'result' in event is true 52 PASS 'code' in event is false 53 PASS 'message' in event is false 54 PASS 'source' in event is true 55 PASS event.source != null is true 56 PASS 'onsuccess' in event.target is true 57 PASS 'onerror' in event.target is true 58 PASS 'readyState' in event.target is true 59 PASS event.target.readyState is event.target.DONE 60 61 store = event.result 62 event.result.createIndex('indexName', 'x') 63 PASS 'onsuccess' in result is true 64 PASS 'onerror' in result is true 65 PASS 'readyState' in result is true 66 An event should fire shortly... 67 68 Success event fired: 69 PASS 'result' in event is true 70 PASS 'code' in event is false 71 PASS 'message' in event is false 72 PASS 'source' in event is true 73 PASS event.source != null is true 74 PASS 'onsuccess' in event.target is true 75 PASS 'onerror' in event.target is true 76 PASS 'readyState' in event.target is true 77 PASS event.target.readyState is event.target.DONE 78 79 PASS event.result === null is false 80 indexObject = event.result 46 store.createIndex('indexName', 'x') 81 47 PASS 'name' in indexObject is true 82 48 PASS indexObject.name is "indexName" … … 91 57 PASS 'getObject' in indexObject is true 92 58 PASS 'get' in indexObject is true 93 event.source.add({x: 'value', y: 'zzz'}, 'key')59 store.add({x: 'value', y: 'zzz'}, 'key') 94 60 PASS 'onsuccess' in result is true 95 61 PASS 'onerror' in result is true -
trunk/LayoutTests/storage/indexeddb/index-basics.html
r68795 r69121 42 42 trans.onabort = unexpectedAbortCallback; 43 43 44 deleteAllObjectStores(db, createObjectStore); 45 } 46 47 function createObjectStore() 48 { 49 result = evalAndLog("db.createObjectStore('storeName', null)"); 50 verifyResult(result); 51 result.onsuccess = createIndex; 52 result.onerror = unexpectedErrorCallback; 44 deleteAllObjectStores(db, createIndex); 53 45 } 54 46 55 47 function createIndex() 56 48 { 57 verifySuccessEvent(event); 58 window.store = evalAndLog("store = event.result"); 59 60 result = evalAndLog("event.result.createIndex('indexName', 'x')"); 61 verifyResult(result); 62 result.onsuccess = addData; 63 result.onerror = unexpectedErrorCallback; 49 window.store = evalAndLog("db.createObjectStore('storeName', null)"); 50 window.indexObject = evalAndLog("store.createIndex('indexName', 'x')"); 51 addData(); 64 52 } 65 53 66 54 function addData() 67 55 { 68 verifySuccessEvent(event);69 shouldBeFalse("event.result === null");70 window.indexObject = evalAndLog("indexObject = event.result");71 56 shouldBeTrue("'name' in indexObject"); 72 57 shouldBeEqualToString("indexObject.name", "indexName"); … … 82 67 shouldBeTrue("'get' in indexObject"); 83 68 84 result = evalAndLog(" event.source.add({x: 'value', y: 'zzz'}, 'key')");69 result = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')"); 85 70 verifyResult(result); 86 71 result.onsuccess = addMore; -
trunk/LayoutTests/storage/indexeddb/index-cursor-expected.txt
r68795 r69121 41 41 trans = event.result 42 42 PASS trans !== null is true 43 Deleted all object stores. 43 44 db.createObjectStore('someObjectStore') 45 objectStore.createIndex('someIndex', 'x') 46 objectStore.add({'x': testData[nextToAdd]}, nextToAdd) 44 47 PASS 'onsuccess' in result is true 45 48 PASS 'onerror' in result is true … … 58 61 PASS event.target.readyState is event.target.DONE 59 62 60 objectStore = event.result 61 objectStore.createIndex('someIndex', 'x') 63 objectStore.add({'x': testData[nextToAdd]}, nextToAdd) 62 64 PASS 'onsuccess' in result is true 63 65 PASS 'onerror' in result is true … … 76 78 PASS event.target.readyState is event.target.DONE 77 79 78 indexObject = event.result 80 objectStore.add({'x': testData[nextToAdd]}, nextToAdd) 81 PASS 'onsuccess' in result is true 82 PASS 'onerror' in result is true 83 PASS 'readyState' in result is true 84 An event should fire shortly... 85 79 86 Success event fired: 80 87 PASS 'result' in event is true … … 162 169 An event should fire shortly... 163 170 164 Success event fired:165 PASS 'result' in event is true166 PASS 'code' in event is false167 PASS 'message' in event is false168 PASS 'source' in event is true169 PASS event.source != null is true170 PASS 'onsuccess' in event.target is true171 PASS 'onerror' in event.target is true172 PASS 'readyState' in event.target is true173 PASS event.target.readyState is event.target.DONE174 175 objectStore.add({'x': testData[nextToAdd]}, nextToAdd)176 PASS 'onsuccess' in result is true177 PASS 'onerror' in result is true178 PASS 'readyState' in result is true179 An event should fire shortly...180 181 Success event fired:182 PASS 'result' in event is true183 PASS 'code' in event is false184 PASS 'message' in event is false185 PASS 'source' in event is true186 PASS event.source != null is true187 PASS 'onsuccess' in event.target is true188 PASS 'onerror' in event.target is true189 PASS 'readyState' in event.target is true190 PASS event.target.readyState is event.target.DONE191 192 objectStore.add({'x': testData[nextToAdd]}, nextToAdd)193 PASS 'onsuccess' in result is true194 PASS 'onerror' in result is true195 PASS 'readyState' in result is true196 An event should fire shortly...197 198 Success event fired:199 PASS 'result' in event is true200 PASS 'code' in event is false201 PASS 'message' in event is false202 PASS 'source' in event is true203 PASS event.source != null is true204 PASS 'onsuccess' in event.target is true205 PASS 'onerror' in event.target is true206 PASS 'readyState' in event.target is true207 PASS event.target.readyState is event.target.DONE208 209 objectStore.add({'x': testData[nextToAdd]}, nextToAdd)210 PASS 'onsuccess' in result is true211 PASS 'onerror' in result is true212 PASS 'readyState' in result is true213 An event should fire shortly...214 215 171 Scheduling tests... 216 172 Running tests... -
trunk/LayoutTests/storage/indexeddb/index-cursor.html
r68795 r69121 54 54 trans.onabort = unexpectedAbortCallback; 55 55 56 deleteAllObjectStores(db, createObjectStores); 57 } 58 59 function createObjectStores() 60 { 61 result = evalAndLog("db.createObjectStore('someObjectStore')"); 62 verifyResult(result); 63 result.onsuccess = openIndex; 64 result.onerror = unexpectedErrorCallback; 65 } 66 67 function openIndex() 68 { 69 verifySuccessEvent(event); 70 window.objectStore = evalAndLog("objectStore = event.result"); 71 72 result = evalAndLog("objectStore.createIndex('someIndex', 'x')"); 73 verifyResult(result); 74 result.onsuccess = startAddingData; 75 result.onerror = unexpectedErrorCallback; 56 deleteAllObjectStores(db, startAddingData); 76 57 } 77 58 78 59 function startAddingData() 79 60 { 80 verifySuccessEvent(event); 81 window.indexObject = evalAndLog("indexObject = event.result"); 82 61 window.objectStore = evalAndLog("db.createObjectStore('someObjectStore')"); 62 window.indexObject = evalAndLog("objectStore.createIndex('someIndex', 'x')"); 83 63 window.nextToAdd = 0; 84 64 addData(); … … 87 67 function addData() 88 68 { 89 // We cheat when called for the first time; we're in the context of the objectStore success event.90 verifySuccessEvent(event);69 if (window.nextToAdd > 0) 70 verifySuccessEvent(event); 91 71 92 72 result = evalAndLog("objectStore.add({'x': testData[nextToAdd]}, nextToAdd)"); -
trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt
r68795 r69121 43 43 trans = event.result 44 44 PASS trans !== null is true 45 db.createObjectStore('storeName', null) 46 PASS 'onsuccess' in result is true 47 PASS 'onerror' in result is true 48 PASS 'readyState' in result is true 49 An event should fire shortly... 50 51 createSuccess(): 52 Success event fired: 53 PASS 'result' in event is true 54 PASS 'code' in event is false 55 PASS 'message' in event is false 56 PASS 'source' in event is true 57 PASS event.source != null is true 58 PASS 'onsuccess' in event.target is true 59 PASS 'onerror' in event.target is true 60 PASS 'readyState' in event.target is true 61 PASS event.target.readyState is event.target.DONE 62 63 store = event.result 45 Deleted all object stores. 46 creatObjectStore(): 47 store = db.createObjectStore('storeName', null) 64 48 storeNames = db.objectStores 65 49 PASS store.name is "storeName" … … 70 54 index = store.index('asdf') 71 55 PASS index is null 72 FAIL Asking for a store that doesn't exist should have thrown. 73 event.result.createIndex('indexName', 'x', true) 74 PASS 'onsuccess' in result is true 75 PASS 'onerror' in result is true 76 PASS 'readyState' in result is true 77 An event should fire shortly... 78 79 addIndexSuccess(): 80 Success event fired: 81 PASS 'result' in event is true 82 PASS 'code' in event is false 83 PASS 'message' in event is false 84 PASS 'source' in event is true 85 PASS event.source != null is true 86 PASS 'onsuccess' in event.target is true 87 PASS 'onerror' in event.target is true 88 PASS 'readyState' in event.target is true 89 PASS event.target.readyState is event.target.DONE 90 91 PASS event.result !== null is true 92 PASS event.source.indexNames.contains('indexName') is true 93 index = event.source.index('indexName') 56 PASS index is null 57 createIndex(): 58 store.createIndex('indexName', 'x', true) 59 PASS index !== null is true 60 PASS store.indexNames.contains('indexName') is true 61 index = store.index('indexName') 94 62 PASS index !== null is true 95 63 Ask for a store that doesn't exist: 96 64 index = store.index('asdf') 97 65 PASS index is null 98 FAIL Asking for a store that doesn't exist should have thrown.99 event.source.add({x: 'value'}, 'key')66 PASS index is null. 67 store.add({x: 'value'}, 'key') 100 68 PASS 'onsuccess' in result is true 101 69 PASS 'onerror' in result is true -
trunk/LayoutTests/storage/indexeddb/objectstore-basics.html
r68795 r69121 43 43 trans.onabort = unexpectedAbortCallback; 44 44 45 deleteAllObjectStores(db, deleteSuccess);45 deleteAllObjectStores(db, createObjectStore); 46 46 } 47 47 48 function deleteSuccess()48 function createObjectStore() 49 49 { 50 result = evalAndLog("db.createObjectStore('storeName', null)"); 51 verifyResult(result); 52 result.onsuccess = createSuccess; 53 result.onerror = unexpectedErrorCallback; 54 } 55 56 function createSuccess() 57 { 58 debug("createSuccess():"); 59 verifySuccessEvent(event); 60 var store = evalAndLog("store = event.result"); 50 debug("creatObjectStore():"); 51 var store = evalAndLog("store = db.createObjectStore('storeName', null)"); 61 52 var storeNames = evalAndLog("storeNames = db.objectStores"); 62 53 … … 71 62 index = evalAndLog("index = store.index('asdf')"); 72 63 shouldBeNull("index"); // Returning null is wrong, but less wrong than returning an actual object! 73 testFailed("Asking for a store that doesn't exist should have thrown."); 64 testPassed("index is null"); 65 // FIXME: testFailed("Asking for a store that doesn't exist should have thrown."); 74 66 } catch (err) { 75 testPassed("Error thrown.");76 67 // FIXME: Verify the correct exception thrown. 77 68 } 78 69 79 result = evalAndLog("event.result.createIndex('indexName', 'x', true)"); // true == unique requirement. 80 verifyResult(result); 81 result.onsuccess = addIndexSuccess; 82 result.onerror = unexpectedErrorCallback; 70 createIndex(); 83 71 } 84 72 85 function addIndexSuccess()73 function createIndex() 86 74 { 87 debug(" addIndexSuccess():");88 verifySuccessEvent(event);89 shouldBeTrue(" event.result!== null");90 shouldBeTrue(" event.source.indexNames.contains('indexName')");91 index = evalAndLog("index = event.source.index('indexName')");75 debug("createIndex():"); 76 window.index = evalAndLog("store.createIndex('indexName', 'x', true)"); // true == unique requirement. 77 shouldBeTrue("index !== null"); 78 shouldBeTrue("store.indexNames.contains('indexName')"); 79 index = evalAndLog("index = store.index('indexName')"); 92 80 shouldBeTrue("index !== null"); 93 81 … … 96 84 index = evalAndLog("index = store.index('asdf')"); 97 85 shouldBeNull("index"); // Returning null is wrong, but less wrong than returning an actual object! 98 testFailed("Asking for a store that doesn't exist should have thrown."); 86 testPassed("index is null."); 87 // FIXME: testFailed("Asking for a store that doesn't exist should have thrown."); 99 88 } catch (err) { 100 testPassed("Error thrown.");101 89 // FIXME: Verify the correct exception thrown. 102 90 } 103 91 104 result = evalAndLog(" event.source.add({x: 'value'}, 'key')");92 result = evalAndLog("store.add({x: 'value'}, 'key')"); 105 93 verifyResult(result); 106 94 result.onsuccess = addSuccess; -
trunk/LayoutTests/storage/indexeddb/objectstore-cursor-expected.txt
r68795 r69121 41 41 trans = event.result 42 42 PASS trans !== null is true 43 Deleted all object stores. 43 44 db.createObjectStore('someObjectStore') 45 objectStore.add('', testData[nextToAdd]) 44 46 PASS 'onsuccess' in result is true 45 47 PASS 'onerror' in result is true … … 58 60 PASS event.target.readyState is event.target.DONE 59 61 60 objectStore = event.result 62 objectStore.add('', testData[nextToAdd]) 63 PASS 'onsuccess' in result is true 64 PASS 'onerror' in result is true 65 PASS 'readyState' in result is true 66 An event should fire shortly... 67 61 68 Success event fired: 62 69 PASS 'result' in event is true … … 144 151 An event should fire shortly... 145 152 146 Success event fired:147 PASS 'result' in event is true148 PASS 'code' in event is false149 PASS 'message' in event is false150 PASS 'source' in event is true151 PASS event.source != null is true152 PASS 'onsuccess' in event.target is true153 PASS 'onerror' in event.target is true154 PASS 'readyState' in event.target is true155 PASS event.target.readyState is event.target.DONE156 157 objectStore.add('', testData[nextToAdd])158 PASS 'onsuccess' in result is true159 PASS 'onerror' in result is true160 PASS 'readyState' in result is true161 An event should fire shortly...162 163 Success event fired:164 PASS 'result' in event is true165 PASS 'code' in event is false166 PASS 'message' in event is false167 PASS 'source' in event is true168 PASS event.source != null is true169 PASS 'onsuccess' in event.target is true170 PASS 'onerror' in event.target is true171 PASS 'readyState' in event.target is true172 PASS event.target.readyState is event.target.DONE173 174 objectStore.add('', testData[nextToAdd])175 PASS 'onsuccess' in result is true176 PASS 'onerror' in result is true177 PASS 'readyState' in result is true178 An event should fire shortly...179 180 153 Scheduling tests... 181 154 Running tests... -
trunk/LayoutTests/storage/indexeddb/objectstore-cursor.html
r68795 r69121 53 53 trans.onabort = unexpectedAbortCallback; 54 54 55 deleteAllObjectStores(db, openObjectStore); 56 } 57 58 function openObjectStore() 59 { 60 result = evalAndLog("db.createObjectStore('someObjectStore')"); 61 verifyResult(result); 62 result.onsuccess = startAddingData; 63 result.onerror = unexpectedErrorCallback; 55 deleteAllObjectStores(db, startAddingData); 64 56 } 65 57 66 58 function startAddingData() 67 59 { 68 verifySuccessEvent(event); 69 window.objectStore = evalAndLog("objectStore = event.result"); 70 60 window.objectStore = evalAndLog("db.createObjectStore('someObjectStore')"); 71 61 window.nextToAdd = 0; 72 62 addData(); … … 75 65 function addData() 76 66 { 77 // We cheat when called for the first time; we're in the context of the objectStore success event.78 verifySuccessEvent(event);67 if (window.nextToAdd > 0) 68 verifySuccessEvent(event); 79 69 80 70 result = evalAndLog("objectStore.add('', testData[nextToAdd])"); -
trunk/LayoutTests/storage/indexeddb/objectstore-removeobjectstore-expected.txt
r68795 r69121 41 41 trans = event.result 42 42 PASS trans !== null is true 43 db.createObjectStore('storeName', null) 44 PASS 'onsuccess' in result is true 45 PASS 'onerror' in result is true 46 PASS 'readyState' in result is true 47 An event should fire shortly... 48 49 Success event fired: 50 PASS 'result' in event is true 51 PASS 'code' in event is false 52 PASS 'message' in event is false 53 PASS 'source' in event is true 54 PASS event.source != null is true 55 PASS 'onsuccess' in event.target is true 56 PASS 'onerror' in event.target is true 57 PASS 'readyState' in event.target is true 58 PASS event.target.readyState is event.target.DONE 59 60 event.result.add('value', 'key') 43 Deleted all object stores. 44 store = db.createObjectStore('storeName', null) 45 store.add('value', 'key') 61 46 PASS 'onsuccess' in result is true 62 47 PASS 'onerror' in result is true … … 96 81 PASS event.result is "value" 97 82 event.source.createIndex('indexName', '') 98 PASS 'onsuccess' in result is true99 PASS 'onerror' in result is true100 PASS 'readyState' in result is true101 An event should fire shortly...102 103 Success event fired:104 PASS 'result' in event is true105 PASS 'code' in event is false106 PASS 'message' in event is false107 PASS 'source' in event is true108 PASS event.source != null is true109 PASS 'onsuccess' in event.target is true110 PASS 'onerror' in event.target is true111 PASS 'readyState' in event.target is true112 PASS event.target.readyState is event.target.DONE113 114 83 PASS event.source.indexNames.contains('indexName') is true 115 84 db.setVersion('new version') … … 133 102 PASS trans !== null is true 134 103 db.removeObjectStore('storeName') 135 PASS 'onsuccess' in result is true136 PASS 'onerror' in result is true137 PASS 'readyState' in result is true138 An event should fire shortly...139 140 Success event fired:141 PASS 'result' in event is true142 PASS 'code' in event is false143 PASS 'message' in event is false144 PASS 'source' in event is true145 PASS event.source != null is true146 PASS 'onsuccess' in event.target is true147 PASS 'onerror' in event.target is true148 PASS 'readyState' in event.target is true149 PASS event.target.readyState is event.target.DONE150 151 104 db.createObjectStore('storeName', null) 152 PASS 'onsuccess' in result is true153 PASS 'onerror' in result is true154 PASS 'readyState' in result is true155 An event should fire shortly...156 157 Success event fired:158 PASS 'result' in event is true159 PASS 'code' in event is false160 PASS 'message' in event is false161 PASS 'source' in event is true162 PASS event.source != null is true163 PASS 'onsuccess' in event.target is true164 PASS 'onerror' in event.target is true165 PASS 'readyState' in event.target is true166 PASS event.target.readyState is event.target.DONE167 168 105 db.transaction() 169 106 store = transaction.objectStore('storeName') -
trunk/LayoutTests/storage/indexeddb/objectstore-removeobjectstore.html
r68795 r69121 40 40 shouldBeTrue("trans !== null"); 41 41 42 deleteAllObjectStores(db, createObjectStore );42 deleteAllObjectStores(db, createObjectStoreAndAddValue); 43 43 } 44 44 45 function createObjectStore ()45 function createObjectStoreAndAddValue() 46 46 { 47 result = evalAndLog("db.createObjectStore('storeName', null)"); 48 verifyResult(result); 49 result.onsuccess = addValue; 50 result.onerror = unexpectedErrorCallback; 51 } 52 53 function addValue() 54 { 55 verifySuccessEvent(event); 56 57 result = evalAndLog("event.result.add('value', 'key')"); 47 var store = evalAndLog("store = db.createObjectStore('storeName', null)"); 48 result = evalAndLog("store.add('value', 'key')"); 58 49 verifyResult(result); 59 50 result.onsuccess = getValue; … … 80 71 shouldBeEqualToString("event.result", "value"); 81 72 82 result = evalAndLog("event.source.createIndex('indexName', '')"); 83 verifyResult(result); 84 result.onsuccess = commitTransaction; 85 result.onerror = unexpectedErrorCallback; 86 } 87 88 function commitTransaction() 89 { 90 verifySuccessEvent(event); 73 window.index = evalAndLog("event.source.createIndex('indexName', '')"); 91 74 shouldBeTrue("event.source.indexNames.contains('indexName')"); 92 75 // Let the transaction commit. … … 109 92 trans.onabort = unexpectedAbortCallback; 110 93 111 result = evalAndLog("db.removeObjectStore('storeName')"); 112 verifyResult(result); 113 result.onsuccess = createObjectStoreAgain; 114 result.onerror = unexpectedErrorCallback; 94 evalAndLog("db.removeObjectStore('storeName')"); 95 createObjectStoreAgain(); 115 96 } 116 97 117 98 function createObjectStoreAgain() 118 99 { 119 verifySuccessEvent(event); 120 121 result = evalAndLog("db.createObjectStore('storeName', null)"); 122 verifyResult(result); 123 result.onsuccess = getValueAgain; 124 result.onerror = unexpectedErrorCallback; 100 evalAndLog("db.createObjectStore('storeName', null)"); 101 getValueAgain(); 125 102 } 126 103 127 104 function getValueAgain() 128 105 { 129 verifySuccessEvent(event);130 131 106 transaction = evalAndLog("db.transaction()"); 132 107 transaction.onabort = unexpectedErrorCallback; -
trunk/LayoutTests/storage/indexeddb/open-cursor-expected.txt
r68795 r69121 42 42 trans = event.result 43 43 PASS trans !== null is true 44 db.createObjectStore('test') 45 PASS 'onsuccess' in result is true 46 PASS 'onerror' in result is true 47 PASS 'readyState' in result is true 48 An event should fire shortly... 49 50 Success event fired: 51 PASS 'result' in event is true 52 PASS 'code' in event is false 53 PASS 'message' in event is false 54 PASS 'source' in event is true 55 PASS event.source != null is true 56 PASS 'onsuccess' in event.target is true 57 PASS 'onerror' in event.target is true 58 PASS 'readyState' in event.target is true 59 PASS event.target.readyState is event.target.DONE 60 61 objectStore = event.result 44 Deleted all object stores. 45 objectStore = db.createObjectStore('test') 62 46 objectStore.add('myValue', 'myKey') 63 47 PASS 'onsuccess' in result is true … … 67 51 68 52 Opening cursor 69 objectStore.openCursor(keyRange)53 event.source.openCursor(keyRange) 70 54 PASS 'onsuccess' in result is true 71 55 PASS 'onerror' in result is true -
trunk/LayoutTests/storage/indexeddb/open-cursor.html
r68795 r69121 49 49 debug("Opening cursor"); 50 50 keyRange = IDBKeyRange.leftBound("myKey"); 51 result = evalAndLog(" objectStore.openCursor(keyRange)");51 result = evalAndLog("event.source.openCursor(keyRange)"); 52 52 verifyResult(result); 53 53 result.onsuccess = cursorSuccess; … … 55 55 } 56 56 57 function populateObjectStore(objectStore)57 function createAndPopulateObjectStore() 58 58 { 59 var objectStore = evalAndLog("objectStore = db.createObjectStore('test')"); 59 60 result = evalAndLog("objectStore.add('myValue', 'myKey')"); 60 61 verifyResult(result); 61 62 result.onsuccess = openCursor; 62 result.onerror = unexpectedErrorCallback;63 }64 65 function createObjectStoreSuccess()66 {67 verifySuccessEvent(event);68 var objectStore = evalAndLog("objectStore = event.result");69 populateObjectStore(objectStore);70 }71 72 function deleteSuccess()73 {74 result = evalAndLog("db.createObjectStore('test')");75 verifyResult(result);76 result.onsuccess = createObjectStoreSuccess;77 63 result.onerror = unexpectedErrorCallback; 78 64 } … … 86 72 trans.onabort = unexpectedAbortCallback; 87 73 88 deleteAllObjectStores(db, deleteSuccess);74 deleteAllObjectStores(db, createAndPopulateObjectStore); 89 75 } 90 76 -
trunk/LayoutTests/storage/indexeddb/resources/shared.js
r69052 r69121 80 80 } 81 81 82 // FIXME: remove the onfinished parameter. 82 83 function deleteAllObjectStores(db, onfinished) 83 84 { 84 objectStores = db.objectStores; 85 if (!objectStores.length) { 86 onfinished(); 87 return; 88 } 85 for (i = 0; i < db.objectStores.length; ++i) 86 db.removeObjectStore(db.objectStores.item(i)); 89 87 90 var request = db.removeObjectStore(objectStores[0]); 91 request.onerror = unexpectedErrorCallback; 92 request.onsuccess = function() { deleteAllObjectStores(db, onfinished); }; 88 debug("Deleted all object stores."); 89 onfinished(); 93 90 } -
trunk/LayoutTests/storage/indexeddb/transaction-basics-expected.txt
r69052 r69121 45 45 trans = event.result 46 46 PASS trans !== null is true 47 Deleted all object stores. 47 48 db.createObjectStore('storeName', null) 48 PASS 'onsuccess' in result is true49 PASS 'onerror' in result is true50 PASS 'readyState' in result is true51 An event should fire shortly...52 53 Success event fired:54 PASS 'result' in event is true55 PASS 'code' in event is false56 PASS 'message' in event is false57 PASS 'source' in event is true58 PASS event.source != null is true59 PASS 'onsuccess' in event.target is true60 PASS 'onerror' in event.target is true61 PASS 'readyState' in event.target is true62 PASS event.target.readyState is event.target.DONE63 64 49 db.transaction() 65 50 store = transaction.objectStore('storeName') -
trunk/LayoutTests/storage/indexeddb/transaction-basics.html
r69052 r69121 48 48 window.completeEventFired = false; 49 49 50 deleteAllObjectStores(db, finishedDeleting); 50 deleteAllObjectStores(db, createObjectStoreAndStartTransaction); 51 } 52 53 function createObjectStoreAndStartTransaction() 54 { 55 evalAndLog("db.createObjectStore('storeName', null)"); 56 transaction = evalAndLog("db.transaction()"); 57 transaction.onabort = abortCallback; 58 var store = evalAndLog("store = transaction.objectStore('storeName')"); 59 shouldBeEqualToString("store.name", "storeName"); 51 60 } 52 61 … … 55 64 verifyCompleteEvent(event); 56 65 window.completeEventFired = true; 57 }58 59 function finishedDeleting()60 {61 result = evalAndLog("db.createObjectStore('storeName', null)");62 verifyResult(result);63 result.onsuccess = createSuccess;64 result.onerror = unexpectedErrorCallback;65 }66 67 function createSuccess()68 {69 verifySuccessEvent(event);70 transaction = evalAndLog("db.transaction()");71 transaction.onabort = abortCallback;72 var store = evalAndLog("store = transaction.objectStore('storeName')");73 shouldBeEqualToString("store.name", "storeName");74 66 } 75 67 -
trunk/WebCore/ChangeLog
r69120 r69121 1 2010-10-04 Andrei Popescu <andreip@google.com> 2 3 Reviewed by Jeremy Orlow. 4 5 IDBDatabase::createObjectStore/removeObjectStore and IDBObjectStore::createIndex/removeIndex should be synchronous. 6 https://bugs.webkit.org/show_bug.cgi?id=46883 7 8 Makes the schema manipulation methods synchronous. Modifies the transaction 9 logic to support tasks that may have pending events as well as tasks that 10 don't have such events. 11 12 * storage/IDBDatabase.cpp: 13 (WebCore::IDBDatabase::createObjectStore): 14 (WebCore::IDBDatabase::removeObjectStore): 15 * storage/IDBDatabase.h: 16 * storage/IDBDatabase.idl: 17 * storage/IDBDatabaseBackendImpl.cpp: 18 (WebCore::IDBDatabaseBackendImpl::createObjectStore): 19 (WebCore::IDBDatabaseBackendImpl::createObjectStoreInternal): 20 (WebCore::IDBDatabaseBackendImpl::removeObjectStore): 21 (WebCore::IDBDatabaseBackendImpl::removeObjectStoreInternal): 22 * storage/IDBDatabaseBackendImpl.h: 23 * storage/IDBDatabaseBackendInterface.h: 24 * storage/IDBIndexBackendImpl.cpp: 25 (WebCore::IDBIndexBackendImpl::IDBIndexBackendImpl): 26 * storage/IDBIndexBackendImpl.h: 27 (WebCore::IDBIndexBackendImpl::create): 28 (WebCore::IDBIndexBackendImpl::id): 29 (WebCore::IDBIndexBackendImpl::setId): 30 * storage/IDBObjectStore.cpp: 31 (WebCore::IDBObjectStore::createIndex): 32 (WebCore::IDBObjectStore::removeIndex): 33 * storage/IDBObjectStore.h: 34 * storage/IDBObjectStore.idl: 35 * storage/IDBObjectStoreBackendImpl.cpp: 36 (WebCore::IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl): 37 (WebCore::IDBObjectStoreBackendImpl::createIndex): 38 (WebCore::IDBObjectStoreBackendImpl::createIndexInternal): 39 (WebCore::IDBObjectStoreBackendImpl::removeIndex): 40 (WebCore::IDBObjectStoreBackendImpl::removeIndexInternal): 41 * storage/IDBObjectStoreBackendImpl.h: 42 (WebCore::IDBObjectStoreBackendImpl::create): 43 (WebCore::IDBObjectStoreBackendImpl::id): 44 (WebCore::IDBObjectStoreBackendImpl::setId): 45 (WebCore::IDBObjectStoreBackendImpl::autoIncrement): 46 * storage/IDBObjectStoreBackendInterface.h: 47 * storage/IDBTransactionBackendImpl.cpp: 48 (WebCore::IDBTransactionBackendImpl::IDBTransactionBackendImpl): 49 (WebCore::IDBTransactionBackendImpl::objectStore): 50 (WebCore::IDBTransactionBackendImpl::scheduleTask): 51 (WebCore::IDBTransactionBackendImpl::abort): 52 (WebCore::IDBTransactionBackendImpl::didCompleteTaskEvents): 53 (WebCore::IDBTransactionBackendImpl::run): 54 (WebCore::IDBTransactionBackendImpl::taskTimerFired): 55 (WebCore::IDBTransactionBackendImpl::taskEventTimerFired): 56 * storage/IDBTransactionBackendImpl.h: 57 1 58 2010-10-05 Chris Fleizach <cfleizach@apple.com> 2 59 -
trunk/WebCore/storage/IDBDatabase.cpp
r68795 r69121 56 56 } 57 57 58 // FIXME: Should be synchronous. 59 PassRefPtr<IDBRequest> IDBDatabase::createObjectStore(ScriptExecutionContext* context, const String& name, const String& keyPath, bool autoIncrement) 58 PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, const String& keyPath, bool autoIncrement) 60 59 { 61 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_setVersionTransaction.get()); 62 if (!m_setVersionTransaction) 63 request->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_ALLOWED_ERR, "createObjectStore must be called from within a setVersion transaction.")); 64 else 65 m_backend->createObjectStore(name, keyPath, autoIncrement, request, m_setVersionTransaction.get()); 66 return request; 60 // FIXME: Raise a NOT_ALLOWED_ERR if m_setVersionTransaction is 0. 61 RefPtr<IDBObjectStoreBackendInterface> objectStore = m_backend->createObjectStore(name, keyPath, autoIncrement, m_setVersionTransaction.get()); 62 if (!objectStore) 63 return 0; 64 return IDBObjectStore::create(objectStore.release(), m_setVersionTransaction.get()); 67 65 } 68 66 69 // FIXME: Should be synchronous. 70 PassRefPtr<IDBRequest> IDBDatabase::removeObjectStore(ScriptExecutionContext* context, const String& name) 67 void IDBDatabase::removeObjectStore(const String& name) 71 68 { 72 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_setVersionTransaction.get()); 73 if (!m_setVersionTransaction) 74 request->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_ALLOWED_ERR, "removeObjectStore must be called from within a setVersion transaction.")); 75 else 76 m_backend->removeObjectStore(name, request, m_setVersionTransaction.get()); 77 return request; 69 m_backend->removeObjectStore(name, m_setVersionTransaction.get()); 78 70 } 79 71 -
trunk/WebCore/storage/IDBDatabase.h
r68795 r69121 58 58 PassRefPtr<DOMStringList> objectStores() const { return m_backend->objectStores(); } 59 59 60 PassRefPtr<IDB Request> createObjectStore(ScriptExecutionContext*,const String& name, const String& keyPath = String(), bool autoIncrement = false);61 PassRefPtr<IDBRequest> removeObjectStore(ScriptExecutionContext*,const String& name);60 PassRefPtr<IDBObjectStore> createObjectStore(const String& name, const String& keyPath = String(), bool autoIncrement = false); 61 void removeObjectStore(const String& name); 62 62 PassRefPtr<IDBRequest> setVersion(ScriptExecutionContext*, const String& version); 63 63 PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext*, DOMStringList* storeNames = 0, unsigned short mode = IDBTransaction::READ_ONLY, -
trunk/WebCore/storage/IDBDatabase.idl
r68795 r69121 33 33 readonly attribute DOMStringList objectStores; 34 34 35 [CallWith=ScriptExecutionContext] IDBRequestcreateObjectStore(in DOMString name, in [Optional, ConvertNullToNullString] DOMString keyPath, in [Optional] boolean autoIncrement);36 [CallWith=ScriptExecutionContext] IDBRequestremoveObjectStore(in DOMString name);35 IDBObjectStore createObjectStore(in DOMString name, in [Optional, ConvertNullToNullString] DOMString keyPath, in [Optional] boolean autoIncrement); 36 void removeObjectStore(in DOMString name); 37 37 [CallWith=ScriptExecutionContext] IDBRequest setVersion(in DOMString version); 38 38 [CallWith=ScriptExecutionContext] IDBTransaction transaction (in [Optional] DOMStringList storeNames, in [Optional] unsigned short mode, in [Optional] unsigned long timeout); -
trunk/WebCore/storage/IDBDatabaseBackendImpl.cpp
r68795 r69121 128 128 } 129 129 130 void IDBDatabaseBackendImpl::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transaction) 131 { 130 PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transaction) 131 { 132 if (m_objectStores.contains(name)) { 133 // FIXME: Throw CONSTRAINT_ERR in this case. 134 return 0; 135 } 136 137 RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create(this, name, keyPath, autoIncrement); 138 ASSERT(objectStore->name() == name); 139 m_objectStores.set(name, objectStore); 140 132 141 RefPtr<IDBDatabaseBackendImpl> database = this; 133 RefPtr<IDBCallbacks> callbacks = prpCallbacks; 134 if (!transaction->scheduleTask(createCallbackTask(&IDBDatabaseBackendImpl::createObjectStoreInternal, database, name, keyPath, autoIncrement, callbacks))) 135 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_ALLOWED_ERR, "createObjectStore must be called from within a setVersion transaction.")); 136 } 137 138 void IDBDatabaseBackendImpl::createObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl> database, const String& name, const String& keyPath, bool autoIncrement, PassRefPtr<IDBCallbacks> callbacks) 139 { 140 if (database->m_objectStores.contains(name)) { 141 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::CONSTRAINT_ERR, "An objectStore with that name already exists.")); 142 return; 143 } 144 142 RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction; 143 if (!transaction->scheduleTask(createCallbackTask(&IDBDatabaseBackendImpl::createObjectStoreInternal, database, objectStore, transactionPtr))) 144 return 0; 145 146 return objectStore.release(); 147 } 148 149 void IDBDatabaseBackendImpl::createObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBTransactionBackendInterface> transaction) 150 { 145 151 SQLiteStatement insert(database->sqliteDatabase(), "INSERT INTO ObjectStores (name, keyPath, doAutoIncrement) VALUES (?, ?, ?)"); 146 152 bool ok = insert.prepare() == SQLResultOk; 147 153 ASSERT_UNUSED(ok, ok); // FIXME: Better error handling. 148 insert.bindText(1, name);149 insert.bindText(2, keyPath);150 insert.bindInt(3, static_cast<int>( autoIncrement));154 insert.bindText(1, objectStore->name()); 155 insert.bindText(2, objectStore->keyPath()); 156 insert.bindInt(3, static_cast<int>(objectStore->autoIncrement())); 151 157 ok = insert.step() == SQLResultDone; 152 158 ASSERT_UNUSED(ok, ok); // FIXME: Better error handling. 153 159 int64_t id = database->sqliteDatabase().lastInsertRowID(); 154 155 RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create(database.get(), id, name, keyPath, autoIncrement); 156 ASSERT(objectStore->name() == name); 157 database->m_objectStores.set(name, objectStore); 158 callbacks->onSuccess(objectStore.get()); 160 objectStore->setId(id); 161 transaction->didCompleteTaskEvents(); 159 162 } 160 163 … … 177 180 } 178 181 179 void IDBDatabaseBackendImpl::removeObjectStore(const String& name, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transaction) 180 { 182 void IDBDatabaseBackendImpl::removeObjectStore(const String& name, IDBTransactionBackendInterface* transaction) 183 { 184 RefPtr<IDBObjectStoreBackendImpl> objectStore = m_objectStores.get(name); 185 if (!objectStore) { 186 // FIXME: Raise NOT_FOUND_ERR. 187 return; 188 } 189 m_objectStores.remove(name); 181 190 RefPtr<IDBDatabaseBackendImpl> database = this; 182 RefPtr<IDBCallbacks> callbacks = prpCallbacks; 183 if (!transaction->scheduleTask(createCallbackTask(&IDBDatabaseBackendImpl::removeObjectStoreInternal, database, name, callbacks))) 184 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_ALLOWED_ERR, "removeObjectStore must be called from within a setVersion transaction.")); 185 } 186 187 void IDBDatabaseBackendImpl::removeObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl> database, const String& name, PassRefPtr<IDBCallbacks> callbacks) 188 { 189 RefPtr<IDBObjectStoreBackendImpl> objectStore = database->m_objectStores.get(name); 190 if (!objectStore) { 191 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "No objectStore with that name exists.")); 192 return; 193 } 194 191 RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction; 192 transaction->scheduleTask(createCallbackTask(&IDBDatabaseBackendImpl::removeObjectStoreInternal, database, objectStore, transactionPtr)); 193 // FIXME: Raise NOT_ALLOWED_ERR if the above fails. 194 } 195 196 void IDBDatabaseBackendImpl::removeObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBTransactionBackendInterface> transaction) 197 { 195 198 doDelete(database->sqliteDatabase(), "DELETE FROM ObjectStores WHERE id = ?", objectStore->id()); 196 199 doDelete(database->sqliteDatabase(), "DELETE FROM ObjectStoreData WHERE objectStoreId = ?", objectStore->id()); … … 198 201 doDelete(database->sqliteDatabase(), "DELETE FROM Indexes WHERE objectStoreId = ?", objectStore->id()); 199 202 200 database->m_objectStores.remove(name); 201 callbacks->onSuccess(); 203 transaction->didCompleteTaskEvents(); 202 204 } 203 205 -
trunk/WebCore/storage/IDBDatabaseBackendImpl.h
r68795 r69121 56 56 virtual PassRefPtr<DOMStringList> objectStores() const; 57 57 58 virtual void createObjectStore(const String& name, const String& keyPath, bool autoIncrement, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);58 virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface*); 59 59 virtual PassRefPtr<IDBObjectStoreBackendInterface> objectStore(const String& name, unsigned short mode); 60 virtual void removeObjectStore(const String& name, PassRefPtr<IDBCallbacks>,IDBTransactionBackendInterface*);60 virtual void removeObjectStore(const String& name, IDBTransactionBackendInterface*); 61 61 virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>); 62 62 virtual PassRefPtr<IDBTransactionBackendInterface> transaction(DOMStringList* storeNames, unsigned short mode, unsigned long timeout); … … 70 70 void loadObjectStores(); 71 71 72 static void createObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl>, const String& name, const String& keyPath, bool autoIncrement, PassRefPtr<IDBCallbacks>);73 static void removeObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl>, const String& name, PassRefPtr<IDBCallbacks>);72 static void createObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl>, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBTransactionBackendInterface>); 73 static void removeObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl>, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBTransactionBackendInterface>); 74 74 static void setVersionInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl>, const String& version, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>); 75 75 -
trunk/WebCore/storage/IDBDatabaseBackendInterface.h
r68795 r69121 55 55 virtual PassRefPtr<DOMStringList> objectStores() const = 0; 56 56 57 virtual void createObjectStore(const String& name, const String& keyPath, bool autoIncrement, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*) = 0;57 virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface*) = 0; 58 58 virtual PassRefPtr<IDBObjectStoreBackendInterface> objectStore(const String& name, unsigned short mode) = 0; 59 virtual void removeObjectStore(const String& name, PassRefPtr<IDBCallbacks>,IDBTransactionBackendInterface*) = 0;59 virtual void removeObjectStore(const String& name, IDBTransactionBackendInterface*) = 0; 60 60 virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>) = 0; 61 61 virtual PassRefPtr<IDBTransactionBackendInterface> transaction(DOMStringList* storeNames, unsigned short mode, unsigned long timeout) = 0; -
trunk/WebCore/storage/IDBIndexBackendImpl.cpp
r68795 r69121 51 51 } 52 52 53 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBObjectStoreBackendImpl* objectStore, const String& name, const String& keyPath, bool unique) 54 : m_objectStore(objectStore) 55 , m_id(InvalidId) 56 , m_name(name) 57 , m_keyPath(keyPath) 58 , m_unique(unique) 59 { 60 } 61 53 62 IDBIndexBackendImpl::~IDBIndexBackendImpl() 54 63 { -
trunk/WebCore/storage/IDBIndexBackendImpl.h
r68795 r69121 44 44 return adoptRef(new IDBIndexBackendImpl(objectStore, id, name, keyPath, unique)); 45 45 } 46 static PassRefPtr<IDBIndexBackendImpl> create(IDBObjectStoreBackendImpl* objectStore, const String& name, const String& keyPath, bool unique) 47 { 48 return adoptRef(new IDBIndexBackendImpl(objectStore, name, keyPath, unique)); 49 } 46 50 virtual ~IDBIndexBackendImpl(); 47 51 48 int64_t id() { return m_id; } 52 int64_t id() const 53 { 54 ASSERT(m_id != InvalidId); 55 return m_id; 56 } 57 void setId(int64_t id) { m_id = id; } 58 49 59 bool addingKeyAllowed(IDBKey*); 50 60 … … 64 74 private: 65 75 IDBIndexBackendImpl(IDBObjectStoreBackendImpl*, int64_t id, const String& name, const String& keyPath, bool unique); 76 IDBIndexBackendImpl(IDBObjectStoreBackendImpl*, const String& name, const String& keyPath, bool unique); 66 77 67 78 SQLiteDatabase& sqliteDatabase() const; … … 69 80 static void openCursorInternal(ScriptExecutionContext*, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBKeyRange>, unsigned short direction, bool objectCursor, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>); 70 81 static void getInternal(ScriptExecutionContext*, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBKey>, bool getObject, PassRefPtr<IDBCallbacks>); 82 83 static const int64_t InvalidId = 0; 71 84 72 85 RefPtr<IDBObjectStoreBackendImpl> m_objectStore; -
trunk/WebCore/storage/IDBObjectStore.cpp
r68795 r69121 93 93 } 94 94 95 PassRefPtr<IDB Request> IDBObjectStore::createIndex(ScriptExecutionContext* context,const String& name, const String& keyPath, bool unique)95 PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const String& keyPath, bool unique) 96 96 { 97 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get()); 98 m_objectStore->createIndex(name, keyPath, unique, request, m_transaction.get()); 99 return request; 97 RefPtr<IDBIndexBackendInterface> index = m_objectStore->createIndex(name, keyPath, unique, m_transaction.get()); 98 if (!index) 99 return 0; 100 return IDBIndex::create(index.release(), m_transaction.get()); 100 101 } 101 102 … … 109 110 } 110 111 111 PassRefPtr<IDBRequest> IDBObjectStore::removeIndex(ScriptExecutionContext* context,const String& name)112 void IDBObjectStore::removeIndex(const String& name) 112 113 { 113 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get()); 114 m_objectStore->removeIndex(name, request, m_transaction.get()); 115 return request; 114 m_objectStore->removeIndex(name, m_transaction.get()); 116 115 } 117 116 -
trunk/WebCore/storage/IDBObjectStore.h
r68138 r69121 64 64 PassRefPtr<IDBRequest> remove(ScriptExecutionContext*, PassRefPtr<IDBKey> key); 65 65 66 PassRefPtr<IDB Request> createIndex(ScriptExecutionContext*,const String& name, const String& keyPath, bool unique = false);66 PassRefPtr<IDBIndex> createIndex(const String& name, const String& keyPath, bool unique = false); 67 67 PassRefPtr<IDBIndex> index(const String& name); 68 PassRefPtr<IDBRequest> removeIndex(ScriptExecutionContext*,const String& name);68 void removeIndex(const String& name); 69 69 70 70 PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, PassRefPtr<IDBKeyRange> = 0, unsigned short direction = IDBCursor::NEXT); -
trunk/WebCore/storage/IDBObjectStore.idl
r68795 r69121 38 38 [CallWith=ScriptExecutionContext] IDBRequest put(in SerializedScriptValue value, in [Optional] IDBKey key); 39 39 [CallWith=ScriptExecutionContext] IDBRequest remove(in IDBKey key); 40 [CallWith=ScriptExecutionContext] IDBRequest createIndex(in DOMString name, in [ConvertNullToNullString] DOMString keyPath, in [Optional] boolean unique); 40 // FIXME: write openCursor 41 IDBIndex createIndex(in DOMString name, in [ConvertNullToNullString] DOMString keyPath, in [Optional] boolean unique); 42 // FIXME: This needs to raise an IDBDatabaseException on errors. 41 43 IDBIndex index(in DOMString name); 42 [CallWith=ScriptExecutionContext] IDBRequest removeIndex(in DOMString name); 44 void removeIndex(in DOMString name); 45 43 46 [CallWith=ScriptExecutionContext] IDBRequest openCursor(in [Optional] IDBKeyRange range, in [Optional] unsigned short direction); 44 47 }; -
trunk/WebCore/storage/IDBObjectStoreBackendImpl.cpp
r68795 r69121 63 63 } 64 64 65 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBDatabaseBackendImpl* database, const String& name, const String& keyPath, bool autoIncrement) 66 : m_database(database) 67 , m_id(InvalidId) 68 , m_name(name) 69 , m_keyPath(keyPath) 70 , m_autoIncrement(autoIncrement) 71 { 72 } 73 65 74 PassRefPtr<DOMStringList> IDBObjectStoreBackendImpl::indexNames() const 66 75 { … … 255 264 } 256 265 257 void IDBObjectStoreBackendImpl::createIndex(const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transaction) 258 { 259 RefPtr<IDBObjectStoreBackendImpl> objectStore = this; 260 RefPtr<IDBCallbacks> callbacks = prpCallbacks; 261 if (!transaction->scheduleTask(createCallbackTask(&IDBObjectStoreBackendImpl::createIndexInternal, objectStore, name, keyPath, unique, callbacks))) 262 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_ALLOWED_ERR, "createIndex must be called in the context of a transaction.")); 263 } 264 265 void IDBObjectStoreBackendImpl::createIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks> callbacks) 266 { 267 if (objectStore->m_indexes.contains(name)) { 268 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::CONSTRAINT_ERR, "Index name already exists.")); 269 return; 270 } 271 266 PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::createIndex(const String& name, const String& keyPath, bool unique, IDBTransactionBackendInterface* transaction) 267 { 268 if (m_indexes.contains(name)) { 269 // FIXME: Raise CONSTRAINT_ERR. 270 return 0; 271 } 272 273 RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(this, name, keyPath, unique); 274 ASSERT(index->name() == name); 275 m_indexes.set(name, index); 276 277 RefPtr<IDBObjectStoreBackendImpl> objectStore = this; 278 RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction; 279 if (!transaction->scheduleTask(createCallbackTask(&IDBObjectStoreBackendImpl::createIndexInternal, objectStore, index, transaction))) 280 return 0; 281 282 return index.release(); 283 } 284 285 void IDBObjectStoreBackendImpl::createIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index, PassRefPtr<IDBTransactionBackendInterface> transaction) 286 { 272 287 SQLiteStatement insert(objectStore->sqliteDatabase(), "INSERT INTO Indexes (objectStoreId, name, keyPath, isUnique) VALUES (?, ?, ?, ?)"); 273 288 bool ok = insert.prepare() == SQLResultOk; 274 289 ASSERT_UNUSED(ok, ok); // FIXME: Better error handling. 275 290 insert.bindInt64(1, objectStore->m_id); 276 insert.bindText(2, name);277 insert.bindText(3, keyPath);278 insert.bindInt(4, static_cast<int>( unique));291 insert.bindText(2, index->name()); 292 insert.bindText(3, index->keyPath()); 293 insert.bindInt(4, static_cast<int>(index->unique())); 279 294 ok = insert.step() == SQLResultDone; 280 295 ASSERT_UNUSED(ok, ok); // FIXME: Better error handling. 281 296 int64_t id = objectStore->sqliteDatabase().lastInsertRowID(); 282 283 RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(objectStore.get(), id, name, keyPath, unique); 284 ASSERT(index->name() == name); 285 objectStore->m_indexes.set(name, index); 286 callbacks->onSuccess(index.get()); 297 index->setId(id); 298 transaction->didCompleteTaskEvents(); 287 299 } 288 300 … … 302 314 } 303 315 304 void IDBObjectStoreBackendImpl::removeIndex(const String& name, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transaction) 305 { 306 RefPtr<IDBObjectStoreBackendImpl> objectStore = this; 307 RefPtr<IDBCallbacks> callbacks = prpCallbacks; 308 if (!transaction->scheduleTask(createCallbackTask(&IDBObjectStoreBackendImpl::removeIndexInternal, objectStore, name, callbacks))) 309 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_ALLOWED_ERR, "createIndex must be called in the context of a transaction.")); 310 } 311 312 void IDBObjectStoreBackendImpl::removeIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, const String& name, PassRefPtr<IDBCallbacks> callbacks) 313 { 314 RefPtr<IDBIndexBackendImpl> index = objectStore->m_indexes.get(name); 316 void IDBObjectStoreBackendImpl::removeIndex(const String& name, IDBTransactionBackendInterface* transaction) 317 { 318 RefPtr<IDBIndexBackendImpl> index = m_indexes.get(name); 315 319 if (!index) { 316 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "Index name does not exist.")); 317 return; 318 } 319 320 // FIXME: Raise NOT_FOUND_ERR. 321 return; 322 } 323 m_indexes.remove(name); 324 RefPtr<IDBObjectStoreBackendImpl> objectStore = this; 325 RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction; 326 transaction->scheduleTask(createCallbackTask(&IDBObjectStoreBackendImpl::removeIndexInternal, objectStore, index, transactionPtr)); 327 // FIXME: Raise NOT_ALLOWED_ERR if the above statement fails. 328 } 329 330 void IDBObjectStoreBackendImpl::removeIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index, PassRefPtr<IDBTransactionBackendInterface> transaction) 331 { 320 332 doDelete(objectStore->sqliteDatabase(), "DELETE FROM Indexes WHERE id = ?", index->id()); 321 333 doDelete(objectStore->sqliteDatabase(), "DELETE FROM IndexData WHERE indexId = ?", index->id()); 322 334 323 objectStore->m_indexes.remove(name); 324 callbacks->onSuccess(); 335 transaction->didCompleteTaskEvents(); 325 336 } 326 337 -
trunk/WebCore/storage/IDBObjectStoreBackendImpl.h
r68795 r69121 47 47 return adoptRef(new IDBObjectStoreBackendImpl(database, id, name, keyPath, autoIncrement)); 48 48 } 49 static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBDatabaseBackendImpl* database, const String& name, const String& keyPath, bool autoIncrement) 50 { 51 return adoptRef(new IDBObjectStoreBackendImpl(database, name, keyPath, autoIncrement)); 52 } 49 53 ~IDBObjectStoreBackendImpl(); 50 54 51 int64_t id() const { return m_id; } 55 int64_t id() const 56 { 57 ASSERT(m_id != InvalidId); 58 return m_id; 59 } 60 void setId(int64_t id) { m_id = id; } 52 61 String name() const { return m_name; } 53 62 String keyPath() const { return m_keyPath; } 54 63 PassRefPtr<DOMStringList> indexNames() const; 64 bool autoIncrement() const { return m_autoIncrement; } 55 65 56 66 void get(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*); … … 58 68 void remove(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*); 59 69 60 void createIndex(const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);70 PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const String& keyPath, bool unique, IDBTransactionBackendInterface*); 61 71 PassRefPtr<IDBIndexBackendInterface> index(const String& name); 62 void removeIndex(const String& name, PassRefPtr<IDBCallbacks>,IDBTransactionBackendInterface*);72 void removeIndex(const String& name, IDBTransactionBackendInterface*); 63 73 64 74 void openCursor(PassRefPtr<IDBKeyRange> range, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*); … … 68 78 private: 69 79 IDBObjectStoreBackendImpl(IDBDatabaseBackendImpl*, int64_t id, const String& name, const String& keyPath, bool autoIncrement); 80 IDBObjectStoreBackendImpl(IDBDatabaseBackendImpl*, const String& name, const String& keyPath, bool autoIncrement); 70 81 71 82 void loadIndexes(); … … 75 86 static void putInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, bool addOnly, PassRefPtr<IDBCallbacks>); 76 87 static void removeInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks>); 77 static void createIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks>);78 static void removeIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, const String& name, PassRefPtr<IDBCallbacks>);88 static void createIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBTransactionBackendInterface>); 89 static void removeIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBTransactionBackendInterface>); 79 90 static void openCursorInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBKeyRange> range, unsigned short direction, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>); 91 92 static const int64_t InvalidId = 0; 80 93 81 94 RefPtr<IDBDatabaseBackendImpl> m_database; -
trunk/WebCore/storage/IDBObjectStoreBackendInterface.h
r68795 r69121 54 54 virtual void remove(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*) = 0; 55 55 56 virtual void createIndex(const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*) = 0;56 virtual PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const String& keyPath, bool unique, IDBTransactionBackendInterface*) = 0; 57 57 virtual PassRefPtr<IDBIndexBackendInterface> index(const String& name) = 0; 58 virtual void removeIndex(const String& name, PassRefPtr<IDBCallbacks>,IDBTransactionBackendInterface*) = 0;58 virtual void removeIndex(const String& name, IDBTransactionBackendInterface*) = 0; 59 59 60 60 virtual void openCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*) = 0; -
trunk/WebCore/storage/IDBTransactionBackendImpl.cpp
r69052 r69121 48 48 , m_database(database) 49 49 , m_transaction(new SQLiteTransaction(database->sqliteDatabase())) 50 , m_timer(this, &IDBTransactionBackendImpl::timerFired) 50 , m_taskTimer(this, &IDBTransactionBackendImpl::taskTimerFired) 51 , m_taskEventTimer(this, &IDBTransactionBackendImpl::taskEventTimerFired) 51 52 , m_pendingEvents(0) 52 53 { … … 55 56 PassRefPtr<IDBObjectStoreBackendInterface> IDBTransactionBackendImpl::objectStore(const String& name) 56 57 { 57 if ( isFinished())58 if (m_state == Finished) 58 59 return 0; 59 60 return m_database->objectStore(name, 0); // FIXME: remove mode param. … … 62 63 bool IDBTransactionBackendImpl::scheduleTask(PassOwnPtr<ScriptExecutionContext::Task> task) 63 64 { 64 if ( isFinished())65 if (m_state == Finished) 65 66 return false; 66 67 … … 74 75 void IDBTransactionBackendImpl::abort() 75 76 { 76 if ( isFinished())77 if (m_state == Finished) 77 78 return; 78 79 79 80 m_state = Finished; 80 m_timer.stop(); 81 m_taskTimer.stop(); 82 m_taskEventTimer.stop(); 81 83 m_transaction->rollback(); 82 84 m_callbacks->onAbort(); … … 91 93 ASSERT(m_state == Running); 92 94 ASSERT(m_pendingEvents); 93 94 95 m_pendingEvents--; 95 96 96 if (!m_pendingEvents && m_taskQueue.isEmpty()) { 97 // The last task event has completed and the task 98 // queue is empty. Commit the transaction. 99 commit(); 100 return; 101 } 102 103 // We are still waiting for other events to complete. However, 104 // the task queue is non-empty and the timer is inactive. 105 // We can therfore schedule the timer again. 106 if (!m_taskQueue.isEmpty() && !m_timer.isActive()) 107 m_timer.startOneShot(0); 97 if (!m_taskEventTimer.isActive()) 98 m_taskEventTimer.startOneShot(0); 108 99 } 109 100 … … 111 102 { 112 103 ASSERT(m_state == StartPending || m_state == Running); 113 ASSERT(!m_t imer.isActive());104 ASSERT(!m_taskTimer.isActive()); 114 105 115 m_t imer.startOneShot(0);106 m_taskTimer.startOneShot(0); 116 107 } 117 108 … … 134 125 } 135 126 136 void IDBTransactionBackendImpl::t imerFired(Timer<IDBTransactionBackendImpl>*)127 void IDBTransactionBackendImpl::taskTimerFired(Timer<IDBTransactionBackendImpl>*) 137 128 { 138 129 ASSERT(!m_taskQueue.isEmpty()); … … 154 145 } 155 146 147 void IDBTransactionBackendImpl::taskEventTimerFired(Timer<IDBTransactionBackendImpl>*) 148 { 149 ASSERT(m_state == Running); 150 151 if (!m_pendingEvents && m_taskQueue.isEmpty()) { 152 // The last task event has completed and the task 153 // queue is empty. Commit the transaction. 154 commit(); 155 return; 156 } 157 158 // We are still waiting for other events to complete. However, 159 // the task queue is non-empty and the timer is inactive. 160 // We can therfore schedule the timer again. 161 if (!m_taskQueue.isEmpty() && !m_taskTimer.isActive()) 162 m_taskTimer.startOneShot(0); 163 } 164 156 165 }; 157 166 -
trunk/WebCore/storage/IDBTransactionBackendImpl.h
r68795 r69121 55 55 56 56 void run(); 57 bool isFinished() const { return m_state == Finished; }58 57 59 58 private: … … 70 69 void commit(); 71 70 72 void timerFired(Timer<IDBTransactionBackendImpl>*); 71 void taskTimerFired(Timer<IDBTransactionBackendImpl>*); 72 void taskEventTimerFired(Timer<IDBTransactionBackendImpl>*); 73 73 74 74 RefPtr<DOMStringList> m_objectStoreNames; … … 87 87 88 88 // FIXME: delete the timer once we have threads instead. 89 Timer<IDBTransactionBackendImpl> m_timer; 89 Timer<IDBTransactionBackendImpl> m_taskTimer; 90 Timer<IDBTransactionBackendImpl> m_taskEventTimer; 90 91 int m_pendingEvents; 91 92 }; -
trunk/WebKit/chromium/ChangeLog
r69098 r69121 1 2010-10-04 Andrei Popescu <andreip@google.com> 2 3 Reviewed by Jeremy Orlow. 4 5 IDBDatabase::createObjectStore/removeObjectStore and IDBObjectStore::createIndex/removeIndex should be synchronous. 6 https://bugs.webkit.org/show_bug.cgi?id=46883 7 8 * public/WebIDBDatabase.h: 9 (WebKit::WebIDBDatabase::createObjectStore): 10 (WebKit::WebIDBDatabase::removeObjectStore): 11 * public/WebIDBObjectStore.h: 12 (WebKit::WebIDBObjectStore::createIndex): 13 (WebKit::WebIDBObjectStore::removeIndex): 14 * src/IDBDatabaseProxy.cpp: 15 (WebCore::IDBDatabaseProxy::createObjectStore): 16 (WebCore::IDBDatabaseProxy::removeObjectStore): 17 * src/IDBDatabaseProxy.h: 18 * src/IDBObjectStoreProxy.cpp: 19 (WebCore::IDBObjectStoreProxy::createIndex): 20 (WebCore::IDBObjectStoreProxy::removeIndex): 21 * src/IDBObjectStoreProxy.h: 22 * src/WebIDBDatabaseImpl.cpp: 23 (WebKit::WebIDBDatabaseImpl::createObjectStore): 24 (WebKit::WebIDBDatabaseImpl::removeObjectStore): 25 * src/WebIDBDatabaseImpl.h: 26 * src/WebIDBObjectStoreImpl.cpp: 27 (WebKit::WebIDBObjectStoreImpl::createIndex): 28 (WebKit::WebIDBObjectStoreImpl::removeIndex): 29 * src/WebIDBObjectStoreImpl.h: 30 1 31 2010-10-04 Andrey Kosyakov <caseq@chromium.org> 2 32 -
trunk/WebKit/chromium/public/WebIDBDatabase.h
r68803 r69121 62 62 return WebDOMStringList(); 63 63 } 64 64 65 // FIXME: Remove once we update Chromium side. 65 66 virtual void createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, WebIDBCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } 66 virtual void createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, WebIDBCallbacks*, const WebIDBTransaction&) { WEBKIT_ASSERT_NOT_REACHED(); } 67 virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction&) 68 { 69 WEBKIT_ASSERT_NOT_REACHED(); 70 return 0; 71 } 67 72 // Transfers ownership of the WebIDBObjectStore to the caller. 68 73 virtual WebIDBObjectStore* objectStore(const WebString& name, unsigned short mode) … … 71 76 return 0; 72 77 } 73 // FIXME: Remove once we update Chromium side.78 // FIXME: Remove after WebKit roll. 74 79 virtual void removeObjectStore(const WebString& name, WebIDBCallbacks* callbacks) { WEBKIT_ASSERT_NOT_REACHED(); } 75 virtual void removeObjectStore(const WebString& name, WebIDBCallbacks* callbacks,const WebIDBTransaction&) { WEBKIT_ASSERT_NOT_REACHED(); }80 virtual void removeObjectStore(const WebString& name, const WebIDBTransaction&) { WEBKIT_ASSERT_NOT_REACHED(); } 76 81 virtual void setVersion(const WebString& version, WebIDBCallbacks* callbacks) { WEBKIT_ASSERT_NOT_REACHED(); } 77 82 // Transfers ownership of the WebIDBTransaction to the caller. -
trunk/WebKit/chromium/public/WebIDBObjectStore.h
r68803 r69121 64 64 // FIXME: Remove once we update Chromium side. 65 65 virtual void createIndex(const WebString& name, const WebString& keyPath, bool unique, WebIDBCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } 66 virtual void createIndex(const WebString& name, const WebString& keyPath, bool unique, WebIDBCallbacks*, const WebIDBTransaction&) { WEBKIT_ASSERT_NOT_REACHED(); } 66 virtual WebIDBIndex* createIndex(const WebString& name, const WebString& keyPath, bool unique, const WebIDBTransaction&) 67 { 68 WEBKIT_ASSERT_NOT_REACHED(); 69 return 0; 70 } 67 71 // Transfers ownership of the WebIDBIndex to the caller. 68 72 virtual WebIDBIndex* index(const WebString& name) … … 73 77 // FIXME: Remove once we update Chromium side. 74 78 virtual void removeIndex(const WebString& name, WebIDBCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } 75 virtual void removeIndex(const WebString& name, WebIDBCallbacks*,const WebIDBTransaction&) { WEBKIT_ASSERT_NOT_REACHED(); }79 virtual void removeIndex(const WebString& name, const WebIDBTransaction&) { WEBKIT_ASSERT_NOT_REACHED(); } 76 80 virtual void openCursor(const WebIDBKeyRange&, unsigned short direction, WebIDBCallbacks*, const WebIDBTransaction&) { WEBKIT_ASSERT_NOT_REACHED(); } 77 81 // FIXME: finish. -
trunk/WebKit/chromium/src/IDBDatabaseProxy.cpp
r68795 r69121 77 77 } 78 78 79 void IDBDatabaseProxy::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction)79 PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseProxy::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transaction) 80 80 { 81 81 // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer, 82 82 // all implementations of IDB interfaces are proxy objects. 83 83 IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction); 84 m_webIDBDatabase->createObjectStore(name, keyPath, autoIncrement, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction()); 84 WebKit::WebIDBObjectStore* objectStore = m_webIDBDatabase->createObjectStore(name, keyPath, autoIncrement, *transactionProxy->getWebIDBTransaction()); 85 if (!objectStore) 86 return 0; 87 return IDBObjectStoreProxy::create(objectStore); 85 88 } 86 89 … … 93 96 } 94 97 95 void IDBDatabaseProxy::removeObjectStore(const String& name, PassRefPtr<IDBCallbacks> callbacks,IDBTransactionBackendInterface* transaction)98 void IDBDatabaseProxy::removeObjectStore(const String& name, IDBTransactionBackendInterface* transaction) 96 99 { 97 100 // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer, 98 101 // all implementations of IDB interfaces are proxy objects. 99 102 IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction); 100 m_webIDBDatabase->removeObjectStore(name, new WebIDBCallbacksImpl(callbacks),*transactionProxy->getWebIDBTransaction());103 m_webIDBDatabase->removeObjectStore(name, *transactionProxy->getWebIDBTransaction()); 101 104 } 102 105 -
trunk/WebKit/chromium/src/IDBDatabaseProxy.h
r68795 r69121 48 48 virtual PassRefPtr<DOMStringList> objectStores() const; 49 49 50 virtual void createObjectStore(const String& name, const String& keyPath, bool autoIncrement, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);50 virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface*); 51 51 virtual PassRefPtr<IDBObjectStoreBackendInterface> objectStore(const String& name, unsigned short mode); 52 virtual void removeObjectStore(const String& name, PassRefPtr<IDBCallbacks>,IDBTransactionBackendInterface*);52 virtual void removeObjectStore(const String& name, IDBTransactionBackendInterface*); 53 53 virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>); 54 54 virtual PassRefPtr<IDBTransactionBackendInterface> transaction(DOMStringList* storeNames, unsigned short mode, unsigned long timeout); -
trunk/WebKit/chromium/src/IDBObjectStoreProxy.cpp
r68795 r69121 97 97 } 98 98 99 void IDBObjectStoreProxy::createIndex(const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction)99 PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreProxy::createIndex(const String& name, const String& keyPath, bool unique, IDBTransactionBackendInterface* transaction) 100 100 { 101 101 // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer, 102 102 // all implementations of IDB interfaces are proxy objects. 103 103 IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction); 104 m_webIDBObjectStore->createIndex(name, keyPath, unique, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction()); 104 WebKit::WebIDBIndex* index = m_webIDBObjectStore->createIndex(name, keyPath, unique, *transactionProxy->getWebIDBTransaction()); 105 if (!index) 106 return 0; 107 return IDBIndexBackendProxy::create(index); 105 108 } 106 109 … … 113 116 } 114 117 115 void IDBObjectStoreProxy::removeIndex(const String& name, PassRefPtr<IDBCallbacks> callbacks,IDBTransactionBackendInterface* transaction)118 void IDBObjectStoreProxy::removeIndex(const String& name, IDBTransactionBackendInterface* transaction) 116 119 { 117 120 // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer, 118 121 // all implementations of IDB interfaces are proxy objects. 119 122 IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction); 120 m_webIDBObjectStore->removeIndex(name, new WebIDBCallbacksImpl(callbacks),*transactionProxy->getWebIDBTransaction());123 m_webIDBObjectStore->removeIndex(name, *transactionProxy->getWebIDBTransaction()); 121 124 } 122 125 -
trunk/WebKit/chromium/src/IDBObjectStoreProxy.h
r68795 r69121 51 51 virtual void remove(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*); 52 52 53 virtual void createIndex(const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);54 virtualPassRefPtr<IDBIndexBackendInterface> index(const String& name);55 v irtual void removeIndex(const String& name, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);53 PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const String& keyPath, bool unique, IDBTransactionBackendInterface*); 54 PassRefPtr<IDBIndexBackendInterface> index(const String& name); 55 void removeIndex(const String& name, IDBTransactionBackendInterface*); 56 56 57 57 virtual void openCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*); -
trunk/WebKit/chromium/src/WebIDBDatabaseImpl.cpp
r68795 r69121 70 70 } 71 71 72 void WebIDBDatabaseImpl::createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction)72 WebIDBObjectStore* WebIDBDatabaseImpl::createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction& transaction) 73 73 { 74 m_databaseBackend->createObjectStore(name, keyPath, autoIncrement, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface()); 74 RefPtr<IDBObjectStoreBackendInterface> objectStore = m_databaseBackend->createObjectStore(name, keyPath, autoIncrement, transaction.getIDBTransactionBackendInterface()); 75 if (!objectStore) 76 return 0; 77 return new WebIDBObjectStoreImpl(objectStore); 75 78 } 76 79 … … 83 86 } 84 87 85 void WebIDBDatabaseImpl::removeObjectStore(const WebString& name, WebIDBCallbacks* callbacks,const WebIDBTransaction& transaction)88 void WebIDBDatabaseImpl::removeObjectStore(const WebString& name, const WebIDBTransaction& transaction) 86 89 { 87 m_databaseBackend->removeObjectStore(name, IDBCallbacksProxy::create(callbacks),transaction.getIDBTransactionBackendInterface());90 m_databaseBackend->removeObjectStore(name, transaction.getIDBTransactionBackendInterface()); 88 91 } 89 92 -
trunk/WebKit/chromium/src/WebIDBDatabaseImpl.h
r68795 r69121 50 50 virtual WebDOMStringList objectStores() const; 51 51 52 virtual void createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, WebIDBCallbacks* callbacks, const WebIDBTransaction&);52 virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction&); 53 53 virtual WebIDBObjectStore* objectStore(const WebString& name, unsigned short mode); 54 virtual void removeObjectStore(const WebString& name, WebIDBCallbacks* callbacks,const WebIDBTransaction&);54 virtual void removeObjectStore(const WebString& name, const WebIDBTransaction&); 55 55 virtual void setVersion(const WebString& version, WebIDBCallbacks* callbacks); 56 56 virtual WebIDBTransaction* transaction(const WebDOMStringList& names, unsigned short mode, unsigned long timeout); -
trunk/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp
r68795 r69121 82 82 } 83 83 84 void WebIDBObjectStoreImpl::createIndex(const WebString& name, const WebString& keyPath, bool unique, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction)84 WebIDBIndex* WebIDBObjectStoreImpl::createIndex(const WebString& name, const WebString& keyPath, bool unique, const WebIDBTransaction& transaction) 85 85 { 86 m_objectStore->createIndex(name, keyPath, unique, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface()); 86 RefPtr<IDBIndexBackendInterface> index = m_objectStore->createIndex(name, keyPath, unique, transaction.getIDBTransactionBackendInterface()); 87 if (!index) 88 return 0; 89 return new WebIDBIndexImpl(index); 87 90 } 88 91 … … 95 98 } 96 99 97 void WebIDBObjectStoreImpl::removeIndex(const WebString& name, WebIDBCallbacks* callbacks,const WebIDBTransaction& transaction)100 void WebIDBObjectStoreImpl::removeIndex(const WebString& name, const WebIDBTransaction& transaction) 98 101 { 99 m_objectStore->removeIndex(name, IDBCallbacksProxy::create(callbacks),transaction.getIDBTransactionBackendInterface());102 m_objectStore->removeIndex(name, transaction.getIDBTransactionBackendInterface()); 100 103 } 101 104 -
trunk/WebKit/chromium/src/WebIDBObjectStoreImpl.h
r68795 r69121 52 52 void remove(const WebIDBKey& key, WebIDBCallbacks*, const WebIDBTransaction&); 53 53 54 void createIndex(const WebString& name, const WebString& keyPath, bool unique, WebIDBCallbacks*, const WebIDBTransaction&);54 WebIDBIndex* createIndex(const WebString& name, const WebString& keyPath, bool unique, const WebIDBTransaction&); 55 55 WebIDBIndex* index(const WebString& name); 56 void removeIndex(const WebString& name, WebIDBCallbacks*,const WebIDBTransaction&);56 void removeIndex(const WebString& name, const WebIDBTransaction&); 57 57 58 58 void openCursor(const WebIDBKeyRange&, unsigned short direction, WebIDBCallbacks*, const WebIDBTransaction&);
Note: See TracChangeset
for help on using the changeset viewer.