OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ | 5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ |
6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ | 6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
11 #include "base/process.h" | 11 #include "base/process.h" |
12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
13 #include "chrome/browser/in_process_webkit/webkit_context.h" | 13 #include "chrome/browser/in_process_webkit/webkit_context.h" |
14 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
15 | 15 |
16 class IndexedDBKey; | 16 class IndexedDBKey; |
17 class SerializedScriptValue; | 17 class SerializedScriptValue; |
18 struct ViewHostMsg_IDBDatabaseCreateObjectStore_Params; | 18 struct ViewHostMsg_IDBDatabaseCreateObjectStore_Params; |
19 struct ViewHostMsg_IDBFactoryOpen_Params; | 19 struct ViewHostMsg_IDBFactoryOpen_Params; |
20 struct ViewHostMsg_IDBObjectStoreCreateIndex_Params; | 20 struct ViewHostMsg_IDBObjectStoreCreateIndex_Params; |
21 | 21 |
22 namespace WebKit { | 22 namespace WebKit { |
23 class WebIDBDatabase; | 23 class WebIDBDatabase; |
24 class WebIDBIndex; | 24 class WebIDBIndex; |
25 class WebIDBObjectStore; | 25 class WebIDBObjectStore; |
| 26 class WebIDBTransaction; |
26 } | 27 } |
27 | 28 |
28 // Handles all IndexedDB related messages from a particular renderer process. | 29 // Handles all IndexedDB related messages from a particular renderer process. |
29 class IndexedDBDispatcherHost | 30 class IndexedDBDispatcherHost |
30 : public base::RefCountedThreadSafe<IndexedDBDispatcherHost> { | 31 : public base::RefCountedThreadSafe<IndexedDBDispatcherHost> { |
31 public: | 32 public: |
32 // Only call the constructor from the UI thread. | 33 // Only call the constructor from the UI thread. |
33 IndexedDBDispatcherHost(IPC::Message::Sender* sender, | 34 IndexedDBDispatcherHost(IPC::Message::Sender* sender, |
34 WebKitContext* webkit_context); | 35 WebKitContext* webkit_context); |
35 | 36 |
(...skipping 14 matching lines...) Expand all Loading... |
50 // A shortcut for accessing our context. | 51 // A shortcut for accessing our context. |
51 IndexedDBContext* Context() { | 52 IndexedDBContext* Context() { |
52 return webkit_context_->indexed_db_context(); | 53 return webkit_context_->indexed_db_context(); |
53 } | 54 } |
54 | 55 |
55 // The various IndexedDBCallbacks children call these methods to add the | 56 // The various IndexedDBCallbacks children call these methods to add the |
56 // results into the applicable map. See below for more details. | 57 // results into the applicable map. See below for more details. |
57 int32 Add(WebKit::WebIDBDatabase* idb_database); | 58 int32 Add(WebKit::WebIDBDatabase* idb_database); |
58 int32 Add(WebKit::WebIDBIndex* idb_index); | 59 int32 Add(WebKit::WebIDBIndex* idb_index); |
59 int32 Add(WebKit::WebIDBObjectStore* idb_object_store); | 60 int32 Add(WebKit::WebIDBObjectStore* idb_object_store); |
| 61 void Add(WebKit::WebIDBTransaction* idb_transaction); |
60 | 62 |
61 private: | 63 private: |
62 friend class base::RefCountedThreadSafe<IndexedDBDispatcherHost>; | 64 friend class base::RefCountedThreadSafe<IndexedDBDispatcherHost>; |
63 ~IndexedDBDispatcherHost(); | 65 ~IndexedDBDispatcherHost(); |
64 | 66 |
65 // Message processing. Most of the work is delegated to the dispatcher hosts | 67 // Message processing. Most of the work is delegated to the dispatcher hosts |
66 // below. | 68 // below. |
67 void OnMessageReceivedWebKit(const IPC::Message& message); | 69 void OnMessageReceivedWebKit(const IPC::Message& message); |
68 void OnIDBFactoryOpen(const ViewHostMsg_IDBFactoryOpen_Params& p); | 70 void OnIDBFactoryOpen(const ViewHostMsg_IDBFactoryOpen_Params& p); |
| 71 void OnIDBFactoryAbortPendingTransactions(const std::vector<int32>& ids); |
69 | 72 |
70 // Helper templates. | 73 // Helper templates. |
71 template <class ReturnType> | 74 template <class ReturnType> |
72 ReturnType* GetOrTerminateProcess( | 75 ReturnType* GetOrTerminateProcess( |
73 IDMap<ReturnType, IDMapOwnPointer>* map, int32 return_object_id, | 76 IDMap<ReturnType, IDMapOwnPointer>* map, int32 return_object_id, |
74 IPC::Message* reply_msg, uint32 message_type); | 77 IPC::Message* reply_msg, uint32 message_type); |
75 | 78 |
76 template <typename ReplyType, typename MessageType, | 79 template <typename ReplyType, typename MessageType, |
77 typename WebObjectType, typename Method> | 80 typename WebObjectType, typename Method> |
78 void SyncGetter(IDMap<WebObjectType, IDMapOwnPointer>* map, int32 object_id, | 81 void SyncGetter(IDMap<WebObjectType, IDMapOwnPointer>* map, int32 object_id, |
(...skipping 14 matching lines...) Expand all Loading... |
93 void OnName(int32 idb_database_id, IPC::Message* reply_msg); | 96 void OnName(int32 idb_database_id, IPC::Message* reply_msg); |
94 void OnDescription(int32 idb_database_id, IPC::Message* reply_msg); | 97 void OnDescription(int32 idb_database_id, IPC::Message* reply_msg); |
95 void OnVersion(int32 idb_database_id, IPC::Message* reply_msg); | 98 void OnVersion(int32 idb_database_id, IPC::Message* reply_msg); |
96 void OnObjectStores(int32 idb_database_id, IPC::Message* reply_msg); | 99 void OnObjectStores(int32 idb_database_id, IPC::Message* reply_msg); |
97 void OnCreateObjectStore( | 100 void OnCreateObjectStore( |
98 const ViewHostMsg_IDBDatabaseCreateObjectStore_Params& params); | 101 const ViewHostMsg_IDBDatabaseCreateObjectStore_Params& params); |
99 void OnObjectStore(int32 idb_database_id, const string16& name, int32 mode, | 102 void OnObjectStore(int32 idb_database_id, const string16& name, int32 mode, |
100 IPC::Message* reply_msg); | 103 IPC::Message* reply_msg); |
101 void OnRemoveObjectStore(int32 idb_database_id, int32 response_id, | 104 void OnRemoveObjectStore(int32 idb_database_id, int32 response_id, |
102 const string16& name); | 105 const string16& name); |
| 106 void OnTransaction(int32 idb_database_id, |
| 107 const std::vector<string16>& names, |
| 108 int32 mode, int32 timeout, IPC::Message* reply_msg); |
103 void OnDestroyed(int32 idb_database_id); | 109 void OnDestroyed(int32 idb_database_id); |
104 | 110 |
105 IndexedDBDispatcherHost* parent_; | 111 IndexedDBDispatcherHost* parent_; |
106 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_; | 112 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_; |
107 }; | 113 }; |
108 | 114 |
109 class IndexDispatcherHost { | 115 class IndexDispatcherHost { |
110 public: | 116 public: |
111 explicit IndexDispatcherHost(IndexedDBDispatcherHost* parent); | 117 explicit IndexDispatcherHost(IndexedDBDispatcherHost* parent); |
112 ~IndexDispatcherHost(); | 118 ~IndexDispatcherHost(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 const ViewHostMsg_IDBObjectStoreCreateIndex_Params& params); | 151 const ViewHostMsg_IDBObjectStoreCreateIndex_Params& params); |
146 void OnIndex(int32 idb_object_store_id, const string16& name, | 152 void OnIndex(int32 idb_object_store_id, const string16& name, |
147 IPC::Message* reply_msg); | 153 IPC::Message* reply_msg); |
148 void OnRemoveIndex(int32 idb_object_store_id, int32 response_id, | 154 void OnRemoveIndex(int32 idb_object_store_id, int32 response_id, |
149 const string16& name); | 155 const string16& name); |
150 void OnDestroyed(int32 idb_object_store_id); | 156 void OnDestroyed(int32 idb_object_store_id); |
151 | 157 |
152 IndexedDBDispatcherHost* parent_; | 158 IndexedDBDispatcherHost* parent_; |
153 IDMap<WebKit::WebIDBObjectStore, IDMapOwnPointer> map_; | 159 IDMap<WebKit::WebIDBObjectStore, IDMapOwnPointer> map_; |
154 }; | 160 }; |
| 161 |
| 162 class TransactionDispatcherHost { |
| 163 public: |
| 164 explicit TransactionDispatcherHost(IndexedDBDispatcherHost* parent); |
| 165 ~TransactionDispatcherHost(); |
| 166 |
| 167 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); |
| 168 void Send(IPC::Message* message); |
| 169 |
| 170 // TODO: add the rest of the transaction methods. |
| 171 void OnDestroyed(int32 idb_transaction_id); |
| 172 |
| 173 IndexedDBDispatcherHost* parent_; |
| 174 IDMap<WebKit::WebIDBTransaction, IDMapOwnPointer> map_; |
| 175 }; |
| 176 |
155 // Only use on the IO thread. | 177 // Only use on the IO thread. |
156 IPC::Message::Sender* sender_; | 178 IPC::Message::Sender* sender_; |
157 | 179 |
158 // Data shared between renderer processes with the same profile. | 180 // Data shared between renderer processes with the same profile. |
159 scoped_refptr<WebKitContext> webkit_context_; | 181 scoped_refptr<WebKitContext> webkit_context_; |
160 | 182 |
161 // Only access on WebKit thread. | 183 // Only access on WebKit thread. |
162 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; | 184 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; |
163 scoped_ptr<IndexDispatcherHost> index_dispatcher_host_; | 185 scoped_ptr<IndexDispatcherHost> index_dispatcher_host_; |
164 scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_; | 186 scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_; |
| 187 scoped_ptr<TransactionDispatcherHost> transaction_dispatcher_host_; |
165 | 188 |
166 // If we get a corrupt message from a renderer, we need to kill it using this | 189 // If we get a corrupt message from a renderer, we need to kill it using this |
167 // handle. | 190 // handle. |
168 base::ProcessHandle process_handle_; | 191 base::ProcessHandle process_handle_; |
169 | 192 |
170 // Used to dispatch messages to the correct view host. | 193 // Used to dispatch messages to the correct view host. |
171 int process_id_; | 194 int process_id_; |
172 | 195 |
173 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); | 196 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); |
174 }; | 197 }; |
175 | 198 |
176 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ | 199 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ |
OLD | NEW |