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

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

Issue 2062203004: IDBObserver: Lifetime Management: Adding Observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Observer moved to connection Created 4 years, 6 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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, 513 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore,
514 OnCreateObjectStore) 514 OnCreateObjectStore)
515 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, 515 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore,
516 OnDeleteObjectStore) 516 OnDeleteObjectStore)
517 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, 517 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction,
518 OnCreateTransaction) 518 OnCreateTransaction)
519 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) 519 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose)
520 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseVersionChangeIgnored, 520 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseVersionChangeIgnored,
521 OnVersionChangeIgnored) 521 OnVersionChangeIgnored)
522 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) 522 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed)
523 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseObserve, OnObserve)
dmurph 2016/06/22 01:09:49 Also add OnUnobserve
palakj1 2016/06/23 20:56:29 Oops! added.
523 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) 524 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet)
524 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGetAll, OnGetAll) 525 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGetAll, OnGetAll)
525 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPutWrapper) 526 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPutWrapper)
526 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, OnSetIndexKeys) 527 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, OnSetIndexKeys)
527 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, 528 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady,
528 OnSetIndexesReady) 529 OnSetIndexesReady)
529 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) 530 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor)
530 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) 531 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount)
531 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange) 532 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange)
532 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) 533 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 if (!connection) 623 if (!connection)
623 return; 624 return;
624 if (connection->IsConnected()) 625 if (connection->IsConnected())
625 connection->Close(); 626 connection->Close();
626 parent_->context()->ConnectionClosed(database_origin_map_[ipc_object_id], 627 parent_->context()->ConnectionClosed(database_origin_map_[ipc_object_id],
627 connection); 628 connection);
628 database_origin_map_.erase(ipc_object_id); 629 database_origin_map_.erase(ipc_object_id);
629 parent_->DestroyObject(&map_, ipc_object_id); 630 parent_->DestroyObject(&map_, ipc_object_id);
630 } 631 }
631 632
633 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObserve(
634 int32_t ipc_database_id,
635 int64_t transaction_id,
636 int32_t observer_id) {
637 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
638 IndexedDBConnection* connection =
639 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
640 if (!connection || !connection->IsConnected())
641 return;
642 connection->database()->Observe(parent_->HostTransactionId(transaction_id),
643 observer_id);
644 }
645
646 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnUnobserve(
647 int32_t ipc_database_id,
648 std::vector<int32_t> observersToRemove) {
649 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
650 IndexedDBConnection* connection =
651 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
652 if (!connection || !connection->IsConnected())
653 return;
654 connection->Unobserve(observersToRemove);
655 }
656
632 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( 657 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet(
633 const IndexedDBHostMsg_DatabaseGet_Params& params) { 658 const IndexedDBHostMsg_DatabaseGet_Params& params) {
634 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 659 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
635 IndexedDBConnection* connection = 660 IndexedDBConnection* connection =
636 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 661 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
637 if (!connection || !connection->IsConnected()) 662 if (!connection || !connection->IsConnected())
638 return; 663 return;
639 664
640 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( 665 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks(
641 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); 666 parent_, params.ipc_thread_id, params.ipc_callbacks_id));
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 DLOG(ERROR) << "Unable to reset prefetch"; 1067 DLOG(ERROR) << "Unable to reset prefetch";
1043 } 1068 }
1044 1069
1045 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( 1070 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
1046 int32_t ipc_object_id) { 1071 int32_t ipc_object_id) {
1047 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 1072 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
1048 parent_->DestroyObject(&map_, ipc_object_id); 1073 parent_->DestroyObject(&map_, ipc_object_id);
1049 } 1074 }
1050 1075
1051 } // namespace content 1076 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698