Changeset 69121 in webkit


Ignore:
Timestamp:
Oct 5, 2010 10:10:39 AM (14 years ago)
Author:
andreip@google.com
Message:

2010-10-04 Andrei Popescu <andreip@google.com>

Reviewed by Jeremy Orlow.

IDBDatabase::createObjectStore/removeObjectStore and IDBObjectStore::createIndex/removeIndex should be synchronous.
https://bugs.webkit.org/show_bug.cgi?id=46883

  • storage/indexeddb/database-basics-expected.txt:
  • storage/indexeddb/database-basics.html:
  • storage/indexeddb/index-basics-expected.txt:
  • storage/indexeddb/index-basics.html:
  • storage/indexeddb/index-cursor-expected.txt:
  • storage/indexeddb/index-cursor.html:
  • storage/indexeddb/objectstore-basics-expected.txt:
  • storage/indexeddb/objectstore-basics.html:
  • storage/indexeddb/objectstore-cursor-expected.txt:
  • storage/indexeddb/objectstore-cursor.html:
  • storage/indexeddb/objectstore-removeobjectstore-expected.txt:
  • storage/indexeddb/objectstore-removeobjectstore.html:
  • storage/indexeddb/open-cursor-expected.txt:
  • storage/indexeddb/open-cursor.html:
  • storage/indexeddb/resources/shared.js: (deleteAllObjectStores):
  • storage/indexeddb/transaction-basics-expected.txt:
  • storage/indexeddb/transaction-basics.html:

2010-10-04 Andrei Popescu <andreip@google.com>

Reviewed by Jeremy Orlow.

IDBDatabase::createObjectStore/removeObjectStore and IDBObjectStore::createIndex/removeIndex should be synchronous.
https://bugs.webkit.org/show_bug.cgi?id=46883

Makes the schema manipulation methods synchronous. Modifies the transaction
logic to support tasks that may have pending events as well as tasks that
don't have such events.

  • storage/IDBDatabase.cpp: (WebCore::IDBDatabase::createObjectStore): (WebCore::IDBDatabase::removeObjectStore):
  • storage/IDBDatabase.h:
  • storage/IDBDatabase.idl:
  • storage/IDBDatabaseBackendImpl.cpp: (WebCore::IDBDatabaseBackendImpl::createObjectStore): (WebCore::IDBDatabaseBackendImpl::createObjectStoreInternal): (WebCore::IDBDatabaseBackendImpl::removeObjectStore): (WebCore::IDBDatabaseBackendImpl::removeObjectStoreInternal):
  • storage/IDBDatabaseBackendImpl.h:
  • storage/IDBDatabaseBackendInterface.h:
  • storage/IDBIndexBackendImpl.cpp: (WebCore::IDBIndexBackendImpl::IDBIndexBackendImpl):
  • storage/IDBIndexBackendImpl.h: (WebCore::IDBIndexBackendImpl::create): (WebCore::IDBIndexBackendImpl::id): (WebCore::IDBIndexBackendImpl::setId):
  • storage/IDBObjectStore.cpp: (WebCore::IDBObjectStore::createIndex): (WebCore::IDBObjectStore::removeIndex):
  • storage/IDBObjectStore.h:
  • storage/IDBObjectStore.idl:
  • storage/IDBObjectStoreBackendImpl.cpp: (WebCore::IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl): (WebCore::IDBObjectStoreBackendImpl::createIndex): (WebCore::IDBObjectStoreBackendImpl::createIndexInternal): (WebCore::IDBObjectStoreBackendImpl::removeIndex): (WebCore::IDBObjectStoreBackendImpl::removeIndexInternal):
  • storage/IDBObjectStoreBackendImpl.h: (WebCore::IDBObjectStoreBackendImpl::create): (WebCore::IDBObjectStoreBackendImpl::id): (WebCore::IDBObjectStoreBackendImpl::setId): (WebCore::IDBObjectStoreBackendImpl::autoIncrement):
  • storage/IDBObjectStoreBackendInterface.h:
  • storage/IDBTransactionBackendImpl.cpp: (WebCore::IDBTransactionBackendImpl::IDBTransactionBackendImpl): (WebCore::IDBTransactionBackendImpl::objectStore): (WebCore::IDBTransactionBackendImpl::scheduleTask): (WebCore::IDBTransactionBackendImpl::abort): (WebCore::IDBTransactionBackendImpl::didCompleteTaskEvents): (WebCore::IDBTransactionBackendImpl::run): (WebCore::IDBTransactionBackendImpl::taskTimerFired): (WebCore::IDBTransactionBackendImpl::taskEventTimerFired):
  • storage/IDBTransactionBackendImpl.h:

2010-10-04 Andrei Popescu <andreip@google.com>

Reviewed by Jeremy Orlow.

IDBDatabase::createObjectStore/removeObjectStore and IDBObjectStore::createIndex/removeIndex should be synchronous.
https://bugs.webkit.org/show_bug.cgi?id=46883

  • public/WebIDBDatabase.h: (WebKit::WebIDBDatabase::createObjectStore): (WebKit::WebIDBDatabase::removeObjectStore):
  • public/WebIDBObjectStore.h: (WebKit::WebIDBObjectStore::createIndex): (WebKit::WebIDBObjectStore::removeIndex):
  • src/IDBDatabaseProxy.cpp: (WebCore::IDBDatabaseProxy::createObjectStore): (WebCore::IDBDatabaseProxy::removeObjectStore):
  • src/IDBDatabaseProxy.h:
  • src/IDBObjectStoreProxy.cpp: (WebCore::IDBObjectStoreProxy::createIndex): (WebCore::IDBObjectStoreProxy::removeIndex):
  • src/IDBObjectStoreProxy.h:
  • src/WebIDBDatabaseImpl.cpp: (WebKit::WebIDBDatabaseImpl::createObjectStore): (WebKit::WebIDBDatabaseImpl::removeObjectStore):
  • src/WebIDBDatabaseImpl.h:
  • src/WebIDBObjectStoreImpl.cpp: (WebKit::WebIDBObjectStoreImpl::createIndex): (WebKit::WebIDBObjectStoreImpl::removeIndex):
  • src/WebIDBObjectStoreImpl.h:
