| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/indexeddb/IDBObserverChanges.h" | 5 #include "modules/indexeddb/IDBObserverChanges.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
| 10 #include "bindings/modules/v8/ToV8ForModules.h" | 10 #include "bindings/modules/v8/ToV8ForModules.h" |
| 11 #include "bindings/modules/v8/V8BindingForModules.h" | 11 #include "bindings/modules/v8/V8BindingForModules.h" |
| 12 #include "modules/indexeddb/IDBAny.h" | 12 #include "modules/indexeddb/IDBAny.h" |
| 13 #include "modules/indexeddb/IDBObservation.h" | 13 #include "modules/indexeddb/IDBObservation.h" |
| 14 #include "public/platform/modules/indexeddb/WebIDBObservation.h" | 14 #include "public/platform/modules/indexeddb/WebIDBObservation.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 ScriptValue IDBObserverChanges::records(ScriptState* scriptState) { | 18 ScriptValue IDBObserverChanges::records(ScriptState* scriptState) { |
| 19 v8::Local<v8::Context> context(scriptState->context()); | 19 v8::Local<v8::Context> context(scriptState->context()); |
| 20 v8::Isolate* isolate(scriptState->isolate()); | 20 v8::Isolate* isolate(scriptState->isolate()); |
| 21 v8::Local<v8::Map> map = v8::Map::New(isolate); | 21 v8::Local<v8::Map> map = v8::Map::New(isolate); |
| 22 for (const auto& it : m_records) { | 22 for (const auto& it : m_records) { |
| 23 v8::Local<v8::String> key = | 23 v8::Local<v8::String> key = |
| 24 v8String(isolate, m_database->getObjectStoreName(it.key)); | 24 v8String(isolate, m_database->getObjectStoreName(it.key)); |
| 25 v8::Local<v8::Value> value = toV8(it.value, context->Global(), isolate); | 25 v8::Local<v8::Value> value = ToV8(it.value, context->Global(), isolate); |
| 26 map->Set(context, key, value).ToLocalChecked(); | 26 map->Set(context, key, value).ToLocalChecked(); |
| 27 } | 27 } |
| 28 return ScriptValue::from(scriptState, map); | 28 return ScriptValue::from(scriptState, map); |
| 29 } | 29 } |
| 30 | 30 |
| 31 IDBObserverChanges* IDBObserverChanges::create( | 31 IDBObserverChanges* IDBObserverChanges::create( |
| 32 IDBDatabase* database, | 32 IDBDatabase* database, |
| 33 const WebVector<WebIDBObservation>& observations, | 33 const WebVector<WebIDBObservation>& observations, |
| 34 const WebVector<int32_t>& observationIndex) { | 34 const WebVector<int32_t>& observationIndex) { |
| 35 return new IDBObserverChanges(database, observations, observationIndex); | 35 return new IDBObserverChanges(database, observations, observationIndex); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 54 .storedValue->value.append(IDBObservation::create(observations[idx])); | 54 .storedValue->value.append(IDBObservation::create(observations[idx])); |
| 55 } | 55 } |
| 56 | 56 |
| 57 DEFINE_TRACE(IDBObserverChanges) { | 57 DEFINE_TRACE(IDBObserverChanges) { |
| 58 visitor->trace(m_database); | 58 visitor->trace(m_database); |
| 59 visitor->trace(m_transaction); | 59 visitor->trace(m_transaction); |
| 60 visitor->trace(m_records); | 60 visitor->trace(m_records); |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace blink | 63 } // namespace blink |
| OLD | NEW |