Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / events / StorageEvent.h
blob255a4a8c27afccdc29cc89dc29e9a367c549319c
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/. */
7 #ifndef mozilla_dom_StorageEvent_h
8 #define mozilla_dom_StorageEvent_h
10 #include "js/RootingAPI.h"
11 #include "mozilla/AlreadyAddRefed.h"
12 #include "mozilla/Assertions.h"
13 #include "mozilla/RefPtr.h"
14 #include "mozilla/dom/Event.h"
15 #include "nsCOMPtr.h"
16 #include "nsCycleCollectionParticipant.h"
17 #include "nsIPrincipal.h"
18 #include "nsISupports.h"
19 #include "nsStringFwd.h"
21 class nsIPrincipal;
23 namespace mozilla::dom {
25 class Storage;
26 struct StorageEventInit;
28 class StorageEvent : public Event {
29 public:
30 NS_DECL_ISUPPORTS_INHERITED
31 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(StorageEvent, Event)
33 explicit StorageEvent(EventTarget* aOwner);
35 protected:
36 virtual ~StorageEvent();
38 nsString mKey;
39 nsString mOldValue;
40 nsString mNewValue;
41 nsString mUrl;
42 RefPtr<Storage> mStorageArea;
43 nsCOMPtr<nsIPrincipal> mPrincipal;
45 public:
46 virtual StorageEvent* AsStorageEvent();
48 virtual JSObject* WrapObjectInternal(
49 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
51 static already_AddRefed<StorageEvent> Constructor(
52 EventTarget* aOwner, const nsAString& aType,
53 const StorageEventInit& aEventInitDict);
55 static already_AddRefed<StorageEvent> Constructor(
56 const GlobalObject& aGlobal, const nsAString& aType,
57 const StorageEventInit& aEventInitDict);
59 void InitStorageEvent(const nsAString& aType, bool aCanBubble,
60 bool aCancelable, const nsAString& aKey,
61 const nsAString& aOldValue, const nsAString& aNewValue,
62 const nsAString& aURL, Storage* aStorageArea);
64 void GetKey(nsString& aRetVal) const { aRetVal = mKey; }
66 void GetOldValue(nsString& aRetVal) const { aRetVal = mOldValue; }
68 void GetNewValue(nsString& aRetVal) const { aRetVal = mNewValue; }
70 void GetUrl(nsString& aRetVal) const { aRetVal = mUrl; }
72 Storage* GetStorageArea() const { return mStorageArea; }
74 // Non WebIDL methods
75 void SetPrincipal(nsIPrincipal* aPrincipal) {
76 MOZ_ASSERT(!mPrincipal);
77 mPrincipal = aPrincipal;
80 nsIPrincipal* GetPrincipal() const { return mPrincipal; }
83 } // namespace mozilla::dom
85 #endif // mozilla_dom_StorageEvent_h