Changeset 65879 in webkit


Ignore:
Timestamp:
Aug 24, 2010 2:05:38 AM (14 years ago)
Author:
andreip@google.com
Message:

2010-08-24 Andrei Popescu <andreip@dhcp-172-16-14-12.lon.corp.google.com>

Reviewed by Jeremy Orlow.

Implement IDBTransaction::objectStore

[IndexedDB] IDBTransaction is missing the implementation for objectStore method
https://bugs.webkit.org/show_bug.cgi?id=44446

  • storage/indexeddb/script-tests/transaction-basics.js: (test): (openSuccess): (createSuccess): (abortCallback):
  • storage/indexeddb/transaction-basics-expected.txt:

2010-08-24 Andrei Popescu <andreip@dhcp-172-16-14-12.lon.corp.google.com>

Reviewed by Jeremy Orlow.

[IndexedDB] IDBTransaction is missing the implementation for objectStore method
https://bugs.webkit.org/show_bug.cgi?id=44446

  • storage/IDBDatabaseBackendImpl.cpp: (WebCore::IDBDatabaseBackendImpl::transaction):
  • storage/IDBTransactionBackendImpl.cpp: (WebCore::IDBTransactionBackendImpl::create): (WebCore::IDBTransactionBackendImpl::IDBTransactionBackendImpl): (WebCore::IDBTransactionBackendImpl::objectStore):
  • storage/IDBTransactionBackendImpl.h:
  • storage/IDBTransactionCoordinator.cpp: (WebCore::IDBTransactionCoordinator::createTransaction):
  • storage/IDBTransactionCoordinator.h:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r65878 r65879  
     12010-08-24  Andrei Popescu  <andreip@dhcp-172-16-14-12.lon.corp.google.com>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        Implement IDBTransaction::objectStore
     6
     7        [IndexedDB] IDBTransaction is missing the implementation for objectStore method
     8        https://bugs.webkit.org/show_bug.cgi?id=44446
     9
     10        * storage/indexeddb/script-tests/transaction-basics.js:
     11        (test):
     12        (openSuccess):
     13        (createSuccess):
     14        (abortCallback):
     15        * storage/indexeddb/transaction-basics-expected.txt:
     16
    1172010-08-24  Andreas Kling  <andreas.kling@nokia.com>
    218
  • trunk/LayoutTests/storage/indexeddb/script-tests/transaction-basics.js

    r65670 r65879  
    22if (window.layoutTestController)
    33    layoutTestController.waitUntilDone();
    4 
    5 function abortCallback()
    6 {
    7     verifyAbortEvent(event);
    8     done();
    9 }
    10 
    11 function createTransactionCallback()
    12 {
    13     verifySuccessEvent(event);
    14     transaction = evalAndLog("event.result.transaction()");
    15     transaction.onabort = abortCallback;
    16 }
    174
    185function test()
     
    2310    result = evalAndLog("indexedDB.open('name', 'description')");
    2411    verifyResult(result);
    25     result.onsuccess = createTransactionCallback;
     12    result.onsuccess = openSuccess;
    2613    result.onerror = unexpectedErrorCallback;
     14}
     15
     16function openSuccess()
     17{
     18    debug("createObjectStoreCallback():");
     19    verifySuccessEvent(event);
     20    db = evalAndLog("db = event.result");
     21
     22    deleteAllObjectStores(db);
     23
     24    result = evalAndLog("db.createObjectStore('storeName', null)");
     25    verifyResult(result);
     26    result.onsuccess = createSuccess;
     27    result.onerror = unexpectedErrorCallback;
     28}
     29
     30function createSuccess()
     31{
     32    verifySuccessEvent(event);
     33    transaction = evalAndLog("db.transaction()");
     34    transaction.onabort = abortCallback;
     35    var store = evalAndLog("store = transaction.objectStore('storeName')");
     36    shouldBeEqualToString("store.name", "storeName");
     37}
     38
     39function abortCallback()
     40{
     41    verifyAbortEvent(event);
     42    done();
    2743}
    2844
  • trunk/LayoutTests/storage/indexeddb/transaction-basics-expected.txt

    r65670 r65879  
    77PASS indexedDB == null is false
    88indexedDB.open('name', 'description')
     9PASS 'onsuccess' in result is true
     10PASS 'onerror' in result is true
     11PASS 'abort' in result is true
     12PASS 'readyState' in result is true
     13An event should fire shortly...
     14
     15createObjectStoreCallback():
     16Success event fired:
     17PASS 'result' in event is true
     18PASS 'code' in event is false
     19PASS 'message' in event is false
     20PASS 'source' in event is true
     21PASS event.source != null is true
     22PASS 'onsuccess' in event.target is true
     23PASS 'onerror' in event.target is true
     24PASS 'abort' in event.target is true
     25PASS 'readyState' in event.target is true
     26PASS event.target.readyState is event.target.DONE
     27
     28db = event.result
     29db.createObjectStore('storeName', null)
    930PASS 'onsuccess' in result is true
    1031PASS 'onerror' in result is true
     
    2546PASS event.target.readyState is event.target.DONE
    2647
    27 event.result.transaction()
     48db.transaction()
     49store = transaction.objectStore('storeName')
     50PASS store.name is "storeName"
    2851Abort event fired:
    2952PASS event.type is "abort"
  • trunk/WebCore/ChangeLog

    r65878 r65879  
     12010-08-24  Andrei Popescu  <andreip@dhcp-172-16-14-12.lon.corp.google.com>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        [IndexedDB] IDBTransaction is missing the implementation for objectStore method
     6        https://bugs.webkit.org/show_bug.cgi?id=44446
     7
     8        * storage/IDBDatabaseBackendImpl.cpp:
     9        (WebCore::IDBDatabaseBackendImpl::transaction):
     10        * storage/IDBTransactionBackendImpl.cpp:
     11        (WebCore::IDBTransactionBackendImpl::create):
     12        (WebCore::IDBTransactionBackendImpl::IDBTransactionBackendImpl):
     13        (WebCore::IDBTransactionBackendImpl::objectStore):
     14        * storage/IDBTransactionBackendImpl.h:
     15        * storage/IDBTransactionCoordinator.cpp:
     16        (WebCore::IDBTransactionCoordinator::createTransaction):
     17        * storage/IDBTransactionCoordinator.h:
     18
    1192010-08-24  Andreas Kling  <andreas.kling@nokia.com>
    220
  • trunk/WebCore/storage/IDBDatabaseBackendImpl.cpp

    r65673 r65879  
    175175PassRefPtr<IDBTransactionBackendInterface> IDBDatabaseBackendImpl::transaction(DOMStringList* objectStores, unsigned short mode, unsigned long timeout)
    176176{
    177     return m_transactionCoordinator->createTransaction(objectStores, mode, timeout);
     177    return m_transactionCoordinator->createTransaction(objectStores, mode, timeout, this);
    178178}
    179179
  • trunk/WebCore/storage/IDBTransactionBackendImpl.cpp

    r65670 r65879  
     1/*
     2 * Copyright (C) 2010 Google Inc. All rights reserved.
     3 *
     4 * Redistribution and use in source and binary forms, with or without
     5 * modification, are permitted provided that the following conditions
     6 * are met:
     7 *
     8 * 1.  Redistributions of source code must retain the above copyright
     9 *     notice, this list of conditions and the following disclaimer.
     10 * 2.  Redistributions in binary form must reproduce the above copyright
     11 *     notice, this list of conditions and the following disclaimer in the
     12 *     documentation and/or other materials provided with the distribution.
     13 *
     14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
     15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24 */
     25
    126#include "config.h"
    227#include "IDBTransactionBackendImpl.h"
     
    429#if ENABLE(INDEXED_DATABASE)
    530
     31#include "IDBDatabaseBackendImpl.h"
     32#include "SQLiteDatabase.h"
     33
    634namespace WebCore {
    735
    8 PassRefPtr<IDBTransactionBackendInterface> IDBTransactionBackendImpl::create(DOMStringList* objectStores, unsigned short mode, unsigned long timeout, int id)
     36PassRefPtr<IDBTransactionBackendInterface> IDBTransactionBackendImpl::create(DOMStringList* objectStores, unsigned short mode, unsigned long timeout, int id, IDBDatabaseBackendImpl* database)
    937{
    10     return adoptRef(new IDBTransactionBackendImpl(objectStores, mode, timeout, id));
     38    return adoptRef(new IDBTransactionBackendImpl(objectStores, mode, timeout, id, database));
    1139}
    1240
    13 IDBTransactionBackendImpl::IDBTransactionBackendImpl(DOMStringList* objectStores, unsigned short mode, unsigned long timeout, int id)
     41IDBTransactionBackendImpl::IDBTransactionBackendImpl(DOMStringList* objectStores, unsigned short mode, unsigned long timeout, int id, IDBDatabaseBackendImpl* database)
    1442    : m_objectStoreNames(objectStores)
    1543    , m_mode(mode)
     
    1745    , m_id(id)
    1846    , m_aborted(false)
     47    , m_database(database)
    1948{
    2049}
     
    2251PassRefPtr<IDBObjectStoreBackendInterface> IDBTransactionBackendImpl::objectStore(const String& name)
    2352{
    24     // FIXME: implement.
    25     ASSERT_NOT_REACHED();
    26     return 0;
     53    return m_database->objectStore(name, 0); // FIXME: remove mode param.
    2754}
    2855
  • trunk/WebCore/storage/IDBTransactionBackendImpl.h

    r65670 r65879  
    3636namespace WebCore {
    3737
     38class IDBDatabaseBackendImpl;
     39
    3840class IDBTransactionBackendImpl : public IDBTransactionBackendInterface {
    3941public:
    40     static PassRefPtr<IDBTransactionBackendInterface> create(DOMStringList* objectStores, unsigned short mode, unsigned long timeout, int id);
     42    static PassRefPtr<IDBTransactionBackendInterface> create(DOMStringList* objectStores, unsigned short mode, unsigned long timeout, int id, IDBDatabaseBackendImpl*);
    4143    virtual ~IDBTransactionBackendImpl() { }
    4244
     
    4951
    5052private:
    51     IDBTransactionBackendImpl(DOMStringList* objectStores, unsigned short mode, unsigned long timeout, int id);
     53    IDBTransactionBackendImpl(DOMStringList* objectStores, unsigned short mode, unsigned long timeout, int id, IDBDatabaseBackendImpl*);
    5254
    5355    RefPtr<DOMStringList> m_objectStoreNames;
     
    5759    bool m_aborted;
    5860    RefPtr<IDBTransactionCallbacks> m_callbacks;
     61    RefPtr<IDBDatabaseBackendImpl> m_database;
    5962};
    6063
  • trunk/WebCore/storage/IDBTransactionCoordinator.cpp

    r65670 r65879  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
    31 #include "IDBObjectStore.h"
     31#include "IDBDatabaseBackendImpl.h"
    3232#include "IDBObjectStoreBackendInterface.h"
    3333#include "IDBTransactionBackendImpl.h"
     34#include "SQLiteDatabase.h"
    3435#include "ScriptExecutionContext.h"
    3536
     
    4546}
    4647
    47 PassRefPtr<IDBTransactionBackendInterface> IDBTransactionCoordinator::createTransaction(DOMStringList* objectStores, unsigned short mode, unsigned long timeout)
     48PassRefPtr<IDBTransactionBackendInterface> IDBTransactionCoordinator::createTransaction(DOMStringList* objectStores, unsigned short mode, unsigned long timeout, IDBDatabaseBackendImpl* database)
    4849{
    49     RefPtr<IDBTransactionBackendInterface> transaction = IDBTransactionBackendImpl::create(objectStores, mode, timeout, ++m_nextID);
     50    RefPtr<IDBTransactionBackendInterface> transaction = IDBTransactionBackendImpl::create(objectStores, mode, timeout, ++m_nextID, database);
    5051    m_transactionQueue.add(transaction.get());
    5152    m_idMap.add(m_nextID, transaction);
  • trunk/WebCore/storage/IDBTransactionCoordinator.h

    r65670 r65879  
    3737
    3838class IDBTransactionCallbacks;
     39class IDBDatabaseBackendImpl;
    3940
    4041// This class manages transactions as follows. Requests for new transactions are
     
    4849// the next transaction in the queue will have to wait until a thread becomes
    4950// available.
     51// Transactions are executed in the order the were created.
    5052class IDBTransactionCoordinator : public RefCounted<IDBTransactionCoordinator> {
    5153public:
     
    5355    virtual ~IDBTransactionCoordinator();
    5456
    55     PassRefPtr<IDBTransactionBackendInterface> createTransaction(DOMStringList* objectStores, unsigned short mode, unsigned long timeout);
     57    PassRefPtr<IDBTransactionBackendInterface> createTransaction(DOMStringList* objectStores, unsigned short mode, unsigned long timeout, IDBDatabaseBackendImpl*);
    5658    void abort(int transactionId);
    5759
Note: See TracChangeset for help on using the changeset viewer.