PaymentRequestUpdateEvent.h (2106B)
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_PaymentRequestUpdateEvent_h 8 #define mozilla_dom_PaymentRequestUpdateEvent_h 9 10 #include "mozilla/dom/Event.h" 11 #include "mozilla/dom/PaymentRequestUpdateEventBinding.h" 12 #include "mozilla/dom/PromiseNativeHandler.h" 13 14 namespace mozilla { 15 class ErrorResult; 16 17 namespace dom { 18 19 class Promise; 20 class PaymentRequest; 21 class PaymentRequestUpdateEvent : public Event, public PromiseNativeHandler { 22 public: 23 NS_DECL_ISUPPORTS_INHERITED 24 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED( 25 PaymentRequestUpdateEvent, Event) 26 27 explicit PaymentRequestUpdateEvent(EventTarget* aOwner); 28 29 virtual JSObject* WrapObjectInternal( 30 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; 31 32 virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue, 33 ErrorResult& aRv) override; 34 virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue, 35 ErrorResult& aRv) override; 36 37 static already_AddRefed<PaymentRequestUpdateEvent> Constructor( 38 EventTarget* aOwner, const nsAString& aType, 39 const PaymentRequestUpdateEventInit& aEventInitDict); 40 41 // Called by WebIDL constructor 42 static already_AddRefed<PaymentRequestUpdateEvent> Constructor( 43 const GlobalObject& aGlobal, const nsAString& aType, 44 const PaymentRequestUpdateEventInit& aEventInitDict); 45 46 void UpdateWith(Promise& aPromise, ErrorResult& aRv); 47 48 void SetRequest(PaymentRequest* aRequest); 49 50 protected: 51 ~PaymentRequestUpdateEvent(); 52 // Indicating whether an updateWith()-initiated update is currently in 53 // progress. 54 bool mWaitForUpdate; 55 RefPtr<PaymentRequest> mRequest; 56 }; 57 58 } // namespace dom 59 } // namespace mozilla 60 61 #endif // mozilla_dom_PaymentRequestUpdateEvent_h