IDB: indexeddb/mozilla/add-twice-failure.html fails
[WebKit-https.git] / Source / WebKit2 / DatabaseProcess / IndexedDB / DatabaseProcessIDBConnection.h
1 /*
2  * Copyright (C) 2013 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 #ifndef DatabaseProcessIDBConnection_h
27 #define DatabaseProcessIDBConnection_h
28
29 #include "MessageSender.h"
30
31 #if ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
32
33 #include "SecurityOriginData.h"
34 #include "UniqueIDBDatabaseIdentifier.h"
35 #include <wtf/text/WTFString.h>
36
37 namespace WebCore {
38 struct IDBKeyData;
39 struct IDBKeyRangeData;
40 }
41
42 namespace WebKit {
43
44 class DatabaseToWebProcessConnection;
45 class UniqueIDBDatabase;
46
47 class DatabaseProcessIDBConnection : public RefCounted<DatabaseProcessIDBConnection>, public IPC::MessageSender {
48 public:
49     static RefPtr<DatabaseProcessIDBConnection> create(DatabaseToWebProcessConnection& connection, uint64_t serverConnectionIdentifier)
50     {
51         return adoptRef(new DatabaseProcessIDBConnection(connection, serverConnectionIdentifier));
52     }
53
54     virtual ~DatabaseProcessIDBConnection();
55
56     // Message handlers.
57     void didReceiveDatabaseProcessIDBConnectionMessage(IPC::Connection*, IPC::MessageDecoder&);
58
59     void disconnectedFromWebProcess();
60
61 private:
62     DatabaseProcessIDBConnection(DatabaseToWebProcessConnection&, uint64_t idbConnectionIdentifier);
63
64     // IPC::MessageSender
65     virtual IPC::Connection* messageSenderConnection() override;
66     virtual uint64_t messageSenderDestinationID() override { return m_serverConnectionIdentifier; }
67
68     // Message handlers.
69     void establishConnection(const String& databaseName, const SecurityOriginData& openingOrigin, const SecurityOriginData& mainFrameOrigin);
70     void getOrEstablishIDBDatabaseMetadata(uint64_t requestID);
71     void deleteDatabase(uint64_t requestID, const String& databaseName);
72     void openTransaction(uint64_t requestID, int64_t transactionID, const Vector<int64_t>& objectStoreIDs, uint64_t transactionMode);
73     void beginTransaction(uint64_t requestID, int64_t transactionID);
74     void commitTransaction(uint64_t requestID, int64_t transactionID);
75     void resetTransaction(uint64_t requestID, int64_t transactionID);
76     void rollbackTransaction(uint64_t requestID, int64_t transactionID);
77     void changeDatabaseVersion(uint64_t requestID, int64_t transactionID, uint64_t newVersion);
78     void createObjectStore(uint64_t requestID, int64_t transactionID, WebCore::IDBObjectStoreMetadata);
79     void deleteObjectStore(uint64_t requestID, int64_t transactionID, int64_t objectStoreID);
80     void clearObjectStore(uint64_t requestID, int64_t transactionID, int64_t objectStoreID);
81     void createIndex(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, const WebCore::IDBIndexMetadata&);
82     void deleteIndex(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, int64_t indexID);
83     void putRecord(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, const WebCore::IDBKeyData&, const IPC::DataReference& value, int64_t putMode, const Vector<int64_t>& indexIDs, const Vector<Vector<WebCore::IDBKeyData>>& indexKeys);
84     void getRecord(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyRangeData&, int64_t cursorType);
85
86     void openCursor(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, int64_t indexID, int64_t cursorDirection, int64_t cursorType, int64_t taskType, const WebCore::IDBKeyRangeData&);
87     void cursorAdvance(uint64_t requestID, int64_t cursorID, uint64_t count);
88     void cursorIterate(uint64_t requestID, int64_t cursorID, const WebCore::IDBKeyData&);
89
90     void count(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyRangeData&);
91     void deleteRange(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, const WebCore::IDBKeyRangeData& keyRange);
92
93     Ref<DatabaseToWebProcessConnection> m_connection;
94     uint64_t m_serverConnectionIdentifier;
95
96     RefPtr<UniqueIDBDatabase> m_uniqueIDBDatabase;
97 };
98
99 } // namespace WebKit
100
101 #endif // ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
102 #endif // DatabaseProcessIDBConnection_h