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 7fc09ae19f6bd3478b54733cbca71494d38364b7..03b92d29c6a95ac528d6e94ace397136181ee3c9 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 = |
cmumford
2016/07/20 00:25:12
Are you missing "value" - or maybe a TODO here?
palakj1
2016/07/20 01:33:35
added a todo
|
+ 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) |
cmumford
2016/07/20 00:25:12
Should this be OnDatabaseChanges (plural) for symm
palakj1
2016/07/20 01:33:35
Changed
|
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
// If a message gets here, IndexedDBMessageFilter already determined that it |
@@ -172,9 +189,13 @@ int32_t IndexedDBDispatcher::AddIDBObserver( |
int32_t ipc_database_id, |
int64_t transaction_id, |
std::unique_ptr<WebIDBObserver> observer) { |
- int32_t observer_id = observers_.Add(observer.release()); |
IndexedDBHostMsg_DatabaseObserve_Params params; |
- // TODO(palakj): Other params are assigned values as a part of next cl. |
+ params.include_transaction = observer->transaction(); |
+ params.no_records = observer->noRecords(); |
+ params.values = observer->values(); |
+ params.operation_types = |
+ static_cast<unsigned short>(observer->operationTypes().to_ulong()); |
cmumford
2016/07/20 00:25:12
Instead of using "unsigned short" we should be usi
palakj1
2016/07/20 01:33:35
Changed
|
+ int32_t observer_id = observers_.Add(observer.release()); |
params.ipc_database_id = ipc_database_id; |
params.transaction_id = transaction_id; |
params.observer_id = observer_id; |
@@ -801,6 +822,26 @@ 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) { |
cmumford
2016/07/20 00:25:12
Nit: When iterating a map we usually use "it" for
palakj1
2016/07/20 01:33:35
Done
|
+ WebIDBObserver* observer = observers_.Lookup(obs.first); |
+ // An observer can be removed from the renderer, but still exist in the |
+ // backend. |
+ // Moreover, observer might have recorded some changes before being removed |
+ // from |
cmumford
2016/07/20 00:25:12
fix line breaks.
palakj1
2016/07/20 01:33:35
done
|
+ // the backend and thus, have its id be present in changes. |
+ if (!observer) |
+ continue; |
+ 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()); |