| 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 | 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; | |
| 23 | 22 |
| 24 class MODULES_EXPORT IDBObserver final : public GarbageCollected<IDBObserver>, | 23 class MODULES_EXPORT IDBObserver final : public GarbageCollected<IDBObserver>, |
| 25 public ScriptWrappable { | 24 public ScriptWrappable { |
| 26 DEFINE_WRAPPERTYPEINFO(); | 25 DEFINE_WRAPPERTYPEINFO(); |
| 27 | 26 |
| 28 public: | 27 public: |
| 29 static IDBObserver* create(IDBObserverCallback*); | 28 static IDBObserver* create(IDBObserverCallback*); |
| 30 | 29 |
| 31 void removeObserver(int32_t id); | 30 IDBObserverCallback* callback() { return m_callback; } |
| 32 void onChange(int32_t id, | |
| 33 const WebVector<WebIDBObservation>&, | |
| 34 const WebVector<int32_t>& observationIndex); | |
| 35 | 31 |
| 36 // Implement the IDBObserver IDL. | 32 // Implement the IDBObserver IDL. |
| 37 void observe(IDBDatabase*, | 33 void observe(IDBDatabase*, |
| 38 IDBTransaction*, | 34 IDBTransaction*, |
| 39 const IDBObserverInit&, | 35 const IDBObserverInit&, |
| 40 ExceptionState&); | 36 ExceptionState&); |
| 41 void unobserve(IDBDatabase*, ExceptionState&); | 37 void unobserve(IDBDatabase*, ExceptionState&); |
| 42 | 38 |
| 43 DECLARE_TRACE(); | 39 DECLARE_TRACE(); |
| 44 | 40 |
| 45 private: | 41 private: |
| 46 explicit IDBObserver(IDBObserverCallback*); | 42 explicit IDBObserver(IDBObserverCallback*); |
| 47 | 43 |
| 48 Member<IDBObserverCallback> m_callback; | 44 Member<IDBObserverCallback> m_callback; |
| 49 HeapHashMap<int32_t, WeakMember<IDBDatabase>> m_observerIds; | 45 HeapHashMap<int32_t, WeakMember<IDBDatabase>> m_observerIds; |
| 50 }; | 46 }; |
| 51 | 47 |
| 52 } // namespace blink | 48 } // namespace blink |
| 53 | 49 |
| 54 #endif // IDBObserver_h | 50 #endif // IDBObserver_h |
| OLD | NEW |