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

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

Issue 2276593002: Support renaming of IndexedDB indexes and object stores. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test coverage for the (slightly incorrect) behavior in strict mode when our flag is not enabl… Created 4 years, 3 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/browser/indexed_db/indexed_db_dispatcher_host.h" 5 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 message.type() == IndexedDBHostMsg_AckReceivedBlobs::ID) || 497 message.type() == IndexedDBHostMsg_AckReceivedBlobs::ID) ||
498 parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 498 parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
499 499
500 bool handled = true; 500 bool handled = true;
501 IPC_BEGIN_MESSAGE_MAP( 501 IPC_BEGIN_MESSAGE_MAP(
502 IndexedDBDispatcherHost::DatabaseDispatcherHost, message) 502 IndexedDBDispatcherHost::DatabaseDispatcherHost, message)
503 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, 503 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore,
504 OnCreateObjectStore) 504 OnCreateObjectStore)
505 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, 505 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore,
506 OnDeleteObjectStore) 506 OnDeleteObjectStore)
507 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseRenameObjectStore,
508 OnRenameObjectStore)
507 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, 509 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction,
508 OnCreateTransaction) 510 OnCreateTransaction)
509 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) 511 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose)
510 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseVersionChangeIgnored, 512 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseVersionChangeIgnored,
511 OnVersionChangeIgnored) 513 OnVersionChangeIgnored)
512 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) 514 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed)
513 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseObserve, OnObserve) 515 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseObserve, OnObserve)
514 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseUnobserve, OnUnobserve) 516 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseUnobserve, OnUnobserve)
515 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) 517 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet)
516 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGetAll, OnGetAll) 518 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGetAll, OnGetAll)
517 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPutWrapper) 519 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPutWrapper)
518 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, OnSetIndexKeys) 520 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, OnSetIndexKeys)
519 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, 521 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady,
520 OnSetIndexesReady) 522 OnSetIndexesReady)
521 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) 523 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor)
522 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) 524 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount)
523 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange) 525 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange)
524 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) 526 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear)
525 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateIndex, OnCreateIndex) 527 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateIndex, OnCreateIndex)
526 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteIndex, OnDeleteIndex) 528 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteIndex, OnDeleteIndex)
529 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseRenameIndex, OnRenameIndex)
527 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseAbort, OnAbort) 530 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseAbort, OnAbort)
528 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCommit, OnCommit) 531 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCommit, OnCommit)
529 IPC_MESSAGE_UNHANDLED(handled = false) 532 IPC_MESSAGE_UNHANDLED(handled = false)
530 IPC_END_MESSAGE_MAP() 533 IPC_END_MESSAGE_MAP()
531 534
532 return handled; 535 return handled;
533 } 536 }
534 537
535 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( 538 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore(
536 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) { 539 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) {
(...skipping 19 matching lines...) Expand all
556 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 559 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
557 IndexedDBConnection* connection = 560 IndexedDBConnection* connection =
558 parent_->GetOrTerminateProcess(&map_, ipc_database_id); 561 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
559 if (!connection || !connection->IsConnected()) 562 if (!connection || !connection->IsConnected())
560 return; 563 return;
561 564
562 connection->database()->DeleteObjectStore( 565 connection->database()->DeleteObjectStore(
563 parent_->HostTransactionId(transaction_id), object_store_id); 566 parent_->HostTransactionId(transaction_id), object_store_id);
564 } 567 }
565 568
569 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnRenameObjectStore(
570 int32_t ipc_database_id,
571 int64_t transaction_id,
572 int64_t object_store_id,
573 const base::string16& new_name) {
574 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
575 IndexedDBConnection* connection =
576 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
577 if (!connection || !connection->IsConnected())
578 return;
579
580 connection->database()->RenameObjectStore(
581 parent_->HostTransactionId(transaction_id), object_store_id, new_name);
582 }
583
566 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( 584 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction(
567 const IndexedDBHostMsg_DatabaseCreateTransaction_Params& params) { 585 const IndexedDBHostMsg_DatabaseCreateTransaction_Params& params) {
568 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 586 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
569 IndexedDBConnection* connection = 587 IndexedDBConnection* connection =
570 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 588 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
571 if (!connection || !connection->IsConnected()) 589 if (!connection || !connection->IsConnected())
572 return; 590 return;
573 591
574 int64_t host_transaction_id = 592 int64_t host_transaction_id =
575 parent_->HostTransactionId(params.transaction_id); 593 parent_->HostTransactionId(params.transaction_id);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 965 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
948 IndexedDBConnection* connection = 966 IndexedDBConnection* connection =
949 parent_->GetOrTerminateProcess(&map_, ipc_database_id); 967 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
950 if (!connection || !connection->IsConnected()) 968 if (!connection || !connection->IsConnected())
951 return; 969 return;
952 970
953 connection->database()->DeleteIndex( 971 connection->database()->DeleteIndex(
954 parent_->HostTransactionId(transaction_id), object_store_id, index_id); 972 parent_->HostTransactionId(transaction_id), object_store_id, index_id);
955 } 973 }
956 974
975 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnRenameIndex(
976 int32_t ipc_database_id,
977 int64_t transaction_id,
978 int64_t object_store_id,
979 int64_t index_id,
980 const base::string16& new_name) {
981 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
982 IndexedDBConnection* connection =
983 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
984 if (!connection || !connection->IsConnected())
985 return;
986
987 connection->database()->RenameIndex(
988 parent_->HostTransactionId(transaction_id), object_store_id, index_id,
989 new_name);
990 }
991
957 ////////////////////////////////////////////////////////////////////// 992 //////////////////////////////////////////////////////////////////////
958 // IndexedDBDispatcherHost::CursorDispatcherHost 993 // IndexedDBDispatcherHost::CursorDispatcherHost
959 // 994 //
960 995
961 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( 996 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost(
962 IndexedDBDispatcherHost* parent) 997 IndexedDBDispatcherHost* parent)
963 : parent_(parent) { 998 : parent_(parent) {
964 map_.set_check_on_null_data(true); 999 map_.set_check_on_null_data(true);
965 } 1000 }
966 1001
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 DLOG(ERROR) << "Unable to reset prefetch"; 1092 DLOG(ERROR) << "Unable to reset prefetch";
1058 } 1093 }
1059 1094
1060 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( 1095 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
1061 int32_t ipc_object_id) { 1096 int32_t ipc_object_id) {
1062 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 1097 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
1063 parent_->DestroyObject(&map_, ipc_object_id); 1098 parent_->DestroyObject(&map_, ipc_object_id);
1064 } 1099 }
1065 1100
1066 } // namespace content 1101 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698