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 14 matching lines...) Expand all Loading... | |
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, nullptr, observations, |
36 observationIndex); | |
cmumford
2017/01/17 20:58:11
Are these really observerIndices?
dmurph
2017/01/17 23:28:04
Yeah, they are the indexes in the observations arr
| |
37 } | |
38 | |
39 IDBObserverChanges* IDBObserverChanges::create( | |
40 IDBDatabase* database, | |
41 IDBTransaction* transaction, | |
42 const WebVector<WebIDBObservation>& observations, | |
43 const WebVector<int32_t>& observationIndex) { | |
44 return new IDBObserverChanges(database, transaction, observations, | |
45 observationIndex); | |
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>& observationIndex) |
42 : m_database(database) { | 53 : m_database(database), m_transaction(transaction) { |
43 extractChanges(observations, observationIndex); | 54 extractChanges(observations, observationIndex); |
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>& observationIndex) { |
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 : observationIndex) |
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.append(IDBObservation::create(observations[idx])); | 65 .storedValue->value.append(IDBObservation::create(observations[idx])); |
55 } | 66 } |
56 | 67 |
57 DEFINE_TRACE(IDBObserverChanges) { | 68 DEFINE_TRACE(IDBObserverChanges) { |
58 visitor->trace(m_database); | 69 visitor->trace(m_database); |
59 visitor->trace(m_transaction); | 70 visitor->trace(m_transaction); |
60 visitor->trace(m_records); | 71 visitor->trace(m_records); |
61 } | 72 } |
62 | 73 |
63 } // namespace blink | 74 } // namespace blink |
OLD | NEW |