Line data Source code
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 :
15 : #define IDBVERSIONCHANGEEVENT_IID \
16 : {0x3b65d4c3, 0x73ad, 0x492e, {0xb1, 0x2d, 0x15, 0xf9, 0xda, 0xc2, 0x08, 0x4b}}
17 :
18 : class nsAString;
19 : class nsDependentString;
20 :
21 : namespace mozilla {
22 :
23 : class ErrorResult;
24 :
25 : namespace dom {
26 :
27 : class EventTarget;
28 : class GlobalObject;
29 : struct IDBVersionChangeEventInit;
30 :
31 : namespace indexedDB {
32 :
33 : enum Bubbles {
34 : eDoesNotBubble,
35 : eDoesBubble
36 : };
37 :
38 : enum Cancelable {
39 : eNotCancelable,
40 : eCancelable
41 : };
42 :
43 : extern const char16_t* kAbortEventType;
44 : extern const char16_t* kBlockedEventType;
45 : extern const char16_t* kCompleteEventType;
46 : extern const char16_t* kErrorEventType;
47 : extern const char16_t* kSuccessEventType;
48 : extern const char16_t* kUpgradeNeededEventType;
49 : extern const char16_t* kVersionChangeEventType;
50 : extern const char16_t* kCloseEventType;
51 :
52 : already_AddRefed<nsIDOMEvent>
53 : CreateGenericEvent(EventTarget* aOwner,
54 : const nsDependentString& aType,
55 : Bubbles aBubbles,
56 : Cancelable aCancelable);
57 :
58 : } // namespace indexedDB
59 :
60 : class IDBVersionChangeEvent final : public Event
61 : {
62 : uint64_t mOldVersion;
63 : Nullable<uint64_t> mNewVersion;
64 :
65 : public:
66 : static already_AddRefed<IDBVersionChangeEvent>
67 0 : Create(EventTarget* aOwner,
68 : const nsDependentString& aName,
69 : uint64_t aOldVersion,
70 : uint64_t aNewVersion)
71 : {
72 0 : Nullable<uint64_t> newVersion(aNewVersion);
73 0 : return CreateInternal(aOwner, aName, aOldVersion, newVersion);
74 : }
75 :
76 : static already_AddRefed<IDBVersionChangeEvent>
77 0 : Create(EventTarget* aOwner,
78 : const nsDependentString& aName,
79 : uint64_t aOldVersion)
80 : {
81 0 : Nullable<uint64_t> newVersion(0);
82 0 : newVersion.SetNull();
83 0 : return CreateInternal(aOwner, aName, aOldVersion, newVersion);
84 : }
85 :
86 : static already_AddRefed<IDBVersionChangeEvent>
87 : Constructor(const GlobalObject& aGlobal,
88 : const nsAString& aType,
89 : const IDBVersionChangeEventInit& aOptions,
90 : ErrorResult& aRv);
91 :
92 : uint64_t
93 0 : OldVersion() const
94 : {
95 0 : return mOldVersion;
96 : }
97 :
98 : Nullable<uint64_t>
99 0 : GetNewVersion() const
100 : {
101 0 : return mNewVersion;
102 : }
103 :
104 : NS_DECLARE_STATIC_IID_ACCESSOR(IDBVERSIONCHANGEEVENT_IID)
105 :
106 : NS_DECL_ISUPPORTS_INHERITED
107 0 : NS_FORWARD_TO_EVENT
108 :
109 : virtual JSObject*
110 : WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
111 :
112 : private:
113 0 : IDBVersionChangeEvent(EventTarget* aOwner, uint64_t aOldVersion)
114 0 : : Event(aOwner, nullptr, nullptr)
115 0 : , mOldVersion(aOldVersion)
116 : {
117 0 : }
118 :
119 0 : ~IDBVersionChangeEvent()
120 0 : { }
121 :
122 : static already_AddRefed<IDBVersionChangeEvent>
123 : CreateInternal(EventTarget* aOwner,
124 : const nsAString& aName,
125 : uint64_t aOldVersion,
126 : const Nullable<uint64_t>& aNewVersion);
127 : };
128 :
129 : NS_DEFINE_STATIC_IID_ACCESSOR(IDBVersionChangeEvent, IDBVERSIONCHANGEEVENT_IID)
130 :
131 : } // namespace dom
132 : } // namespace mozilla
133 :
134 : #endif // mozilla_dom_idbevents_h__
|