Chromium Code Reviews| 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 #include "content/common_child/indexed_db/indexed_db_dispatcher.h" | 5 #include "content/common_child/indexed_db/indexed_db_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 } | 70 } |
| 71 if (g_idb_dispatcher_tls.Pointer()->Get()) | 71 if (g_idb_dispatcher_tls.Pointer()->Get()) |
| 72 return g_idb_dispatcher_tls.Pointer()->Get(); | 72 return g_idb_dispatcher_tls.Pointer()->Get(); |
| 73 | 73 |
| 74 IndexedDBDispatcher* dispatcher = new IndexedDBDispatcher; | 74 IndexedDBDispatcher* dispatcher = new IndexedDBDispatcher; |
| 75 if (WorkerTaskRunner::Instance()->CurrentWorkerId()) | 75 if (WorkerTaskRunner::Instance()->CurrentWorkerId()) |
| 76 webkit_glue::WorkerTaskRunner::Instance()->AddStopObserver(dispatcher); | 76 webkit_glue::WorkerTaskRunner::Instance()->AddStopObserver(dispatcher); |
| 77 return dispatcher; | 77 return dispatcher; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void IndexedDBDispatcher::OnWorkerRunLoopStopped() { | 80 void IndexedDBDispatcher::OnWorkerRunLoopStopped() { delete this; } |
|
jsbell
2013/06/03 17:52:27
more clang-format...
| |
| 81 delete this; | |
| 82 } | |
| 83 | 81 |
| 84 WebIDBMetadata IndexedDBDispatcher::ConvertMetadata( | 82 WebIDBMetadata IndexedDBDispatcher::ConvertMetadata( |
| 85 const IndexedDBDatabaseMetadata& idb_metadata) { | 83 const IndexedDBDatabaseMetadata& idb_metadata) { |
| 86 WebIDBMetadata web_metadata; | 84 WebIDBMetadata web_metadata; |
| 87 web_metadata.id = idb_metadata.id; | 85 web_metadata.id = idb_metadata.id; |
| 88 web_metadata.name = idb_metadata.name; | 86 web_metadata.name = idb_metadata.name; |
| 89 web_metadata.version = idb_metadata.version; | 87 web_metadata.version = idb_metadata.version; |
| 90 web_metadata.intVersion = idb_metadata.int_version; | 88 web_metadata.intVersion = idb_metadata.int_version; |
| 91 web_metadata.maxObjectStoreId = idb_metadata.max_object_store_id; | 89 web_metadata.maxObjectStoreId = idb_metadata.max_object_store_id; |
| 92 web_metadata.objectStores = WebVector<WebIDBMetadata::ObjectStore>( | 90 web_metadata.objectStores = |
| 93 idb_metadata.object_stores.size()); | 91 WebVector<WebIDBMetadata::ObjectStore>(idb_metadata.object_stores.size()); |
| 94 | 92 |
| 95 for (size_t i = 0; i < idb_metadata.object_stores.size(); ++i) { | 93 for (size_t i = 0; i < idb_metadata.object_stores.size(); ++i) { |
| 96 const IndexedDBObjectStoreMetadata& idb_store_metadata = | 94 const IndexedDBObjectStoreMetadata& idb_store_metadata = |
| 97 idb_metadata.object_stores[i]; | 95 idb_metadata.object_stores[i]; |
| 98 WebIDBMetadata::ObjectStore& web_store_metadata = | 96 WebIDBMetadata::ObjectStore& web_store_metadata = |
| 99 web_metadata.objectStores[i]; | 97 web_metadata.objectStores[i]; |
| 100 | 98 |
| 101 web_store_metadata.id = idb_store_metadata.id; | 99 web_store_metadata.id = idb_store_metadata.id; |
| 102 web_store_metadata.name = idb_store_metadata.name; | 100 web_store_metadata.name = idb_store_metadata.name; |
| 103 web_store_metadata.keyPath = idb_store_metadata.keyPath; | 101 web_store_metadata.keyPath = idb_store_metadata.keyPath; |
| 104 web_store_metadata.autoIncrement = idb_store_metadata.autoIncrement; | 102 web_store_metadata.autoIncrement = idb_store_metadata.autoIncrement; |
| 105 web_store_metadata.maxIndexId = idb_store_metadata.max_index_id; | 103 web_store_metadata.maxIndexId = idb_store_metadata.max_index_id; |
| 106 web_store_metadata.indexes = WebVector<WebIDBMetadata::Index>( | 104 web_store_metadata.indexes = |
| 107 idb_store_metadata.indexes.size()); | 105 WebVector<WebIDBMetadata::Index>(idb_store_metadata.indexes.size()); |
| 108 | 106 |
| 109 for (size_t j = 0; j < idb_store_metadata.indexes.size(); ++j) { | 107 for (size_t j = 0; j < idb_store_metadata.indexes.size(); ++j) { |
| 110 const IndexedDBIndexMetadata& idb_index_metadata = | 108 const IndexedDBIndexMetadata& idb_index_metadata = |
| 111 idb_store_metadata.indexes[j]; | 109 idb_store_metadata.indexes[j]; |
| 112 WebIDBMetadata::Index& web_index_metadata = | 110 WebIDBMetadata::Index& web_index_metadata = web_store_metadata.indexes[j]; |
| 113 web_store_metadata.indexes[j]; | |
| 114 | 111 |
| 115 web_index_metadata.id = idb_index_metadata.id; | 112 web_index_metadata.id = idb_index_metadata.id; |
| 116 web_index_metadata.name = idb_index_metadata.name; | 113 web_index_metadata.name = idb_index_metadata.name; |
| 117 web_index_metadata.keyPath = idb_index_metadata.keyPath; | 114 web_index_metadata.keyPath = idb_index_metadata.keyPath; |
| 118 web_index_metadata.unique = idb_index_metadata.unique; | 115 web_index_metadata.unique = idb_index_metadata.unique; |
| 119 web_index_metadata.multiEntry = idb_index_metadata.multiEntry; | 116 web_index_metadata.multiEntry = idb_index_metadata.multiEntry; |
| 120 } | 117 } |
| 121 } | 118 } |
| 122 | 119 |
| 123 return web_metadata; | 120 return web_metadata; |
| 124 } | 121 } |
| 125 | 122 |
| 126 void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { | 123 void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { |
| 127 bool handled = true; | 124 bool handled = true; |
| 128 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg) | 125 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg) |
| 129 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor, | 126 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor, |
| 130 OnSuccessOpenCursor) | 127 OnSuccessOpenCursor) |
| 131 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorAdvance, | 128 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorAdvance, |
| 132 OnSuccessCursorContinue) | 129 OnSuccessCursorContinue) |
| 133 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue, | 130 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue, |
| 134 OnSuccessCursorContinue) | 131 OnSuccessCursorContinue) |
| 135 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorPrefetch, | 132 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorPrefetch, |
| 136 OnSuccessCursorPrefetch) | 133 OnSuccessCursorPrefetch) |
| 137 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, | 134 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, |
| 138 OnSuccessIDBDatabase) | 135 OnSuccessIDBDatabase) |
| 139 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, | 136 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, |
| 140 OnSuccessIndexedDBKey) | 137 OnSuccessIndexedDBKey) |
| 141 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, | 138 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, |
| 142 OnSuccessStringList) | 139 OnSuccessStringList) |
| 143 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessValue, | 140 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessValue, OnSuccessValue) |
| 144 OnSuccessValue) | |
| 145 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessValueWithKey, | 141 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessValueWithKey, |
| 146 OnSuccessValueWithKey) | 142 OnSuccessValueWithKey) |
| 147 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessInteger, | 143 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessInteger, OnSuccessInteger) |
| 148 OnSuccessInteger) | |
| 149 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessUndefined, | 144 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessUndefined, |
| 150 OnSuccessUndefined) | 145 OnSuccessUndefined) |
| 151 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) | 146 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) |
| 152 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksIntBlocked, OnIntBlocked) | 147 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksIntBlocked, OnIntBlocked) |
| 153 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksUpgradeNeeded, OnUpgradeNeeded) | 148 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksUpgradeNeeded, OnUpgradeNeeded) |
| 154 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksForcedClose, | 149 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksForcedClose, |
| 155 OnForcedClose) | 150 OnForcedClose) |
| 156 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksIntVersionChange, | 151 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksIntVersionChange, |
| 157 OnIntVersionChange) | 152 OnIntVersionChange) |
| 158 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksAbort, OnAbort) | 153 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksAbort, OnAbort) |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 182 void IndexedDBDispatcher::RequestIDBCursorAdvance( | 177 void IndexedDBDispatcher::RequestIDBCursorAdvance( |
| 183 unsigned long count, | 178 unsigned long count, |
| 184 WebIDBCallbacks* callbacks_ptr, | 179 WebIDBCallbacks* callbacks_ptr, |
| 185 int32 ipc_cursor_id) { | 180 int32 ipc_cursor_id) { |
| 186 // Reset all cursor prefetch caches except for this cursor. | 181 // Reset all cursor prefetch caches except for this cursor. |
| 187 ResetCursorPrefetchCaches(ipc_cursor_id); | 182 ResetCursorPrefetchCaches(ipc_cursor_id); |
| 188 | 183 |
| 189 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 184 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 190 | 185 |
| 191 int32 ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | 186 int32 ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); |
| 192 Send(new IndexedDBHostMsg_CursorAdvance(ipc_cursor_id, CurrentWorkerId(), | 187 Send(new IndexedDBHostMsg_CursorAdvance( |
| 193 ipc_callbacks_id, count)); | 188 ipc_cursor_id, CurrentWorkerId(), ipc_callbacks_id, count)); |
| 194 } | 189 } |
| 195 | 190 |
| 196 void IndexedDBDispatcher::RequestIDBCursorContinue( | 191 void IndexedDBDispatcher::RequestIDBCursorContinue( |
| 197 const IndexedDBKey& key, | 192 const IndexedDBKey& key, |
| 198 WebIDBCallbacks* callbacks_ptr, | 193 WebIDBCallbacks* callbacks_ptr, |
| 199 int32 ipc_cursor_id) { | 194 int32 ipc_cursor_id) { |
| 200 // Reset all cursor prefetch caches except for this cursor. | 195 // Reset all cursor prefetch caches except for this cursor. |
| 201 ResetCursorPrefetchCaches(ipc_cursor_id); | 196 ResetCursorPrefetchCaches(ipc_cursor_id); |
| 202 | 197 |
| 203 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 198 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 204 | 199 |
| 205 int32 ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | 200 int32 ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); |
| 206 Send( | 201 Send(new IndexedDBHostMsg_CursorContinue( |
| 207 new IndexedDBHostMsg_CursorContinue(ipc_cursor_id, CurrentWorkerId(), | 202 ipc_cursor_id, CurrentWorkerId(), ipc_callbacks_id, key)); |
| 208 ipc_callbacks_id, key)); | |
| 209 } | 203 } |
| 210 | 204 |
| 211 void IndexedDBDispatcher::RequestIDBCursorPrefetch( | 205 void IndexedDBDispatcher::RequestIDBCursorPrefetch( |
| 212 int n, | 206 int n, |
| 213 WebIDBCallbacks* callbacks_ptr, | 207 WebIDBCallbacks* callbacks_ptr, |
| 214 int32 ipc_cursor_id) { | 208 int32 ipc_cursor_id) { |
| 215 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 209 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 216 | 210 |
| 217 int32 ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | 211 int32 ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); |
| 218 Send(new IndexedDBHostMsg_CursorPrefetch(ipc_cursor_id, CurrentWorkerId(), | 212 Send(new IndexedDBHostMsg_CursorPrefetch( |
| 219 ipc_callbacks_id, n)); | 213 ipc_cursor_id, CurrentWorkerId(), ipc_callbacks_id, n)); |
| 220 } | 214 } |
| 221 | 215 |
| 222 void IndexedDBDispatcher::RequestIDBCursorPrefetchReset( | 216 void IndexedDBDispatcher::RequestIDBCursorPrefetchReset(int used_prefetches, |
| 223 int used_prefetches, int unused_prefetches, int32 ipc_cursor_id) { | 217 int unused_prefetches, |
| 224 Send(new IndexedDBHostMsg_CursorPrefetchReset(ipc_cursor_id, | 218 int32 ipc_cursor_id) { |
| 225 used_prefetches, | 219 Send(new IndexedDBHostMsg_CursorPrefetchReset( |
| 226 unused_prefetches)); | 220 ipc_cursor_id, used_prefetches, unused_prefetches)); |
| 227 } | |
| 228 | |
| 229 void IndexedDBDispatcher::RequestIDBCursorDelete( | |
|
jsbell
2013/06/03 17:52:27
This is the only real change in the file.
| |
| 230 WebIDBCallbacks* callbacks_ptr, | |
| 231 int32 ipc_cursor_id) { | |
| 232 ResetCursorPrefetchCaches(); | |
| 233 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | |
| 234 | |
| 235 int32 ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | |
| 236 Send(new IndexedDBHostMsg_CursorDelete(ipc_cursor_id, CurrentWorkerId(), | |
| 237 ipc_callbacks_id)); | |
| 238 } | 221 } |
| 239 | 222 |
| 240 void IndexedDBDispatcher::RequestIDBFactoryOpen( | 223 void IndexedDBDispatcher::RequestIDBFactoryOpen( |
| 241 const string16& name, | 224 const string16& name, |
| 242 int64 version, | 225 int64 version, |
| 243 int64 transaction_id, | 226 int64 transaction_id, |
| 244 WebIDBCallbacks* callbacks_ptr, | 227 WebIDBCallbacks* callbacks_ptr, |
| 245 WebIDBDatabaseCallbacks* database_callbacks_ptr, | 228 WebIDBDatabaseCallbacks* database_callbacks_ptr, |
| 246 const string16& database_identifier) { | 229 const string16& database_identifier) { |
| 247 ResetCursorPrefetchCaches(); | 230 ResetCursorPrefetchCaches(); |
| 248 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 231 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 249 scoped_ptr<WebIDBDatabaseCallbacks> | 232 scoped_ptr<WebIDBDatabaseCallbacks> database_callbacks( |
| 250 database_callbacks(database_callbacks_ptr); | 233 database_callbacks_ptr); |
| 251 | 234 |
| 252 IndexedDBHostMsg_FactoryOpen_Params params; | 235 IndexedDBHostMsg_FactoryOpen_Params params; |
| 253 params.ipc_thread_id = CurrentWorkerId(); | 236 params.ipc_thread_id = CurrentWorkerId(); |
| 254 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | 237 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); |
| 255 params.ipc_database_callbacks_id = pending_database_callbacks_.Add( | 238 params.ipc_database_callbacks_id = |
| 256 database_callbacks.release()); | 239 pending_database_callbacks_.Add(database_callbacks.release()); |
| 257 params.database_identifier = database_identifier; | 240 params.database_identifier = database_identifier; |
| 258 params.name = name; | 241 params.name = name; |
| 259 params.transaction_id = transaction_id; | 242 params.transaction_id = transaction_id; |
| 260 params.version = version; | 243 params.version = version; |
| 261 Send(new IndexedDBHostMsg_FactoryOpen(params)); | 244 Send(new IndexedDBHostMsg_FactoryOpen(params)); |
| 262 } | 245 } |
| 263 | 246 |
| 264 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( | 247 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( |
| 265 WebIDBCallbacks* callbacks_ptr, | 248 WebIDBCallbacks* callbacks_ptr, |
| 266 const string16& database_identifier) { | 249 const string16& database_identifier) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 if (pending_database_callbacks_.Lookup(ipc_database_callbacks_id)) | 282 if (pending_database_callbacks_.Lookup(ipc_database_callbacks_id)) |
| 300 pending_database_callbacks_.Remove(ipc_database_callbacks_id); | 283 pending_database_callbacks_.Remove(ipc_database_callbacks_id); |
| 301 } | 284 } |
| 302 | 285 |
| 303 void IndexedDBDispatcher::RequestIDBDatabaseCreateTransaction( | 286 void IndexedDBDispatcher::RequestIDBDatabaseCreateTransaction( |
| 304 int32 ipc_database_id, | 287 int32 ipc_database_id, |
| 305 int64 transaction_id, | 288 int64 transaction_id, |
| 306 WebIDBDatabaseCallbacks* database_callbacks_ptr, | 289 WebIDBDatabaseCallbacks* database_callbacks_ptr, |
| 307 WebKit::WebVector<long long> object_store_ids, | 290 WebKit::WebVector<long long> object_store_ids, |
| 308 unsigned short mode) { | 291 unsigned short mode) { |
| 309 scoped_ptr<WebIDBDatabaseCallbacks> | 292 scoped_ptr<WebIDBDatabaseCallbacks> database_callbacks( |
| 310 database_callbacks(database_callbacks_ptr); | 293 database_callbacks_ptr); |
| 311 IndexedDBHostMsg_DatabaseCreateTransaction_Params params; | 294 IndexedDBHostMsg_DatabaseCreateTransaction_Params params; |
| 312 params.ipc_thread_id = CurrentWorkerId(); | 295 params.ipc_thread_id = CurrentWorkerId(); |
| 313 params.ipc_database_id = ipc_database_id; | 296 params.ipc_database_id = ipc_database_id; |
| 314 params.transaction_id = transaction_id; | 297 params.transaction_id = transaction_id; |
| 315 params.ipc_database_callbacks_id = pending_database_callbacks_.Add( | 298 params.ipc_database_callbacks_id = |
| 316 database_callbacks.release()); | 299 pending_database_callbacks_.Add(database_callbacks.release()); |
| 317 params.object_store_ids.assign(object_store_ids.data(), | 300 params.object_store_ids |
| 318 object_store_ids.data() + | 301 .assign(object_store_ids.data(), |
| 319 object_store_ids.size()); | 302 object_store_ids.data() + object_store_ids.size()); |
| 320 params.mode = mode; | 303 params.mode = mode; |
| 321 | 304 |
| 322 Send(new IndexedDBHostMsg_DatabaseCreateTransaction(params)); | 305 Send(new IndexedDBHostMsg_DatabaseCreateTransaction(params)); |
| 323 } | 306 } |
| 324 | 307 |
| 325 | |
| 326 void IndexedDBDispatcher::RequestIDBDatabaseGet( | 308 void IndexedDBDispatcher::RequestIDBDatabaseGet( |
| 327 int32 ipc_database_id, | 309 int32 ipc_database_id, |
| 328 int64 transaction_id, | 310 int64 transaction_id, |
| 329 int64 object_store_id, | 311 int64 object_store_id, |
| 330 int64 index_id, | 312 int64 index_id, |
| 331 const IndexedDBKeyRange& key_range, | 313 const IndexedDBKeyRange& key_range, |
| 332 bool key_only, | 314 bool key_only, |
| 333 WebIDBCallbacks* callbacks) { | 315 WebIDBCallbacks* callbacks) { |
| 334 ResetCursorPrefetchCaches(); | 316 ResetCursorPrefetchCaches(); |
| 335 IndexedDBHostMsg_DatabaseGet_Params params; | 317 IndexedDBHostMsg_DatabaseGet_Params params; |
| 336 init_params(params, callbacks); | 318 init_params(params, callbacks); |
| 337 params.ipc_database_id = ipc_database_id; | 319 params.ipc_database_id = ipc_database_id; |
| 338 params.transaction_id = transaction_id; | 320 params.transaction_id = transaction_id; |
| 339 params.object_store_id = object_store_id; | 321 params.object_store_id = object_store_id; |
| 340 params.index_id = index_id; | 322 params.index_id = index_id; |
| 341 params.key_range = key_range; | 323 params.key_range = key_range; |
| 342 params.key_only = key_only; | 324 params.key_only = key_only; |
| 343 Send(new IndexedDBHostMsg_DatabaseGet(params)); | 325 Send(new IndexedDBHostMsg_DatabaseGet(params)); |
| 344 } | 326 } |
| 345 | 327 |
| 346 | |
| 347 void IndexedDBDispatcher::RequestIDBDatabasePut( | 328 void IndexedDBDispatcher::RequestIDBDatabasePut( |
| 348 int32 ipc_database_id, | 329 int32 ipc_database_id, |
| 349 int64 transaction_id, | 330 int64 transaction_id, |
| 350 int64 object_store_id, | 331 int64 object_store_id, |
| 351 const WebData& value, | 332 const WebData& value, |
| 352 const IndexedDBKey& key, | 333 const IndexedDBKey& key, |
| 353 WebIDBDatabase::PutMode put_mode, | 334 WebIDBDatabase::PutMode put_mode, |
| 354 WebIDBCallbacks* callbacks, | 335 WebIDBCallbacks* callbacks, |
| 355 const WebVector<long long>& index_ids, | 336 const WebVector<long long>& index_ids, |
| 356 const WebVector<WebKit::WebVector< | 337 const WebVector<WebKit::WebVector<WebIDBKey> >& index_keys) { |
| 357 WebIDBKey> >& index_keys) { | |
| 358 | 338 |
| 359 if (value.size() > kMaxIDBValueSizeInBytes) { | 339 if (value.size() > kMaxIDBValueSizeInBytes) { |
| 360 callbacks->onError(WebIDBDatabaseError( | 340 callbacks->onError(WebIDBDatabaseError( |
| 361 WebKit::WebIDBDatabaseExceptionUnknownError, | 341 WebKit::WebIDBDatabaseExceptionUnknownError, |
| 362 WebString::fromUTF8( | 342 WebString::fromUTF8(base::StringPrintf( |
| 363 base::StringPrintf( | 343 "The serialized value is too large" |
| 364 "The serialized value is too large" | 344 " (size=%" PRIuS " bytes, max=%" PRIuS " bytes).", |
| 365 " (size=%" PRIuS " bytes, max=%" PRIuS " bytes).", | 345 value.size(), |
| 366 value.size(), kMaxIDBValueSizeInBytes).c_str()))); | 346 kMaxIDBValueSizeInBytes).c_str()))); |
| 367 return; | 347 return; |
| 368 } | 348 } |
| 369 | 349 |
| 370 ResetCursorPrefetchCaches(); | 350 ResetCursorPrefetchCaches(); |
| 371 IndexedDBHostMsg_DatabasePut_Params params; | 351 IndexedDBHostMsg_DatabasePut_Params params; |
| 372 init_params(params, callbacks); | 352 init_params(params, callbacks); |
| 373 params.ipc_database_id = ipc_database_id; | 353 params.ipc_database_id = ipc_database_id; |
| 374 params.transaction_id = transaction_id; | 354 params.transaction_id = transaction_id; |
| 375 params.object_store_id = object_store_id; | 355 params.object_store_id = object_store_id; |
| 376 | 356 |
| 377 params.value.assign(value.data(), value.data() + value.size()); | 357 params.value.assign(value.data(), value.data() + value.size()); |
| 378 params.key = key; | 358 params.key = key; |
| 379 params.put_mode = put_mode; | 359 params.put_mode = put_mode; |
| 380 | 360 |
| 381 COMPILE_ASSERT(sizeof(params.index_ids[0]) == | 361 COMPILE_ASSERT(sizeof(params.index_ids[0]) == sizeof(index_ids[0]), |
| 382 sizeof(index_ids[0]), Cant_copy); | 362 Cant_copy); |
| 383 params.index_ids.assign(index_ids.data(), | 363 params.index_ids |
| 384 index_ids.data() + index_ids.size()); | 364 .assign(index_ids.data(), index_ids.data() + index_ids.size()); |
| 385 | 365 |
| 386 params.index_keys.resize(index_keys.size()); | 366 params.index_keys.resize(index_keys.size()); |
| 387 for (size_t i = 0; i < index_keys.size(); ++i) { | 367 for (size_t i = 0; i < index_keys.size(); ++i) { |
| 388 params.index_keys[i].resize(index_keys[i].size()); | 368 params.index_keys[i].resize(index_keys[i].size()); |
| 389 for (size_t j = 0; j < index_keys[i].size(); ++j) { | 369 for (size_t j = 0; j < index_keys[i].size(); ++j) { |
| 390 params.index_keys[i][j] = IndexedDBKey(index_keys[i][j]); | 370 params.index_keys[i][j] = IndexedDBKey(index_keys[i][j]); |
| 391 } | 371 } |
| 392 } | 372 } |
| 393 Send(new IndexedDBHostMsg_DatabasePut(params)); | 373 Send(new IndexedDBHostMsg_DatabasePut(params)); |
| 394 } | 374 } |
| 395 | 375 |
| 396 void IndexedDBDispatcher::RequestIDBDatabaseOpenCursor( | 376 void IndexedDBDispatcher::RequestIDBDatabaseOpenCursor( |
| 397 int32 ipc_database_id, | 377 int32 ipc_database_id, |
| 398 int64 transaction_id, | 378 int64 transaction_id, |
| 399 int64 object_store_id, | 379 int64 object_store_id, |
| 400 int64 index_id, | 380 int64 index_id, |
| 401 const IndexedDBKeyRange& key_range, | 381 const IndexedDBKeyRange& key_range, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 params.index_id = index_id; | 413 params.index_id = index_id; |
| 434 params.key_range = IndexedDBKeyRange(key_range); | 414 params.key_range = IndexedDBKeyRange(key_range); |
| 435 Send(new IndexedDBHostMsg_DatabaseCount(params)); | 415 Send(new IndexedDBHostMsg_DatabaseCount(params)); |
| 436 } | 416 } |
| 437 | 417 |
| 438 void IndexedDBDispatcher::RequestIDBDatabaseDeleteRange( | 418 void IndexedDBDispatcher::RequestIDBDatabaseDeleteRange( |
| 439 int32 ipc_database_id, | 419 int32 ipc_database_id, |
| 440 int64 transaction_id, | 420 int64 transaction_id, |
| 441 int64 object_store_id, | 421 int64 object_store_id, |
| 442 const IndexedDBKeyRange& key_range, | 422 const IndexedDBKeyRange& key_range, |
| 443 WebKit::WebIDBCallbacks* callbacks) | 423 WebKit::WebIDBCallbacks* callbacks) { |
| 444 { | |
| 445 ResetCursorPrefetchCaches(); | 424 ResetCursorPrefetchCaches(); |
| 446 IndexedDBHostMsg_DatabaseDeleteRange_Params params; | 425 IndexedDBHostMsg_DatabaseDeleteRange_Params params; |
| 447 init_params(params, callbacks); | 426 init_params(params, callbacks); |
| 448 params.ipc_database_id = ipc_database_id; | 427 params.ipc_database_id = ipc_database_id; |
| 449 params.transaction_id = transaction_id; | 428 params.transaction_id = transaction_id; |
| 450 params.object_store_id = object_store_id; | 429 params.object_store_id = object_store_id; |
| 451 params.key_range = key_range; | 430 params.key_range = key_range; |
| 452 Send(new IndexedDBHostMsg_DatabaseDeleteRange(params)); | 431 Send(new IndexedDBHostMsg_DatabaseDeleteRange(params)); |
| 453 } | 432 } |
| 454 | 433 |
| 455 void IndexedDBDispatcher::RequestIDBDatabaseClear( | 434 void IndexedDBDispatcher::RequestIDBDatabaseClear( |
| 456 int32 ipc_database_id, | 435 int32 ipc_database_id, |
| 457 int64 transaction_id, | 436 int64 transaction_id, |
| 458 int64 object_store_id, | 437 int64 object_store_id, |
| 459 WebKit::WebIDBCallbacks* callbacks_ptr) { | 438 WebKit::WebIDBCallbacks* callbacks_ptr) { |
| 460 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 439 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 461 int32 ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | 440 int32 ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); |
| 462 Send(new IndexedDBHostMsg_DatabaseClear( | 441 Send(new IndexedDBHostMsg_DatabaseClear(CurrentWorkerId(), |
| 463 CurrentWorkerId(), ipc_callbacks_id, ipc_database_id, | 442 ipc_callbacks_id, |
| 464 transaction_id, object_store_id)); | 443 ipc_database_id, |
| 444 transaction_id, | |
| 445 object_store_id)); | |
| 465 } | 446 } |
| 466 | 447 |
| 467 void IndexedDBDispatcher::CursorDestroyed(int32 ipc_cursor_id) { | 448 void IndexedDBDispatcher::CursorDestroyed(int32 ipc_cursor_id) { |
| 468 cursors_.erase(ipc_cursor_id); | 449 cursors_.erase(ipc_cursor_id); |
| 469 } | 450 } |
| 470 | 451 |
| 471 void IndexedDBDispatcher::DatabaseDestroyed(int32 ipc_database_id) { | 452 void IndexedDBDispatcher::DatabaseDestroyed(int32 ipc_database_id) { |
| 472 DCHECK_EQ(databases_.count(ipc_database_id), 1u); | 453 DCHECK_EQ(databases_.count(ipc_database_id), 1u); |
| 473 databases_.erase(ipc_database_id); | 454 databases_.erase(ipc_database_id); |
| 474 } | 455 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 486 WebIDBMetadata metadata(ConvertMetadata(idb_metadata)); | 467 WebIDBMetadata metadata(ConvertMetadata(idb_metadata)); |
| 487 // If an upgrade was performed, count will be non-zero. | 468 // If an upgrade was performed, count will be non-zero. |
| 488 if (!databases_.count(ipc_object_id)) | 469 if (!databases_.count(ipc_object_id)) |
| 489 databases_[ipc_object_id] = new RendererWebIDBDatabaseImpl( | 470 databases_[ipc_object_id] = new RendererWebIDBDatabaseImpl( |
| 490 ipc_object_id, ipc_database_callbacks_id); | 471 ipc_object_id, ipc_database_callbacks_id); |
| 491 DCHECK_EQ(databases_.count(ipc_object_id), 1u); | 472 DCHECK_EQ(databases_.count(ipc_object_id), 1u); |
| 492 callbacks->onSuccess(databases_[ipc_object_id], metadata); | 473 callbacks->onSuccess(databases_[ipc_object_id], metadata); |
| 493 pending_callbacks_.Remove(ipc_callbacks_id); | 474 pending_callbacks_.Remove(ipc_callbacks_id); |
| 494 } | 475 } |
| 495 | 476 |
| 496 void IndexedDBDispatcher::OnSuccessIndexedDBKey( | 477 void IndexedDBDispatcher::OnSuccessIndexedDBKey(int32 ipc_thread_id, |
| 497 int32 ipc_thread_id, | 478 int32 ipc_callbacks_id, |
| 498 int32 ipc_callbacks_id, | 479 const IndexedDBKey& key) { |
| 499 const IndexedDBKey& key) { | |
| 500 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 480 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 501 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 481 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 502 if (!callbacks) | 482 if (!callbacks) |
| 503 return; | 483 return; |
| 504 callbacks->onSuccess(WebIDBKey(key)); | 484 callbacks->onSuccess(WebIDBKey(key)); |
| 505 pending_callbacks_.Remove(ipc_callbacks_id); | 485 pending_callbacks_.Remove(ipc_callbacks_id); |
| 506 } | 486 } |
| 507 | 487 |
| 508 void IndexedDBDispatcher::OnSuccessStringList( | 488 void IndexedDBDispatcher::OnSuccessStringList( |
| 509 int32 ipc_thread_id, int32 ipc_callbacks_id, | 489 int32 ipc_thread_id, |
| 490 int32 ipc_callbacks_id, | |
| 510 const std::vector<string16>& value) { | 491 const std::vector<string16>& value) { |
| 511 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 492 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 512 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 493 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 513 if (!callbacks) | 494 if (!callbacks) |
| 514 return; | 495 return; |
| 515 callbacks->onSuccess(WebVector<WebString>(value)); | 496 callbacks->onSuccess(WebVector<WebString>(value)); |
| 516 pending_callbacks_.Remove(ipc_callbacks_id); | 497 pending_callbacks_.Remove(ipc_callbacks_id); |
| 517 } | 498 } |
| 518 | 499 |
| 519 void IndexedDBDispatcher::OnSuccessValue( | 500 void IndexedDBDispatcher::OnSuccessValue(int32 ipc_thread_id, |
| 520 int32 ipc_thread_id, int32 ipc_callbacks_id, | 501 int32 ipc_callbacks_id, |
| 521 const std::vector<char>& value) { | 502 const std::vector<char>& value) { |
| 522 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 503 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 523 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 504 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 524 if (!callbacks) | 505 if (!callbacks) |
| 525 return; | 506 return; |
| 526 WebData web_value; | 507 WebData web_value; |
| 527 if (value.size()) | 508 if (value.size()) |
| 528 web_value.assign(&value.front(), value.size()); | 509 web_value.assign(&value.front(), value.size()); |
| 529 callbacks->onSuccess(web_value); | 510 callbacks->onSuccess(web_value); |
| 530 pending_callbacks_.Remove(ipc_callbacks_id); | 511 pending_callbacks_.Remove(ipc_callbacks_id); |
| 531 } | 512 } |
| 532 | 513 |
| 533 void IndexedDBDispatcher::OnSuccessValueWithKey( | 514 void IndexedDBDispatcher::OnSuccessValueWithKey( |
| 534 int32 ipc_thread_id, int32 ipc_callbacks_id, | 515 int32 ipc_thread_id, |
| 516 int32 ipc_callbacks_id, | |
| 535 const std::vector<char>& value, | 517 const std::vector<char>& value, |
| 536 const IndexedDBKey& primary_key, | 518 const IndexedDBKey& primary_key, |
| 537 const IndexedDBKeyPath& key_path) { | 519 const IndexedDBKeyPath& key_path) { |
| 538 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 520 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 539 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 521 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 540 if (!callbacks) | 522 if (!callbacks) |
| 541 return; | 523 return; |
| 542 WebData web_value; | 524 WebData web_value; |
| 543 if (value.size()) | 525 if (value.size()) |
| 544 web_value.assign(&value.front(), value.size()); | 526 web_value.assign(&value.front(), value.size()); |
| 545 callbacks->onSuccess(web_value, | 527 callbacks->onSuccess(web_value, primary_key, key_path); |
| 546 primary_key, key_path); | |
| 547 pending_callbacks_.Remove(ipc_callbacks_id); | 528 pending_callbacks_.Remove(ipc_callbacks_id); |
| 548 } | 529 } |
| 549 | 530 |
| 550 void IndexedDBDispatcher::OnSuccessInteger( | 531 void IndexedDBDispatcher::OnSuccessInteger(int32 ipc_thread_id, |
| 551 int32 ipc_thread_id, int32 ipc_callbacks_id, int64 value) { | 532 int32 ipc_callbacks_id, |
| 533 int64 value) { | |
| 552 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 534 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 553 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 535 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 554 if (!callbacks) | 536 if (!callbacks) |
| 555 return; | 537 return; |
| 556 callbacks->onSuccess(value); | 538 callbacks->onSuccess(value); |
| 557 pending_callbacks_.Remove(ipc_callbacks_id); | 539 pending_callbacks_.Remove(ipc_callbacks_id); |
| 558 } | 540 } |
| 559 | 541 |
| 560 void IndexedDBDispatcher::OnSuccessUndefined( | 542 void IndexedDBDispatcher::OnSuccessUndefined(int32 ipc_thread_id, |
| 561 int32 ipc_thread_id, int32 ipc_callbacks_id) { | 543 int32 ipc_callbacks_id) { |
| 562 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 544 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 563 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 545 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 564 if (!callbacks) | 546 if (!callbacks) |
| 565 return; | 547 return; |
| 566 callbacks->onSuccess(); | 548 callbacks->onSuccess(); |
| 567 pending_callbacks_.Remove(ipc_callbacks_id); | 549 pending_callbacks_.Remove(ipc_callbacks_id); |
| 568 } | 550 } |
| 569 | 551 |
| 570 void IndexedDBDispatcher::OnSuccessOpenCursor( | 552 void IndexedDBDispatcher::OnSuccessOpenCursor( |
| 571 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p) { | 553 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p) { |
| 572 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); | 554 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); |
| 573 int32 ipc_callbacks_id = p.ipc_callbacks_id; | 555 int32 ipc_callbacks_id = p.ipc_callbacks_id; |
| 574 int32 ipc_object_id = p.ipc_cursor_id; | 556 int32 ipc_object_id = p.ipc_cursor_id; |
| 575 const IndexedDBKey& key = p.key; | 557 const IndexedDBKey& key = p.key; |
| 576 const IndexedDBKey& primary_key = p.primary_key; | 558 const IndexedDBKey& primary_key = p.primary_key; |
| 577 WebData web_value; | 559 WebData web_value; |
| 578 if (p.value.size()) | 560 if (p.value.size()) |
| 579 web_value.assign(&p.value.front(), p.value.size()); | 561 web_value.assign(&p.value.front(), p.value.size()); |
| 580 | 562 |
| 581 WebIDBCallbacks* callbacks = | 563 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 582 pending_callbacks_.Lookup(ipc_callbacks_id); | |
| 583 if (!callbacks) | 564 if (!callbacks) |
| 584 return; | 565 return; |
| 585 | 566 |
| 586 RendererWebIDBCursorImpl* cursor = | 567 RendererWebIDBCursorImpl* cursor = |
| 587 new RendererWebIDBCursorImpl(ipc_object_id); | 568 new RendererWebIDBCursorImpl(ipc_object_id); |
| 588 cursors_[ipc_object_id] = cursor; | 569 cursors_[ipc_object_id] = cursor; |
| 589 callbacks->onSuccess(cursor, key, primary_key, web_value); | 570 callbacks->onSuccess(cursor, key, primary_key, web_value); |
| 590 | 571 |
| 591 pending_callbacks_.Remove(ipc_callbacks_id); | 572 pending_callbacks_.Remove(ipc_callbacks_id); |
| 592 } | 573 } |
| 593 | 574 |
| 594 void IndexedDBDispatcher::OnSuccessCursorContinue( | 575 void IndexedDBDispatcher::OnSuccessCursorContinue( |
| 595 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p) { | 576 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p) { |
| 596 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); | 577 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); |
| 597 int32 ipc_callbacks_id = p.ipc_callbacks_id; | 578 int32 ipc_callbacks_id = p.ipc_callbacks_id; |
| 598 int32 ipc_cursor_id = p.ipc_cursor_id; | 579 int32 ipc_cursor_id = p.ipc_cursor_id; |
| 599 const IndexedDBKey& key = p.key; | 580 const IndexedDBKey& key = p.key; |
| 600 const IndexedDBKey& primary_key = p.primary_key; | 581 const IndexedDBKey& primary_key = p.primary_key; |
| 601 const std::vector<char>& value = p.value; | 582 const std::vector<char>& value = p.value; |
| 602 | 583 |
| 603 RendererWebIDBCursorImpl* cursor = cursors_[ipc_cursor_id]; | 584 RendererWebIDBCursorImpl* cursor = cursors_[ipc_cursor_id]; |
| 604 DCHECK(cursor); | 585 DCHECK(cursor); |
| 605 | 586 |
| 606 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 587 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 607 if (!callbacks) | 588 if (!callbacks) |
| 608 return; | 589 return; |
| 609 | 590 |
| 610 WebData web_value; | 591 WebData web_value; |
| 611 if (value.size()) | 592 if (value.size()) |
| 612 web_value.assign(&value.front(), value.size()); | 593 web_value.assign(&value.front(), value.size()); |
| 613 callbacks->onSuccess(key, primary_key, web_value); | 594 callbacks->onSuccess(key, primary_key, web_value); |
| 614 | 595 |
| 615 pending_callbacks_.Remove(ipc_callbacks_id); | 596 pending_callbacks_.Remove(ipc_callbacks_id); |
| 616 } | 597 } |
| 617 | 598 |
| 618 void IndexedDBDispatcher::OnSuccessCursorPrefetch( | 599 void IndexedDBDispatcher::OnSuccessCursorPrefetch( |
| 619 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p) { | 600 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p) { |
| 620 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); | 601 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); |
| 621 int32 ipc_callbacks_id = p.ipc_callbacks_id; | 602 int32 ipc_callbacks_id = p.ipc_callbacks_id; |
| 622 int32 ipc_cursor_id = p.ipc_cursor_id; | 603 int32 ipc_cursor_id = p.ipc_cursor_id; |
| 623 const std::vector<IndexedDBKey>& keys = p.keys; | 604 const std::vector<IndexedDBKey>& keys = p.keys; |
| 624 const std::vector<IndexedDBKey>& primary_keys = p.primary_keys; | 605 const std::vector<IndexedDBKey>& primary_keys = p.primary_keys; |
| 625 std::vector<WebData> values(p.values.size()); | 606 std::vector<WebData> values(p.values.size()); |
| 626 for (size_t i = 0; i < p.values.size(); ++i) { | 607 for (size_t i = 0; i < p.values.size(); ++i) { |
| 627 if (p.values[i].size()) | 608 if (p.values[i].size()) |
| 628 values[i].assign(&p.values[i].front(), p.values[i].size()); | 609 values[i].assign(&p.values[i].front(), p.values[i].size()); |
| 629 } | 610 } |
| 630 RendererWebIDBCursorImpl* cursor = cursors_[ipc_cursor_id]; | 611 RendererWebIDBCursorImpl* cursor = cursors_[ipc_cursor_id]; |
| 631 DCHECK(cursor); | 612 DCHECK(cursor); |
| 632 cursor->SetPrefetchData(keys, primary_keys, values); | 613 cursor->SetPrefetchData(keys, primary_keys, values); |
| 633 | 614 |
| 634 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 615 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 635 DCHECK(callbacks); | 616 DCHECK(callbacks); |
| 636 cursor->CachedContinue(callbacks); | 617 cursor->CachedContinue(callbacks); |
| 637 pending_callbacks_.Remove(ipc_callbacks_id); | 618 pending_callbacks_.Remove(ipc_callbacks_id); |
| 638 } | 619 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 649 void IndexedDBDispatcher::OnUpgradeNeeded( | 630 void IndexedDBDispatcher::OnUpgradeNeeded( |
| 650 const IndexedDBMsg_CallbacksUpgradeNeeded_Params& p) { | 631 const IndexedDBMsg_CallbacksUpgradeNeeded_Params& p) { |
| 651 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); | 632 DCHECK_EQ(p.ipc_thread_id, CurrentWorkerId()); |
| 652 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(p.ipc_callbacks_id); | 633 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(p.ipc_callbacks_id); |
| 653 DCHECK(callbacks); | 634 DCHECK(callbacks); |
| 654 WebIDBMetadata metadata(ConvertMetadata(p.idb_metadata)); | 635 WebIDBMetadata metadata(ConvertMetadata(p.idb_metadata)); |
| 655 DCHECK(!databases_.count(p.ipc_database_id)); | 636 DCHECK(!databases_.count(p.ipc_database_id)); |
| 656 databases_[p.ipc_database_id] = new RendererWebIDBDatabaseImpl( | 637 databases_[p.ipc_database_id] = new RendererWebIDBDatabaseImpl( |
| 657 p.ipc_database_id, p.ipc_database_callbacks_id); | 638 p.ipc_database_id, p.ipc_database_callbacks_id); |
| 658 callbacks->onUpgradeNeeded( | 639 callbacks->onUpgradeNeeded( |
| 659 p.old_version, | 640 p.old_version, databases_[p.ipc_database_id], metadata); |
| 660 databases_[p.ipc_database_id], | |
| 661 metadata); | |
| 662 } | 641 } |
| 663 | 642 |
| 664 void IndexedDBDispatcher::OnError(int32 ipc_thread_id, | 643 void IndexedDBDispatcher::OnError(int32 ipc_thread_id, |
| 665 int32 ipc_callbacks_id, | 644 int32 ipc_callbacks_id, |
| 666 int code, | 645 int code, |
| 667 const string16& message) { | 646 const string16& message) { |
| 668 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 647 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 669 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 648 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 670 if (!callbacks) | 649 if (!callbacks) |
| 671 return; | 650 return; |
| 672 callbacks->onError(WebIDBDatabaseError(code, message)); | 651 callbacks->onError(WebIDBDatabaseError(code, message)); |
| 673 pending_callbacks_.Remove(ipc_callbacks_id); | 652 pending_callbacks_.Remove(ipc_callbacks_id); |
| 674 } | 653 } |
| 675 | 654 |
| 676 void IndexedDBDispatcher::OnAbort(int32 ipc_thread_id, | 655 void IndexedDBDispatcher::OnAbort(int32 ipc_thread_id, |
| 677 int32 ipc_database_callbacks_id, | 656 int32 ipc_database_callbacks_id, |
| 678 int64 transaction_id, | 657 int64 transaction_id, |
| 679 int code, const string16& message) { | 658 int code, |
| 659 const string16& message) { | |
| 680 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 660 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 681 WebIDBDatabaseCallbacks* callbacks = | 661 WebIDBDatabaseCallbacks* callbacks = |
| 682 pending_database_callbacks_.Lookup(ipc_database_callbacks_id); | 662 pending_database_callbacks_.Lookup(ipc_database_callbacks_id); |
| 683 if (!callbacks) | 663 if (!callbacks) |
| 684 return; | 664 return; |
| 685 callbacks->onAbort(transaction_id, WebIDBDatabaseError(code, message)); | 665 callbacks->onAbort(transaction_id, WebIDBDatabaseError(code, message)); |
| 686 } | 666 } |
| 687 | 667 |
| 688 void IndexedDBDispatcher::OnComplete(int32 ipc_thread_id, | 668 void IndexedDBDispatcher::OnComplete(int32 ipc_thread_id, |
| 689 int32 ipc_database_callbacks_id, | 669 int32 ipc_database_callbacks_id, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 724 int32 ipc_exception_cursor_id) { | 704 int32 ipc_exception_cursor_id) { |
| 725 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 705 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| 726 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 706 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 727 if (i->first == ipc_exception_cursor_id) | 707 if (i->first == ipc_exception_cursor_id) |
| 728 continue; | 708 continue; |
| 729 i->second->ResetPrefetchCache(); | 709 i->second->ResetPrefetchCache(); |
| 730 } | 710 } |
| 731 } | 711 } |
| 732 | 712 |
| 733 } // namespace content | 713 } // namespace content |
| OLD | NEW |