1 | /* |
2 | * Copyright (C) 2015 Apple 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 | * 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. |
12 | * |
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. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #if ENABLE(INDEXED_DATABASE) |
29 | |
30 | #include "IDBDatabaseInfo.h" |
31 | #include "IDBError.h" |
32 | #include <wtf/MainThread.h> |
33 | |
34 | namespace WebCore { |
35 | |
36 | class IDBCursorInfo; |
37 | class IDBGetAllResult; |
38 | class IDBGetResult; |
39 | class IDBIndexInfo; |
40 | class IDBKeyData; |
41 | class IDBObjectStoreInfo; |
42 | class IDBResourceIdentifier; |
43 | class IDBTransactionInfo; |
44 | class IDBValue; |
45 | class ThreadSafeDataBuffer; |
46 | |
47 | enum class IDBGetRecordDataType; |
48 | |
49 | struct IDBGetAllRecordsData; |
50 | struct IDBIterateCursorData; |
51 | struct IDBKeyRangeData; |
52 | |
53 | namespace IndexedDB { |
54 | enum class IndexRecordType; |
55 | } |
56 | |
57 | namespace IDBServer { |
58 | |
59 | class IDBBackingStoreTemporaryFileHandler { |
60 | public: |
61 | virtual ~IDBBackingStoreTemporaryFileHandler() = default; |
62 | virtual void accessToTemporaryFileComplete(const String& path) = 0; |
63 | }; |
64 | |
65 | class IDBBackingStore { |
66 | public: |
67 | virtual ~IDBBackingStore() { RELEASE_ASSERT(!isMainThread()); } |
68 | |
69 | virtual IDBError getOrEstablishDatabaseInfo(IDBDatabaseInfo&) = 0; |
70 | |
71 | virtual IDBError beginTransaction(const IDBTransactionInfo&) = 0; |
72 | virtual IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier) = 0; |
73 | virtual IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) = 0; |
74 | |
75 | virtual IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) = 0; |
76 | virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0; |
77 | virtual IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName) = 0; |
78 | virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0; |
79 | virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) = 0; |
80 | virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) = 0; |
81 | virtual IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) = 0; |
82 | virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) = 0; |
83 | virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) = 0; |
84 | virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&, const IDBKeyData&, const IDBValue&) = 0; |
85 | virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IDBGetRecordDataType, IDBGetResult& outValue) = 0; |
86 | virtual IDBError getAllRecords(const IDBResourceIdentifier& transactionIdentifier, const IDBGetAllRecordsData&, IDBGetAllResult& outValue) = 0; |
87 | virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) = 0; |
88 | virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) = 0; |
89 | virtual IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) = 0; |
90 | virtual IDBError revertGeneratedKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t keyNumber) = 0; |
91 | virtual IDBError maybeUpdateKeyGeneratorNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, double newKeyNumber) = 0; |
92 | virtual IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult) = 0; |
93 | virtual IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBIterateCursorData&, IDBGetResult& outResult) = 0; |
94 | virtual bool prefetchCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier) = 0; |
95 | |
96 | virtual IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier) = 0; |
97 | virtual void deleteBackingStore() = 0; |
98 | |
99 | virtual bool supportsSimultaneousTransactions() = 0; |
100 | virtual bool isEphemeral() = 0; |
101 | |
102 | virtual uint64_t databasesSizeForOrigin() const = 0; |
103 | virtual void setQuota(uint64_t) = 0; |
104 | |
105 | virtual bool hasTransaction(const IDBResourceIdentifier&) const = 0; |
106 | protected: |
107 | IDBBackingStore() { RELEASE_ASSERT(!isMainThread()); } |
108 | }; |
109 | |
110 | } // namespace IDBServer |
111 | } // namespace WebCore |
112 | |
113 | #endif // ENABLE(INDEXED_DATABASE) |
114 | |