OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ |
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 // A shortcut for accessing our context. | 70 // A shortcut for accessing our context. |
71 IndexedDBContextImpl* Context() { return indexed_db_context_; } | 71 IndexedDBContextImpl* Context() { return indexed_db_context_; } |
72 | 72 |
73 // The various IndexedDBCallbacks children call these methods to add the | 73 // The various IndexedDBCallbacks children call these methods to add the |
74 // results into the applicable map. See below for more details. | 74 // results into the applicable map. See below for more details. |
75 int32 Add(WebKit::WebIDBCursor* idb_cursor); | 75 int32 Add(WebKit::WebIDBCursor* idb_cursor); |
76 int32 Add(WebKit::WebIDBDatabase* idb_database, | 76 int32 Add(WebKit::WebIDBDatabase* idb_database, |
77 int32 ipc_thread_id, | 77 int32 ipc_thread_id, |
78 const GURL& origin_url); | 78 const GURL& origin_url); |
79 int32 Add(WebKit::WebIDBIndex* idb_index); | |
80 int32 Add(WebKit::WebIDBObjectStore* idb_object_store); | |
81 int32 Add(WebKit::WebIDBTransaction* idb_transaction, | 79 int32 Add(WebKit::WebIDBTransaction* idb_transaction, |
82 int32 ipc_thread_id, | 80 int32 ipc_thread_id, |
83 const GURL& origin_url); | 81 const GURL& origin_url); |
84 int32 Add(WebKit::WebDOMStringList* domStringList); | 82 int32 Add(WebKit::WebDOMStringList* domStringList); |
85 | 83 |
86 WebKit::WebIDBCursor* GetCursorFromId(int32 ipc_cursor_id); | 84 WebKit::WebIDBCursor* GetCursorFromId(int32 ipc_cursor_id); |
87 | 85 |
88 int64 HostTransactionId(int64 transaction_id); | 86 int64 HostTransactionId(int64 transaction_id); |
89 | 87 |
90 private: | 88 private: |
91 virtual ~IndexedDBDispatcherHost(); | 89 virtual ~IndexedDBDispatcherHost(); |
92 | 90 |
93 // Message processing. Most of the work is delegated to the dispatcher hosts | 91 // Message processing. Most of the work is delegated to the dispatcher hosts |
94 // below. | 92 // below. |
95 void OnIDBFactoryGetDatabaseNames( | 93 void OnIDBFactoryGetDatabaseNames( |
96 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p); | 94 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p); |
97 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p); | 95 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p); |
98 void OnIDBFactoryOpenOld(const IndexedDBHostMsg_FactoryOpen_Params& p); | |
99 | 96 |
100 void OnIDBFactoryDeleteDatabase( | 97 void OnIDBFactoryDeleteDatabase( |
101 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p); | 98 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p); |
102 | 99 |
103 void ResetDispatcherHosts(); | 100 void ResetDispatcherHosts(); |
104 | 101 |
105 // Helper templates. | 102 // Helper templates. |
106 template <class ReturnType> | 103 template <class ReturnType> |
107 ReturnType* GetOrTerminateProcess( | 104 ReturnType* GetOrTerminateProcess( |
108 IDMap<ReturnType, IDMapOwnPointer>* map, int32 ipc_return_object_id); | 105 IDMap<ReturnType, IDMapOwnPointer>* map, int32 ipc_return_object_id); |
(...skipping 10 matching lines...) Expand all Loading... |
119 class DatabaseDispatcherHost { | 116 class DatabaseDispatcherHost { |
120 public: | 117 public: |
121 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent); | 118 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent); |
122 ~DatabaseDispatcherHost(); | 119 ~DatabaseDispatcherHost(); |
123 | 120 |
124 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); | 121 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); |
125 void Send(IPC::Message* message); | 122 void Send(IPC::Message* message); |
126 | 123 |
127 void OnMetadata(int32 ipc_database_id, | 124 void OnMetadata(int32 ipc_database_id, |
128 IndexedDBDatabaseMetadata* metadata); | 125 IndexedDBDatabaseMetadata* metadata); |
129 void OnCreateObjectStoreOld( | |
130 const IndexedDBHostMsg_DatabaseCreateObjectStoreOld_Params& params, | |
131 int32* object_store_id, WebKit::WebExceptionCode* ec); | |
132 void OnCreateObjectStore( | 126 void OnCreateObjectStore( |
133 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params); | 127 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params); |
134 void OnDeleteObjectStoreOld(int32 ipc_database_id, | |
135 int64 object_store_id, | |
136 int32 ipc_transaction_id, | |
137 WebKit::WebExceptionCode* ec); | |
138 void OnDeleteObjectStore(int32 ipc_database_id, | 128 void OnDeleteObjectStore(int32 ipc_database_id, |
139 int64 transaction_id, | 129 int64 transaction_id, |
140 int64 object_store_id); | 130 int64 object_store_id); |
141 void OnCreateTransaction(int32 ipc_thread_id, | 131 void OnCreateTransaction(int32 ipc_thread_id, |
142 int32 ipc_database_id, | 132 int32 ipc_database_id, |
143 int64 transaction_id, | 133 int64 transaction_id, |
144 const std::vector<int64>& scope, | 134 const std::vector<int64>& scope, |
145 int32 mode, | 135 int32 mode, |
146 int32* ipc_transaction_id); | 136 int32* ipc_transaction_id); |
147 void OnOpen(int32 ipc_database_id, int32 ipc_thread_id, | 137 void OnOpen(int32 ipc_database_id, int32 ipc_thread_id, |
(...skipping 26 matching lines...) Expand all Loading... |
174 int64 transaction_id, | 164 int64 transaction_id, |
175 int64 object_store_id, | 165 int64 object_store_id, |
176 int64 index_id); | 166 int64 index_id); |
177 | 167 |
178 IndexedDBDispatcherHost* parent_; | 168 IndexedDBDispatcherHost* parent_; |
179 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_; | 169 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_; |
180 WebIDBObjectIDToURLMap database_url_map_; | 170 WebIDBObjectIDToURLMap database_url_map_; |
181 WebIDBTransactionIDToSizeMap transaction_size_map_; | 171 WebIDBTransactionIDToSizeMap transaction_size_map_; |
182 }; | 172 }; |
183 | 173 |
184 class IndexDispatcherHost { | |
185 public: | |
186 explicit IndexDispatcherHost(IndexedDBDispatcherHost* parent); | |
187 ~IndexDispatcherHost(); | |
188 | |
189 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); | |
190 void Send(IPC::Message* message); | |
191 | |
192 void OnOpenObjectCursor( | |
193 const IndexedDBHostMsg_IndexOpenCursor_Params& params); | |
194 void OnOpenKeyCursor(const IndexedDBHostMsg_IndexOpenCursor_Params& params); | |
195 void OnCount(const IndexedDBHostMsg_IndexCount_Params& params); | |
196 void OnGetObject(int ipc_index_id, | |
197 int32 ipc_thread_id, | |
198 int32 ipc_response_id, | |
199 const IndexedDBKeyRange& key_range, | |
200 int32 ipc_transaction_id); | |
201 void OnGetKey(int ipc_index_id, | |
202 int32 ipc_thread_id, | |
203 int32 ipc_response_id, | |
204 const IndexedDBKeyRange& key_range, | |
205 int32 ipc_transaction_id); | |
206 void OnDestroyed(int32 ipc_index_id); | |
207 | |
208 IndexedDBDispatcherHost* parent_; | |
209 IDMap<WebKit::WebIDBIndex, IDMapOwnPointer> map_; | |
210 }; | |
211 | |
212 class ObjectStoreDispatcherHost { | |
213 public: | |
214 explicit ObjectStoreDispatcherHost(IndexedDBDispatcherHost* parent); | |
215 ~ObjectStoreDispatcherHost(); | |
216 | |
217 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); | |
218 void Send(IPC::Message* message); | |
219 | |
220 void OnGet(int ipc_object_store_id, | |
221 int32 ipc_thread_id, | |
222 int32 ipc_response_id, | |
223 const IndexedDBKeyRange& key_range, | |
224 int32 ipc_transaction_id); | |
225 void OnPut(const IndexedDBHostMsg_ObjectStorePut_Params& params); | |
226 void OnSetIndexKeys( | |
227 int32 ipc_object_store_id, | |
228 const IndexedDBKey& primary_key, | |
229 const std::vector<int64>& index_ids, | |
230 const std::vector<std::vector<IndexedDBKey> >& index_keys, | |
231 int32 ipc_transaction_id); | |
232 void OnSetIndexesReady(int32 ipc_object_store_id, | |
233 const std::vector<int64>& ids, | |
234 int32 ipc_transaction_id); | |
235 void OnDelete(int ipc_object_store_id, | |
236 int32 ipc_thread_id, | |
237 int32 ipc_response_id, | |
238 const IndexedDBKeyRange& key_range, | |
239 int32 ipc_transaction_id); | |
240 void OnClear(int ipc_object_store_id, | |
241 int32 ipc_thread_id, | |
242 int32 ipc_response_id, | |
243 int32 ipc_transaction_id); | |
244 void OnCreateIndex( | |
245 const IndexedDBHostMsg_ObjectStoreCreateIndex_Params& params, | |
246 int32* index_id, | |
247 WebKit::WebExceptionCode* ec); | |
248 void OnIndex(int32 ipc_object_store_id, | |
249 int64 index_id, | |
250 int32* ipc_index_id); | |
251 void OnDeleteIndex(int32 ipc_object_store_id, | |
252 int64 index_id, | |
253 int32 ipc_transaction_id, | |
254 WebKit::WebExceptionCode* ec); | |
255 void OnOpenCursor( | |
256 const IndexedDBHostMsg_ObjectStoreOpenCursor_Params& params); | |
257 void OnCount(const IndexedDBHostMsg_ObjectStoreCount_Params& params); | |
258 void OnDestroyed(int32 ipc_object_store_id); | |
259 | |
260 IndexedDBDispatcherHost* parent_; | |
261 IDMap<WebKit::WebIDBObjectStore, IDMapOwnPointer> map_; | |
262 }; | |
263 | |
264 class CursorDispatcherHost { | 174 class CursorDispatcherHost { |
265 public: | 175 public: |
266 explicit CursorDispatcherHost(IndexedDBDispatcherHost* parent); | 176 explicit CursorDispatcherHost(IndexedDBDispatcherHost* parent); |
267 ~CursorDispatcherHost(); | 177 ~CursorDispatcherHost(); |
268 | 178 |
269 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); | 179 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); |
270 void Send(IPC::Message* message); | 180 void Send(IPC::Message* message); |
271 | 181 |
272 void OnUpdate(int32 ipc_object_store_id, | 182 void OnUpdate(int32 ipc_object_store_id, |
273 int32 ipc_thread_id, | 183 int32 ipc_thread_id, |
(...skipping 25 matching lines...) Expand all Loading... |
299 class TransactionDispatcherHost { | 209 class TransactionDispatcherHost { |
300 public: | 210 public: |
301 explicit TransactionDispatcherHost(IndexedDBDispatcherHost* parent); | 211 explicit TransactionDispatcherHost(IndexedDBDispatcherHost* parent); |
302 ~TransactionDispatcherHost(); | 212 ~TransactionDispatcherHost(); |
303 | 213 |
304 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); | 214 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); |
305 void Send(IPC::Message* message); | 215 void Send(IPC::Message* message); |
306 | 216 |
307 void OnCommit(int32 ipc_transaction_id); | 217 void OnCommit(int32 ipc_transaction_id); |
308 void OnAbort(int32 ipc_transaction_id); | 218 void OnAbort(int32 ipc_transaction_id); |
309 void OnObjectStore(int32 ipc_transaction_id, | |
310 int64 object_store_id, | |
311 int32* ipc_object_store_id, | |
312 WebKit::WebExceptionCode* ec); | |
313 void OnDidCompleteTaskEvents(int ipc_transaction_id); | 219 void OnDidCompleteTaskEvents(int ipc_transaction_id); |
314 void OnDestroyed(int32 ipc_transaction_id); | 220 void OnDestroyed(int32 ipc_transaction_id); |
315 | 221 |
316 IndexedDBDispatcherHost* parent_; | 222 IndexedDBDispatcherHost* parent_; |
317 typedef IDMap<WebKit::WebIDBTransaction, IDMapOwnPointer> MapType; | 223 typedef IDMap<WebKit::WebIDBTransaction, IDMapOwnPointer> MapType; |
318 MapType map_; | 224 MapType map_; |
319 WebIDBObjectIDToURLMap transaction_url_map_; | 225 WebIDBObjectIDToURLMap transaction_url_map_; |
320 WebIDBTransactionIPCIDToSizeMap transaction_ipc_size_map_; | 226 WebIDBTransactionIPCIDToSizeMap transaction_ipc_size_map_; |
321 }; | 227 }; |
322 | 228 |
323 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; | 229 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
324 | 230 |
325 // Only access on WebKit thread. | 231 // Only access on WebKit thread. |
326 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; | 232 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; |
327 scoped_ptr<IndexDispatcherHost> index_dispatcher_host_; | |
328 scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_; | |
329 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; | 233 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; |
330 scoped_ptr<TransactionDispatcherHost> transaction_dispatcher_host_; | 234 scoped_ptr<TransactionDispatcherHost> transaction_dispatcher_host_; |
331 | 235 |
332 // Used to dispatch messages to the correct view host. | 236 // Used to dispatch messages to the correct view host. |
333 int ipc_process_id_; | 237 int ipc_process_id_; |
334 | 238 |
335 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); | 239 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); |
336 }; | 240 }; |
337 | 241 |
338 } // namespace content | 242 } // namespace content |
339 | 243 |
340 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ | 244 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ |
OLD | NEW |