OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_RENDERER_INDEXED_DB_DISPATCHER_H_ | |
6 #define CHROME_RENDERER_INDEXED_DB_DISPATCHER_H_ | |
7 #pragma once | |
8 | |
9 #include "base/id_map.h" | |
10 #include "base/nullable_string16.h" | |
11 #include "ipc/ipc_channel.h" | |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" | |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" | |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" | |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCall
backs.h" | |
17 | |
18 class IndexedDBKey; | |
19 class SerializedScriptValue; | |
20 | |
21 namespace WebKit { | |
22 class WebFrame; | |
23 class WebIDBKeyRange; | |
24 class WebIDBTransaction; | |
25 } | |
26 | |
27 // Handle the indexed db related communication for this entire renderer. | |
28 class IndexedDBDispatcher : public IPC::Channel::Listener { | |
29 public: | |
30 IndexedDBDispatcher(); | |
31 ~IndexedDBDispatcher(); | |
32 | |
33 // IPC::Channel::Listener implementation. | |
34 virtual bool OnMessageReceived(const IPC::Message& msg); | |
35 | |
36 void RequestIDBFactoryOpen( | |
37 const string16& name, | |
38 WebKit::WebIDBCallbacks* callbacks, | |
39 const string16& origin, | |
40 WebKit::WebFrame* web_frame, | |
41 uint64 maximum_size); | |
42 | |
43 void RequestIDBFactoryDeleteDatabase( | |
44 const string16& name, | |
45 WebKit::WebIDBCallbacks* callbacks, | |
46 const string16& origin, | |
47 WebKit::WebFrame* web_frame); | |
48 | |
49 void RequestIDBCursorUpdate( | |
50 const SerializedScriptValue& value, | |
51 WebKit::WebIDBCallbacks* callbacks_ptr, | |
52 int32 idb_cursor_id, | |
53 WebKit::WebExceptionCode* ec); | |
54 | |
55 void RequestIDBCursorContinue( | |
56 const IndexedDBKey& key, | |
57 WebKit::WebIDBCallbacks* callbacks_ptr, | |
58 int32 idb_cursor_id, | |
59 WebKit::WebExceptionCode* ec); | |
60 | |
61 void RequestIDBCursorDelete( | |
62 WebKit::WebIDBCallbacks* callbacks_ptr, | |
63 int32 idb_cursor_id, | |
64 WebKit::WebExceptionCode* ec); | |
65 | |
66 void RequestIDBDatabaseClose( | |
67 int32 idb_database_id); | |
68 | |
69 void RequestIDBDatabaseOpen( | |
70 WebKit::WebIDBDatabaseCallbacks* callbacks_ptr, | |
71 int32 idb_database_id); | |
72 | |
73 void RequestIDBDatabaseSetVersion( | |
74 const string16& version, | |
75 WebKit::WebIDBCallbacks* callbacks, | |
76 int32 idb_database_id, | |
77 WebKit::WebExceptionCode* ec); | |
78 | |
79 void RequestIDBIndexOpenObjectCursor( | |
80 const WebKit::WebIDBKeyRange& idb_key_range, | |
81 unsigned short direction, | |
82 WebKit::WebIDBCallbacks* callbacks, | |
83 int32 idb_index_id, | |
84 const WebKit::WebIDBTransaction& transaction, | |
85 WebKit::WebExceptionCode* ec); | |
86 | |
87 void RequestIDBIndexOpenKeyCursor( | |
88 const WebKit::WebIDBKeyRange& idb_key_range, | |
89 unsigned short direction, | |
90 WebKit::WebIDBCallbacks* callbacks, | |
91 int32 idb_index_id, | |
92 const WebKit::WebIDBTransaction& transaction, | |
93 WebKit::WebExceptionCode* ec); | |
94 | |
95 void RequestIDBIndexGetObject(const IndexedDBKey& key, | |
96 WebKit::WebIDBCallbacks* callbacks, | |
97 int32 idb_index_id, | |
98 const WebKit::WebIDBTransaction& transaction, | |
99 WebKit::WebExceptionCode* ec); | |
100 | |
101 void RequestIDBIndexGetKey(const IndexedDBKey& key, | |
102 WebKit::WebIDBCallbacks* callbacks, | |
103 int32 idb_index_id, | |
104 const WebKit::WebIDBTransaction& transaction, | |
105 WebKit::WebExceptionCode* ec); | |
106 | |
107 void RequestIDBObjectStoreGet(const IndexedDBKey& key, | |
108 WebKit::WebIDBCallbacks* callbacks, | |
109 int32 idb_object_store_id, | |
110 const WebKit::WebIDBTransaction& transaction, | |
111 WebKit::WebExceptionCode* ec); | |
112 | |
113 void RequestIDBObjectStorePut(const SerializedScriptValue& value, | |
114 const IndexedDBKey& key, | |
115 WebKit::WebIDBObjectStore::PutMode putMode, | |
116 WebKit::WebIDBCallbacks* callbacks, | |
117 int32 idb_object_store_id, | |
118 const WebKit::WebIDBTransaction& transaction, | |
119 WebKit::WebExceptionCode* ec); | |
120 | |
121 void RequestIDBObjectStoreDelete( | |
122 const IndexedDBKey& key, | |
123 WebKit::WebIDBCallbacks* callbacks, | |
124 int32 idb_object_store_id, | |
125 const WebKit::WebIDBTransaction& transaction, | |
126 WebKit::WebExceptionCode* ec); | |
127 | |
128 void RequestIDBObjectStoreClear( | |
129 WebKit::WebIDBCallbacks* callbacks, | |
130 int32 idb_object_store_id, | |
131 const WebKit::WebIDBTransaction& transaction, | |
132 WebKit::WebExceptionCode* ec); | |
133 | |
134 void RequestIDBObjectStoreOpenCursor( | |
135 const WebKit::WebIDBKeyRange& idb_key_range, | |
136 unsigned short direction, | |
137 WebKit::WebIDBCallbacks* callbacks, | |
138 int32 idb_object_store_id, | |
139 const WebKit::WebIDBTransaction& transaction, | |
140 WebKit::WebExceptionCode* ec); | |
141 | |
142 void RegisterWebIDBTransactionCallbacks( | |
143 WebKit::WebIDBTransactionCallbacks* callbacks, | |
144 int32 id); | |
145 | |
146 static int32 TransactionId(const WebKit::WebIDBTransaction& transaction); | |
147 | |
148 private: | |
149 // IDBCallback message handlers. | |
150 void OnSuccessNull(int32 response_id); | |
151 void OnSuccessIDBDatabase(int32 response_id, int32 object_id); | |
152 void OnSuccessIndexedDBKey(int32 response_id, const IndexedDBKey& key); | |
153 void OnSuccessIDBTransaction(int32 response_id, int32 object_id); | |
154 void OnSuccessIDBIndex(int32 response_id, int32 object_id); | |
155 void OnSuccessOpenCursor(int32 response_id, int32 object_id); | |
156 void OnSuccessSerializedScriptValue(int32 response_id, | |
157 const SerializedScriptValue& value); | |
158 void OnError(int32 response_id, int code, const string16& message); | |
159 void OnBlocked(int32 response_id); | |
160 void OnAbort(int32 transaction_id); | |
161 void OnComplete(int32 transaction_id); | |
162 void OnTimeout(int32 transaction_id); | |
163 void OnVersionChange(int32 database_id, const string16& newVersion); | |
164 | |
165 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be | |
166 // destroyed and used on the same thread it was created on. | |
167 IDMap<WebKit::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; | |
168 IDMap<WebKit::WebIDBTransactionCallbacks, IDMapOwnPointer> | |
169 pending_transaction_callbacks_; | |
170 IDMap<WebKit::WebIDBDatabaseCallbacks, IDMapOwnPointer> | |
171 pending_database_callbacks_; | |
172 | |
173 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); | |
174 }; | |
175 | |
176 #endif // CHROME_RENDERER_INDEXED_DB_DISPATCHER_H_ | |
OLD | NEW |