/src/mozilla-central/dom/indexedDB/IDBEvents.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_idbevents_h__ |
8 | | #define mozilla_dom_idbevents_h__ |
9 | | |
10 | | #include "js/RootingAPI.h" |
11 | | #include "mozilla/dom/BindingDeclarations.h" |
12 | | #include "mozilla/dom/Event.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "nsStringFwd.h" |
15 | | |
16 | | #define IDBVERSIONCHANGEEVENT_IID \ |
17 | | {0x3b65d4c3, 0x73ad, 0x492e, {0xb1, 0x2d, 0x15, 0xf9, 0xda, 0xc2, 0x08, 0x4b}} |
18 | | |
19 | | namespace mozilla { |
20 | | |
21 | | class ErrorResult; |
22 | | |
23 | | namespace dom { |
24 | | |
25 | | class EventTarget; |
26 | | class GlobalObject; |
27 | | struct IDBVersionChangeEventInit; |
28 | | |
29 | | namespace indexedDB { |
30 | | |
31 | | enum Bubbles { |
32 | | eDoesNotBubble, |
33 | | eDoesBubble |
34 | | }; |
35 | | |
36 | | enum Cancelable { |
37 | | eNotCancelable, |
38 | | eCancelable |
39 | | }; |
40 | | |
41 | | extern const char16_t* kAbortEventType; |
42 | | extern const char16_t* kBlockedEventType; |
43 | | extern const char16_t* kCompleteEventType; |
44 | | extern const char16_t* kErrorEventType; |
45 | | extern const char16_t* kSuccessEventType; |
46 | | extern const char16_t* kUpgradeNeededEventType; |
47 | | extern const char16_t* kVersionChangeEventType; |
48 | | extern const char16_t* kCloseEventType; |
49 | | |
50 | | already_AddRefed<Event> |
51 | | CreateGenericEvent(EventTarget* aOwner, |
52 | | const nsDependentString& aType, |
53 | | Bubbles aBubbles, |
54 | | Cancelable aCancelable); |
55 | | |
56 | | } // namespace indexedDB |
57 | | |
58 | | class IDBVersionChangeEvent final : public Event |
59 | | { |
60 | | uint64_t mOldVersion; |
61 | | Nullable<uint64_t> mNewVersion; |
62 | | |
63 | | public: |
64 | | static already_AddRefed<IDBVersionChangeEvent> |
65 | | Create(EventTarget* aOwner, |
66 | | const nsDependentString& aName, |
67 | | uint64_t aOldVersion, |
68 | | uint64_t aNewVersion) |
69 | 0 | { |
70 | 0 | Nullable<uint64_t> newVersion(aNewVersion); |
71 | 0 | return CreateInternal(aOwner, aName, aOldVersion, newVersion); |
72 | 0 | } |
73 | | |
74 | | static already_AddRefed<IDBVersionChangeEvent> |
75 | | Create(EventTarget* aOwner, |
76 | | const nsDependentString& aName, |
77 | | uint64_t aOldVersion) |
78 | 0 | { |
79 | 0 | Nullable<uint64_t> newVersion(0); |
80 | 0 | newVersion.SetNull(); |
81 | 0 | return CreateInternal(aOwner, aName, aOldVersion, newVersion); |
82 | 0 | } |
83 | | |
84 | | static already_AddRefed<IDBVersionChangeEvent> |
85 | | Constructor(const GlobalObject& aGlobal, |
86 | | const nsAString& aType, |
87 | | const IDBVersionChangeEventInit& aOptions, |
88 | | ErrorResult& aRv); |
89 | | |
90 | | uint64_t |
91 | | OldVersion() const |
92 | | { |
93 | | return mOldVersion; |
94 | | } |
95 | | |
96 | | Nullable<uint64_t> |
97 | | GetNewVersion() const |
98 | | { |
99 | | return mNewVersion; |
100 | | } |
101 | | |
102 | | NS_DECLARE_STATIC_IID_ACCESSOR(IDBVERSIONCHANGEEVENT_IID) |
103 | | |
104 | | NS_DECL_ISUPPORTS_INHERITED |
105 | | |
106 | | virtual JSObject* |
107 | | WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
108 | | |
109 | | private: |
110 | | IDBVersionChangeEvent(EventTarget* aOwner, uint64_t aOldVersion) |
111 | | : Event(aOwner, nullptr, nullptr) |
112 | | , mOldVersion(aOldVersion) |
113 | 0 | { |
114 | 0 | } |
115 | | |
116 | | ~IDBVersionChangeEvent() |
117 | 0 | { } |
118 | | |
119 | | static already_AddRefed<IDBVersionChangeEvent> |
120 | | CreateInternal(EventTarget* aOwner, |
121 | | const nsAString& aName, |
122 | | uint64_t aOldVersion, |
123 | | const Nullable<uint64_t>& aNewVersion); |
124 | | }; |
125 | | |
126 | | NS_DEFINE_STATIC_IID_ACCESSOR(IDBVersionChangeEvent, IDBVERSIONCHANGEEVENT_IID) |
127 | | |
128 | | } // namespace dom |
129 | | } // namespace mozilla |
130 | | |
131 | | #endif // mozilla_dom_idbevents_h__ |