OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "content/renderer/indexed_db_dispatcher.h" | 5 #include "content/renderer/indexed_db_dispatcher.h" |
6 | 6 |
7 #include "content/common/indexed_db_messages.h" | 7 #include "content/common/indexed_db_messages.h" |
8 #include "content/renderer/render_thread_impl.h" | 8 #include "content/renderer/render_thread_impl.h" |
9 #include "content/renderer/render_view_impl.h" | 9 #include "content/renderer/render_view_impl.h" |
10 #include "content/renderer/renderer_webidbcursor_impl.h" | 10 #include "content/renderer/renderer_webidbcursor_impl.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
37 IndexedDBDispatcher::~IndexedDBDispatcher() { | 37 IndexedDBDispatcher::~IndexedDBDispatcher() { |
38 } | 38 } |
39 | 39 |
40 bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { | 40 bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { |
41 bool handled = true; | 41 bool handled = true; |
42 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg) | 42 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg) |
43 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor, | 43 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor, |
44 OnSuccessOpenCursor) | 44 OnSuccessOpenCursor) |
45 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue, | 45 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue, |
46 OnSuccessCursorContinue) | 46 OnSuccessCursorContinue) |
47 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorPrefetch, | |
48 OnSuccessCursorPrefetch) | |
47 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, | 49 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, |
48 OnSuccessIDBDatabase) | 50 OnSuccessIDBDatabase) |
49 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, | 51 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, |
50 OnSuccessIndexedDBKey) | 52 OnSuccessIndexedDBKey) |
51 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction, | 53 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction, |
52 OnSuccessIDBTransaction) | 54 OnSuccessIDBTransaction) |
53 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, | 55 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, |
54 OnSuccessStringList) | 56 OnSuccessStringList) |
55 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue, | 57 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue, |
56 OnSuccessSerializedScriptValue) | 58 OnSuccessSerializedScriptValue) |
57 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) | 59 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) |
58 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) | 60 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) |
59 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) | 61 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) |
60 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) | 62 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) |
61 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange, | 63 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange, |
62 OnVersionChange) | 64 OnVersionChange) |
63 IPC_MESSAGE_UNHANDLED(handled = false) | 65 IPC_MESSAGE_UNHANDLED(handled = false) |
64 IPC_END_MESSAGE_MAP() | 66 IPC_END_MESSAGE_MAP() |
65 return handled; | 67 return handled; |
66 } | 68 } |
67 | 69 |
68 void IndexedDBDispatcher::RequestIDBCursorUpdate( | 70 void IndexedDBDispatcher::RequestIDBCursorUpdate( |
69 const content::SerializedScriptValue& value, | 71 const content::SerializedScriptValue& value, |
70 WebIDBCallbacks* callbacks_ptr, | 72 WebIDBCallbacks* callbacks_ptr, |
71 int32 idb_cursor_id, | 73 int32 idb_cursor_id, |
72 WebExceptionCode* ec) { | 74 WebExceptionCode* ec) { |
75 ResetCursorPrefetchCaches(); | |
73 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 76 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
74 | 77 |
75 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 78 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
76 RenderThreadImpl::current()->Send( | 79 RenderThreadImpl::current()->Send( |
77 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, response_id, value, ec)); | 80 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, response_id, value, ec)); |
78 if (*ec) | 81 if (*ec) |
79 pending_callbacks_.Remove(response_id); | 82 pending_callbacks_.Remove(response_id); |
80 } | 83 } |
81 | 84 |
82 void IndexedDBDispatcher::RequestIDBCursorContinue( | 85 void IndexedDBDispatcher::RequestIDBCursorContinue( |
83 const IndexedDBKey& key, | 86 const IndexedDBKey& key, |
84 WebIDBCallbacks* callbacks_ptr, | 87 WebIDBCallbacks* callbacks_ptr, |
85 int32 idb_cursor_id, | 88 int32 idb_cursor_id, |
86 WebExceptionCode* ec) { | 89 WebExceptionCode* ec) { |
90 // Reset all cursor prefetch caches except for this cursor. | |
91 ResetCursorPrefetchCaches(idb_cursor_id); | |
92 | |
87 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 93 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
88 | 94 |
89 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 95 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
90 RenderThreadImpl::current()->Send( | 96 RenderThreadImpl::current()->Send( |
91 new IndexedDBHostMsg_CursorContinue(idb_cursor_id, response_id, key, ec)); | 97 new IndexedDBHostMsg_CursorContinue(idb_cursor_id, response_id, key, ec)); |
92 if (*ec) | 98 if (*ec) |
93 pending_callbacks_.Remove(response_id); | 99 pending_callbacks_.Remove(response_id); |
94 } | 100 } |
95 | 101 |
102 void IndexedDBDispatcher::RequestIDBCursorPrefetch( | |
103 int n, | |
104 WebIDBCallbacks* callbacks_ptr, | |
105 int32 idb_cursor_id, | |
106 WebExceptionCode* ec) { | |
107 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | |
108 | |
109 int32 response_id = pending_callbacks_.Add(callbacks.release()); | |
110 RenderThreadImpl::current()->Send( | |
111 new IndexedDBHostMsg_CursorPrefetch(idb_cursor_id, response_id, n, ec)); | |
112 if (*ec) | |
113 pending_callbacks_.Remove(response_id); | |
114 } | |
115 | |
116 void IndexedDBDispatcher::RequestIDBCursorPrefetchReset( | |
117 int used_prefetches, int unused_prefetches, int32 idb_cursor_id) { | |
118 RenderThreadImpl::current()->Send( | |
119 new IndexedDBHostMsg_CursorPrefetchReset(idb_cursor_id, used_prefetches, | |
120 unused_prefetches)); | |
121 } | |
122 | |
96 void IndexedDBDispatcher::RequestIDBCursorDelete( | 123 void IndexedDBDispatcher::RequestIDBCursorDelete( |
97 WebIDBCallbacks* callbacks_ptr, | 124 WebIDBCallbacks* callbacks_ptr, |
98 int32 idb_cursor_id, | 125 int32 idb_cursor_id, |
99 WebExceptionCode* ec) { | 126 WebExceptionCode* ec) { |
127 ResetCursorPrefetchCaches(); | |
100 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 128 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
101 | 129 |
102 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 130 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
103 RenderThreadImpl::current()->Send( | 131 RenderThreadImpl::current()->Send( |
104 new IndexedDBHostMsg_CursorDelete(idb_cursor_id, response_id, ec)); | 132 new IndexedDBHostMsg_CursorDelete(idb_cursor_id, response_id, ec)); |
105 if (*ec) | 133 if (*ec) |
106 pending_callbacks_.Remove(response_id); | 134 pending_callbacks_.Remove(response_id); |
107 } | 135 } |
108 | 136 |
109 void IndexedDBDispatcher::RequestIDBFactoryOpen( | 137 void IndexedDBDispatcher::RequestIDBFactoryOpen( |
110 const string16& name, | 138 const string16& name, |
111 WebIDBCallbacks* callbacks_ptr, | 139 WebIDBCallbacks* callbacks_ptr, |
112 const string16& origin, | 140 const string16& origin, |
113 WebFrame* web_frame) { | 141 WebFrame* web_frame) { |
142 ResetCursorPrefetchCaches(); | |
114 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 143 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
115 | 144 |
116 if (!web_frame) | 145 if (!web_frame) |
117 return; // We must be shutting down. | 146 return; // We must be shutting down. |
118 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 147 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
119 if (!render_view) | 148 if (!render_view) |
120 return; // We must be shutting down. | 149 return; // We must be shutting down. |
121 | 150 |
122 IndexedDBHostMsg_FactoryOpen_Params params; | 151 IndexedDBHostMsg_FactoryOpen_Params params; |
123 params.response_id = pending_callbacks_.Add(callbacks.release()); | 152 params.response_id = pending_callbacks_.Add(callbacks.release()); |
124 params.origin = origin; | 153 params.origin = origin; |
125 params.name = name; | 154 params.name = name; |
126 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_FactoryOpen(params)); | 155 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_FactoryOpen(params)); |
127 } | 156 } |
128 | 157 |
129 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( | 158 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( |
130 WebIDBCallbacks* callbacks_ptr, | 159 WebIDBCallbacks* callbacks_ptr, |
131 const string16& origin, | 160 const string16& origin, |
132 WebFrame* web_frame) { | 161 WebFrame* web_frame) { |
162 ResetCursorPrefetchCaches(); | |
133 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 163 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
134 | 164 |
135 if (!web_frame) | 165 if (!web_frame) |
136 return; // We must be shutting down. | 166 return; // We must be shutting down. |
137 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 167 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
138 if (!render_view) | 168 if (!render_view) |
139 return; // We must be shutting down. | 169 return; // We must be shutting down. |
140 | 170 |
141 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; | 171 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; |
142 params.response_id = pending_callbacks_.Add(callbacks.release()); | 172 params.response_id = pending_callbacks_.Add(callbacks.release()); |
143 params.origin = origin; | 173 params.origin = origin; |
144 RenderThreadImpl::current()->Send( | 174 RenderThreadImpl::current()->Send( |
145 new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); | 175 new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); |
146 } | 176 } |
147 | 177 |
148 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( | 178 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( |
149 const string16& name, | 179 const string16& name, |
150 WebIDBCallbacks* callbacks_ptr, | 180 WebIDBCallbacks* callbacks_ptr, |
151 const string16& origin, | 181 const string16& origin, |
152 WebFrame* web_frame) { | 182 WebFrame* web_frame) { |
183 ResetCursorPrefetchCaches(); | |
153 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 184 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
154 | 185 |
155 if (!web_frame) | 186 if (!web_frame) |
156 return; // We must be shutting down. | 187 return; // We must be shutting down. |
157 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 188 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
158 if (!render_view) | 189 if (!render_view) |
159 return; // We must be shutting down. | 190 return; // We must be shutting down. |
160 | 191 |
161 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; | 192 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; |
162 params.response_id = pending_callbacks_.Add(callbacks.release()); | 193 params.response_id = pending_callbacks_.Add(callbacks.release()); |
163 params.origin = origin; | 194 params.origin = origin; |
164 params.name = name; | 195 params.name = name; |
165 RenderThreadImpl::current()->Send( | 196 RenderThreadImpl::current()->Send( |
166 new IndexedDBHostMsg_FactoryDeleteDatabase(params)); | 197 new IndexedDBHostMsg_FactoryDeleteDatabase(params)); |
167 } | 198 } |
168 | 199 |
169 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { | 200 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { |
201 ResetCursorPrefetchCaches(); | |
170 RenderThreadImpl::current()->Send( | 202 RenderThreadImpl::current()->Send( |
171 new IndexedDBHostMsg_DatabaseClose(idb_database_id)); | 203 new IndexedDBHostMsg_DatabaseClose(idb_database_id)); |
172 pending_database_callbacks_.Remove(idb_database_id); | 204 pending_database_callbacks_.Remove(idb_database_id); |
173 } | 205 } |
174 | 206 |
175 void IndexedDBDispatcher::RequestIDBDatabaseOpen( | 207 void IndexedDBDispatcher::RequestIDBDatabaseOpen( |
176 WebIDBDatabaseCallbacks* callbacks_ptr, | 208 WebIDBDatabaseCallbacks* callbacks_ptr, |
177 int32 idb_database_id) { | 209 int32 idb_database_id) { |
210 ResetCursorPrefetchCaches(); | |
178 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr); | 211 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr); |
179 | 212 |
180 int32 response_id = pending_database_callbacks_.Add(callbacks.release()); | 213 int32 response_id = pending_database_callbacks_.Add(callbacks.release()); |
181 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_DatabaseOpen( | 214 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_DatabaseOpen( |
182 response_id, idb_database_id)); | 215 response_id, idb_database_id)); |
183 } | 216 } |
184 | 217 |
185 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( | 218 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( |
186 const string16& version, | 219 const string16& version, |
187 WebIDBCallbacks* callbacks_ptr, | 220 WebIDBCallbacks* callbacks_ptr, |
188 int32 idb_database_id, | 221 int32 idb_database_id, |
189 WebExceptionCode* ec) { | 222 WebExceptionCode* ec) { |
223 ResetCursorPrefetchCaches(); | |
190 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 224 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
191 | 225 |
192 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 226 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
193 RenderThreadImpl::current()->Send( | 227 RenderThreadImpl::current()->Send( |
194 new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, response_id, | 228 new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, response_id, |
195 version, ec)); | 229 version, ec)); |
196 if (*ec) | 230 if (*ec) |
197 pending_callbacks_.Remove(response_id); | 231 pending_callbacks_.Remove(response_id); |
198 } | 232 } |
199 | 233 |
200 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( | 234 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( |
201 const WebIDBKeyRange& idb_key_range, | 235 const WebIDBKeyRange& idb_key_range, |
202 unsigned short direction, | 236 unsigned short direction, |
203 WebIDBCallbacks* callbacks_ptr, | 237 WebIDBCallbacks* callbacks_ptr, |
204 int32 idb_index_id, | 238 int32 idb_index_id, |
205 const WebIDBTransaction& transaction, | 239 const WebIDBTransaction& transaction, |
206 WebExceptionCode* ec) { | 240 WebExceptionCode* ec) { |
241 ResetCursorPrefetchCaches(); | |
207 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 242 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
208 IndexedDBHostMsg_IndexOpenCursor_Params params; | 243 IndexedDBHostMsg_IndexOpenCursor_Params params; |
209 params.response_id = pending_callbacks_.Add(callbacks.release()); | 244 params.response_id = pending_callbacks_.Add(callbacks.release()); |
210 params.lower_key.Set(idb_key_range.lower()); | 245 params.lower_key.Set(idb_key_range.lower()); |
211 params.upper_key.Set(idb_key_range.upper()); | 246 params.upper_key.Set(idb_key_range.upper()); |
212 params.lower_open = idb_key_range.lowerOpen(); | 247 params.lower_open = idb_key_range.lowerOpen(); |
213 params.upper_open = idb_key_range.upperOpen(); | 248 params.upper_open = idb_key_range.upperOpen(); |
214 params.direction = direction; | 249 params.direction = direction; |
215 params.idb_index_id = idb_index_id; | 250 params.idb_index_id = idb_index_id; |
216 params.transaction_id = TransactionId(transaction); | 251 params.transaction_id = TransactionId(transaction); |
217 RenderThreadImpl::current()->Send( | 252 RenderThreadImpl::current()->Send( |
218 new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec)); | 253 new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec)); |
219 if (*ec) | 254 if (*ec) |
220 pending_callbacks_.Remove(params.response_id); | 255 pending_callbacks_.Remove(params.response_id); |
221 } | 256 } |
222 | 257 |
223 void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor( | 258 void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor( |
224 const WebIDBKeyRange& idb_key_range, | 259 const WebIDBKeyRange& idb_key_range, |
225 unsigned short direction, | 260 unsigned short direction, |
226 WebIDBCallbacks* callbacks_ptr, | 261 WebIDBCallbacks* callbacks_ptr, |
227 int32 idb_index_id, | 262 int32 idb_index_id, |
228 const WebIDBTransaction& transaction, | 263 const WebIDBTransaction& transaction, |
229 WebExceptionCode* ec) { | 264 WebExceptionCode* ec) { |
265 ResetCursorPrefetchCaches(); | |
230 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 266 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
231 IndexedDBHostMsg_IndexOpenCursor_Params params; | 267 IndexedDBHostMsg_IndexOpenCursor_Params params; |
232 params.response_id = pending_callbacks_.Add(callbacks.release()); | 268 params.response_id = pending_callbacks_.Add(callbacks.release()); |
233 // TODO(jorlow): We really should just create a Chromium abstraction for | 269 // TODO(jorlow): We really should just create a Chromium abstraction for |
234 // KeyRange rather than doing it ad-hoc like this. | 270 // KeyRange rather than doing it ad-hoc like this. |
235 params.lower_key.Set(idb_key_range.lower()); | 271 params.lower_key.Set(idb_key_range.lower()); |
236 params.upper_key.Set(idb_key_range.upper()); | 272 params.upper_key.Set(idb_key_range.upper()); |
237 params.lower_open = idb_key_range.lowerOpen(); | 273 params.lower_open = idb_key_range.lowerOpen(); |
238 params.upper_open = idb_key_range.upperOpen(); | 274 params.upper_open = idb_key_range.upperOpen(); |
239 params.direction = direction; | 275 params.direction = direction; |
240 params.idb_index_id = idb_index_id; | 276 params.idb_index_id = idb_index_id; |
241 params.transaction_id = TransactionId(transaction); | 277 params.transaction_id = TransactionId(transaction); |
242 RenderThreadImpl::current()->Send( | 278 RenderThreadImpl::current()->Send( |
243 new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec)); | 279 new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec)); |
244 if (*ec) | 280 if (*ec) |
245 pending_callbacks_.Remove(params.response_id); | 281 pending_callbacks_.Remove(params.response_id); |
246 } | 282 } |
247 | 283 |
248 void IndexedDBDispatcher::RequestIDBIndexGetObject( | 284 void IndexedDBDispatcher::RequestIDBIndexGetObject( |
249 const IndexedDBKey& key, | 285 const IndexedDBKey& key, |
250 WebIDBCallbacks* callbacks_ptr, | 286 WebIDBCallbacks* callbacks_ptr, |
251 int32 idb_index_id, | 287 int32 idb_index_id, |
252 const WebIDBTransaction& transaction, | 288 const WebIDBTransaction& transaction, |
253 WebExceptionCode* ec) { | 289 WebExceptionCode* ec) { |
290 ResetCursorPrefetchCaches(); | |
254 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 291 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
255 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 292 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
256 RenderThreadImpl::current()->Send( | 293 RenderThreadImpl::current()->Send( |
257 new IndexedDBHostMsg_IndexGetObject( | 294 new IndexedDBHostMsg_IndexGetObject( |
258 idb_index_id, response_id, key, | 295 idb_index_id, response_id, key, |
259 TransactionId(transaction), ec)); | 296 TransactionId(transaction), ec)); |
260 if (*ec) | 297 if (*ec) |
261 pending_callbacks_.Remove(response_id); | 298 pending_callbacks_.Remove(response_id); |
262 } | 299 } |
263 | 300 |
264 void IndexedDBDispatcher::RequestIDBIndexGetKey( | 301 void IndexedDBDispatcher::RequestIDBIndexGetKey( |
265 const IndexedDBKey& key, | 302 const IndexedDBKey& key, |
266 WebIDBCallbacks* callbacks_ptr, | 303 WebIDBCallbacks* callbacks_ptr, |
267 int32 idb_index_id, | 304 int32 idb_index_id, |
268 const WebIDBTransaction& transaction, | 305 const WebIDBTransaction& transaction, |
269 WebExceptionCode* ec) { | 306 WebExceptionCode* ec) { |
307 ResetCursorPrefetchCaches(); | |
270 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 308 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
271 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 309 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
272 RenderThreadImpl::current()->Send( | 310 RenderThreadImpl::current()->Send( |
273 new IndexedDBHostMsg_IndexGetKey( | 311 new IndexedDBHostMsg_IndexGetKey( |
274 idb_index_id, response_id, key, | 312 idb_index_id, response_id, key, |
275 TransactionId(transaction), ec)); | 313 TransactionId(transaction), ec)); |
276 if (*ec) | 314 if (*ec) |
277 pending_callbacks_.Remove(response_id); | 315 pending_callbacks_.Remove(response_id); |
278 } | 316 } |
279 | 317 |
280 void IndexedDBDispatcher::RequestIDBObjectStoreGet( | 318 void IndexedDBDispatcher::RequestIDBObjectStoreGet( |
281 const IndexedDBKey& key, | 319 const IndexedDBKey& key, |
282 WebIDBCallbacks* callbacks_ptr, | 320 WebIDBCallbacks* callbacks_ptr, |
283 int32 idb_object_store_id, | 321 int32 idb_object_store_id, |
284 const WebIDBTransaction& transaction, | 322 const WebIDBTransaction& transaction, |
285 WebExceptionCode* ec) { | 323 WebExceptionCode* ec) { |
324 ResetCursorPrefetchCaches(); | |
286 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 325 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
287 | 326 |
288 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 327 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
289 RenderThreadImpl::current()->Send( | 328 RenderThreadImpl::current()->Send( |
290 new IndexedDBHostMsg_ObjectStoreGet( | 329 new IndexedDBHostMsg_ObjectStoreGet( |
291 idb_object_store_id, response_id, | 330 idb_object_store_id, response_id, |
292 key, TransactionId(transaction), ec)); | 331 key, TransactionId(transaction), ec)); |
293 if (*ec) | 332 if (*ec) |
294 pending_callbacks_.Remove(response_id); | 333 pending_callbacks_.Remove(response_id); |
295 } | 334 } |
296 | 335 |
297 void IndexedDBDispatcher::RequestIDBObjectStorePut( | 336 void IndexedDBDispatcher::RequestIDBObjectStorePut( |
298 const content::SerializedScriptValue& value, | 337 const content::SerializedScriptValue& value, |
299 const IndexedDBKey& key, | 338 const IndexedDBKey& key, |
300 WebKit::WebIDBObjectStore::PutMode put_mode, | 339 WebKit::WebIDBObjectStore::PutMode put_mode, |
301 WebIDBCallbacks* callbacks_ptr, | 340 WebIDBCallbacks* callbacks_ptr, |
302 int32 idb_object_store_id, | 341 int32 idb_object_store_id, |
303 const WebIDBTransaction& transaction, | 342 const WebIDBTransaction& transaction, |
304 WebExceptionCode* ec) { | 343 WebExceptionCode* ec) { |
344 ResetCursorPrefetchCaches(); | |
305 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 345 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
306 IndexedDBHostMsg_ObjectStorePut_Params params; | 346 IndexedDBHostMsg_ObjectStorePut_Params params; |
307 params.idb_object_store_id = idb_object_store_id; | 347 params.idb_object_store_id = idb_object_store_id; |
308 params.response_id = pending_callbacks_.Add(callbacks.release()); | 348 params.response_id = pending_callbacks_.Add(callbacks.release()); |
309 params.serialized_value = value; | 349 params.serialized_value = value; |
310 params.key = key; | 350 params.key = key; |
311 params.put_mode = put_mode; | 351 params.put_mode = put_mode; |
312 params.transaction_id = TransactionId(transaction); | 352 params.transaction_id = TransactionId(transaction); |
313 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_ObjectStorePut( | 353 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_ObjectStorePut( |
314 params, ec)); | 354 params, ec)); |
315 if (*ec) | 355 if (*ec) |
316 pending_callbacks_.Remove(params.response_id); | 356 pending_callbacks_.Remove(params.response_id); |
317 } | 357 } |
318 | 358 |
319 void IndexedDBDispatcher::RequestIDBObjectStoreDelete( | 359 void IndexedDBDispatcher::RequestIDBObjectStoreDelete( |
320 const IndexedDBKey& key, | 360 const IndexedDBKey& key, |
321 WebIDBCallbacks* callbacks_ptr, | 361 WebIDBCallbacks* callbacks_ptr, |
322 int32 idb_object_store_id, | 362 int32 idb_object_store_id, |
323 const WebIDBTransaction& transaction, | 363 const WebIDBTransaction& transaction, |
324 WebExceptionCode* ec) { | 364 WebExceptionCode* ec) { |
365 ResetCursorPrefetchCaches(); | |
325 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 366 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
326 | 367 |
327 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 368 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
328 RenderThreadImpl::current()->Send( | 369 RenderThreadImpl::current()->Send( |
329 new IndexedDBHostMsg_ObjectStoreDelete( | 370 new IndexedDBHostMsg_ObjectStoreDelete( |
330 idb_object_store_id, response_id, | 371 idb_object_store_id, response_id, |
331 key, TransactionId(transaction), ec)); | 372 key, TransactionId(transaction), ec)); |
332 if (*ec) | 373 if (*ec) |
333 pending_callbacks_.Remove(response_id); | 374 pending_callbacks_.Remove(response_id); |
334 } | 375 } |
335 | 376 |
336 void IndexedDBDispatcher::RequestIDBObjectStoreClear( | 377 void IndexedDBDispatcher::RequestIDBObjectStoreClear( |
337 WebIDBCallbacks* callbacks_ptr, | 378 WebIDBCallbacks* callbacks_ptr, |
338 int32 idb_object_store_id, | 379 int32 idb_object_store_id, |
339 const WebIDBTransaction& transaction, | 380 const WebIDBTransaction& transaction, |
340 WebExceptionCode* ec) { | 381 WebExceptionCode* ec) { |
382 ResetCursorPrefetchCaches(); | |
341 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 383 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
342 | 384 |
343 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 385 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
344 RenderThreadImpl::current()->Send( | 386 RenderThreadImpl::current()->Send( |
345 new IndexedDBHostMsg_ObjectStoreClear( | 387 new IndexedDBHostMsg_ObjectStoreClear( |
346 idb_object_store_id, response_id, | 388 idb_object_store_id, response_id, |
347 TransactionId(transaction), ec)); | 389 TransactionId(transaction), ec)); |
348 if (*ec) | 390 if (*ec) |
349 pending_callbacks_.Remove(response_id); | 391 pending_callbacks_.Remove(response_id); |
350 } | 392 } |
351 | 393 |
352 void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( | 394 void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( |
353 const WebIDBKeyRange& idb_key_range, | 395 const WebIDBKeyRange& idb_key_range, |
354 unsigned short direction, | 396 unsigned short direction, |
355 WebIDBCallbacks* callbacks_ptr, | 397 WebIDBCallbacks* callbacks_ptr, |
356 int32 idb_object_store_id, | 398 int32 idb_object_store_id, |
357 const WebIDBTransaction& transaction, | 399 const WebIDBTransaction& transaction, |
358 WebExceptionCode* ec) { | 400 WebExceptionCode* ec) { |
401 ResetCursorPrefetchCaches(); | |
359 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 402 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
360 IndexedDBHostMsg_ObjectStoreOpenCursor_Params params; | 403 IndexedDBHostMsg_ObjectStoreOpenCursor_Params params; |
361 params.response_id = pending_callbacks_.Add(callbacks.release()); | 404 params.response_id = pending_callbacks_.Add(callbacks.release()); |
362 params.lower_key.Set(idb_key_range.lower()); | 405 params.lower_key.Set(idb_key_range.lower()); |
363 params.upper_key.Set(idb_key_range.upper()); | 406 params.upper_key.Set(idb_key_range.upper()); |
364 params.lower_open = idb_key_range.lowerOpen(); | 407 params.lower_open = idb_key_range.lowerOpen(); |
365 params.upper_open = idb_key_range.upperOpen(); | 408 params.upper_open = idb_key_range.upperOpen(); |
366 params.direction = direction; | 409 params.direction = direction; |
367 params.idb_object_store_id = idb_object_store_id; | 410 params.idb_object_store_id = idb_object_store_id; |
368 params.transaction_id = TransactionId(transaction); | 411 params.transaction_id = TransactionId(transaction); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id]; | 494 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id]; |
452 DCHECK(cursor); | 495 DCHECK(cursor); |
453 cursor->SetKeyAndValue(key, primary_key, value); | 496 cursor->SetKeyAndValue(key, primary_key, value); |
454 | 497 |
455 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 498 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
456 callbacks->onSuccessWithContinuation(); | 499 callbacks->onSuccessWithContinuation(); |
457 | 500 |
458 pending_callbacks_.Remove(response_id); | 501 pending_callbacks_.Remove(response_id); |
459 } | 502 } |
460 | 503 |
504 void IndexedDBDispatcher::OnSuccessCursorPrefetch( | |
505 int32 response_id, | |
506 int32 cursor_id, | |
507 const std::vector<IndexedDBKey>& keys, | |
508 const std::vector<IndexedDBKey>& primary_keys, | |
509 const std::vector<content::SerializedScriptValue>& values) { | |
510 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id]; | |
511 DCHECK(cursor); | |
512 cursor->SetPrefetchData(keys, primary_keys, values); | |
513 | |
514 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | |
515 cursor->CachedContinue(callbacks); | |
516 pending_callbacks_.Remove(response_id); | |
517 } | |
518 | |
461 void IndexedDBDispatcher::OnBlocked(int32 response_id) { | 519 void IndexedDBDispatcher::OnBlocked(int32 response_id) { |
462 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 520 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
463 callbacks->onBlocked(); | 521 callbacks->onBlocked(); |
464 } | 522 } |
465 | 523 |
466 void IndexedDBDispatcher::OnError(int32 response_id, int code, | 524 void IndexedDBDispatcher::OnError(int32 response_id, int code, |
467 const string16& message) { | 525 const string16& message) { |
468 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 526 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
469 callbacks->onError(WebIDBDatabaseError(code, message)); | 527 callbacks->onError(WebIDBDatabaseError(code, message)); |
470 pending_callbacks_.Remove(response_id); | 528 pending_callbacks_.Remove(response_id); |
(...skipping 15 matching lines...) Expand all Loading... | |
486 | 544 |
487 void IndexedDBDispatcher::OnVersionChange(int32 database_id, | 545 void IndexedDBDispatcher::OnVersionChange(int32 database_id, |
488 const string16& newVersion) { | 546 const string16& newVersion) { |
489 WebIDBDatabaseCallbacks* callbacks = | 547 WebIDBDatabaseCallbacks* callbacks = |
490 pending_database_callbacks_.Lookup(database_id); | 548 pending_database_callbacks_.Lookup(database_id); |
491 // callbacks would be NULL if a versionchange event is received after close | 549 // callbacks would be NULL if a versionchange event is received after close |
492 // has been called. | 550 // has been called. |
493 if (callbacks) | 551 if (callbacks) |
494 callbacks->onVersionChange(newVersion); | 552 callbacks->onVersionChange(newVersion); |
495 } | 553 } |
554 | |
555 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { | |
jsbell
2011/11/28 20:29:16
Should this at least be scoped to database_id? Is
hans
2011/11/29 14:44:34
That would make sense, but it doesn't make any dif
| |
556 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | |
557 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | |
558 if (i->first == exception_cursor_id) | |
559 continue; | |
560 i->second->ResetPrefetchCache(); | |
561 } | |
562 } | |
OLD | NEW |