| 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) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 67 | 69 |
| 68 void IndexedDBDispatcher::Send(IPC::Message* msg) { | 70 void IndexedDBDispatcher::Send(IPC::Message* msg) { |
| 69 ChildThread::current()->Send(msg); | 71 ChildThread::current()->Send(msg); |
| 70 } | 72 } |
| 71 | 73 |
| 72 void IndexedDBDispatcher::RequestIDBCursorUpdate( | 74 void IndexedDBDispatcher::RequestIDBCursorUpdate( |
| 73 const content::SerializedScriptValue& value, | 75 const content::SerializedScriptValue& value, |
| 74 WebIDBCallbacks* callbacks_ptr, | 76 WebIDBCallbacks* callbacks_ptr, |
| 75 int32 idb_cursor_id, | 77 int32 idb_cursor_id, |
| 76 WebExceptionCode* ec) { | 78 WebExceptionCode* ec) { |
| 79 ResetCursorPrefetchCaches(); |
| 77 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 80 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 78 | 81 |
| 79 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 82 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 80 Send( | 83 Send( |
| 81 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, response_id, value, ec)); | 84 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, response_id, value, ec)); |
| 82 if (*ec) | 85 if (*ec) |
| 83 pending_callbacks_.Remove(response_id); | 86 pending_callbacks_.Remove(response_id); |
| 84 } | 87 } |
| 85 | 88 |
| 86 void IndexedDBDispatcher::RequestIDBCursorContinue( | 89 void IndexedDBDispatcher::RequestIDBCursorContinue( |
| 87 const IndexedDBKey& key, | 90 const IndexedDBKey& key, |
| 88 WebIDBCallbacks* callbacks_ptr, | 91 WebIDBCallbacks* callbacks_ptr, |
| 89 int32 idb_cursor_id, | 92 int32 idb_cursor_id, |
| 90 WebExceptionCode* ec) { | 93 WebExceptionCode* ec) { |
| 94 // Reset all cursor prefetch caches except for this cursor. |
| 95 ResetCursorPrefetchCaches(idb_cursor_id); |
| 96 |
| 91 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 97 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 92 | 98 |
| 93 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 99 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 94 Send( | 100 Send( |
| 95 new IndexedDBHostMsg_CursorContinue(idb_cursor_id, response_id, key, ec)); | 101 new IndexedDBHostMsg_CursorContinue(idb_cursor_id, response_id, key, ec)); |
| 96 if (*ec) | 102 if (*ec) |
| 97 pending_callbacks_.Remove(response_id); | 103 pending_callbacks_.Remove(response_id); |
| 98 } | 104 } |
| 99 | 105 |
| 106 void IndexedDBDispatcher::RequestIDBCursorPrefetch( |
| 107 int n, |
| 108 WebIDBCallbacks* callbacks_ptr, |
| 109 int32 idb_cursor_id, |
| 110 WebExceptionCode* ec) { |
| 111 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 112 |
| 113 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 114 RenderThreadImpl::current()->Send( |
| 115 new IndexedDBHostMsg_CursorPrefetch(idb_cursor_id, response_id, n, ec)); |
| 116 if (*ec) |
| 117 pending_callbacks_.Remove(response_id); |
| 118 } |
| 119 |
| 120 void IndexedDBDispatcher::RequestIDBCursorPrefetchReset( |
| 121 int used_prefetches, int unused_prefetches, int32 idb_cursor_id) { |
| 122 RenderThreadImpl::current()->Send( |
| 123 new IndexedDBHostMsg_CursorPrefetchReset(idb_cursor_id, used_prefetches, |
| 124 unused_prefetches)); |
| 125 } |
| 126 |
| 100 void IndexedDBDispatcher::RequestIDBCursorDelete( | 127 void IndexedDBDispatcher::RequestIDBCursorDelete( |
| 101 WebIDBCallbacks* callbacks_ptr, | 128 WebIDBCallbacks* callbacks_ptr, |
| 102 int32 idb_cursor_id, | 129 int32 idb_cursor_id, |
| 103 WebExceptionCode* ec) { | 130 WebExceptionCode* ec) { |
| 131 ResetCursorPrefetchCaches(); |
| 104 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 132 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 105 | 133 |
| 106 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 134 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 107 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, response_id, ec)); | 135 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, response_id, ec)); |
| 108 if (*ec) | 136 if (*ec) |
| 109 pending_callbacks_.Remove(response_id); | 137 pending_callbacks_.Remove(response_id); |
| 110 } | 138 } |
| 111 | 139 |
| 112 void IndexedDBDispatcher::RequestIDBFactoryOpen( | 140 void IndexedDBDispatcher::RequestIDBFactoryOpen( |
| 113 const string16& name, | 141 const string16& name, |
| 114 WebIDBCallbacks* callbacks_ptr, | 142 WebIDBCallbacks* callbacks_ptr, |
| 115 const string16& origin, | 143 const string16& origin, |
| 116 WebFrame* web_frame) { | 144 WebFrame* web_frame) { |
| 145 ResetCursorPrefetchCaches(); |
| 117 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 146 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 118 | 147 |
| 119 if (!web_frame) | 148 if (!web_frame) |
| 120 return; // We must be shutting down. | 149 return; // We must be shutting down. |
| 121 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 150 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
| 122 if (!render_view) | 151 if (!render_view) |
| 123 return; // We must be shutting down. | 152 return; // We must be shutting down. |
| 124 | 153 |
| 125 IndexedDBHostMsg_FactoryOpen_Params params; | 154 IndexedDBHostMsg_FactoryOpen_Params params; |
| 126 params.response_id = pending_callbacks_.Add(callbacks.release()); | 155 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 127 params.origin = origin; | 156 params.origin = origin; |
| 128 params.name = name; | 157 params.name = name; |
| 129 Send(new IndexedDBHostMsg_FactoryOpen(params)); | 158 Send(new IndexedDBHostMsg_FactoryOpen(params)); |
| 130 } | 159 } |
| 131 | 160 |
| 132 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( | 161 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( |
| 133 WebIDBCallbacks* callbacks_ptr, | 162 WebIDBCallbacks* callbacks_ptr, |
| 134 const string16& origin, | 163 const string16& origin, |
| 135 WebFrame* web_frame) { | 164 WebFrame* web_frame) { |
| 165 ResetCursorPrefetchCaches(); |
| 136 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 166 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 137 | 167 |
| 138 if (!web_frame) | 168 if (!web_frame) |
| 139 return; // We must be shutting down. | 169 return; // We must be shutting down. |
| 140 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 170 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
| 141 if (!render_view) | 171 if (!render_view) |
| 142 return; // We must be shutting down. | 172 return; // We must be shutting down. |
| 143 | 173 |
| 144 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; | 174 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; |
| 145 params.response_id = pending_callbacks_.Add(callbacks.release()); | 175 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 146 params.origin = origin; | 176 params.origin = origin; |
| 147 Send(new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); | 177 Send(new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); |
| 148 } | 178 } |
| 149 | 179 |
| 150 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( | 180 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( |
| 151 const string16& name, | 181 const string16& name, |
| 152 WebIDBCallbacks* callbacks_ptr, | 182 WebIDBCallbacks* callbacks_ptr, |
| 153 const string16& origin, | 183 const string16& origin, |
| 154 WebFrame* web_frame) { | 184 WebFrame* web_frame) { |
| 185 ResetCursorPrefetchCaches(); |
| 155 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 186 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 156 | 187 |
| 157 if (!web_frame) | 188 if (!web_frame) |
| 158 return; // We must be shutting down. | 189 return; // We must be shutting down. |
| 159 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 190 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
| 160 if (!render_view) | 191 if (!render_view) |
| 161 return; // We must be shutting down. | 192 return; // We must be shutting down. |
| 162 | 193 |
| 163 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; | 194 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; |
| 164 params.response_id = pending_callbacks_.Add(callbacks.release()); | 195 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 165 params.origin = origin; | 196 params.origin = origin; |
| 166 params.name = name; | 197 params.name = name; |
| 167 Send(new IndexedDBHostMsg_FactoryDeleteDatabase(params)); | 198 Send(new IndexedDBHostMsg_FactoryDeleteDatabase(params)); |
| 168 } | 199 } |
| 169 | 200 |
| 170 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { | 201 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { |
| 202 ResetCursorPrefetchCaches(); |
| 171 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); | 203 Send(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 Send(new IndexedDBHostMsg_DatabaseOpen(response_id, idb_database_id)); | 214 Send(new IndexedDBHostMsg_DatabaseOpen(response_id, idb_database_id)); |
| 182 } | 215 } |
| 183 | 216 |
| 184 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( | 217 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( |
| 185 const string16& version, | 218 const string16& version, |
| 186 WebIDBCallbacks* callbacks_ptr, | 219 WebIDBCallbacks* callbacks_ptr, |
| 187 int32 idb_database_id, | 220 int32 idb_database_id, |
| 188 WebExceptionCode* ec) { | 221 WebExceptionCode* ec) { |
| 222 ResetCursorPrefetchCaches(); |
| 189 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 223 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 190 | 224 |
| 191 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 225 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 192 Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, response_id, | 226 Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, response_id, |
| 193 version, ec)); | 227 version, ec)); |
| 194 if (*ec) | 228 if (*ec) |
| 195 pending_callbacks_.Remove(response_id); | 229 pending_callbacks_.Remove(response_id); |
| 196 } | 230 } |
| 197 | 231 |
| 198 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( | 232 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( |
| 199 const WebIDBKeyRange& idb_key_range, | 233 const WebIDBKeyRange& idb_key_range, |
| 200 unsigned short direction, | 234 unsigned short direction, |
| 201 WebIDBCallbacks* callbacks_ptr, | 235 WebIDBCallbacks* callbacks_ptr, |
| 202 int32 idb_index_id, | 236 int32 idb_index_id, |
| 203 const WebIDBTransaction& transaction, | 237 const WebIDBTransaction& transaction, |
| 204 WebExceptionCode* ec) { | 238 WebExceptionCode* ec) { |
| 239 ResetCursorPrefetchCaches(); |
| 205 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 240 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 206 IndexedDBHostMsg_IndexOpenCursor_Params params; | 241 IndexedDBHostMsg_IndexOpenCursor_Params params; |
| 207 params.response_id = pending_callbacks_.Add(callbacks.release()); | 242 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 208 params.lower_key.Set(idb_key_range.lower()); | 243 params.lower_key.Set(idb_key_range.lower()); |
| 209 params.upper_key.Set(idb_key_range.upper()); | 244 params.upper_key.Set(idb_key_range.upper()); |
| 210 params.lower_open = idb_key_range.lowerOpen(); | 245 params.lower_open = idb_key_range.lowerOpen(); |
| 211 params.upper_open = idb_key_range.upperOpen(); | 246 params.upper_open = idb_key_range.upperOpen(); |
| 212 params.direction = direction; | 247 params.direction = direction; |
| 213 params.idb_index_id = idb_index_id; | 248 params.idb_index_id = idb_index_id; |
| 214 params.transaction_id = TransactionId(transaction); | 249 params.transaction_id = TransactionId(transaction); |
| 215 Send(new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec)); | 250 Send(new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec)); |
| 216 if (*ec) | 251 if (*ec) |
| 217 pending_callbacks_.Remove(params.response_id); | 252 pending_callbacks_.Remove(params.response_id); |
| 218 } | 253 } |
| 219 | 254 |
| 220 void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor( | 255 void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor( |
| 221 const WebIDBKeyRange& idb_key_range, | 256 const WebIDBKeyRange& idb_key_range, |
| 222 unsigned short direction, | 257 unsigned short direction, |
| 223 WebIDBCallbacks* callbacks_ptr, | 258 WebIDBCallbacks* callbacks_ptr, |
| 224 int32 idb_index_id, | 259 int32 idb_index_id, |
| 225 const WebIDBTransaction& transaction, | 260 const WebIDBTransaction& transaction, |
| 226 WebExceptionCode* ec) { | 261 WebExceptionCode* ec) { |
| 262 ResetCursorPrefetchCaches(); |
| 227 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 263 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 228 IndexedDBHostMsg_IndexOpenCursor_Params params; | 264 IndexedDBHostMsg_IndexOpenCursor_Params params; |
| 229 params.response_id = pending_callbacks_.Add(callbacks.release()); | 265 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 230 // TODO(jorlow): We really should just create a Chromium abstraction for | 266 // TODO(jorlow): We really should just create a Chromium abstraction for |
| 231 // KeyRange rather than doing it ad-hoc like this. | 267 // KeyRange rather than doing it ad-hoc like this. |
| 232 params.lower_key.Set(idb_key_range.lower()); | 268 params.lower_key.Set(idb_key_range.lower()); |
| 233 params.upper_key.Set(idb_key_range.upper()); | 269 params.upper_key.Set(idb_key_range.upper()); |
| 234 params.lower_open = idb_key_range.lowerOpen(); | 270 params.lower_open = idb_key_range.lowerOpen(); |
| 235 params.upper_open = idb_key_range.upperOpen(); | 271 params.upper_open = idb_key_range.upperOpen(); |
| 236 params.direction = direction; | 272 params.direction = direction; |
| 237 params.idb_index_id = idb_index_id; | 273 params.idb_index_id = idb_index_id; |
| 238 params.transaction_id = TransactionId(transaction); | 274 params.transaction_id = TransactionId(transaction); |
| 239 Send(new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec)); | 275 Send(new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec)); |
| 240 if (*ec) | 276 if (*ec) |
| 241 pending_callbacks_.Remove(params.response_id); | 277 pending_callbacks_.Remove(params.response_id); |
| 242 } | 278 } |
| 243 | 279 |
| 244 void IndexedDBDispatcher::RequestIDBIndexGetObject( | 280 void IndexedDBDispatcher::RequestIDBIndexGetObject( |
| 245 const IndexedDBKey& key, | 281 const IndexedDBKey& key, |
| 246 WebIDBCallbacks* callbacks_ptr, | 282 WebIDBCallbacks* callbacks_ptr, |
| 247 int32 idb_index_id, | 283 int32 idb_index_id, |
| 248 const WebIDBTransaction& transaction, | 284 const WebIDBTransaction& transaction, |
| 249 WebExceptionCode* ec) { | 285 WebExceptionCode* ec) { |
| 286 ResetCursorPrefetchCaches(); |
| 250 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 287 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 251 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 288 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 252 Send(new IndexedDBHostMsg_IndexGetObject(idb_index_id, response_id, key, | 289 Send(new IndexedDBHostMsg_IndexGetObject(idb_index_id, response_id, key, |
| 253 TransactionId(transaction), ec)); | 290 TransactionId(transaction), ec)); |
| 254 if (*ec) | 291 if (*ec) |
| 255 pending_callbacks_.Remove(response_id); | 292 pending_callbacks_.Remove(response_id); |
| 256 } | 293 } |
| 257 | 294 |
| 258 void IndexedDBDispatcher::RequestIDBIndexGetKey( | 295 void IndexedDBDispatcher::RequestIDBIndexGetKey( |
| 259 const IndexedDBKey& key, | 296 const IndexedDBKey& key, |
| 260 WebIDBCallbacks* callbacks_ptr, | 297 WebIDBCallbacks* callbacks_ptr, |
| 261 int32 idb_index_id, | 298 int32 idb_index_id, |
| 262 const WebIDBTransaction& transaction, | 299 const WebIDBTransaction& transaction, |
| 263 WebExceptionCode* ec) { | 300 WebExceptionCode* ec) { |
| 301 ResetCursorPrefetchCaches(); |
| 264 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 302 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 265 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 303 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 266 Send(new IndexedDBHostMsg_IndexGetKey( | 304 Send(new IndexedDBHostMsg_IndexGetKey( |
| 267 idb_index_id, response_id, key, | 305 idb_index_id, response_id, key, |
| 268 TransactionId(transaction), ec)); | 306 TransactionId(transaction), ec)); |
| 269 if (*ec) | 307 if (*ec) |
| 270 pending_callbacks_.Remove(response_id); | 308 pending_callbacks_.Remove(response_id); |
| 271 } | 309 } |
| 272 | 310 |
| 273 void IndexedDBDispatcher::RequestIDBObjectStoreGet( | 311 void IndexedDBDispatcher::RequestIDBObjectStoreGet( |
| 274 const IndexedDBKey& key, | 312 const IndexedDBKey& key, |
| 275 WebIDBCallbacks* callbacks_ptr, | 313 WebIDBCallbacks* callbacks_ptr, |
| 276 int32 idb_object_store_id, | 314 int32 idb_object_store_id, |
| 277 const WebIDBTransaction& transaction, | 315 const WebIDBTransaction& transaction, |
| 278 WebExceptionCode* ec) { | 316 WebExceptionCode* ec) { |
| 317 ResetCursorPrefetchCaches(); |
| 279 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 318 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 280 | 319 |
| 281 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 320 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 282 Send(new IndexedDBHostMsg_ObjectStoreGet( | 321 Send(new IndexedDBHostMsg_ObjectStoreGet( |
| 283 idb_object_store_id, response_id, | 322 idb_object_store_id, response_id, |
| 284 key, TransactionId(transaction), ec)); | 323 key, TransactionId(transaction), ec)); |
| 285 if (*ec) | 324 if (*ec) |
| 286 pending_callbacks_.Remove(response_id); | 325 pending_callbacks_.Remove(response_id); |
| 287 } | 326 } |
| 288 | 327 |
| 289 void IndexedDBDispatcher::RequestIDBObjectStorePut( | 328 void IndexedDBDispatcher::RequestIDBObjectStorePut( |
| 290 const content::SerializedScriptValue& value, | 329 const content::SerializedScriptValue& value, |
| 291 const IndexedDBKey& key, | 330 const IndexedDBKey& key, |
| 292 WebKit::WebIDBObjectStore::PutMode put_mode, | 331 WebKit::WebIDBObjectStore::PutMode put_mode, |
| 293 WebIDBCallbacks* callbacks_ptr, | 332 WebIDBCallbacks* callbacks_ptr, |
| 294 int32 idb_object_store_id, | 333 int32 idb_object_store_id, |
| 295 const WebIDBTransaction& transaction, | 334 const WebIDBTransaction& transaction, |
| 296 WebExceptionCode* ec) { | 335 WebExceptionCode* ec) { |
| 336 ResetCursorPrefetchCaches(); |
| 297 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 337 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 298 IndexedDBHostMsg_ObjectStorePut_Params params; | 338 IndexedDBHostMsg_ObjectStorePut_Params params; |
| 299 params.idb_object_store_id = idb_object_store_id; | 339 params.idb_object_store_id = idb_object_store_id; |
| 300 params.response_id = pending_callbacks_.Add(callbacks.release()); | 340 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 301 params.serialized_value = value; | 341 params.serialized_value = value; |
| 302 params.key = key; | 342 params.key = key; |
| 303 params.put_mode = put_mode; | 343 params.put_mode = put_mode; |
| 304 params.transaction_id = TransactionId(transaction); | 344 params.transaction_id = TransactionId(transaction); |
| 305 Send(new IndexedDBHostMsg_ObjectStorePut(params, ec)); | 345 Send(new IndexedDBHostMsg_ObjectStorePut(params, ec)); |
| 306 if (*ec) | 346 if (*ec) |
| 307 pending_callbacks_.Remove(params.response_id); | 347 pending_callbacks_.Remove(params.response_id); |
| 308 } | 348 } |
| 309 | 349 |
| 310 void IndexedDBDispatcher::RequestIDBObjectStoreDelete( | 350 void IndexedDBDispatcher::RequestIDBObjectStoreDelete( |
| 311 const IndexedDBKey& key, | 351 const IndexedDBKey& key, |
| 312 WebIDBCallbacks* callbacks_ptr, | 352 WebIDBCallbacks* callbacks_ptr, |
| 313 int32 idb_object_store_id, | 353 int32 idb_object_store_id, |
| 314 const WebIDBTransaction& transaction, | 354 const WebIDBTransaction& transaction, |
| 315 WebExceptionCode* ec) { | 355 WebExceptionCode* ec) { |
| 356 ResetCursorPrefetchCaches(); |
| 316 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 357 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 317 | 358 |
| 318 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 359 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 319 Send(new IndexedDBHostMsg_ObjectStoreDelete( | 360 Send(new IndexedDBHostMsg_ObjectStoreDelete( |
| 320 idb_object_store_id, response_id, key, TransactionId(transaction), ec)); | 361 idb_object_store_id, response_id, key, TransactionId(transaction), ec)); |
| 321 if (*ec) | 362 if (*ec) |
| 322 pending_callbacks_.Remove(response_id); | 363 pending_callbacks_.Remove(response_id); |
| 323 } | 364 } |
| 324 | 365 |
| 325 void IndexedDBDispatcher::RequestIDBObjectStoreClear( | 366 void IndexedDBDispatcher::RequestIDBObjectStoreClear( |
| 326 WebIDBCallbacks* callbacks_ptr, | 367 WebIDBCallbacks* callbacks_ptr, |
| 327 int32 idb_object_store_id, | 368 int32 idb_object_store_id, |
| 328 const WebIDBTransaction& transaction, | 369 const WebIDBTransaction& transaction, |
| 329 WebExceptionCode* ec) { | 370 WebExceptionCode* ec) { |
| 371 ResetCursorPrefetchCaches(); |
| 330 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 372 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 331 | 373 |
| 332 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 374 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 333 Send(new IndexedDBHostMsg_ObjectStoreClear( | 375 Send(new IndexedDBHostMsg_ObjectStoreClear( |
| 334 idb_object_store_id, response_id, TransactionId(transaction), ec)); | 376 idb_object_store_id, response_id, TransactionId(transaction), ec)); |
| 335 if (*ec) | 377 if (*ec) |
| 336 pending_callbacks_.Remove(response_id); | 378 pending_callbacks_.Remove(response_id); |
| 337 } | 379 } |
| 338 | 380 |
| 339 void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( | 381 void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( |
| 340 const WebIDBKeyRange& idb_key_range, | 382 const WebIDBKeyRange& idb_key_range, |
| 341 unsigned short direction, | 383 unsigned short direction, |
| 342 WebIDBCallbacks* callbacks_ptr, | 384 WebIDBCallbacks* callbacks_ptr, |
| 343 int32 idb_object_store_id, | 385 int32 idb_object_store_id, |
| 344 const WebIDBTransaction& transaction, | 386 const WebIDBTransaction& transaction, |
| 345 WebExceptionCode* ec) { | 387 WebExceptionCode* ec) { |
| 388 ResetCursorPrefetchCaches(); |
| 346 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 389 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 347 IndexedDBHostMsg_ObjectStoreOpenCursor_Params params; | 390 IndexedDBHostMsg_ObjectStoreOpenCursor_Params params; |
| 348 params.response_id = pending_callbacks_.Add(callbacks.release()); | 391 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 349 params.lower_key.Set(idb_key_range.lower()); | 392 params.lower_key.Set(idb_key_range.lower()); |
| 350 params.upper_key.Set(idb_key_range.upper()); | 393 params.upper_key.Set(idb_key_range.upper()); |
| 351 params.lower_open = idb_key_range.lowerOpen(); | 394 params.lower_open = idb_key_range.lowerOpen(); |
| 352 params.upper_open = idb_key_range.upperOpen(); | 395 params.upper_open = idb_key_range.upperOpen(); |
| 353 params.direction = direction; | 396 params.direction = direction; |
| 354 params.idb_object_store_id = idb_object_store_id; | 397 params.idb_object_store_id = idb_object_store_id; |
| 355 params.transaction_id = TransactionId(transaction); | 398 params.transaction_id = TransactionId(transaction); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 cursor->SetKeyAndValue(key, primary_key, value); | 494 cursor->SetKeyAndValue(key, primary_key, value); |
| 452 | 495 |
| 453 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 496 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| 454 if (!callbacks) | 497 if (!callbacks) |
| 455 return; | 498 return; |
| 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 if (!callbacks) | 527 if (!callbacks) |
| 470 return; | 528 return; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 493 void IndexedDBDispatcher::OnVersionChange(int32 database_id, | 551 void IndexedDBDispatcher::OnVersionChange(int32 database_id, |
| 494 const string16& newVersion) { | 552 const string16& newVersion) { |
| 495 WebIDBDatabaseCallbacks* callbacks = | 553 WebIDBDatabaseCallbacks* callbacks = |
| 496 pending_database_callbacks_.Lookup(database_id); | 554 pending_database_callbacks_.Lookup(database_id); |
| 497 // callbacks would be NULL if a versionchange event is received after close | 555 // callbacks would be NULL if a versionchange event is received after close |
| 498 // has been called. | 556 // has been called. |
| 499 if (!callbacks) | 557 if (!callbacks) |
| 500 return; | 558 return; |
| 501 callbacks->onVersionChange(newVersion); | 559 callbacks->onVersionChange(newVersion); |
| 502 } | 560 } |
| 561 |
| 562 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { |
| 563 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| 564 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 565 if (i->first == exception_cursor_id) |
| 566 continue; |
| 567 i->second->ResetPrefetchCache(); |
| 568 } |
| 569 } |
| OLD | NEW |