2 * Copyright (C) 2015 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.
28 #if ENABLE(INDEXED_DATABASE)
30 #include "UniqueIDBDatabaseTransaction.h"
31 #include <wtf/HashMap.h>
33 #include <wtf/RefCounted.h>
42 class IDBConnectionToClient;
43 class ServerOpenDBRequest;
44 class UniqueIDBDatabase;
45 class UniqueIDBDatabaseTransaction;
47 class UniqueIDBDatabaseConnection : public RefCounted<UniqueIDBDatabaseConnection> {
49 static Ref<UniqueIDBDatabaseConnection> create(UniqueIDBDatabase&, ServerOpenDBRequest&);
51 ~UniqueIDBDatabaseConnection();
53 uint64_t identifier() const { return m_identifier; }
54 const IDBResourceIdentifier& openRequestIdentifier() { return m_openRequestIdentifier; }
55 UniqueIDBDatabase& database() { return m_database; }
56 IDBConnectionToClient& connectionToClient() { return m_connectionToClient; }
58 void connectionClosedFromClient();
60 bool closePending() const { return m_closePending; }
62 bool hasNonFinishedTransactions() const;
64 void fireVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion);
65 UniqueIDBDatabaseTransaction& createVersionChangeTransaction(uint64_t newVersion);
67 void establishTransaction(const IDBTransactionInfo&);
68 void didAbortTransaction(UniqueIDBDatabaseTransaction&, const IDBError&);
69 void didCommitTransaction(UniqueIDBDatabaseTransaction&, const IDBError&);
70 void didCreateObjectStore(const IDBResultData&);
71 void didDeleteObjectStore(const IDBResultData&);
72 void didRenameObjectStore(const IDBResultData&);
73 void didClearObjectStore(const IDBResultData&);
74 void didCreateIndex(const IDBResultData&);
75 void didDeleteIndex(const IDBResultData&);
76 void didRenameIndex(const IDBResultData&);
77 void didFireVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier);
78 void didFinishHandlingVersionChange(const IDBResourceIdentifier& transactionIdentifier);
79 void confirmDidCloseFromServer();
81 void abortTransactionWithoutCallback(UniqueIDBDatabaseTransaction&);
84 UniqueIDBDatabaseConnection(UniqueIDBDatabase&, ServerOpenDBRequest&);
86 uint64_t m_identifier { 0 };
87 UniqueIDBDatabase& m_database;
88 IDBConnectionToClient& m_connectionToClient;
89 IDBResourceIdentifier m_openRequestIdentifier;
91 bool m_closePending { false };
93 HashMap<IDBResourceIdentifier, RefPtr<UniqueIDBDatabaseTransaction>> m_transactionMap;
96 } // namespace IDBServer
97 } // namespace WebCore
99 #endif // ENABLE(INDEXED_DATABASE)