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