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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, | 94 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, |
95 OnSuccessIndexedDBKey) | 95 OnSuccessIndexedDBKey) |
96 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction, | 96 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction, |
97 OnSuccessIDBTransaction) | 97 OnSuccessIDBTransaction) |
98 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, | 98 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, |
99 OnSuccessStringList) | 99 OnSuccessStringList) |
100 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue, | 100 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue, |
101 OnSuccessSerializedScriptValue) | 101 OnSuccessSerializedScriptValue) |
102 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValueWithKe y, | 102 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValueWithKe y, |
103 OnSuccessSerializedScriptValueWithKey) | 103 OnSuccessSerializedScriptValueWithKey) |
104 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessInteger, | |
105 OnSuccessInteger) | |
106 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessUndefined, | |
107 OnSuccessUndefined) | |
104 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) | 108 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) |
105 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) | 109 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) |
106 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksIntBlocked, OnIntBlocked) | 110 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksIntBlocked, OnIntBlocked) |
107 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksUpgradeNeeded, OnUpgradeNeeded) | 111 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksUpgradeNeeded, OnUpgradeNeeded) |
108 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbortLegacy, | 112 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbortLegacy, |
109 OnAbortLegacy) | 113 OnAbortLegacy) |
110 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) | 114 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) |
111 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) | 115 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) |
112 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksForcedClose, | 116 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksForcedClose, |
113 OnForcedClose) | 117 OnForcedClose) |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 if (!callbacks) | 524 if (!callbacks) |
521 return; | 525 return; |
522 // If an upgrade was performed, count will be non-zero. | 526 // If an upgrade was performed, count will be non-zero. |
523 if (!databases_.count(object_id)) | 527 if (!databases_.count(object_id)) |
524 databases_[object_id] = new RendererWebIDBDatabaseImpl(object_id); | 528 databases_[object_id] = new RendererWebIDBDatabaseImpl(object_id); |
525 DCHECK_EQ(databases_.count(object_id), 1u); | 529 DCHECK_EQ(databases_.count(object_id), 1u); |
526 callbacks->onSuccess(databases_[object_id]); | 530 callbacks->onSuccess(databases_[object_id]); |
527 pending_callbacks_.Remove(response_id); | 531 pending_callbacks_.Remove(response_id); |
528 } | 532 } |
529 | 533 |
534 void IndexedDBDispatcher::OnSuccessIDBDatabaseDeleted( | |
dgrogan
2012/10/17 01:21:00
Does this guy have an IPC_MESSAGE_HANDLER line?
| |
535 int32 thread_id, | |
536 int32 response_id, | |
537 int32 database_id) { | |
538 DCHECK_EQ(thread_id, CurrentWorkerId()); | |
539 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | |
540 if (!callbacks) | |
541 return; | |
542 DCHECK_EQ(databases_.count(database_id), 1u); | |
543 callbacks->onSuccess(); | |
544 pending_callbacks_.Remove(response_id); | |
545 } | |
546 | |
530 void IndexedDBDispatcher::OnSuccessIndexedDBKey( | 547 void IndexedDBDispatcher::OnSuccessIndexedDBKey( |
531 int32 thread_id, | 548 int32 thread_id, |
532 int32 response_id, | 549 int32 response_id, |
533 const IndexedDBKey& key) { | 550 const IndexedDBKey& key) { |
534 DCHECK_EQ(thread_id, CurrentWorkerId()); | 551 DCHECK_EQ(thread_id, CurrentWorkerId()); |
535 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 552 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
536 if (!callbacks) | 553 if (!callbacks) |
537 return; | 554 return; |
538 callbacks->onSuccess(key); | 555 callbacks->onSuccess(key); |
539 pending_callbacks_.Remove(response_id); | 556 pending_callbacks_.Remove(response_id); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 const IndexedDBKey& primary_key, | 598 const IndexedDBKey& primary_key, |
582 const IndexedDBKeyPath& key_path) { | 599 const IndexedDBKeyPath& key_path) { |
583 DCHECK_EQ(thread_id, CurrentWorkerId()); | 600 DCHECK_EQ(thread_id, CurrentWorkerId()); |
584 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 601 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
585 if (!callbacks) | 602 if (!callbacks) |
586 return; | 603 return; |
587 callbacks->onSuccess(value, primary_key, key_path); | 604 callbacks->onSuccess(value, primary_key, key_path); |
588 pending_callbacks_.Remove(response_id); | 605 pending_callbacks_.Remove(response_id); |
589 } | 606 } |
590 | 607 |
608 void IndexedDBDispatcher::OnSuccessInteger( | |
609 int32 thread_id, int32 response_id, | |
610 int64 value) { | |
611 DCHECK_EQ(thread_id, CurrentWorkerId()); | |
612 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | |
613 if (!callbacks) | |
614 return; | |
615 callbacks->onSuccess(value); | |
616 pending_callbacks_.Remove(response_id); | |
617 } | |
618 | |
619 void IndexedDBDispatcher::OnSuccessUndefined( | |
620 int32 thread_id, int32 response_id) { | |
621 DCHECK_EQ(thread_id, CurrentWorkerId()); | |
622 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | |
623 if (!callbacks) | |
624 return; | |
625 callbacks->onSuccess(); | |
626 pending_callbacks_.Remove(response_id); | |
627 } | |
628 | |
591 void IndexedDBDispatcher::OnSuccessOpenCursor( | 629 void IndexedDBDispatcher::OnSuccessOpenCursor( |
592 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p) { | 630 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p) { |
593 DCHECK_EQ(p.thread_id, CurrentWorkerId()); | 631 DCHECK_EQ(p.thread_id, CurrentWorkerId()); |
594 int32 response_id = p.response_id; | 632 int32 response_id = p.response_id; |
595 int32 object_id = p.cursor_id; | 633 int32 object_id = p.cursor_id; |
596 const IndexedDBKey& key = p.key; | 634 const IndexedDBKey& key = p.key; |
597 const IndexedDBKey& primary_key = p.primary_key; | 635 const IndexedDBKey& primary_key = p.primary_key; |
598 const SerializedScriptValue& value = p.serialized_value; | 636 const SerializedScriptValue& value = p.serialized_value; |
599 | 637 |
600 WebIDBCallbacks* callbacks = | 638 WebIDBCallbacks* callbacks = |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
759 } | 797 } |
760 | 798 |
761 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { | 799 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { |
762 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 800 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
763 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 801 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
764 if (i->first == exception_cursor_id) | 802 if (i->first == exception_cursor_id) |
765 continue; | 803 continue; |
766 i->second->ResetPrefetchCache(); | 804 i->second->ResetPrefetchCache(); |
767 } | 805 } |
768 } | 806 } |
OLD | NEW |