| 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 { | 19 { |
| 20 v8::Local<v8::Context> context(scriptState->context()); | 20 v8::Local<v8::Context> context(scriptState->context()); |
| 21 v8::Isolate* isolate(scriptState->isolate()); | 21 v8::Isolate* isolate(scriptState->isolate()); |
| 22 v8::Local<v8::Map> map = v8::Map::New(isolate); | 22 v8::Local<v8::Map> map = v8::Map::New(isolate); |
| 23 for (const auto& it : m_records) { | 23 for (const auto& it : m_records) { |
| 24 v8::Local<v8::String> key = v8String(isolate, m_database->getObjectStore
Name(it.key)); | 24 v8::Local<v8::String> key = v8String(isolate, m_database->getObjectStore
Name(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 v8CallOrCrash(map->Set(context, key, value)); | 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(IDBDatabase* database, const WebV
ector<WebIDBObservation>& observations, const WebVector<int32_t>& observationInd
ex) | 31 IDBObserverChanges* IDBObserverChanges::create(IDBDatabase* database, const WebV
ector<WebIDBObservation>& observations, const WebVector<int32_t>& observationInd
ex) |
| 32 { | 32 { |
| 33 return new IDBObserverChanges(database, observations, observationIndex); | 33 return new IDBObserverChanges(database, observations, observationIndex); |
| 34 } | 34 } |
| 35 | 35 |
| 36 IDBObserverChanges::IDBObserverChanges(IDBDatabase* database, const WebVector<We
bIDBObservation>& observations, const WebVector<int32_t>& observationIndex) | 36 IDBObserverChanges::IDBObserverChanges(IDBDatabase* database, const WebVector<We
bIDBObservation>& observations, const WebVector<int32_t>& observationIndex) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 DEFINE_TRACE(IDBObserverChanges) | 49 DEFINE_TRACE(IDBObserverChanges) |
| 50 { | 50 { |
| 51 visitor->trace(m_database); | 51 visitor->trace(m_database); |
| 52 visitor->trace(m_transaction); | 52 visitor->trace(m_transaction); |
| 53 visitor->trace(m_records); | 53 visitor->trace(m_records); |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace blink | 56 } // namespace blink |
| OLD | NEW |