| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 key_range, TransactionId(transaction))); | 393 key_range, TransactionId(transaction))); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void IndexedDBDispatcher::RequestIDBObjectStorePut( | 396 void IndexedDBDispatcher::RequestIDBObjectStorePut( |
| 397 const SerializedScriptValue& value, | 397 const SerializedScriptValue& value, |
| 398 const IndexedDBKey& key, | 398 const IndexedDBKey& key, |
| 399 WebKit::WebIDBObjectStore::PutMode put_mode, | 399 WebKit::WebIDBObjectStore::PutMode put_mode, |
| 400 WebIDBCallbacks* callbacks_ptr, | 400 WebIDBCallbacks* callbacks_ptr, |
| 401 int32 object_store_ipc_id, | 401 int32 object_store_ipc_id, |
| 402 const WebIDBTransaction& transaction, | 402 const WebIDBTransaction& transaction, |
| 403 const WebKit::WebVector<WebKit::WebString>& index_names, | |
| 404 const WebKit::WebVector<WebKit::WebVector<WebKit::WebIDBKey> >& index_keys, | |
| 405 WebExceptionCode* ec) { | |
| 406 ResetCursorPrefetchCaches(); | |
| 407 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | |
| 408 if (!value.is_null() && | |
| 409 (value.data().length() * sizeof(char16)) > kMaxIDBValueSizeInBytes) { | |
| 410 *ec = WebKit::WebIDBDatabaseExceptionDataError; | |
| 411 return; | |
| 412 } | |
| 413 IndexedDBHostMsg_ObjectStorePutOld_Params params; | |
| 414 params.thread_id = CurrentWorkerId(); | |
| 415 params.object_store_ipc_id = object_store_ipc_id; | |
| 416 params.response_id = pending_callbacks_.Add(callbacks.release()); | |
| 417 params.serialized_value = value; | |
| 418 params.key = key; | |
| 419 params.put_mode = put_mode; | |
| 420 params.transaction_id = TransactionId(transaction); | |
| 421 params.index_names.resize(index_names.size()); | |
| 422 for (size_t i = 0; i < index_names.size(); ++i) { | |
| 423 params.index_names[i] = index_names[i]; | |
| 424 } | |
| 425 | |
| 426 params.index_keys.resize(index_keys.size()); | |
| 427 for (size_t i = 0; i < index_keys.size(); ++i) { | |
| 428 params.index_keys[i].resize(index_keys[i].size()); | |
| 429 for (size_t j = 0; j < index_keys[i].size(); ++j) { | |
| 430 params.index_keys[i][j] = IndexedDBKey(index_keys[i][j]); | |
| 431 } | |
| 432 } | |
| 433 Send(new IndexedDBHostMsg_ObjectStorePutOld(params)); | |
| 434 } | |
| 435 | |
| 436 void IndexedDBDispatcher::RequestIDBObjectStorePut( | |
| 437 const SerializedScriptValue& value, | |
| 438 const IndexedDBKey& key, | |
| 439 WebKit::WebIDBObjectStore::PutMode put_mode, | |
| 440 WebIDBCallbacks* callbacks_ptr, | |
| 441 int32 object_store_ipc_id, | |
| 442 const WebIDBTransaction& transaction, | |
| 443 const WebKit::WebVector<long long>& index_ids, | 403 const WebKit::WebVector<long long>& index_ids, |
| 444 const WebKit::WebVector<WebKit::WebVector< | 404 const WebKit::WebVector<WebKit::WebVector< |
| 445 WebKit::WebIDBKey> >& index_keys) { | 405 WebKit::WebIDBKey> >& index_keys) { |
| 446 ResetCursorPrefetchCaches(); | 406 ResetCursorPrefetchCaches(); |
| 447 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 407 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 448 IndexedDBHostMsg_ObjectStorePut_Params params; | 408 IndexedDBHostMsg_ObjectStorePut_Params params; |
| 449 params.thread_id = CurrentWorkerId(); | 409 params.thread_id = CurrentWorkerId(); |
| 450 params.object_store_ipc_id = object_store_ipc_id; | 410 params.object_store_ipc_id = object_store_ipc_id; |
| 451 params.response_id = pending_callbacks_.Add(callbacks.release()); | 411 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 452 params.serialized_value = value; | 412 params.serialized_value = value; |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { | 775 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { |
| 816 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 776 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| 817 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 777 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 818 if (i->first == exception_cursor_id) | 778 if (i->first == exception_cursor_id) |
| 819 continue; | 779 continue; |
| 820 i->second->ResetPrefetchCache(); | 780 i->second->ResetPrefetchCache(); |
| 821 } | 781 } |
| 822 } | 782 } |
| 823 | 783 |
| 824 } // namespace content | 784 } // namespace content |
| OLD | NEW |