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

Unified 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: Post dmurph review 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_dispatcher_host.cc
diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.cc b/content/browser/indexed_db/indexed_db_dispatcher_host.cc
index 96cad054d68c0110179e1aeb1e3a8c516ae73e60..c23d66938b1296cb84caa6204b546db45c2453cd 100644
--- a/content/browser/indexed_db/indexed_db_dispatcher_host.cc
+++ b/content/browser/indexed_db/indexed_db_dispatcher_host.cc
@@ -193,6 +193,13 @@ int32_t IndexedDBDispatcherHost::Add(IndexedDBConnection* connection,
return ipc_database_id;
}
+int64_t
+IndexedDBDispatcherHost::DatabaseDispatcherHost::GenerateObserverAndThreadId(
+ int32_t observer_id,
+ int32_t ipc_thread_id) {
+ return observer_id | (static_cast<uint64_t>(ipc_thread_id) << 32);
+}
+
void IndexedDBDispatcherHost::RegisterTransactionId(int64_t host_transaction_id,
const url::Origin& origin) {
if (!database_dispatcher_host_)
@@ -520,6 +527,7 @@ bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived(
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseVersionChangeIgnored,
OnVersionChangeIgnored)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed)
+ IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseObserve, OnObserve)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGetAll, OnGetAll)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPutWrapper)
@@ -629,6 +637,47 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed(
parent_->DestroyObject(&map_, ipc_object_id);
}
+void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObserve(
+ int32_t ipc_thread_id,
+ int32_t ipc_database_id,
+ int64_t transaction_id,
+ int32_t observer_id) {
dmurph 2016/06/17 09:05:06 can your rename the int32_t version of observer_id
palakj1 2016/06/18 05:13:40 It's only local to the renderer thread right, not
+ DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
+ IndexedDBConnection* connection =
+ parent_->GetOrTerminateProcess(&map_, ipc_database_id);
+ if (!connection || !connection->IsConnected())
+ return;
+ int64_t observer_thread_id =
+ GenerateObserverAndThreadId(observer_id, ipc_thread_id);
+
+ observers_.push_back(std::make_pair(observer_id, observer_thread_id));
dmurph 2016/06/17 09:05:06 You need to figure out how to store these so that
+ connection->database()->Observe(parent_->HostTransactionId(transaction_id),
+ observer_thread_id);
+}
+
+void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnUnobserve(
+ int32_t ipc_thread_id,
+ int32_t ipc_database_id,
+ std::vector<int32_t> remove_observers) {
+ DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
+ IndexedDBConnection* connection =
+ parent_->GetOrTerminateProcess(&map_, ipc_database_id);
+ if (!connection || !connection->IsConnected())
+ return;
+ std::vector<int64_t> observersToRemove =
+ RemoveObservers(remove_observers, ipc_thread_id);
+ connection->database()->Unobserve(observersToRemove);
+}
+
+std::vector<int64_t>
+IndexedDBDispatcherHost::DatabaseDispatcherHost::RemoveObservers(
+ std::vector<int32_t> remove_observers,
+ int32_t ipc_database_id) {
+ // TODO(palakj): remove from observers_ and return vector of the hashed id.
+ std::vector<int64_t> observersToRemove;
+ return observersToRemove;
+}
+
void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet(
const IndexedDBHostMsg_DatabaseGet_Params& params) {
DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());

Powered by Google App Engine
This is Rietveld 408576698