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