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 #ifndef IDBObserver_h | 5 #ifndef IDBObserver_h |
6 #define IDBObserver_h | 6 #define IDBObserver_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
10 #include "modules/ModulesExport.h" | 10 #include "modules/ModulesExport.h" |
11 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
12 #include "public/platform/WebVector.h" | 12 #include "public/platform/WebVector.h" |
13 #include "public/platform/modules/indexeddb/WebIDBTypes.h" | 13 #include "public/platform/modules/indexeddb/WebIDBTypes.h" |
14 #include <bitset> | |
15 | 14 |
16 namespace blink { | 15 namespace blink { |
17 | 16 |
18 class ExceptionState; | 17 class ExceptionState; |
19 class IDBDatabase; | 18 class IDBDatabase; |
20 class IDBObserverCallback; | 19 class IDBObserverCallback; |
21 class IDBObserverInit; | 20 class IDBObserverInit; |
22 class IDBTransaction; | 21 class IDBTransaction; |
23 struct WebIDBObservation; | 22 struct WebIDBObservation; |
24 | 23 |
25 class MODULES_EXPORT IDBObserver final | 24 class MODULES_EXPORT IDBObserver final |
26 : public GarbageCollectedFinalized<IDBObserver>, | 25 : public GarbageCollectedFinalized<IDBObserver>, |
27 public ScriptWrappable { | 26 public ScriptWrappable { |
28 DEFINE_WRAPPERTYPEINFO(); | 27 DEFINE_WRAPPERTYPEINFO(); |
29 | 28 |
30 public: | 29 public: |
31 static IDBObserver* create(IDBObserverCallback*, const IDBObserverInit&); | 30 static IDBObserver* create(IDBObserverCallback*); |
32 | 31 |
33 void removeObserver(int32_t id); | 32 void removeObserver(int32_t id); |
34 void onChange(int32_t id, | 33 void onChange(int32_t id, |
35 const WebVector<WebIDBObservation>&, | 34 const WebVector<WebIDBObservation>&, |
36 const WebVector<int32_t>& observationIndex); | 35 const WebVector<int32_t>& observationIndex); |
37 | 36 |
38 bool transaction() const { return m_transaction; } | |
39 bool noRecords() const { return m_noRecords; } | |
40 bool values() const { return m_values; } | |
41 const std::bitset<WebIDBOperationTypeCount>& operationTypes() const { | |
42 return m_operationTypes; | |
43 } | |
44 | |
45 // Implement the IDBObserver IDL. | 37 // Implement the IDBObserver IDL. |
46 void observe(IDBDatabase*, IDBTransaction*, ExceptionState&); | 38 void observe(IDBDatabase*, |
| 39 IDBTransaction*, |
| 40 const IDBObserverInit&, |
| 41 ExceptionState&); |
47 void unobserve(IDBDatabase*, ExceptionState&); | 42 void unobserve(IDBDatabase*, ExceptionState&); |
48 | 43 |
49 DECLARE_TRACE(); | 44 DECLARE_TRACE(); |
50 | 45 |
51 private: | 46 private: |
52 IDBObserver(IDBObserverCallback*, const IDBObserverInit&); | 47 IDBObserver(IDBObserverCallback*); |
53 | 48 |
54 Member<IDBObserverCallback> m_callback; | 49 Member<IDBObserverCallback> m_callback; |
55 bool m_transaction; | |
56 bool m_values; | |
57 bool m_noRecords; | |
58 // Operation type bits are set corresponding to WebIDBOperationType. | |
59 std::bitset<WebIDBOperationTypeCount> m_operationTypes; | |
60 HeapHashMap<int32_t, WeakMember<IDBDatabase>> m_observerIds; | 50 HeapHashMap<int32_t, WeakMember<IDBDatabase>> m_observerIds; |
61 }; | 51 }; |
62 | 52 |
63 } // namespace blink | 53 } // namespace blink |
64 | 54 |
65 #endif // IDBObserver_h | 55 #endif // IDBObserver_h |
OLD | NEW |