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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 ResetCursorPrefetchCaches(); | 362 ResetCursorPrefetchCaches(); |
363 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 363 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
364 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 364 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
365 Send(new IndexedDBHostMsg_IndexGetObject(idb_index_id, CurrentWorkerId(), | 365 Send(new IndexedDBHostMsg_IndexGetObject(idb_index_id, CurrentWorkerId(), |
366 response_id, key, | 366 response_id, key, |
367 TransactionId(transaction), ec)); | 367 TransactionId(transaction), ec)); |
368 if (*ec) | 368 if (*ec) |
369 pending_callbacks_.Remove(response_id); | 369 pending_callbacks_.Remove(response_id); |
370 } | 370 } |
371 | 371 |
| 372 void IndexedDBDispatcher::RequestIDBIndexGetObjectByRange( |
| 373 const IndexedDBKeyRange& key_range, |
| 374 WebIDBCallbacks* callbacks_ptr, |
| 375 int32 idb_index_id, |
| 376 const WebIDBTransaction& transaction, |
| 377 WebExceptionCode* ec) { |
| 378 ResetCursorPrefetchCaches(); |
| 379 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 380 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 381 Send(new IndexedDBHostMsg_IndexGetObjectByRange( |
| 382 idb_index_id, CurrentWorkerId(), |
| 383 response_id, key_range, |
| 384 TransactionId(transaction), ec)); |
| 385 if (*ec) |
| 386 pending_callbacks_.Remove(response_id); |
| 387 } |
| 388 |
372 void IndexedDBDispatcher::RequestIDBIndexGetKey( | 389 void IndexedDBDispatcher::RequestIDBIndexGetKey( |
373 const IndexedDBKey& key, | 390 const IndexedDBKey& key, |
374 WebIDBCallbacks* callbacks_ptr, | 391 WebIDBCallbacks* callbacks_ptr, |
375 int32 idb_index_id, | 392 int32 idb_index_id, |
376 const WebIDBTransaction& transaction, | 393 const WebIDBTransaction& transaction, |
377 WebExceptionCode* ec) { | 394 WebExceptionCode* ec) { |
378 ResetCursorPrefetchCaches(); | 395 ResetCursorPrefetchCaches(); |
379 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 396 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
380 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 397 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
381 Send(new IndexedDBHostMsg_IndexGetKey( | 398 Send(new IndexedDBHostMsg_IndexGetKey( |
382 idb_index_id, CurrentWorkerId(), response_id, key, | 399 idb_index_id, CurrentWorkerId(), response_id, key, |
383 TransactionId(transaction), ec)); | 400 TransactionId(transaction), ec)); |
384 if (*ec) | 401 if (*ec) |
385 pending_callbacks_.Remove(response_id); | 402 pending_callbacks_.Remove(response_id); |
386 } | 403 } |
387 | 404 |
| 405 void IndexedDBDispatcher::RequestIDBIndexGetKeyByRange( |
| 406 const IndexedDBKeyRange& key_range, |
| 407 WebIDBCallbacks* callbacks_ptr, |
| 408 int32 idb_index_id, |
| 409 const WebIDBTransaction& transaction, |
| 410 WebExceptionCode* ec) { |
| 411 ResetCursorPrefetchCaches(); |
| 412 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 413 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 414 Send(new IndexedDBHostMsg_IndexGetKeyByRange( |
| 415 idb_index_id, CurrentWorkerId(), response_id, key_range, |
| 416 TransactionId(transaction), ec)); |
| 417 if (*ec) |
| 418 pending_callbacks_.Remove(response_id); |
| 419 } |
| 420 |
388 void IndexedDBDispatcher::RequestIDBObjectStoreGet( | 421 void IndexedDBDispatcher::RequestIDBObjectStoreGet( |
389 const IndexedDBKey& key, | 422 const IndexedDBKey& key, |
390 WebIDBCallbacks* callbacks_ptr, | 423 WebIDBCallbacks* callbacks_ptr, |
391 int32 idb_object_store_id, | 424 int32 idb_object_store_id, |
392 const WebIDBTransaction& transaction, | 425 const WebIDBTransaction& transaction, |
393 WebExceptionCode* ec) { | 426 WebExceptionCode* ec) { |
394 ResetCursorPrefetchCaches(); | 427 ResetCursorPrefetchCaches(); |
395 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 428 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
396 | 429 |
397 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 430 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
398 Send(new IndexedDBHostMsg_ObjectStoreGet( | 431 Send(new IndexedDBHostMsg_ObjectStoreGet( |
399 idb_object_store_id, CurrentWorkerId(), response_id, | 432 idb_object_store_id, CurrentWorkerId(), response_id, |
400 key, TransactionId(transaction), ec)); | 433 key, TransactionId(transaction), ec)); |
401 if (*ec) | 434 if (*ec) |
402 pending_callbacks_.Remove(response_id); | 435 pending_callbacks_.Remove(response_id); |
403 } | 436 } |
404 | 437 |
| 438 void IndexedDBDispatcher::RequestIDBObjectStoreGetByRange( |
| 439 const IndexedDBKeyRange& key_range, |
| 440 WebIDBCallbacks* callbacks_ptr, |
| 441 int32 idb_object_store_id, |
| 442 const WebIDBTransaction& transaction, |
| 443 WebExceptionCode* ec) { |
| 444 ResetCursorPrefetchCaches(); |
| 445 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 446 |
| 447 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 448 Send(new IndexedDBHostMsg_ObjectStoreGetByRange( |
| 449 idb_object_store_id, CurrentWorkerId(), response_id, |
| 450 key_range, TransactionId(transaction), ec)); |
| 451 if (*ec) |
| 452 pending_callbacks_.Remove(response_id); |
| 453 } |
| 454 |
405 void IndexedDBDispatcher::RequestIDBObjectStorePut( | 455 void IndexedDBDispatcher::RequestIDBObjectStorePut( |
406 const content::SerializedScriptValue& value, | 456 const content::SerializedScriptValue& value, |
407 const IndexedDBKey& key, | 457 const IndexedDBKey& key, |
408 WebKit::WebIDBObjectStore::PutMode put_mode, | 458 WebKit::WebIDBObjectStore::PutMode put_mode, |
409 WebIDBCallbacks* callbacks_ptr, | 459 WebIDBCallbacks* callbacks_ptr, |
410 int32 idb_object_store_id, | 460 int32 idb_object_store_id, |
411 const WebIDBTransaction& transaction, | 461 const WebIDBTransaction& transaction, |
412 WebExceptionCode* ec) { | 462 WebExceptionCode* ec) { |
413 ResetCursorPrefetchCaches(); | 463 ResetCursorPrefetchCaches(); |
414 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 464 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 } | 763 } |
714 | 764 |
715 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { | 765 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { |
716 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 766 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
717 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 767 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
718 if (i->first == exception_cursor_id) | 768 if (i->first == exception_cursor_id) |
719 continue; | 769 continue; |
720 i->second->ResetPrefetchCache(); | 770 i->second->ResetPrefetchCache(); |
721 } | 771 } |
722 } | 772 } |
OLD | NEW |