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