Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: content/common/indexed_db/indexed_db_dispatcher.cc

Issue 10759012: Chromium side of plumbing for passing renderer-generated keys through IPC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Include unit tests too Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 pending_callbacks_.Remove(response_id); 414 pending_callbacks_.Remove(response_id);
415 } 415 }
416 416
417 void IndexedDBDispatcher::RequestIDBObjectStorePut( 417 void IndexedDBDispatcher::RequestIDBObjectStorePut(
418 const SerializedScriptValue& value, 418 const SerializedScriptValue& value,
419 const IndexedDBKey& key, 419 const IndexedDBKey& key,
420 WebKit::WebIDBObjectStore::PutMode put_mode, 420 WebKit::WebIDBObjectStore::PutMode put_mode,
421 WebIDBCallbacks* callbacks_ptr, 421 WebIDBCallbacks* callbacks_ptr,
422 int32 idb_object_store_id, 422 int32 idb_object_store_id,
423 const WebIDBTransaction& transaction, 423 const WebIDBTransaction& transaction,
424 const WebKit::WebVector<WebKit::WebString>& index_names,
425 const WebKit::WebVector<WebKit::WebVector<WebKit::WebIDBKey> >& index_keys,
424 WebExceptionCode* ec) { 426 WebExceptionCode* ec) {
425 ResetCursorPrefetchCaches(); 427 ResetCursorPrefetchCaches();
426 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 428 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
427 if (!value.is_null() && 429 if (!value.is_null() &&
428 (value.data().length() * sizeof(char16)) > kMaxIDBValueSizeInBytes) { 430 (value.data().length() * sizeof(char16)) > kMaxIDBValueSizeInBytes) {
429 *ec = WebKit::WebIDBDatabaseExceptionDataError; 431 *ec = WebKit::WebIDBDatabaseExceptionDataError;
430 return; 432 return;
431 } 433 }
432 IndexedDBHostMsg_ObjectStorePut_Params params; 434 IndexedDBHostMsg_ObjectStorePut_Params params;
433 params.thread_id = CurrentWorkerId(); 435 params.thread_id = CurrentWorkerId();
434 params.idb_object_store_id = idb_object_store_id; 436 params.idb_object_store_id = idb_object_store_id;
435 params.response_id = pending_callbacks_.Add(callbacks.release()); 437 params.response_id = pending_callbacks_.Add(callbacks.release());
436 params.serialized_value = value; 438 params.serialized_value = value;
437 params.key = key; 439 params.key = key;
438 params.put_mode = put_mode; 440 params.put_mode = put_mode;
439 params.transaction_id = TransactionId(transaction); 441 params.transaction_id = TransactionId(transaction);
442 params.index_names.resize(index_names.size());
443 for (size_t i = 0; i < index_names.size(); ++i) {
444 params.index_names[i] = index_names[i];
445 }
446
447 params.index_keys.resize(index_keys.size());
448 for (size_t i = 0; i < index_keys.size(); ++i) {
449 params.index_keys[i].resize(index_keys[i].size());
450 for (size_t j = 0; j < index_keys[i].size(); ++j) {
451 params.index_keys[i][j] = content::IndexedDBKey(index_keys[i][j]);
452 }
453 }
440 Send(new IndexedDBHostMsg_ObjectStorePut(params, ec)); 454 Send(new IndexedDBHostMsg_ObjectStorePut(params, ec));
441 if (*ec) 455 if (*ec)
442 pending_callbacks_.Remove(params.response_id); 456 pending_callbacks_.Remove(params.response_id);
443 } 457 }
444 458
445 void IndexedDBDispatcher::RequestIDBObjectStoreDelete( 459 void IndexedDBDispatcher::RequestIDBObjectStoreDelete(
446 const IndexedDBKeyRange& key_range, 460 const IndexedDBKeyRange& key_range,
447 WebIDBCallbacks* callbacks_ptr, 461 WebIDBCallbacks* callbacks_ptr,
448 int32 idb_object_store_id, 462 int32 idb_object_store_id,
449 const WebIDBTransaction& transaction, 463 const WebIDBTransaction& transaction,
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 } 717 }
704 718
705 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { 719 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) {
706 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; 720 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator;
707 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { 721 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) {
708 if (i->first == exception_cursor_id) 722 if (i->first == exception_cursor_id)
709 continue; 723 continue;
710 i->second->ResetPrefetchCache(); 724 i->second->ResetPrefetchCache();
711 } 725 }
712 } 726 }
OLDNEW
« no previous file with comments | « content/common/indexed_db/indexed_db_dispatcher.h ('k') | content/common/indexed_db/indexed_db_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698