Location:
trunk
Files:
46 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r69120 r69121  
     12010-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
    1272010-10-05  Chris Fleizach  <cfleizach@apple.com>
    228
  • trunk/LayoutTests/storage/indexeddb/database-basics-expected.txt

    r68795 r69121  
    4242trans = event.result
    4343PASS trans !== null is true
     44Deleted all object stores.
    4445Testing setVersion.
    4546db.setVersion("version a")
     
    8384PASS db.objectStores.contains('') is false
    8485db.createObjectStore("test123")
    85 PASS 'onsuccess' in result is true
    86 PASS 'onerror' in result is true
    87 PASS 'readyState' in result is true
    88 An event should fire shortly...
    89 
    90 Success event fired:
    91 PASS 'result' in event is true
    92 PASS 'code' in event is false
    93 PASS 'message' in event is false
    94 PASS 'source' in event is true
    95 PASS event.source != null is true
    96 PASS 'onsuccess' in event.target is true
    97 PASS 'onerror' in event.target is true
    98 PASS 'readyState' in event.target is true
    99 PASS event.target.readyState is event.target.DONE
    100 
    10186PASS db.objectStores is ['test123']
    10287PASS db.objectStores.length is 1
  • trunk/LayoutTests/storage/indexeddb/database-basics.html

    r68795 r69121  
    5151    verifyResult(result);
    5252    result.onsuccess = setVersionAgain;
    53     result.onError = unexpectedErrorCallback;
     53    result.onerror = unexpectedErrorCallback;
    5454}
    5555
     
    6161    verifyResult(result);
    6262    result.onsuccess = createObjectStore;
    63     result.onError = unexpectedErrorCallback;
     63    result.onerror = unexpectedErrorCallback;
    6464}
    6565
     
    7373    shouldBe("db.objectStores.contains('')", "false");
    7474
    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);
    7977}
    8078
    81 function checkObjectStore()
     79function checkObjectStore(objectStore)
    8280{
    83     verifySuccessEvent(event);
    8481    shouldBe("db.objectStores", "['test123']");
    8582    shouldBe("db.objectStores.length", "1");
  • trunk/LayoutTests/storage/indexeddb/index-basics-expected.txt

    r68795 r69121  
    4242trans = event.result
    4343PASS trans !== null is true
     44Deleted all object stores.
    4445db.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
     46store.createIndex('indexName', 'x')
    8147PASS 'name' in indexObject is true
    8248PASS indexObject.name is "indexName"
     
    9157PASS 'getObject' in indexObject is true
    9258PASS 'get' in indexObject is true
    93 event.source.add({x: 'value', y: 'zzz'}, 'key')
     59store.add({x: 'value', y: 'zzz'}, 'key')
    9460PASS 'onsuccess' in result is true
    9561PASS 'onerror' in result is true
  • trunk/LayoutTests/storage/indexeddb/index-basics.html

    r68795 r69121  
    4242    trans.onabort = unexpectedAbortCallback;
    4343
    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);
    5345}
    5446
    5547function createIndex()
    5648{
    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();
    6452}
    6553
    6654function addData()
    6755{
    68     verifySuccessEvent(event);
    69     shouldBeFalse("event.result === null");
    70     window.indexObject = evalAndLog("indexObject = event.result");
    7156    shouldBeTrue("'name' in indexObject");
    7257    shouldBeEqualToString("indexObject.name", "indexName");
     
    8267    shouldBeTrue("'get' in indexObject");
    8368
    84     result = evalAndLog("event.source.add({x: 'value', y: 'zzz'}, 'key')");
     69    result = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
    8570    verifyResult(result);
    8671    result.onsuccess = addMore;
  • trunk/LayoutTests/storage/indexeddb/index-cursor-expected.txt

    r68795 r69121  
    4141trans = event.result
    4242PASS trans !== null is true
     43Deleted all object stores.
    4344db.createObjectStore('someObjectStore')
     45objectStore.createIndex('someIndex', 'x')
     46objectStore.add({'x': testData[nextToAdd]}, nextToAdd)
    4447PASS 'onsuccess' in result is true
    4548PASS 'onerror' in result is true
     
    5861PASS event.target.readyState is event.target.DONE
    5962
    60 objectStore = event.result
    61 objectStore.createIndex('someIndex', 'x')
     63objectStore.add({'x': testData[nextToAdd]}, nextToAdd)
    6264PASS 'onsuccess' in result is true
    6365PASS 'onerror' in result is true
     
    7678PASS event.target.readyState is event.target.DONE
    7779
    78 indexObject = event.result
     80objectStore.add({'x': testData[nextToAdd]}, nextToAdd)
     81PASS 'onsuccess' in result is true
     82PASS 'onerror' in result is true
     83PASS 'readyState' in result is true
     84An event should fire shortly...
     85
    7986Success event fired:
    8087PASS 'result' in event is true
     
    162169An event should fire shortly...
    163170
    164 Success event fired:
    165 PASS 'result' in event is true
    166 PASS 'code' in event is false
    167 PASS 'message' in event is false
    168 PASS 'source' in event is true
    169 PASS event.source != null is true
    170 PASS 'onsuccess' in event.target is true
    171 PASS 'onerror' in event.target is true
    172 PASS 'readyState' in event.target is true
    173 PASS event.target.readyState is event.target.DONE
    174 
    175 objectStore.add({'x': testData[nextToAdd]}, nextToAdd)
    176 PASS 'onsuccess' in result is true
    177 PASS 'onerror' in result is true
    178 PASS 'readyState' in result is true
    179 An event should fire shortly...
    180 
    181 Success event fired:
    182 PASS 'result' in event is true
    183 PASS 'code' in event is false
    184 PASS 'message' in event is false
    185 PASS 'source' in event is true
    186 PASS event.source != null is true
    187 PASS 'onsuccess' in event.target is true
    188 PASS 'onerror' in event.target is true
    189 PASS 'readyState' in event.target is true
    190 PASS event.target.readyState is event.target.DONE
    191 
    192 objectStore.add({'x': testData[nextToAdd]}, nextToAdd)
    193 PASS 'onsuccess' in result is true
    194 PASS 'onerror' in result is true
    195 PASS 'readyState' in result is true
    196 An event should fire shortly...
    197 
    198 Success event fired:
    199 PASS 'result' in event is true
    200 PASS 'code' in event is false
    201 PASS 'message' in event is false
    202 PASS 'source' in event is true
    203 PASS event.source != null is true
    204 PASS 'onsuccess' in event.target is true
    205 PASS 'onerror' in event.target is true
    206 PASS 'readyState' in event.target is true
    207 PASS event.target.readyState is event.target.DONE
    208 
    209 objectStore.add({'x': testData[nextToAdd]}, nextToAdd)
    210 PASS 'onsuccess' in result is true
    211 PASS 'onerror' in result is true
    212 PASS 'readyState' in result is true
    213 An event should fire shortly...
    214 
    215171Scheduling tests...
    216172Running tests...
  • trunk/LayoutTests/storage/indexeddb/index-cursor.html

    r68795 r69121  
    5454    trans.onabort = unexpectedAbortCallback;
    5555
    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);
    7657}
    7758 
    7859function startAddingData()
    7960{
    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')");
    8363    window.nextToAdd = 0;
    8464    addData();
     
    8767function addData()
    8868{
    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);
    9171
    9272    result = evalAndLog("objectStore.add({'x': testData[nextToAdd]}, nextToAdd)");
  • trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt

    r68795 r69121  
    4343trans = event.result
    4444PASS 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
     45Deleted all object stores.
     46creatObjectStore():
     47store = db.createObjectStore('storeName', null)
    6448storeNames = db.objectStores
    6549PASS store.name is "storeName"
     
    7054index = store.index('asdf')
    7155PASS 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')
     56PASS index is null
     57createIndex():
     58store.createIndex('indexName', 'x', true)
     59PASS index !== null is true
     60PASS store.indexNames.contains('indexName') is true
     61index = store.index('indexName')
    9462PASS index !== null is true
    9563Ask for a store that doesn't exist:
    9664index = store.index('asdf')
    9765PASS index is null
    98 FAIL Asking for a store that doesn't exist should have thrown.
    99 event.source.add({x: 'value'}, 'key')
     66PASS index is null.
     67store.add({x: 'value'}, 'key')
    10068PASS 'onsuccess' in result is true
    10169PASS 'onerror' in result is true
  • trunk/LayoutTests/storage/indexeddb/objectstore-basics.html

    r68795 r69121  
    4343    trans.onabort = unexpectedAbortCallback;
    4444
    45     deleteAllObjectStores(db, deleteSuccess);
     45    deleteAllObjectStores(db, createObjectStore);
    4646}
    4747
    48 function deleteSuccess()
     48function createObjectStore()
    4949{
    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)");
    6152    var storeNames = evalAndLog("storeNames = db.objectStores");
    6253
     
    7162        index = evalAndLog("index = store.index('asdf')");
    7263        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.");
    7466    } catch (err) {
    75         testPassed("Error thrown.");
    7667        // FIXME: Verify the correct exception thrown.
    7768    }
    7869
    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();
    8371}
    8472
    85 function addIndexSuccess()
     73function createIndex()
    8674{
    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')");
    9280    shouldBeTrue("index !== null");
    9381
     
    9684        index = evalAndLog("index = store.index('asdf')");
    9785        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.");
    9988    } catch (err) {
    100         testPassed("Error thrown.");
    10189        // FIXME: Verify the correct exception thrown.
    10290    }
    10391
    104     result = evalAndLog("event.source.add({x: 'value'}, 'key')");
     92    result = evalAndLog("store.add({x: 'value'}, 'key')");
    10593    verifyResult(result);
    10694    result.onsuccess = addSuccess;
  • trunk/LayoutTests/storage/indexeddb/objectstore-cursor-expected.txt

    r68795 r69121  
    4141trans = event.result
    4242PASS trans !== null is true
     43Deleted all object stores.
    4344db.createObjectStore('someObjectStore')
     45objectStore.add('', testData[nextToAdd])
    4446PASS 'onsuccess' in result is true
    4547PASS 'onerror' in result is true
     
    5860PASS event.target.readyState is event.target.DONE
    5961
    60 objectStore = event.result
     62objectStore.add('', testData[nextToAdd])
     63PASS 'onsuccess' in result is true
     64PASS 'onerror' in result is true
     65PASS 'readyState' in result is true
     66An event should fire shortly...
     67
    6168Success event fired:
    6269PASS 'result' in event is true
     
    144151An event should fire shortly...
    145152
    146 Success event fired:
    147 PASS 'result' in event is true
    148 PASS 'code' in event is false
    149 PASS 'message' in event is false
    150 PASS 'source' in event is true
    151 PASS event.source != null is true
    152 PASS 'onsuccess' in event.target is true
    153 PASS 'onerror' in event.target is true
    154 PASS 'readyState' in event.target is true
    155 PASS event.target.readyState is event.target.DONE
    156 
    157 objectStore.add('', testData[nextToAdd])
    158 PASS 'onsuccess' in result is true
    159 PASS 'onerror' in result is true
    160 PASS 'readyState' in result is true
    161 An event should fire shortly...
    162 
    163 Success event fired:
    164 PASS 'result' in event is true
    165 PASS 'code' in event is false
    166 PASS 'message' in event is false
    167 PASS 'source' in event is true
    168 PASS event.source != null is true
    169 PASS 'onsuccess' in event.target is true
    170 PASS 'onerror' in event.target is true
    171 PASS 'readyState' in event.target is true
    172 PASS event.target.readyState is event.target.DONE
    173 
    174 objectStore.add('', testData[nextToAdd])
    175 PASS 'onsuccess' in result is true
    176 PASS 'onerror' in result is true
    177 PASS 'readyState' in result is true
    178 An event should fire shortly...
    179 
    180153Scheduling tests...
    181154Running tests...
  • trunk/LayoutTests/storage/indexeddb/objectstore-cursor.html

    r68795 r69121  
    5353    trans.onabort = unexpectedAbortCallback;
    5454
    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);
    6456}
    6557 
    6658function startAddingData()
    6759{
    68     verifySuccessEvent(event);
    69     window.objectStore = evalAndLog("objectStore = event.result");
    70 
     60    window.objectStore = evalAndLog("db.createObjectStore('someObjectStore')");
    7161    window.nextToAdd = 0;
    7262    addData();
     
    7565function addData()
    7666{
    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);
    7969
    8070    result = evalAndLog("objectStore.add('', testData[nextToAdd])");
  • trunk/LayoutTests/storage/indexeddb/objectstore-removeobjectstore-expected.txt

    r68795 r69121  
    4141trans = event.result
    4242PASS 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')
     43Deleted all object stores.
     44store = db.createObjectStore('storeName', null)
     45store.add('value', 'key')
    6146PASS 'onsuccess' in result is true
    6247PASS 'onerror' in result is true
     
    9681PASS event.result is "value"
    9782event.source.createIndex('indexName', '')
    98 PASS 'onsuccess' in result is true
    99 PASS 'onerror' in result is true
    100 PASS 'readyState' in result is true
    101 An event should fire shortly...
    102 
    103 Success event fired:
    104 PASS 'result' in event is true
    105 PASS 'code' in event is false
    106 PASS 'message' in event is false
    107 PASS 'source' in event is true
    108 PASS event.source != null is true
    109 PASS 'onsuccess' in event.target is true
    110 PASS 'onerror' in event.target is true
    111 PASS 'readyState' in event.target is true
    112 PASS event.target.readyState is event.target.DONE
    113 
    11483PASS event.source.indexNames.contains('indexName') is true
    11584db.setVersion('new version')
     
    133102PASS trans !== null is true
    134103db.removeObjectStore('storeName')
    135 PASS 'onsuccess' in result is true
    136 PASS 'onerror' in result is true
    137 PASS 'readyState' in result is true
    138 An event should fire shortly...
    139 
    140 Success event fired:
    141 PASS 'result' in event is true
    142 PASS 'code' in event is false
    143 PASS 'message' in event is false
    144 PASS 'source' in event is true
    145 PASS event.source != null is true
    146 PASS 'onsuccess' in event.target is true
    147 PASS 'onerror' in event.target is true
    148 PASS 'readyState' in event.target is true
    149 PASS event.target.readyState is event.target.DONE
    150 
    151104db.createObjectStore('storeName', null)
    152 PASS 'onsuccess' in result is true
    153 PASS 'onerror' in result is true
    154 PASS 'readyState' in result is true
    155 An event should fire shortly...
    156 
    157 Success event fired:
    158 PASS 'result' in event is true
    159 PASS 'code' in event is false
    160 PASS 'message' in event is false
    161 PASS 'source' in event is true
    162 PASS event.source != null is true
    163 PASS 'onsuccess' in event.target is true
    164 PASS 'onerror' in event.target is true
    165 PASS 'readyState' in event.target is true
    166 PASS event.target.readyState is event.target.DONE
    167 
    168105db.transaction()
    169106store = transaction.objectStore('storeName')
  • trunk/LayoutTests/storage/indexeddb/objectstore-removeobjectstore.html

    r68795 r69121  
    4040    shouldBeTrue("trans !== null");
    4141
    42     deleteAllObjectStores(db, createObjectStore);
     42    deleteAllObjectStores(db, createObjectStoreAndAddValue);
    4343}
    4444
    45 function createObjectStore()
     45function createObjectStoreAndAddValue()
    4646{
    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')");
    5849    verifyResult(result);
    5950    result.onsuccess = getValue;
     
    8071    shouldBeEqualToString("event.result", "value");
    8172
    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', '')");
    9174    shouldBeTrue("event.source.indexNames.contains('indexName')");
    9275    // Let the transaction commit.
     
    10992    trans.onabort = unexpectedAbortCallback;
    11093
    111     result = evalAndLog("db.removeObjectStore('storeName')");
    112     verifyResult(result);
    113     result.onsuccess = createObjectStoreAgain;
    114     result.onerror = unexpectedErrorCallback;
     94    evalAndLog("db.removeObjectStore('storeName')");
     95    createObjectStoreAgain();
    11596}
    11697
    11798function createObjectStoreAgain()
    11899{
    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();
    125102}
    126103
    127104function getValueAgain()
    128105{
    129     verifySuccessEvent(event);
    130 
    131106    transaction = evalAndLog("db.transaction()");
    132107    transaction.onabort = unexpectedErrorCallback;
  • trunk/LayoutTests/storage/indexeddb/open-cursor-expected.txt

    r68795 r69121  
    4242trans = event.result
    4343PASS 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
     44Deleted all object stores.
     45objectStore = db.createObjectStore('test')
    6246objectStore.add('myValue', 'myKey')
    6347PASS 'onsuccess' in result is true
     
    6751
    6852Opening cursor
    69 objectStore.openCursor(keyRange)
     53event.source.openCursor(keyRange)
    7054PASS 'onsuccess' in result is true
    7155PASS 'onerror' in result is true
  • trunk/LayoutTests/storage/indexeddb/open-cursor.html

    r68795 r69121  
    4949    debug("Opening cursor");
    5050    keyRange = IDBKeyRange.leftBound("myKey");
    51     result = evalAndLog("objectStore.openCursor(keyRange)");
     51    result = evalAndLog("event.source.openCursor(keyRange)");
    5252    verifyResult(result);
    5353    result.onsuccess = cursorSuccess;
     
    5555}
    5656
    57 function populateObjectStore(objectStore)
     57function createAndPopulateObjectStore()
    5858{
     59    var objectStore = evalAndLog("objectStore = db.createObjectStore('test')");
    5960    result = evalAndLog("objectStore.add('myValue', 'myKey')");
    6061    verifyResult(result);
    6162    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;
    7763    result.onerror = unexpectedErrorCallback;
    7864}
     
    8672    trans.onabort = unexpectedAbortCallback;
    8773
    88     deleteAllObjectStores(db, deleteSuccess);
     74    deleteAllObjectStores(db, createAndPopulateObjectStore);
    8975}
    9076
  • trunk/LayoutTests/storage/indexeddb/resources/shared.js

    r69052 r69121  
    8080}
    8181
     82// FIXME: remove the onfinished parameter.
    8283function deleteAllObjectStores(db, onfinished)
    8384{
    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));
    8987
    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();
    9390}
  • trunk/LayoutTests/storage/indexeddb/transaction-basics-expected.txt

    r69052 r69121  
    4545trans = event.result
    4646PASS trans !== null is true
     47Deleted all object stores.
    4748db.createObjectStore('storeName', null)
    48 PASS 'onsuccess' in result is true
    49 PASS 'onerror' in result is true
    50 PASS 'readyState' in result is true
    51 An event should fire shortly...
    52 
    53 Success event fired:
    54 PASS 'result' in event is true
    55 PASS 'code' in event is false
    56 PASS 'message' in event is false
    57 PASS 'source' in event is true
    58 PASS event.source != null is true
    59 PASS 'onsuccess' in event.target is true
    60 PASS 'onerror' in event.target is true
    61 PASS 'readyState' in event.target is true
    62 PASS event.target.readyState is event.target.DONE
    63 
    6449db.transaction()
    6550store = transaction.objectStore('storeName')
  • trunk/LayoutTests/storage/indexeddb/transaction-basics.html

    r69052 r69121  
    4848    window.completeEventFired = false;
    4949
    50     deleteAllObjectStores(db, finishedDeleting);
     50    deleteAllObjectStores(db, createObjectStoreAndStartTransaction);
     51}
     52
     53function 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");
    5160}
    5261
     
    5564    verifyCompleteEvent(event);
    5665    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");
    7466}
    7567
  • trunk/WebCore/ChangeLog

    r69120 r69121  
     12010-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
    1582010-10-05  Chris Fleizach  <cfleizach@apple.com>
    259
  • trunk/WebCore/storage/IDBDatabase.cpp

    r68795 r69121  
    5656}
    5757
    58 // FIXME: Should be synchronous.
    59 PassRefPtr<IDBRequest> IDBDatabase::createObjectStore(ScriptExecutionContext* context, const String& name, const String& keyPath, bool autoIncrement)
     58PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, const String& keyPath, bool autoIncrement)
    6059{
    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());
    6765}
    6866
    69 // FIXME: Should be synchronous.
    70 PassRefPtr<IDBRequest> IDBDatabase::removeObjectStore(ScriptExecutionContext* context, const String& name)
     67void IDBDatabase::removeObjectStore(const String& name)
    7168{
    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());
    7870}
    7971
  • trunk/WebCore/storage/IDBDatabase.h

    r68795 r69121  
    5858    PassRefPtr<DOMStringList> objectStores() const { return m_backend->objectStores(); }
    5959
    60     PassRefPtr<IDBRequest> 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);
    6262    PassRefPtr<IDBRequest> setVersion(ScriptExecutionContext*, const String& version);
    6363    PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext*, DOMStringList* storeNames = 0, unsigned short mode = IDBTransaction::READ_ONLY,
  • trunk/WebCore/storage/IDBDatabase.idl

    r68795 r69121  
    3333        readonly attribute DOMStringList objectStores;
    3434
    35         [CallWith=ScriptExecutionContext] IDBRequest createObjectStore(in DOMString name, in [Optional, ConvertNullToNullString] DOMString keyPath, in [Optional] boolean autoIncrement);
    36         [CallWith=ScriptExecutionContext] IDBRequest removeObjectStore(in DOMString name);
     35        IDBObjectStore createObjectStore(in DOMString name, in [Optional, ConvertNullToNullString] DOMString keyPath, in [Optional] boolean autoIncrement);
     36        void removeObjectStore(in DOMString name);
    3737        [CallWith=ScriptExecutionContext] IDBRequest setVersion(in DOMString version);
    3838        [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  
    128128}
    129129
    130 void IDBDatabaseBackendImpl::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transaction)
    131 {
     130PassRefPtr<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
    132141    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
     149void IDBDatabaseBackendImpl::createObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore,  PassRefPtr<IDBTransactionBackendInterface> transaction)
     150{
    145151    SQLiteStatement insert(database->sqliteDatabase(), "INSERT INTO ObjectStores (name, keyPath, doAutoIncrement) VALUES (?, ?, ?)");
    146152    bool ok = insert.prepare() == SQLResultOk;
    147153    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()));
    151157    ok = insert.step() == SQLResultDone;
    152158    ASSERT_UNUSED(ok, ok); // FIXME: Better error handling.
    153159    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();
    159162}
    160163
     
    177180}
    178181
    179 void IDBDatabaseBackendImpl::removeObjectStore(const String& name, PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transaction)
    180 {
     182void 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);
    181190    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
     196void IDBDatabaseBackendImpl::removeObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBTransactionBackendInterface> transaction)
     197{
    195198    doDelete(database->sqliteDatabase(), "DELETE FROM ObjectStores WHERE id = ?", objectStore->id());
    196199    doDelete(database->sqliteDatabase(), "DELETE FROM ObjectStoreData WHERE objectStoreId = ?", objectStore->id());
     
    198201    doDelete(database->sqliteDatabase(), "DELETE FROM Indexes WHERE objectStoreId = ?", objectStore->id());
    199202
    200     database->m_objectStores.remove(name);
    201     callbacks->onSuccess();
     203    transaction->didCompleteTaskEvents();
    202204}
    203205
  • trunk/WebCore/storage/IDBDatabaseBackendImpl.h

    r68795 r69121  
    5656    virtual PassRefPtr<DOMStringList> objectStores() const;
    5757
    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*);
    5959    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*);
    6161    virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>);
    6262    virtual PassRefPtr<IDBTransactionBackendInterface> transaction(DOMStringList* storeNames, unsigned short mode, unsigned long timeout);
     
    7070    void loadObjectStores();
    7171
    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>);
    7474    static void setVersionInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl>, const String& version, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>);
    7575
  • trunk/WebCore/storage/IDBDatabaseBackendInterface.h

    r68795 r69121  
    5555    virtual PassRefPtr<DOMStringList> objectStores() const = 0;
    5656
    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;
    5858    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;
    6060    virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>) = 0;
    6161    virtual PassRefPtr<IDBTransactionBackendInterface> transaction(DOMStringList* storeNames, unsigned short mode, unsigned long timeout) = 0;
  • trunk/WebCore/storage/IDBIndexBackendImpl.cpp

    r68795 r69121  
    5151}
    5252
     53IDBIndexBackendImpl::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
    5362IDBIndexBackendImpl::~IDBIndexBackendImpl()
    5463{
  • trunk/WebCore/storage/IDBIndexBackendImpl.h

    r68795 r69121  
    4444        return adoptRef(new IDBIndexBackendImpl(objectStore, id, name, keyPath, unique));
    4545    }
     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    }
    4650    virtual ~IDBIndexBackendImpl();
    4751
    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
    4959    bool addingKeyAllowed(IDBKey*);
    5060
     
    6474private:
    6575    IDBIndexBackendImpl(IDBObjectStoreBackendImpl*, int64_t id, const String& name, const String& keyPath, bool unique);
     76    IDBIndexBackendImpl(IDBObjectStoreBackendImpl*, const String& name, const String& keyPath, bool unique);
    6677
    6778    SQLiteDatabase& sqliteDatabase() const;
     
    6980    static void openCursorInternal(ScriptExecutionContext*, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBKeyRange>, unsigned short direction, bool objectCursor, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>);
    7081    static void getInternal(ScriptExecutionContext*, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBKey>, bool getObject, PassRefPtr<IDBCallbacks>);
     82
     83    static const int64_t InvalidId = 0;
    7184
    7285    RefPtr<IDBObjectStoreBackendImpl> m_objectStore;
  • trunk/WebCore/storage/IDBObjectStore.cpp

    r68795 r69121  
    9393}
    9494
    95 PassRefPtr<IDBRequest> IDBObjectStore::createIndex(ScriptExecutionContext* context, const String& name, const String& keyPath, bool unique)
     95PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const String& keyPath, bool unique)
    9696{
    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());
    100101}
    101102
     
    109110}
    110111
    111 PassRefPtr<IDBRequest> IDBObjectStore::removeIndex(ScriptExecutionContext* context, const String& name)
     112void IDBObjectStore::removeIndex(const String& name)
    112113{
    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());
    116115}
    117116
  • trunk/WebCore/storage/IDBObjectStore.h

    r68138 r69121  
    6464    PassRefPtr<IDBRequest> remove(ScriptExecutionContext*, PassRefPtr<IDBKey> key);
    6565
    66     PassRefPtr<IDBRequest> createIndex(ScriptExecutionContext*, const String& name, const String& keyPath, bool unique = false);
     66    PassRefPtr<IDBIndex> createIndex(const String& name, const String& keyPath, bool unique = false);
    6767    PassRefPtr<IDBIndex> index(const String& name);
    68     PassRefPtr<IDBRequest> removeIndex(ScriptExecutionContext*, const String& name);
     68    void removeIndex(const String& name);
    6969
    7070    PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, PassRefPtr<IDBKeyRange> = 0, unsigned short direction = IDBCursor::NEXT);
  • trunk/WebCore/storage/IDBObjectStore.idl

    r68795 r69121  
    3838        [CallWith=ScriptExecutionContext] IDBRequest put(in SerializedScriptValue value, in [Optional] IDBKey key);
    3939        [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.
    4143        IDBIndex index(in DOMString name);
    42         [CallWith=ScriptExecutionContext] IDBRequest removeIndex(in DOMString name);
     44        void removeIndex(in DOMString name);
     45
    4346        [CallWith=ScriptExecutionContext] IDBRequest openCursor(in [Optional] IDBKeyRange range, in [Optional] unsigned short direction);
    4447    };
  • trunk/WebCore/storage/IDBObjectStoreBackendImpl.cpp

    r68795 r69121  
    6363}
    6464
     65IDBObjectStoreBackendImpl::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
    6574PassRefPtr<DOMStringList> IDBObjectStoreBackendImpl::indexNames() const
    6675{
     
    255264}
    256265
    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 
     266PassRefPtr<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
     285void IDBObjectStoreBackendImpl::createIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index, PassRefPtr<IDBTransactionBackendInterface> transaction)
     286{
    272287    SQLiteStatement insert(objectStore->sqliteDatabase(), "INSERT INTO Indexes (objectStoreId, name, keyPath, isUnique) VALUES (?, ?, ?, ?)");
    273288    bool ok = insert.prepare() == SQLResultOk;
    274289    ASSERT_UNUSED(ok, ok); // FIXME: Better error handling.
    275290    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()));
    279294    ok = insert.step() == SQLResultDone;
    280295    ASSERT_UNUSED(ok, ok); // FIXME: Better error handling.
    281296    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();
    287299}
    288300
     
    302314}
    303315
    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);
     316void IDBObjectStoreBackendImpl::removeIndex(const String& name, IDBTransactionBackendInterface* transaction)
     317{
     318    RefPtr<IDBIndexBackendImpl> index = m_indexes.get(name);
    315319    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
     330void IDBObjectStoreBackendImpl::removeIndexInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index, PassRefPtr<IDBTransactionBackendInterface> transaction)
     331{
    320332    doDelete(objectStore->sqliteDatabase(), "DELETE FROM Indexes WHERE id = ?", index->id());
    321333    doDelete(objectStore->sqliteDatabase(), "DELETE FROM IndexData WHERE indexId = ?", index->id());
    322334
    323     objectStore->m_indexes.remove(name);
    324     callbacks->onSuccess();
     335    transaction->didCompleteTaskEvents();
    325336}
    326337
  • trunk/WebCore/storage/IDBObjectStoreBackendImpl.h

    r68795 r69121  
    4747        return adoptRef(new IDBObjectStoreBackendImpl(database, id, name, keyPath, autoIncrement));
    4848    }
     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    }
    4953    ~IDBObjectStoreBackendImpl();
    5054
    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; }
    5261    String name() const { return m_name; }
    5362    String keyPath() const { return m_keyPath; }
    5463    PassRefPtr<DOMStringList> indexNames() const;
     64    bool autoIncrement() const { return m_autoIncrement; }
    5565
    5666    void get(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);
     
    5868    void remove(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);
    5969
    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*);
    6171    PassRefPtr<IDBIndexBackendInterface> index(const String& name);
    62     void removeIndex(const String& name, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);
     72    void removeIndex(const String& name, IDBTransactionBackendInterface*);
    6373
    6474    void openCursor(PassRefPtr<IDBKeyRange> range, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);
     
    6878private:
    6979    IDBObjectStoreBackendImpl(IDBDatabaseBackendImpl*, int64_t id, const String& name, const String& keyPath, bool autoIncrement);
     80    IDBObjectStoreBackendImpl(IDBDatabaseBackendImpl*, const String& name, const String& keyPath, bool autoIncrement);
    7081
    7182    void loadIndexes();
     
    7586    static void putInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, bool addOnly, PassRefPtr<IDBCallbacks>);
    7687    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>);
    7990    static void openCursorInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBKeyRange> range, unsigned short direction, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>);
     91
     92    static const int64_t InvalidId = 0;
    8093
    8194    RefPtr<IDBDatabaseBackendImpl> m_database;
  • trunk/WebCore/storage/IDBObjectStoreBackendInterface.h

    r68795 r69121  
    5454    virtual void remove(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*) = 0;
    5555
    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;
    5757    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;
    5959
    6060    virtual void openCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*) = 0;
  • trunk/WebCore/storage/IDBTransactionBackendImpl.cpp

    r69052 r69121  
    4848    , m_database(database)
    4949    , m_transaction(new SQLiteTransaction(database->sqliteDatabase()))
    50     , m_timer(this, &IDBTransactionBackendImpl::timerFired)
     50    , m_taskTimer(this, &IDBTransactionBackendImpl::taskTimerFired)
     51    , m_taskEventTimer(this, &IDBTransactionBackendImpl::taskEventTimerFired)
    5152    , m_pendingEvents(0)
    5253{
     
    5556PassRefPtr<IDBObjectStoreBackendInterface> IDBTransactionBackendImpl::objectStore(const String& name)
    5657{
    57     if (isFinished())
     58    if (m_state == Finished)
    5859        return 0;
    5960    return m_database->objectStore(name, 0); // FIXME: remove mode param.
     
    6263bool IDBTransactionBackendImpl::scheduleTask(PassOwnPtr<ScriptExecutionContext::Task> task)
    6364{
    64     if (isFinished())
     65    if (m_state == Finished)
    6566        return false;
    6667
     
    7475void IDBTransactionBackendImpl::abort()
    7576{
    76     if (isFinished())
     77    if (m_state == Finished)
    7778        return;
    7879
    7980    m_state = Finished;
    80     m_timer.stop();
     81    m_taskTimer.stop();
     82    m_taskEventTimer.stop();
    8183    m_transaction->rollback();
    8284    m_callbacks->onAbort();
     
    9193    ASSERT(m_state == Running);
    9294    ASSERT(m_pendingEvents);
    93 
    9495    m_pendingEvents--;
    9596
    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);
    10899}
    109100
     
    111102{
    112103    ASSERT(m_state == StartPending || m_state == Running);
    113     ASSERT(!m_timer.isActive());
     104    ASSERT(!m_taskTimer.isActive());
    114105
    115     m_timer.startOneShot(0);
     106    m_taskTimer.startOneShot(0);
    116107}
    117108
     
    134125}
    135126
    136 void IDBTransactionBackendImpl::timerFired(Timer<IDBTransactionBackendImpl>*)
     127void IDBTransactionBackendImpl::taskTimerFired(Timer<IDBTransactionBackendImpl>*)
    137128{
    138129    ASSERT(!m_taskQueue.isEmpty());
     
    154145}
    155146
     147void 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
    156165};
    157166
  • trunk/WebCore/storage/IDBTransactionBackendImpl.h

    r68795 r69121  
    5555
    5656    void run();
    57     bool isFinished() const { return m_state == Finished; }
    5857
    5958private:
     
    7069    void commit();
    7170
    72     void timerFired(Timer<IDBTransactionBackendImpl>*);
     71    void taskTimerFired(Timer<IDBTransactionBackendImpl>*);
     72    void taskEventTimerFired(Timer<IDBTransactionBackendImpl>*);
    7373
    7474    RefPtr<DOMStringList> m_objectStoreNames;
     
    8787
    8888    // FIXME: delete the timer once we have threads instead.
    89     Timer<IDBTransactionBackendImpl> m_timer;
     89    Timer<IDBTransactionBackendImpl> m_taskTimer;
     90    Timer<IDBTransactionBackendImpl> m_taskEventTimer;
    9091    int m_pendingEvents;
    9192};
  • trunk/WebKit/chromium/ChangeLog

    r69098 r69121  
     12010-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
    1312010-10-04  Andrey Kosyakov  <caseq@chromium.org>
    232
  • trunk/WebKit/chromium/public/WebIDBDatabase.h

    r68803 r69121  
    6262        return WebDOMStringList();
    6363    }
     64
    6465    // FIXME: Remove once we update Chromium side.
    6566    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    }
    6772    // Transfers ownership of the WebIDBObjectStore to the caller.
    6873    virtual WebIDBObjectStore* objectStore(const WebString& name, unsigned short mode)
     
    7176        return 0;
    7277    }
    73     // FIXME: Remove once we update Chromium side.
     78    // FIXME: Remove after WebKit roll.
    7479    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(); }
    7681    virtual void setVersion(const WebString& version, WebIDBCallbacks* callbacks) { WEBKIT_ASSERT_NOT_REACHED(); }
    7782    // Transfers ownership of the WebIDBTransaction to the caller.
  • trunk/WebKit/chromium/public/WebIDBObjectStore.h

    r68803 r69121  
    6464    // FIXME: Remove once we update Chromium side.
    6565    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    }
    6771    // Transfers ownership of the WebIDBIndex to the caller.
    6872    virtual WebIDBIndex* index(const WebString& name)
     
    7377    // FIXME: Remove once we update Chromium side.
    7478    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(); }
    7680    virtual void openCursor(const WebIDBKeyRange&, unsigned short direction, WebIDBCallbacks*, const WebIDBTransaction&) { WEBKIT_ASSERT_NOT_REACHED(); }
    7781    // FIXME: finish.
  • trunk/WebKit/chromium/src/IDBDatabaseProxy.cpp

    r68795 r69121  
    7777}
    7878
    79 void IDBDatabaseProxy::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction)
     79PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseProxy::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transaction)
    8080{
    8181    // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
    8282    // all implementations of IDB interfaces are proxy objects.
    8383    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);
    8588}
    8689
     
    9396}
    9497
    95 void IDBDatabaseProxy::removeObjectStore(const String& name, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction)
     98void IDBDatabaseProxy::removeObjectStore(const String& name, IDBTransactionBackendInterface* transaction)
    9699{
    97100    // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
    98101    // all implementations of IDB interfaces are proxy objects.
    99102    IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
    100     m_webIDBDatabase->removeObjectStore(name, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction());
     103    m_webIDBDatabase->removeObjectStore(name, *transactionProxy->getWebIDBTransaction());
    101104}
    102105
  • trunk/WebKit/chromium/src/IDBDatabaseProxy.h

    r68795 r69121  
    4848    virtual PassRefPtr<DOMStringList> objectStores() const;
    4949
    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*);
    5151    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*);
    5353    virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>);
    5454    virtual PassRefPtr<IDBTransactionBackendInterface> transaction(DOMStringList* storeNames, unsigned short mode, unsigned long timeout);
  • trunk/WebKit/chromium/src/IDBObjectStoreProxy.cpp

    r68795 r69121  
    9797}
    9898
    99 void IDBObjectStoreProxy::createIndex(const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction)
     99PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreProxy::createIndex(const String& name, const String& keyPath, bool unique, IDBTransactionBackendInterface* transaction)
    100100{
    101101    // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
    102102    // all implementations of IDB interfaces are proxy objects.
    103103    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);
    105108}
    106109
     
    113116}
    114117
    115 void IDBObjectStoreProxy::removeIndex(const String& name, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction)
     118void IDBObjectStoreProxy::removeIndex(const String& name, IDBTransactionBackendInterface* transaction)
    116119{
    117120    // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
    118121    // all implementations of IDB interfaces are proxy objects.
    119122    IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction);
    120     m_webIDBObjectStore->removeIndex(name, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction());
     123    m_webIDBObjectStore->removeIndex(name, *transactionProxy->getWebIDBTransaction());
    121124}
    122125
  • trunk/WebKit/chromium/src/IDBObjectStoreProxy.h

    r68795 r69121  
    5151    virtual void remove(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);
    5252
    53     virtual void createIndex(const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);
    54     virtual PassRefPtr<IDBIndexBackendInterface> index(const String& name);
    55     virtual 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*);
    5656
    5757    virtual void openCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*);
  • trunk/WebKit/chromium/src/WebIDBDatabaseImpl.cpp

    r68795 r69121  
    7070}
    7171
    72 void WebIDBDatabaseImpl::createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction)
     72WebIDBObjectStore* WebIDBDatabaseImpl::createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction& transaction)
    7373{
    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);
    7578}
    7679
     
    8386}
    8487
    85 void WebIDBDatabaseImpl::removeObjectStore(const WebString& name, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction)
     88void WebIDBDatabaseImpl::removeObjectStore(const WebString& name, const WebIDBTransaction& transaction)
    8689{
    87     m_databaseBackend->removeObjectStore(name, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface());
     90    m_databaseBackend->removeObjectStore(name, transaction.getIDBTransactionBackendInterface());
    8891}
    8992
  • trunk/WebKit/chromium/src/WebIDBDatabaseImpl.h

    r68795 r69121  
    5050    virtual WebDOMStringList objectStores() const;
    5151
    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&);
    5353    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&);
    5555    virtual void setVersion(const WebString& version, WebIDBCallbacks* callbacks);
    5656    virtual WebIDBTransaction* transaction(const WebDOMStringList& names, unsigned short mode, unsigned long timeout);
  • trunk/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp

    r68795 r69121  
    8282}
    8383
    84 void WebIDBObjectStoreImpl::createIndex(const WebString& name, const WebString& keyPath, bool unique, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction)
     84WebIDBIndex* WebIDBObjectStoreImpl::createIndex(const WebString& name, const WebString& keyPath, bool unique, const WebIDBTransaction& transaction)
    8585{
    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);
    8790}
    8891
     
    9598}
    9699
    97 void WebIDBObjectStoreImpl::removeIndex(const WebString& name, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction)
     100void WebIDBObjectStoreImpl::removeIndex(const WebString& name, const WebIDBTransaction& transaction)
    98101{
    99     m_objectStore->removeIndex(name, IDBCallbacksProxy::create(callbacks), transaction.getIDBTransactionBackendInterface());
     102    m_objectStore->removeIndex(name, transaction.getIDBTransactionBackendInterface());
    100103}
    101104
  • trunk/WebKit/chromium/src/WebIDBObjectStoreImpl.h

    r68795 r69121  
    5252    void remove(const WebIDBKey& key, WebIDBCallbacks*, const WebIDBTransaction&);
    5353
    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&);
    5555    WebIDBIndex* index(const WebString& name);
    56     void removeIndex(const WebString& name, WebIDBCallbacks*, const WebIDBTransaction&);
     56    void removeIndex(const WebString& name, const WebIDBTransaction&);
    5757
    5858    void openCursor(const WebIDBKeyRange&, unsigned short direction, WebIDBCallbacks*, const WebIDBTransaction&);
Note: See TracChangeset for help on using the changeset viewer.