Chromium Code Reviews| 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..54a2c04312f0556b23ec9af6792770b20f6ffff7 100644 |
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBObserverChanges.cpp |
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBObserverChanges.cpp |
| @@ -6,27 +6,43 @@ |
| #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" |
| 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)); |
|
haraken
2016/07/20 16:22:12
Use CreateDataProperty instead of Set. If the sett
palakj1
2016/07/20 18:22:11
Is using CreateDataProperty on map identical to Se
jsbell
2016/07/20 18:41:48
CreateDataProperty is definitely not correct here;
haraken
2016/07/20 19:02:14
Thanks for the clarification! Yeah, I realized tha
adamk
2016/07/20 19:04:04
jsbell's reading of the code is correct: v8::Map::
|
| + } |
| + return ScriptValue::from(scriptState, map); |
| } |
| -IDBObserverChanges* IDBObserverChanges::create(IDBDatabase* database, IDBTransaction* transaction, IDBAny* records) |
| +IDBObserverChanges* IDBObserverChanges::create(IDBDatabase* database, const WebVector<WebIDBObservation>& observations, const WebVector<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 WebVector<WebIDBObservation>& observations, const WebVector<int32_t>& observationIndex) |
| : m_database(database) |
| - , m_transaction(transaction) |
| - , m_records(records) |
| { |
| + extractChanges(observations, observationIndex); |
| +} |
| + |
| +void IDBObserverChanges::extractChanges(const WebVector<WebIDBObservation>& observations, const WebVector<int32_t>& observationIndex) |
| +{ |
| + for (const auto& idx : observationIndex) |
| + m_records.add(observations[idx].objectStoreId, HeapVector<Member<IDBObservation>>()).storedValue->value.append(IDBObservation::create(observations[idx])); |
| } |
| DEFINE_TRACE(IDBObserverChanges) |