| 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/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 OnSuccessInteger) | 152 OnSuccessInteger) |
| 153 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessUndefined, | 153 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessUndefined, |
| 154 OnSuccessUndefined) | 154 OnSuccessUndefined) |
| 155 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) | 155 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) |
| 156 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksIntBlocked, OnIntBlocked) | 156 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksIntBlocked, OnIntBlocked) |
| 157 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksUpgradeNeeded, OnUpgradeNeeded) | 157 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksUpgradeNeeded, OnUpgradeNeeded) |
| 158 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksForcedClose, | 158 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksForcedClose, |
| 159 OnForcedClose) | 159 OnForcedClose) |
| 160 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksIntVersionChange, | 160 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksIntVersionChange, |
| 161 OnIntVersionChange) | 161 OnIntVersionChange) |
| 162 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange, | |
| 163 OnVersionChange) | |
| 164 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksAbort, OnAbort) | 162 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksAbort, OnAbort) |
| 165 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksComplete, OnComplete) | 163 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksComplete, OnComplete) |
| 166 IPC_MESSAGE_UNHANDLED(handled = false) | 164 IPC_MESSAGE_UNHANDLED(handled = false) |
| 167 IPC_END_MESSAGE_MAP() | 165 IPC_END_MESSAGE_MAP() |
| 168 // If a message gets here, IndexedDBMessageFilter already determined that it | 166 // If a message gets here, IndexedDBMessageFilter already determined that it |
| 169 // is an IndexedDB message. | 167 // is an IndexedDB message. |
| 170 DCHECK(handled) << "Didn't handle a message defined at line " | 168 DCHECK(handled) << "Didn't handle a message defined at line " |
| 171 << IPC_MESSAGE_ID_LINE(msg.type()); | 169 << IPC_MESSAGE_ID_LINE(msg.type()); |
| 172 } | 170 } |
| 173 | 171 |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 760 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 763 WebIDBDatabaseCallbacks* callbacks = | 761 WebIDBDatabaseCallbacks* callbacks = |
| 764 pending_database_callbacks_.Lookup(ipc_database_id); | 762 pending_database_callbacks_.Lookup(ipc_database_id); |
| 765 // callbacks would be NULL if a versionchange event is received after close | 763 // callbacks would be NULL if a versionchange event is received after close |
| 766 // has been called. | 764 // has been called. |
| 767 if (!callbacks) | 765 if (!callbacks) |
| 768 return; | 766 return; |
| 769 callbacks->onVersionChange(old_version, new_version); | 767 callbacks->onVersionChange(old_version, new_version); |
| 770 } | 768 } |
| 771 | 769 |
| 772 void IndexedDBDispatcher::OnVersionChange(int32 ipc_thread_id, | |
| 773 int32 ipc_database_id, | |
| 774 const string16& newVersion) { | |
| 775 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | |
| 776 WebIDBDatabaseCallbacks* callbacks = | |
| 777 pending_database_callbacks_.Lookup(ipc_database_id); | |
| 778 // callbacks would be NULL if a versionchange event is received after close | |
| 779 // has been called. | |
| 780 if (!callbacks) | |
| 781 return; | |
| 782 callbacks->onVersionChange(newVersion); | |
| 783 } | |
| 784 | |
| 785 void IndexedDBDispatcher::ResetCursorPrefetchCaches( | 770 void IndexedDBDispatcher::ResetCursorPrefetchCaches( |
| 786 int32 ipc_exception_cursor_id) { | 771 int32 ipc_exception_cursor_id) { |
| 787 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 772 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| 788 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 773 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 789 if (i->first == ipc_exception_cursor_id) | 774 if (i->first == ipc_exception_cursor_id) |
| 790 continue; | 775 continue; |
| 791 i->second->ResetPrefetchCache(); | 776 i->second->ResetPrefetchCache(); |
| 792 } | 777 } |
| 793 } | 778 } |
| 794 | 779 |
| 795 } // namespace content | 780 } // namespace content |
| OLD | NEW |