| 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_TransactionCallbacksAbort, OnAbort) | 112 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) |
| 109 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) | 113 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) |
| 110 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksForcedClose, | 114 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksForcedClose, |
| 111 OnForcedClose) | 115 OnForcedClose) |
| 112 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksIntVersionChange, | 116 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksIntVersionChange, |
| 113 OnIntVersionChange) | 117 OnIntVersionChange) |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 const IndexedDBKey& primary_key, | 583 const IndexedDBKey& primary_key, |
| 580 const IndexedDBKeyPath& key_path) { | 584 const IndexedDBKeyPath& key_path) { |
| 581 DCHECK_EQ(thread_id, CurrentWorkerId()); | 585 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 582 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 586 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| 583 if (!callbacks) | 587 if (!callbacks) |
| 584 return; | 588 return; |
| 585 callbacks->onSuccess(value, primary_key, key_path); | 589 callbacks->onSuccess(value, primary_key, key_path); |
| 586 pending_callbacks_.Remove(response_id); | 590 pending_callbacks_.Remove(response_id); |
| 587 } | 591 } |
| 588 | 592 |
| 593 void IndexedDBDispatcher::OnSuccessInteger( |
| 594 int32 thread_id, int32 response_id, int64 value) { |
| 595 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 596 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| 597 if (!callbacks) |
| 598 return; |
| 599 callbacks->onSuccess(value); |
| 600 pending_callbacks_.Remove(response_id); |
| 601 } |
| 602 |
| 603 void IndexedDBDispatcher::OnSuccessUndefined( |
| 604 int32 thread_id, int32 response_id) { |
| 605 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 606 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| 607 if (!callbacks) |
| 608 return; |
| 609 callbacks->onSuccess(); |
| 610 pending_callbacks_.Remove(response_id); |
| 611 } |
| 612 |
| 589 void IndexedDBDispatcher::OnSuccessOpenCursor( | 613 void IndexedDBDispatcher::OnSuccessOpenCursor( |
| 590 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p) { | 614 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p) { |
| 591 DCHECK_EQ(p.thread_id, CurrentWorkerId()); | 615 DCHECK_EQ(p.thread_id, CurrentWorkerId()); |
| 592 int32 response_id = p.response_id; | 616 int32 response_id = p.response_id; |
| 593 int32 object_id = p.cursor_id; | 617 int32 object_id = p.cursor_id; |
| 594 const IndexedDBKey& key = p.key; | 618 const IndexedDBKey& key = p.key; |
| 595 const IndexedDBKey& primary_key = p.primary_key; | 619 const IndexedDBKey& primary_key = p.primary_key; |
| 596 const SerializedScriptValue& value = p.serialized_value; | 620 const SerializedScriptValue& value = p.serialized_value; |
| 597 | 621 |
| 598 WebIDBCallbacks* callbacks = | 622 WebIDBCallbacks* callbacks = |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 } | 770 } |
| 747 | 771 |
| 748 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { | 772 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { |
| 749 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 773 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| 750 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 774 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 751 if (i->first == exception_cursor_id) | 775 if (i->first == exception_cursor_id) |
| 752 continue; | 776 continue; |
| 753 i->second->ResetPrefetchCache(); | 777 i->second->ResetPrefetchCache(); |
| 754 } | 778 } |
| 755 } | 779 } |
| OLD | NEW |