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..41f9aa4212facb1f21c8ddaff630f1f964ec1ab0 100644 |
--- a/third_party/WebKit/Source/modules/indexeddb/IDBObserverChanges.cpp |
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBObserverChanges.cpp |
@@ -6,27 +6,50 @@ |
#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::Isolate* isolate(scriptState->isolate()); |
+ v8::Local<v8::Map> map = v8::Map::New(isolate); |
+ for (const auto& it : m_records) { |
+ v8::Local<v8::String> key = v8String(isolate, m_database->getObjectStoreName(it.key)); |
+ v8::Local<v8::Value> value = toV8(it.value, context->Global(), isolate); |
+ v8CallOrCrash(map->Set(context, key, value)); |
+ } |
+ return ScriptValue::from(scriptState, map); |
} |
-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) |
dmurph
2016/07/13 23:29:13
maybe extractChanges is a better name? I'm expecti
palakj1
2016/07/14 17:52:06
True. changed.
|
+{ |
+ for (const auto& idx : observationIndex) { |
+ int64_t key = observations[idx].objectStoreId; |
+ HeapVector<Member<IDBObservation>> result; |
dmurph
2016/07/13 23:29:13
Do you always have to get/set here? It's doing a l
Marijn Kruisselbrink
2016/07/13 23:34:39
Or just something like (since add returns the exis
palakj1
2016/07/14 17:52:06
Wow! I was really looking for some suggestions her
|
+ if (m_records.contains(key)) |
+ result = m_records.get(key); |
+ result.append(IDBObservation::create(observations[idx])); |
+ m_records.set(key, result); |
+ } |
} |
DEFINE_TRACE(IDBObserverChanges) |