PromiseNativeHandler.h 1018 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_PromiseNativeHandler_h
  6. #define mozilla_dom_PromiseNativeHandler_h
  7. #include "nsISupports.h"
  8. #include "js/TypeDecls.h"
  9. namespace mozilla {
  10. namespace dom {
  11. /*
  12. * PromiseNativeHandler allows C++ to react to a Promise being rejected/resolved.
  13. * A PromiseNativeHandler can be appended to a Promise using
  14. * Promise::AppendNativeHandler().
  15. */
  16. class PromiseNativeHandler : public nsISupports
  17. {
  18. protected:
  19. virtual ~PromiseNativeHandler()
  20. { }
  21. public:
  22. virtual void
  23. ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) = 0;
  24. virtual void
  25. RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) = 0;
  26. };
  27. } // namespace dom
  28. } // namespace mozilla
  29. #endif // mozilla_dom_PromiseNativeHandler_h