2 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef IDBTransactionBackendInterface_h
27 #define IDBTransactionBackendInterface_h
29 #include "IDBBackingStoreInterface.h"
30 #include "IDBDatabaseBackendInterface.h"
31 #include "IndexedDB.h"
32 #include <wtf/HashSet.h>
33 #include <wtf/RefCounted.h>
34 #include <wtf/Vector.h>
36 #if ENABLE(INDEXED_DATABASE)
41 class IDBDatabaseCallbacks;
42 class IDBDatabaseError;
47 struct IDBDatabaseMetadata;
48 struct IDBIndexMetadata;
49 struct IDBObjectStoreMetadata;
51 class IDBTransactionBackendInterface : public RefCounted<IDBTransactionBackendInterface> {
53 virtual ~IDBTransactionBackendInterface() { }
55 virtual IndexedDB::TransactionMode mode() const = 0;
57 virtual void run() = 0;
58 virtual void commit() = 0;
59 virtual void abort() = 0;
60 virtual void abort(PassRefPtr<IDBDatabaseError>) = 0;
61 virtual const HashSet<int64_t>& scope() const = 0;
63 virtual void scheduleTask(PassOwnPtr<IDBOperation>, PassOwnPtr<IDBOperation> abortTask = nullptr) = 0;
64 virtual void scheduleTask(IDBDatabaseBackendInterface::TaskType, PassOwnPtr<IDBOperation>, PassOwnPtr<IDBOperation> abortTask = nullptr) = 0;
66 virtual void registerOpenCursor(IDBCursorBackend*) = 0;
67 virtual void unregisterOpenCursor(IDBCursorBackend*) = 0;
69 virtual void scheduleCreateObjectStoreOperation(const IDBObjectStoreMetadata&) = 0;
70 virtual void scheduleDeleteObjectStoreOperation(const IDBObjectStoreMetadata&) = 0;
71 virtual void scheduleVersionChangeOperation(int64_t transactionId, int64_t requestedVersion, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, const IDBDatabaseMetadata&) = 0;
72 virtual void scheduleCreateIndexOperation(int64_t objectStoreId, const IDBIndexMetadata&) = 0;
73 virtual void scheduleDeleteIndexOperation(int64_t objectStoreId, const IDBIndexMetadata&) = 0;
74 virtual void scheduleGetOperation(const IDBDatabaseMetadata&, int64_t objectStoreId, int64_t indexId, PassRefPtr<IDBKeyRange>, IndexedDB::CursorType, PassRefPtr<IDBCallbacks>) = 0;
75 virtual void schedulePutOperation(const IDBObjectStoreMetadata&, PassRefPtr<SharedBuffer> value, PassRefPtr<IDBKey>, IDBDatabaseBackendInterface::PutMode, PassRefPtr<IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) = 0;
76 virtual void scheduleSetIndexesReadyOperation(size_t indexCount) = 0;
77 virtual void scheduleOpenCursorOperation(int64_t objectStoreId, int64_t indexId, PassRefPtr<IDBKeyRange>, IndexedDB::CursorDirection, IndexedDB::CursorType, IDBDatabaseBackendInterface::TaskType, PassRefPtr<IDBCallbacks>) = 0;
78 virtual void scheduleCountOperation(int64_t objectStoreId, int64_t indexId, PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) = 0;
79 virtual void scheduleDeleteRangeOperation(int64_t objectStoreId, PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) = 0;
80 virtual void scheduleClearOperation(int64_t objectStoreId, PassRefPtr<IDBCallbacks>) = 0;
82 virtual void addPreemptiveEvent() = 0;
83 virtual void didCompletePreemptiveEvent() = 0;
85 virtual IDBBackingStoreTransactionInterface& backingStoreTransaction() = 0;
86 virtual IDBDatabaseBackendInterface& database() const = 0;
88 virtual PassRefPtr<IDBCursorBackend> createCursorBackend(IDBBackingStoreCursorInterface&, IndexedDB::CursorType, IDBDatabaseBackendInterface::TaskType, int64_t objectStoreId) = 0;
90 int64_t id() const { return m_id; }
93 IDBTransactionBackendInterface(int64_t id)
102 } // namespace WebCore
104 #endif // ENABLE(INDEXED_DATABASE)
105 #endif // IDBTransactionBackendInterface_h