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 12 matching lines...) Expand all Loading... |
23 struct IndexedDBHostMsg_DatabaseOpenCursor_Params; | 23 struct IndexedDBHostMsg_DatabaseOpenCursor_Params; |
24 struct IndexedDBHostMsg_DatabasePut_Params; | 24 struct IndexedDBHostMsg_DatabasePut_Params; |
25 struct IndexedDBHostMsg_DatabaseSetIndexKeys_Params; | 25 struct IndexedDBHostMsg_DatabaseSetIndexKeys_Params; |
26 struct IndexedDBHostMsg_FactoryDeleteDatabase_Params; | 26 struct IndexedDBHostMsg_FactoryDeleteDatabase_Params; |
27 struct IndexedDBHostMsg_FactoryGetDatabaseNames_Params; | 27 struct IndexedDBHostMsg_FactoryGetDatabaseNames_Params; |
28 struct IndexedDBHostMsg_FactoryOpen_Params; | 28 struct IndexedDBHostMsg_FactoryOpen_Params; |
29 | 29 |
30 namespace WebKit { | 30 namespace WebKit { |
31 class WebIDBCursor; | 31 class WebIDBCursor; |
32 class WebIDBDatabase; | 32 class WebIDBDatabase; |
33 class WebIDBIndex; | |
34 class WebIDBObjectStore; | |
35 struct WebIDBMetadata; | 33 struct WebIDBMetadata; |
36 } | 34 } |
37 | 35 |
38 namespace content { | 36 namespace content { |
39 class IndexedDBContextImpl; | 37 class IndexedDBContextImpl; |
40 class IndexedDBKey; | 38 class IndexedDBKey; |
41 class IndexedDBKeyPath; | 39 class IndexedDBKeyPath; |
42 class IndexedDBKeyRange; | 40 class IndexedDBKeyRange; |
43 | 41 |
44 // Handles all IndexedDB related messages from a particular renderer process. | 42 // Handles all IndexedDB related messages from a particular renderer process. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p); | 84 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p); |
87 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p); | 85 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p); |
88 | 86 |
89 void OnIDBFactoryDeleteDatabase( | 87 void OnIDBFactoryDeleteDatabase( |
90 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p); | 88 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p); |
91 | 89 |
92 void ResetDispatcherHosts(); | 90 void ResetDispatcherHosts(); |
93 | 91 |
94 // Helper templates. | 92 // Helper templates. |
95 template <class ReturnType> | 93 template <class ReturnType> |
96 ReturnType* GetOrTerminateProcess( | 94 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map, |
97 IDMap<ReturnType, IDMapOwnPointer>* map, int32 ipc_return_object_id); | 95 int32 ipc_return_object_id); |
98 | 96 |
99 template <typename ObjectType> | 97 template <typename ObjectType> |
100 void DestroyObject(IDMap<ObjectType, IDMapOwnPointer>* map, | 98 void DestroyObject(IDMap<ObjectType, IDMapOwnPointer>* map, |
101 int32 ipc_object_id); | 99 int32 ipc_object_id); |
102 | 100 |
103 // Used in nested classes. | 101 // Used in nested classes. |
104 typedef std::map<int32, GURL> WebIDBObjectIDToURLMap; | 102 typedef std::map<int32, GURL> WebIDBObjectIDToURLMap; |
105 | 103 |
106 typedef std::map<int64, GURL> TransactionIDToURLMap; | 104 typedef std::map<int64, GURL> TransactionIDToURLMap; |
107 typedef std::map<int64, uint64> TransactionIDToSizeMap; | 105 typedef std::map<int64, uint64> TransactionIDToSizeMap; |
108 typedef std::map<int64, int64> TransactionIDToDatabaseIDMap; | 106 typedef std::map<int64, int64> TransactionIDToDatabaseIDMap; |
109 | 107 |
110 class DatabaseDispatcherHost { | 108 class DatabaseDispatcherHost { |
111 public: | 109 public: |
112 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent); | 110 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent); |
113 ~DatabaseDispatcherHost(); | 111 ~DatabaseDispatcherHost(); |
114 | 112 |
115 void CloseAll(); | 113 void CloseAll(); |
116 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); | 114 bool OnMessageReceived(const IPC::Message& message, bool* msg_is_ok); |
117 void Send(IPC::Message* message); | 115 void Send(IPC::Message* message); |
118 | 116 |
119 void OnCreateObjectStore( | 117 void OnCreateObjectStore( |
120 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params); | 118 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params); |
121 void OnDeleteObjectStore(int32 ipc_database_id, | 119 void OnDeleteObjectStore(int32 ipc_database_id, |
122 int64 transaction_id, | 120 int64 transaction_id, |
123 int64 object_store_id); | 121 int64 object_store_id); |
124 void OnCreateTransaction( | 122 void OnCreateTransaction( |
125 const IndexedDBHostMsg_DatabaseCreateTransaction_Params&); | 123 const IndexedDBHostMsg_DatabaseCreateTransaction_Params&); |
126 void OnOpen(int32 ipc_database_id, int32 ipc_thread_id, | 124 void OnOpen(int32 ipc_database_id, |
| 125 int32 ipc_thread_id, |
127 int32 ipc_callbacks_id); | 126 int32 ipc_callbacks_id); |
128 void OnClose(int32 ipc_database_id); | 127 void OnClose(int32 ipc_database_id); |
129 void OnDestroyed(int32 ipc_database_id); | 128 void OnDestroyed(int32 ipc_database_id); |
130 | 129 |
131 void OnGet(const IndexedDBHostMsg_DatabaseGet_Params& params); | 130 void OnGet(const IndexedDBHostMsg_DatabaseGet_Params& params); |
132 void OnPut(const IndexedDBHostMsg_DatabasePut_Params& params); | 131 void OnPut(const IndexedDBHostMsg_DatabasePut_Params& params); |
133 void OnSetIndexKeys( | 132 void OnSetIndexKeys( |
134 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params); | 133 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params); |
135 void OnSetIndexesReady( | 134 void OnSetIndexesReady(int32 ipc_database_id, |
136 int32 ipc_database_id, | 135 int64 transaction_id, |
137 int64 transaction_id, | 136 int64 object_store_id, |
138 int64 object_store_id, | 137 const std::vector<int64>& ids); |
139 const std::vector<int64>& ids); | 138 void OnOpenCursor(const IndexedDBHostMsg_DatabaseOpenCursor_Params& params); |
140 void OnOpenCursor( | |
141 const IndexedDBHostMsg_DatabaseOpenCursor_Params& params); | |
142 void OnCount(const IndexedDBHostMsg_DatabaseCount_Params& params); | 139 void OnCount(const IndexedDBHostMsg_DatabaseCount_Params& params); |
143 void OnDeleteRange( | 140 void OnDeleteRange( |
144 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params); | 141 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params); |
145 void OnClear(int32 ipc_thread_id, | 142 void OnClear(int32 ipc_thread_id, |
146 int32 ipc_callbacks_id, | 143 int32 ipc_callbacks_id, |
147 int32 ipc_database_id, | 144 int32 ipc_database_id, |
148 int64 transaction_id, | 145 int64 transaction_id, |
149 int64 object_store_id); | 146 int64 object_store_id); |
150 void OnCreateIndex( | 147 void OnCreateIndex( |
151 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params); | 148 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params); |
(...skipping 10 matching lines...) Expand all Loading... |
162 TransactionIDToSizeMap transaction_size_map_; | 159 TransactionIDToSizeMap transaction_size_map_; |
163 TransactionIDToURLMap transaction_url_map_; | 160 TransactionIDToURLMap transaction_url_map_; |
164 TransactionIDToDatabaseIDMap transaction_database_map_; | 161 TransactionIDToDatabaseIDMap transaction_database_map_; |
165 }; | 162 }; |
166 | 163 |
167 class CursorDispatcherHost { | 164 class CursorDispatcherHost { |
168 public: | 165 public: |
169 explicit CursorDispatcherHost(IndexedDBDispatcherHost* parent); | 166 explicit CursorDispatcherHost(IndexedDBDispatcherHost* parent); |
170 ~CursorDispatcherHost(); | 167 ~CursorDispatcherHost(); |
171 | 168 |
172 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); | 169 bool OnMessageReceived(const IPC::Message& message, bool* msg_is_ok); |
173 void Send(IPC::Message* message); | 170 void Send(IPC::Message* message); |
174 | 171 |
175 void OnAdvance(int32 ipc_object_store_id, | 172 void OnAdvance(int32 ipc_object_store_id, |
176 int32 ipc_thread_id, | 173 int32 ipc_thread_id, |
177 int32 ipc_callbacks_id, | 174 int32 ipc_callbacks_id, |
178 unsigned long count); | 175 unsigned long count); |
179 void OnContinue(int32 ipc_object_store_id, | 176 void OnContinue(int32 ipc_object_store_id, |
180 int32 ipc_thread_id, | 177 int32 ipc_thread_id, |
181 int32 ipc_callbacks_id, | 178 int32 ipc_callbacks_id, |
182 const IndexedDBKey& key); | 179 const IndexedDBKey& key); |
183 void OnPrefetch(int32 ipc_cursor_id, | 180 void OnPrefetch(int32 ipc_cursor_id, |
184 int32 ipc_thread_id, | 181 int32 ipc_thread_id, |
185 int32 ipc_callbacks_id, | 182 int32 ipc_callbacks_id, |
186 int n); | 183 int n); |
187 void OnPrefetchReset(int32 ipc_cursor_id, int used_prefetches, | 184 void OnPrefetchReset(int32 ipc_cursor_id, |
| 185 int used_prefetches, |
188 int unused_prefetches); | 186 int unused_prefetches); |
189 void OnDelete(int32 ipc_object_store_id, | 187 void OnDelete(int32 ipc_object_store_id, |
190 int32 ipc_thread_id, | 188 int32 ipc_thread_id, |
191 int32 ipc_callbacks_id); | 189 int32 ipc_callbacks_id); |
192 void OnDestroyed(int32 ipc_cursor_id); | 190 void OnDestroyed(int32 ipc_cursor_id); |
193 | 191 |
194 IndexedDBDispatcherHost* parent_; | 192 IndexedDBDispatcherHost* parent_; |
195 IDMap<WebKit::WebIDBCursor, IDMapOwnPointer> map_; | 193 IDMap<WebKit::WebIDBCursor, IDMapOwnPointer> map_; |
196 }; | 194 }; |
197 | 195 |
198 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; | 196 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
199 | 197 |
200 // Only access on WebKit thread. | 198 // Only access on WebKit thread. |
201 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; | 199 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; |
202 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; | 200 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; |
203 | 201 |
204 // Used to dispatch messages to the correct view host. | 202 // Used to dispatch messages to the correct view host. |
205 int ipc_process_id_; | 203 int ipc_process_id_; |
206 | 204 |
207 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); | 205 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); |
208 }; | 206 }; |
209 | 207 |
210 } // namespace content | 208 } // namespace content |
211 | 209 |
212 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ | 210 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ |
OLD | NEW |