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" |
(...skipping 13 matching lines...) Expand all Loading... |
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>& observationIndices) { |
35 return new IDBObserverChanges(database, observations, observationIndex); | 35 return new IDBObserverChanges(database, nullptr, observations, |
| 36 observationIndices); |
| 37 } |
| 38 |
| 39 IDBObserverChanges* IDBObserverChanges::create( |
| 40 IDBDatabase* database, |
| 41 IDBTransaction* transaction, |
| 42 const WebVector<WebIDBObservation>& observations, |
| 43 const WebVector<int32_t>& observationIndices) { |
| 44 return new IDBObserverChanges(database, transaction, observations, |
| 45 observationIndices); |
36 } | 46 } |
37 | 47 |
38 IDBObserverChanges::IDBObserverChanges( | 48 IDBObserverChanges::IDBObserverChanges( |
39 IDBDatabase* database, | 49 IDBDatabase* database, |
| 50 IDBTransaction* transaction, |
40 const WebVector<WebIDBObservation>& observations, | 51 const WebVector<WebIDBObservation>& observations, |
41 const WebVector<int32_t>& observationIndex) | 52 const WebVector<int32_t>& observationIndices) |
42 : m_database(database) { | 53 : m_database(database), m_transaction(transaction) { |
43 extractChanges(observations, observationIndex); | 54 extractChanges(observations, observationIndices); |
44 } | 55 } |
45 | 56 |
46 void IDBObserverChanges::extractChanges( | 57 void IDBObserverChanges::extractChanges( |
47 const WebVector<WebIDBObservation>& observations, | 58 const WebVector<WebIDBObservation>& observations, |
48 const WebVector<int32_t>& observationIndex) { | 59 const WebVector<int32_t>& observationIndices) { |
49 // TODO(dmurph): Avoid getting and setting repeated times. | 60 // TODO(dmurph): Avoid getting and setting repeated times. |
50 for (const auto& idx : observationIndex) | 61 for (const auto& idx : observationIndices) { |
51 m_records | 62 m_records |
52 .add(observations[idx].objectStoreId, | 63 .add(observations[idx].objectStoreId, |
53 HeapVector<Member<IDBObservation>>()) | 64 HeapVector<Member<IDBObservation>>()) |
54 .storedValue->value.push_back( | 65 .storedValue->value.push_back( |
55 IDBObservation::create(observations[idx])); | 66 IDBObservation::create(observations[idx])); |
| 67 } |
56 } | 68 } |
57 | 69 |
58 DEFINE_TRACE(IDBObserverChanges) { | 70 DEFINE_TRACE(IDBObserverChanges) { |
59 visitor->trace(m_database); | 71 visitor->trace(m_database); |
60 visitor->trace(m_transaction); | 72 visitor->trace(m_transaction); |
61 visitor->trace(m_records); | 73 visitor->trace(m_records); |
62 } | 74 } |
63 | 75 |
64 } // namespace blink | 76 } // namespace blink |
OLD | NEW |