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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_dispatcher_host.cc

Issue 11567029: Proxy new objectstore/index methods through IPC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years 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/browser/in_process_webkit/indexed_db_dispatcher_host.h" 5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 message, *msg_is_ok) 354 message, *msg_is_ok)
355 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) 355 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata)
356 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, 356 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore,
357 OnCreateObjectStore) 357 OnCreateObjectStore)
358 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, 358 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore,
359 OnDeleteObjectStore) 359 OnDeleteObjectStore)
360 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, 360 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction,
361 OnCreateTransaction) 361 OnCreateTransaction)
362 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) 362 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose)
363 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) 363 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed)
364 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet)
365 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut)
366 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys,
367 OnSetIndexKeys)
368 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady,
369 OnSetIndexesReady)
370 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor)
371 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount)
372 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDelete)
373 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear)
364 IPC_MESSAGE_UNHANDLED(handled = false) 374 IPC_MESSAGE_UNHANDLED(handled = false)
365 IPC_END_MESSAGE_MAP() 375 IPC_END_MESSAGE_MAP()
366 return handled; 376 return handled;
367 } 377 }
368 378
369 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( 379 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send(
370 IPC::Message* message) { 380 IPC::Message* message) {
371 parent_->Send(message); 381 parent_->Send(message);
372 } 382 }
373 383
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 494
485 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( 495 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed(
486 int32 ipc_object_id) { 496 int32 ipc_object_id) {
487 WebIDBDatabase* database = map_.Lookup(ipc_object_id); 497 WebIDBDatabase* database = map_.Lookup(ipc_object_id);
488 parent_->Context()->ConnectionClosed(database_url_map_[ipc_object_id], 498 parent_->Context()->ConnectionClosed(database_url_map_[ipc_object_id],
489 database); 499 database);
490 database_url_map_.erase(ipc_object_id); 500 database_url_map_.erase(ipc_object_id);
491 parent_->DestroyObject(&map_, ipc_object_id); 501 parent_->DestroyObject(&map_, ipc_object_id);
492 } 502 }
493 503
504 // XXX alecf
505 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet(
506 const IndexedDBHostMsg_DatabaseGet_Params& params) {
507 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
508 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
509 &map_, params.ipc_database_id);
510 if (!database)
511 return;
512
513 scoped_ptr<WebIDBCallbacks> callbacks(
514 new IndexedDBCallbacks<WebSerializedScriptValue>(
515 parent_, params.ipc_thread_id,
516 params.ipc_response_id));
517 database->get(params.transaction_id, params.object_store_id,
518 params.index_id,
519 params.key_range, params.key_only, callbacks.release());
520 }
521
522 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut(
523 const IndexedDBHostMsg_DatabasePut_Params& params) {
524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
525
526 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
527 &map_, params.ipc_database_id);
528 if (!database)
529 return;
530 scoped_ptr<WebIDBCallbacks> callbacks(
531 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id,
532 params.ipc_response_id));
533
534 database->put(params.transaction_id, params.object_store_id,
535 params.value, params.key,
536 params.put_mode, callbacks.release(),
537 params.index_ids,
538 params.index_keys);
539 WebIDBTransactionIDToSizeMap* map =
540 &parent_->database_dispatcher_host_->transaction_size_map_;
541 (*map)[params.transaction_id] += params.value.size();
Tom Sepez 2012/12/14 01:34:43 Safe from overflow because a corrupt renderer can'
542 }
543
544 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys(
545 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) {
546 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
547 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
548 &map_, params.ipc_database_id);
549 if (!database)
550 return;
551
552 database->setIndexKeys(params.transaction_id, params.object_store_id,
553 params.primary_key, params.index_ids,
554 params.index_keys);
555 }
556
557 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady(
558 int32 ipc_database_id,
559 int64 transaction_id,
560 int64 object_store_id,
561 const std::vector<int64>& index_ids) {
562 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
563 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
564 &map_, ipc_database_id);
565 if (!database)
566 return;
567
568 database->setIndexesReady(transaction_id, object_store_id,
569 WebVector<long long>(index_ids));
570 }
571
572 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor(
573 const IndexedDBHostMsg_DatabaseOpenCursor_Params& params) {
574 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
575 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
576 &map_, params.ipc_database_id);
577 if (!database)
578 return;
579
580 scoped_ptr<WebIDBCallbacks> callbacks(
581 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.ipc_thread_id,
582 params.ipc_response_id, -1));
583 database->openCursor(
584 params.transaction_id, params.object_store_id, params.index_id,
585 params.key_range, params.direction, params.key_only, params.task_type,
586 callbacks.release());
587 }
588
589 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount(
590 const IndexedDBHostMsg_DatabaseCount_Params& params) {
591 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
592 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
593 &map_, params.ipc_database_id);
594 if (!database)
595 return;
596
597 scoped_ptr<WebIDBCallbacks> callbacks(
598 new IndexedDBCallbacks<WebSerializedScriptValue>(
599 parent_, params.ipc_thread_id,
600 params.ipc_response_id));
601 database->count(
602 params.transaction_id, params.object_store_id, params.index_id,
603 params.key_range, callbacks.release());
604 }
605
606 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDelete(
607 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params) {
608 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
609 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
610 &map_, params.ipc_database_id);
611 if (!database)
612 return;
613
614 scoped_ptr<WebIDBCallbacks> callbacks(
615 new IndexedDBCallbacks<WebSerializedScriptValue>(
616 parent_, params.ipc_thread_id,
617 params.ipc_response_id));
618 database->deleteRange(params.transaction_id, params.object_store_id,
619 params.key_range, callbacks.release());
620 }
621
622 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear(
623 int32 ipc_thread_id,
624 int32 ipc_response_id,
625 int32 ipc_database_id,
626 int64 transaction_id,
627 int64 object_store_id) {
628 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
629 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
630 &map_, ipc_database_id);
631 if (!database)
632 return;
633
634 scoped_ptr<WebIDBCallbacks> callbacks(
635 new IndexedDBCallbacks<WebSerializedScriptValue>(
636 parent_, ipc_thread_id,
637 ipc_response_id));
638
639 database->clear(transaction_id, object_store_id, callbacks.release());
640 }
641
642 // xxx end alecf
494 643
495 ////////////////////////////////////////////////////////////////////// 644 //////////////////////////////////////////////////////////////////////
496 // IndexedDBDispatcherHost::IndexDispatcherHost 645 // IndexedDBDispatcherHost::IndexDispatcherHost
497 // 646 //
498 647
499 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( 648 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost(
500 IndexedDBDispatcherHost* parent) 649 IndexedDBDispatcherHost* parent)
501 : parent_(parent) { 650 : parent_(parent) {
502 map_.set_check_on_null_data(true); 651 map_.set_check_on_null_data(true);
503 } 652 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 return; 861 return;
713 862
714 scoped_ptr<WebIDBCallbacks> callbacks( 863 scoped_ptr<WebIDBCallbacks> callbacks(
715 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, 864 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id,
716 params.ipc_response_id)); 865 params.ipc_response_id));
717 idb_object_store->put(params.serialized_value, params.key, 866 idb_object_store->put(params.serialized_value, params.key,
718 params.put_mode, callbacks.release(), 867 params.put_mode, callbacks.release(),
719 *idb_transaction, params.index_ids, 868 *idb_transaction, params.index_ids,
720 params.index_keys); 869 params.index_keys);
721 int64 size = UTF16ToUTF8(params.serialized_value.data()).size(); 870 int64 size = UTF16ToUTF8(params.serialized_value.data()).size();
722 WebIDBTransactionIDToSizeMap* map = 871 WebIDBTransactionIPCIDToSizeMap* map =
723 &parent_->transaction_dispatcher_host_->transaction_size_map_; 872 &parent_->transaction_dispatcher_host_->transaction_ipc_size_map_;
724 (*map)[params.ipc_transaction_id] += size; 873 (*map)[params.ipc_transaction_id] += size;
725 } 874 }
726 875
727 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexKeys( 876 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexKeys(
728 int32 ipc_object_store_id, 877 int32 ipc_object_store_id,
729 const IndexedDBKey& primary_key, 878 const IndexedDBKey& primary_key,
730 const std::vector<int64>& index_names, 879 const std::vector<int64>& index_names,
731 const std::vector<std::vector<IndexedDBKey> >& index_keys, 880 const std::vector<std::vector<IndexedDBKey> >& index_keys,
732 int32 ipc_transaction_id) { 881 int32 ipc_transaction_id) {
733 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 882 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 int32 ipc_transaction_id) { 1225 int32 ipc_transaction_id) {
1077 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 1226 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
1078 &map_, ipc_transaction_id); 1227 &map_, ipc_transaction_id);
1079 if (!idb_transaction) 1228 if (!idb_transaction)
1080 return; 1229 return;
1081 1230
1082 // TODO(dgrogan): Tell the page the transaction aborted because of quota. 1231 // TODO(dgrogan): Tell the page the transaction aborted because of quota.
1083 // http://crbug.com/113118 1232 // http://crbug.com/113118
1084 if (parent_->Context()->WouldBeOverQuota( 1233 if (parent_->Context()->WouldBeOverQuota(
1085 transaction_url_map_[ipc_transaction_id], 1234 transaction_url_map_[ipc_transaction_id],
1086 transaction_size_map_[ipc_transaction_id])) { 1235 transaction_ipc_size_map_[ipc_transaction_id])) {
1087 idb_transaction->abort(); 1236 idb_transaction->abort();
1088 return; 1237 return;
1089 } 1238 }
1090 1239
1091 idb_transaction->commit(); 1240 idb_transaction->commit();
1092 } 1241 }
1093 1242
1094 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnAbort( 1243 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnAbort(
1095 int32 ipc_transaction_id) { 1244 int32 ipc_transaction_id) {
1096 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 1245 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
(...skipping 25 matching lines...) Expand all
1122 &map_, ipc_transaction_id); 1271 &map_, ipc_transaction_id);
1123 if (!idb_transaction) 1272 if (!idb_transaction)
1124 return; 1273 return;
1125 idb_transaction->didCompleteTaskEvents(); 1274 idb_transaction->didCompleteTaskEvents();
1126 } 1275 }
1127 1276
1128 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( 1277 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed(
1129 int32 ipc_object_id) { 1278 int32 ipc_object_id) {
1130 // TODO(dgrogan): This doesn't seem to be happening with some version change 1279 // TODO(dgrogan): This doesn't seem to be happening with some version change
1131 // transactions. Possibly introduced with integer version support. 1280 // transactions. Possibly introduced with integer version support.
1132 transaction_size_map_.erase(ipc_object_id); 1281 transaction_ipc_size_map_.erase(ipc_object_id);
1133 transaction_url_map_.erase(ipc_object_id); 1282 transaction_url_map_.erase(ipc_object_id);
1134 parent_->DestroyObject(&map_, ipc_object_id); 1283 parent_->DestroyObject(&map_, ipc_object_id);
1135 } 1284 }
1136 1285
1137 } // namespace content 1286 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698