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

Unified Diff: content/browser/indexed_db/indexed_db_dispatcher_host.cc

Issue 2160163002: [IndexedDB] Propogating Changes to Observer : Browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Browser changes Created 4 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 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..ac0c4ff9b7f012ef1e9844738d282e11e0961d27 100644
--- a/content/browser/indexed_db/indexed_db_dispatcher_host.cc
+++ b/content/browser/indexed_db/indexed_db_dispatcher_host.cc
@@ -23,6 +23,9 @@
#include "content/browser/indexed_db/indexed_db_cursor.h"
#include "content/browser/indexed_db/indexed_db_database_callbacks.h"
#include "content/browser/indexed_db/indexed_db_metadata.h"
+#include "content/browser/indexed_db/indexed_db_observation.h"
+#include "content/browser/indexed_db/indexed_db_observation.h"
+#include "content/browser/indexed_db/indexed_db_observer_changes.h"
#include "content/browser/indexed_db/indexed_db_pending_connection.h"
#include "content/browser/indexed_db/indexed_db_value.h"
#include "content/browser/renderer_host/render_message_filter.h"
@@ -188,6 +191,7 @@ int32_t IndexedDBDispatcherHost::Add(IndexedDBConnection* connection,
return -1;
}
int32_t ipc_database_id = database_dispatcher_host_->map_.Add(connection);
+ connection->set_id(ipc_database_id);
context()->ConnectionOpened(origin, connection);
database_dispatcher_host_->database_origin_map_[ipc_database_id] = origin;
return ipc_database_id;
@@ -317,6 +321,25 @@ IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId(
return metadata;
}
+IndexedDBMsg_ObserverChanges IndexedDBDispatcherHost::ConvertObserverChanges(
+ std::unique_ptr<IndexedDBObserverChanges> changes) {
+ IndexedDBMsg_ObserverChanges idb_changes;
+ idb_changes.observation_index = changes->release_observation_indices_map();
+ for (auto& observation : changes->release_observations())
+ idb_changes.observations.push_back(ConvertObservation(observation.get()));
+ return idb_changes;
+}
+
+IndexedDBMsg_Observation IndexedDBDispatcherHost::ConvertObservation(
+ const IndexedDBObservation* observation) {
+ // TODO(palakj): Modify function for indexed_db_value. Issue crbug.com/609934.
+ IndexedDBMsg_Observation idb_observation;
+ idb_observation.object_store_id = observation->object_store_id();
+ idb_observation.type = observation->type();
+ idb_observation.key_range = observation->key_range();
+ return idb_observation;
+}
+
void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames(
const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) {
DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
@@ -520,6 +543,8 @@ 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_DatabaseUnobserve, OnUnobserve)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGetAll, OnGetAll)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPutWrapper)
@@ -629,6 +654,33 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed(
parent_->DestroyObject(&map_, ipc_object_id);
}
+void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObserve(
+ const IndexedDBHostMsg_DatabaseObserve_Params& params) {
+ DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
+ IndexedDBConnection* connection =
+ parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
+ if (!connection || !connection->IsConnected())
+ return;
+ IndexedDBObserver::Options options(params.include_transaction,
+ params.no_records, params.values,
+ params.operation_types);
+ connection->database()->AddPendingObserver(
+ parent_->HostTransactionId(params.transaction_id), params.observer_id,
+ options);
+}
+
+void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnUnobserve(
+ int32_t ipc_database_id,
+ const std::vector<int32_t>& observer_ids_to_remove) {
+ DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
+ DCHECK(!observer_ids_to_remove.empty());
+ IndexedDBConnection* connection =
+ parent_->GetOrTerminateProcess(&map_, ipc_database_id);
+ if (!connection || !connection->IsConnected())
+ return;
+ connection->RemoveObservers(observer_ids_to_remove);
+}
+
void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet(
const IndexedDBHostMsg_DatabaseGet_Params& params) {
DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());

Powered by Google App Engine
This is Rietveld 408576698