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_CallbacksSuccessCursorAdvance, | 94 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorAdvance, |
95 OnSuccessCursorContinue) | 95 OnSuccessCursorContinue) |
96 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue, | 96 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue, |
97 OnSuccessCursorContinue) | 97 OnSuccessCursorContinue) |
98 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorPrefetch, | 98 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorPrefetch, |
99 OnSuccessCursorPrefetch) | 99 OnSuccessCursorPrefetch) |
100 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, | 100 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, |
101 OnSuccessIDBDatabase) | 101 OnSuccessIDBDatabase) |
102 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, | 102 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, |
103 OnSuccessIndexedDBKey) | 103 OnSuccessIndexedDBKey) |
104 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction, | |
105 OnSuccessIDBTransaction) | |
106 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, | 104 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, |
107 OnSuccessStringList) | 105 OnSuccessStringList) |
108 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue, | 106 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue, |
109 OnSuccessSerializedScriptValue) | 107 OnSuccessSerializedScriptValue) |
110 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValueWithKe
y, | 108 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValueWithKe
y, |
111 OnSuccessSerializedScriptValueWithKey) | 109 OnSuccessSerializedScriptValueWithKey) |
112 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessInteger, | 110 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessInteger, |
113 OnSuccessInteger) | 111 OnSuccessInteger) |
114 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessUndefined, | 112 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessUndefined, |
115 OnSuccessUndefined) | 113 OnSuccessUndefined) |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 269 |
272 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { | 270 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { |
273 ResetCursorPrefetchCaches(); | 271 ResetCursorPrefetchCaches(); |
274 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); | 272 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); |
275 // There won't be pending database callbacks if the transaction was aborted in | 273 // There won't be pending database callbacks if the transaction was aborted in |
276 // the initial upgradeneeded event handler. | 274 // the initial upgradeneeded event handler. |
277 if (pending_database_callbacks_.Lookup(idb_database_id)) | 275 if (pending_database_callbacks_.Lookup(idb_database_id)) |
278 pending_database_callbacks_.Remove(idb_database_id); | 276 pending_database_callbacks_.Remove(idb_database_id); |
279 } | 277 } |
280 | 278 |
281 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( | |
282 const string16& version, | |
283 WebIDBCallbacks* callbacks_ptr, | |
284 int32 idb_database_id, | |
285 WebExceptionCode* ec) { | |
286 ResetCursorPrefetchCaches(); | |
287 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | |
288 | |
289 int32 response_id = pending_callbacks_.Add(callbacks.release()); | |
290 Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, | |
291 CurrentWorkerId(), | |
292 response_id, version, ec)); | |
293 if (*ec) | |
294 pending_callbacks_.Remove(response_id); | |
295 } | |
296 | |
297 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( | 279 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( |
298 const WebIDBKeyRange& idb_key_range, | 280 const WebIDBKeyRange& idb_key_range, |
299 unsigned short direction, | 281 unsigned short direction, |
300 WebIDBCallbacks* callbacks_ptr, | 282 WebIDBCallbacks* callbacks_ptr, |
301 int32 idb_index_id, | 283 int32 idb_index_id, |
302 const WebIDBTransaction& transaction, | 284 const WebIDBTransaction& transaction, |
303 WebExceptionCode* ec) { | 285 WebExceptionCode* ec) { |
304 ResetCursorPrefetchCaches(); | 286 ResetCursorPrefetchCaches(); |
305 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 287 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
306 IndexedDBHostMsg_IndexOpenCursor_Params params; | 288 IndexedDBHostMsg_IndexOpenCursor_Params params; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 int32 response_id, | 519 int32 response_id, |
538 const IndexedDBKey& key) { | 520 const IndexedDBKey& key) { |
539 DCHECK_EQ(thread_id, CurrentWorkerId()); | 521 DCHECK_EQ(thread_id, CurrentWorkerId()); |
540 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 522 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
541 if (!callbacks) | 523 if (!callbacks) |
542 return; | 524 return; |
543 callbacks->onSuccess(key); | 525 callbacks->onSuccess(key); |
544 pending_callbacks_.Remove(response_id); | 526 pending_callbacks_.Remove(response_id); |
545 } | 527 } |
546 | 528 |
547 void IndexedDBDispatcher::OnSuccessIDBTransaction(int32 thread_id, | |
548 int32 response_id, | |
549 int32 object_id) { | |
550 DCHECK_EQ(thread_id, CurrentWorkerId()); | |
551 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | |
552 if (!callbacks) | |
553 return; | |
554 callbacks->onSuccess(new RendererWebIDBTransactionImpl(object_id)); | |
555 pending_callbacks_.Remove(response_id); | |
556 } | |
557 | |
558 void IndexedDBDispatcher::OnSuccessStringList( | 529 void IndexedDBDispatcher::OnSuccessStringList( |
559 int32 thread_id, int32 response_id, const std::vector<string16>& value) { | 530 int32 thread_id, int32 response_id, const std::vector<string16>& value) { |
560 DCHECK_EQ(thread_id, CurrentWorkerId()); | 531 DCHECK_EQ(thread_id, CurrentWorkerId()); |
561 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 532 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
562 if (!callbacks) | 533 if (!callbacks) |
563 return; | 534 return; |
564 WebDOMStringList string_list; | 535 WebDOMStringList string_list; |
565 for (std::vector<string16>::const_iterator it = value.begin(); | 536 for (std::vector<string16>::const_iterator it = value.begin(); |
566 it != value.end(); ++it) | 537 it != value.end(); ++it) |
567 string_list.append(*it); | 538 string_list.append(*it); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { | 746 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { |
776 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 747 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
777 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 748 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
778 if (i->first == exception_cursor_id) | 749 if (i->first == exception_cursor_id) |
779 continue; | 750 continue; |
780 i->second->ResetPrefetchCache(); | 751 i->second->ResetPrefetchCache(); |
781 } | 752 } |
782 } | 753 } |
783 | 754 |
784 } // namespace content | 755 } // namespace content |
OLD | NEW |