Index: content/child/indexed_db/indexed_db_dispatcher.cc |
diff --git a/content/child/indexed_db/indexed_db_dispatcher.cc b/content/child/indexed_db/indexed_db_dispatcher.cc |
index 7d6196c637d58a625027c509e93055c00d1588d4..d50c47ec15a7024aff2f0460fcff3aa1c05be6f3 100644 |
--- a/content/child/indexed_db/indexed_db_dispatcher.cc |
+++ b/content/child/indexed_db/indexed_db_dispatcher.cc |
@@ -19,6 +19,7 @@ |
#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCallbacks.h" |
#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseError.h" |
#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseException.h" |
+#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBObservation.h" |
#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBValue.h" |
using blink::WebBlobInfo; |
@@ -30,6 +31,7 @@ using blink::WebIDBDatabaseCallbacks; |
using blink::WebIDBDatabaseError; |
using blink::WebIDBKey; |
using blink::WebIDBMetadata; |
+using blink::WebIDBObservation; |
using blink::WebIDBObserver; |
using blink::WebIDBValue; |
using blink::WebString; |
@@ -125,6 +127,20 @@ WebIDBMetadata IndexedDBDispatcher::ConvertMetadata( |
return web_metadata; |
} |
+std::vector<WebIDBObservation> IndexedDBDispatcher::ConvertObservations( |
+ const std::vector<IndexedDBMsg_Observation>& idb_observations) { |
+ std::vector<WebIDBObservation> web_observations; |
+ for (const auto& idb_observation : idb_observations) { |
+ WebIDBObservation web_observation; |
+ web_observation.objectStoreId = idb_observation.object_store_id; |
+ web_observation.type = idb_observation.type; |
+ web_observation.keyRange = |
+ WebIDBKeyRangeBuilder::Build(idb_observation.key_range); |
+ web_observations.push_back(std::move(web_observation)); |
+ } |
+ return web_observations; |
+} |
+ |
void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg) |
@@ -156,6 +172,7 @@ void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { |
OnVersionChange) |
IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksAbort, OnAbort) |
IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksComplete, OnComplete) |
+ IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksChanges, OnDatabaseChange) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
// If a message gets here, IndexedDBMessageFilter already determined that it |
@@ -172,9 +189,15 @@ int32_t IndexedDBDispatcher::AddIDBObserver( |
int32_t ipc_database_id, |
int64_t transaction_id, |
std::unique_ptr<WebIDBObserver> observer) { |
+ IndexedDBHostMsg_DatabaseObserve_Params params; |
+ params.include_transaction = observer->transaction(); |
+ params.no_records = observer->noRecords(); |
+ params.values = observer->values(); |
int32_t observer_id = observers_.Add(observer.release()); |
- Send(new IndexedDBHostMsg_DatabaseObserve(ipc_database_id, transaction_id, |
- observer_id)); |
+ params.ipc_database_id = ipc_database_id; |
+ params.transaction_id = transaction_id; |
+ params.observer_id = observer_id; |
+ Send(new IndexedDBHostMsg_DatabaseObserve(params)); |
return observer_id; |
} |
@@ -797,6 +820,20 @@ void IndexedDBDispatcher::OnComplete(int32_t ipc_thread_id, |
callbacks->onComplete(transaction_id); |
} |
+void IndexedDBDispatcher::OnDatabaseChange( |
+ int32_t ipc_thread_id, |
+ int32_t ipc_database_id, |
+ const IndexedDBMsg_ObserverChanges& changes) { |
+ DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
+ std::vector<WebIDBObservation> observations( |
+ ConvertObservations(changes.observations)); |
+ for (auto& obs : changes.observation_index) { |
+ WebIDBObserver* observer = observers_.Lookup(obs.first); |
+ // TODO(palakj): Get IDBDatabase object from ipc_database_id. |
dmurph
2016/07/13 23:29:13
Does this TODO still apply?
palakj1
2016/07/14 17:52:06
removed.
|
+ observer->onChange(observations, std::move(obs.second)); |
+ } |
+} |
+ |
void IndexedDBDispatcher::OnForcedClose(int32_t ipc_thread_id, |
int32_t ipc_database_callbacks_id) { |
DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |