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