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/indexed_db/indexed_db_dispatcher.h" | 5 #include "content/common/indexed_db/indexed_db_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/threading/thread_local.h" | 8 #include "base/threading/thread_local.h" |
| 9 #include "content/common/child_thread.h" | 9 #include "content/common/child_thread.h" |
| 10 #include "content/common/indexed_db/indexed_db_messages.h" | 10 #include "content/common/indexed_db/indexed_db_messages.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 | 298 |
| 299 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 ipc_database_id) { | 299 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 ipc_database_id) { |
| 300 ResetCursorPrefetchCaches(); | 300 ResetCursorPrefetchCaches(); |
| 301 Send(new IndexedDBHostMsg_DatabaseClose(ipc_database_id)); | 301 Send(new IndexedDBHostMsg_DatabaseClose(ipc_database_id)); |
| 302 // There won't be pending database callbacks if the transaction was aborted in | 302 // There won't be pending database callbacks if the transaction was aborted in |
| 303 // the initial upgradeneeded event handler. | 303 // the initial upgradeneeded event handler. |
| 304 if (pending_database_callbacks_.Lookup(ipc_database_id)) | 304 if (pending_database_callbacks_.Lookup(ipc_database_id)) |
| 305 pending_database_callbacks_.Remove(ipc_database_id); | 305 pending_database_callbacks_.Remove(ipc_database_id); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void IndexedDBDispatcher::RequestIDBDatabaseGet( | |
| 309 int32 ipc_database_id, | |
| 310 int64 transaction_id, | |
| 311 int64 object_store_id, | |
| 312 int64 index_id, | |
| 313 const IndexedDBKeyRange& key_range, | |
| 314 bool key_only, | |
| 315 WebIDBCallbacks* callbacks) { | |
| 316 ResetCursorPrefetchCaches(); | |
| 317 IndexedDBHostMsg_DatabaseGet_Params params; | |
| 318 init_params(params, callbacks); | |
| 319 params.ipc_database_id = ipc_database_id; | |
| 320 params.transaction_id = transaction_id; | |
| 321 params.object_store_id = object_store_id; | |
| 322 params.index_id = index_id; | |
| 323 params.key_range = key_range; | |
| 324 params.key_only = key_only; | |
| 325 Send(new IndexedDBHostMsg_DatabaseGet(params)); | |
| 326 } | |
| 327 | |
| 328 | |
| 329 void IndexedDBDispatcher::RequestIDBDatabasePut( | |
| 330 int32 ipc_database_id, | |
| 331 int64 transaction_id, | |
| 332 int64 object_store_id, | |
| 333 WebKit::WebVector<unsigned char>* value, | |
| 334 const IndexedDBKey& key, | |
| 335 WebKit::WebIDBDatabase::PutMode put_mode, | |
| 336 WebKit::WebIDBCallbacks* callbacks, | |
| 337 const WebKit::WebVector<long long>& index_ids, | |
| 338 const WebKit::WebVector<WebKit::WebVector< | |
| 339 WebKit::WebIDBKey> >& index_keys) { | |
| 340 ResetCursorPrefetchCaches(); | |
| 341 IndexedDBHostMsg_DatabasePut_Params params; | |
| 342 init_params(params, callbacks); | |
| 343 params.ipc_database_id = ipc_database_id; | |
| 344 params.transaction_id = transaction_id; | |
| 345 params.object_store_id = object_store_id; | |
| 346 | |
| 347 params.value.resize(value->size()); | |
| 348 for (size_t i = 0; i < value->size(); ++i) { | |
|
jsbell
2013/01/03 01:17:35
Do this using memcpy instead, with appropriate com
| |
| 349 params.value[i] = (*value)[i]; | |
| 350 } | |
| 351 params.key = key; | |
| 352 params.put_mode = put_mode; | |
| 353 | |
| 354 params.index_ids.resize(index_ids.size()); | |
| 355 for (size_t i = 0; i < index_ids.size(); ++i) { | |
| 356 params.index_ids[i] = index_ids[i]; | |
| 357 } | |
| 358 | |
| 359 params.index_keys.resize(index_keys.size()); | |
| 360 for (size_t i = 0; i < index_keys.size(); ++i) { | |
| 361 params.index_keys[i].resize(index_keys[i].size()); | |
| 362 for (size_t j = 0; j < index_keys[i].size(); ++j) { | |
| 363 params.index_keys[i][j] = IndexedDBKey(index_keys[i][j]); | |
| 364 } | |
| 365 } | |
| 366 Send(new IndexedDBHostMsg_DatabasePut(params)); | |
| 367 } | |
| 368 | |
| 369 void IndexedDBDispatcher::RequestIDBDatabaseOpenCursor( | |
| 370 int32 ipc_database_id, | |
| 371 int64 transaction_id, | |
| 372 int64 object_store_id, | |
| 373 int64 index_id, | |
| 374 const IndexedDBKeyRange& key_range, | |
| 375 unsigned short direction, | |
| 376 bool key_only, | |
| 377 WebKit::WebIDBDatabase::TaskType task_type, | |
| 378 WebIDBCallbacks* callbacks) { | |
| 379 ResetCursorPrefetchCaches(); | |
| 380 IndexedDBHostMsg_DatabaseOpenCursor_Params params; | |
| 381 init_params(params, callbacks); | |
| 382 params.ipc_database_id = ipc_database_id; | |
| 383 params.transaction_id = transaction_id; | |
| 384 params.object_store_id = object_store_id; | |
| 385 params.index_id = index_id; | |
| 386 params.key_range = IndexedDBKeyRange(key_range); | |
| 387 params.direction = direction; | |
| 388 params.key_only = key_only; | |
| 389 params.task_type = task_type; | |
| 390 Send(new IndexedDBHostMsg_DatabaseOpenCursor(params)); | |
| 391 } | |
| 392 | |
| 393 void IndexedDBDispatcher::RequestIDBDatabaseCount( | |
| 394 int32 ipc_database_id, | |
| 395 int64 transaction_id, | |
| 396 int64 object_store_id, | |
| 397 int64 index_id, | |
| 398 const IndexedDBKeyRange& key_range, | |
| 399 WebKit::WebIDBCallbacks* callbacks) { | |
| 400 ResetCursorPrefetchCaches(); | |
| 401 IndexedDBHostMsg_DatabaseCount_Params params; | |
| 402 init_params(params, callbacks); | |
| 403 params.ipc_database_id = ipc_database_id; | |
| 404 params.transaction_id = transaction_id; | |
| 405 params.object_store_id = object_store_id; | |
| 406 params.index_id = index_id; | |
| 407 params.key_range = IndexedDBKeyRange(key_range); | |
| 408 Send(new IndexedDBHostMsg_DatabaseCount(params)); | |
| 409 } | |
| 410 | |
| 411 void IndexedDBDispatcher::RequestIDBDatabaseDeleteRange( | |
| 412 int32 ipc_database_id, | |
| 413 int64 transaction_id, | |
| 414 int64 object_store_id, | |
| 415 const IndexedDBKeyRange& key_range, | |
| 416 WebKit::WebIDBCallbacks* callbacks) | |
| 417 { | |
| 418 ResetCursorPrefetchCaches(); | |
| 419 IndexedDBHostMsg_DatabaseDeleteRange_Params params; | |
| 420 init_params(params, callbacks); | |
| 421 params.ipc_database_id = ipc_database_id; | |
| 422 params.transaction_id = transaction_id; | |
| 423 params.object_store_id = object_store_id; | |
| 424 params.key_range = key_range; | |
| 425 Send(new IndexedDBHostMsg_DatabaseDeleteRange(params)); | |
| 426 } | |
| 427 | |
| 428 void IndexedDBDispatcher::RequestIDBDatabaseClear( | |
| 429 int32 ipc_database_id, | |
| 430 int64 transaction_id, | |
| 431 int64 object_store_id, | |
| 432 WebKit::WebIDBCallbacks* callbacks_ptr) { | |
| 433 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | |
| 434 int32 ipc_response_id = pending_callbacks_.Add(callbacks.release()); | |
| 435 Send(new IndexedDBHostMsg_DatabaseClear( | |
| 436 CurrentWorkerId(), ipc_response_id, ipc_database_id, | |
| 437 transaction_id, object_store_id)); | |
| 438 } | |
| 439 | |
| 308 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( | 440 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( |
| 309 const WebIDBKeyRange& idb_key_range, | 441 const WebIDBKeyRange& idb_key_range, |
| 310 unsigned short direction, | 442 unsigned short direction, |
| 311 WebIDBCallbacks* callbacks_ptr, | 443 WebIDBCallbacks* callbacks_ptr, |
| 312 int32 ipc_index_id, | 444 int32 ipc_index_id, |
| 313 const WebIDBTransaction& transaction, | 445 const WebIDBTransaction& transaction, |
| 314 WebExceptionCode* ec) { | 446 WebExceptionCode* ec) { |
| 315 ResetCursorPrefetchCaches(); | 447 ResetCursorPrefetchCaches(); |
| 316 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 448 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 317 IndexedDBHostMsg_IndexOpenCursor_Params params; | 449 IndexedDBHostMsg_IndexOpenCursor_Params params; |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 int32 ipc_exception_cursor_id) { | 914 int32 ipc_exception_cursor_id) { |
| 783 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 915 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| 784 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 916 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 785 if (i->first == ipc_exception_cursor_id) | 917 if (i->first == ipc_exception_cursor_id) |
| 786 continue; | 918 continue; |
| 787 i->second->ResetPrefetchCache(); | 919 i->second->ResetPrefetchCache(); |
| 788 } | 920 } |
| 789 } | 921 } |
| 790 | 922 |
| 791 } // namespace content | 923 } // namespace content |
| OLD | NEW |