Index: third_party/WebKit/Source/modules/indexeddb/IDBObserverChanges.cpp |
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBObserverChanges.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBObserverChanges.cpp |
index abb4042ff9422d42bb4a623c04727b979e96e9ad..000f144f9eb099371104d7b41cd1604fc2b2c3eb 100644 |
--- a/third_party/WebKit/Source/modules/indexeddb/IDBObserverChanges.cpp |
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBObserverChanges.cpp |
@@ -6,27 +6,49 @@ |
#include "bindings/core/v8/ExceptionState.h" |
#include "bindings/core/v8/ScriptState.h" |
+#include "bindings/core/v8/V8Binding.h" |
#include "bindings/modules/v8/ToV8ForModules.h" |
#include "bindings/modules/v8/V8BindingForModules.h" |
#include "modules/indexeddb/IDBAny.h" |
+#include "modules/indexeddb/IDBObservation.h" |
+#include "public/platform/modules/indexeddb/WebIDBObservation.h" |
+#include "public/platform/modules/indexeddb/WebIDBTypes.h" |
namespace blink { |
ScriptValue IDBObserverChanges::records(ScriptState* scriptState) |
{ |
- return ScriptValue::from(scriptState, m_records); |
+ v8::Local<v8::Context> context(scriptState->context()); |
+ v8::Local<v8::Object> result = toV8(m_records, context->Global(), scriptState->isolate())->ToObject(context).ToLocalChecked(); |
+ return ScriptValue::from(scriptState, result); |
} |
-IDBObserverChanges* IDBObserverChanges::create(IDBDatabase* database, IDBTransaction* transaction, IDBAny* records) |
+IDBObserverChanges* IDBObserverChanges::create(IDBDatabase* database, const std::vector<WebIDBObservation>& observations, const std::vector<int32_t>& observationIndex) |
{ |
- return new IDBObserverChanges(database, transaction, records); |
+ return new IDBObserverChanges(database, observations, observationIndex); |
} |
-IDBObserverChanges::IDBObserverChanges(IDBDatabase* database, IDBTransaction* transaction, IDBAny* records) |
+IDBObserverChanges::IDBObserverChanges(IDBDatabase* database, const std::vector<WebIDBObservation>& observations, const std::vector<int32_t>& observationIndex) |
: m_database(database) |
- , m_transaction(transaction) |
- , m_records(records) |
{ |
+ createMap(observations, observationIndex); |
+} |
+ |
+void IDBObserverChanges::createMap(const std::vector<WebIDBObservation>& observations, const std::vector<int32_t>& observationIndex) |
+{ |
+ std::map<int64_t, HeapVector<Member<IDBObservation>>> records; |
+ for (const auto& idx : observationIndex) { |
+ auto it = records.find(observations[idx].objectStoreId); |
+ if (it == records.end()) { |
+ HeapVector<Member<IDBObservation>> v; |
+ it = records.insert(std::make_pair(observations[idx].objectStoreId, v)).first; |
+ } |
+ it->second.append(IDBObservation::create(observations[idx])); |
+ } |
+ for (auto it : records) { |
+ String objectStoreName = m_database->getObjectStoreName(it.first); |
+ m_records.append(std::make_pair(objectStoreName, it.second)); |
+ } |
} |
DEFINE_TRACE(IDBObserverChanges) |