ModuleScript.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_ModuleScript_h
  6. #define mozilla_dom_ModuleScript_h
  7. #include "nsCOMPtr.h"
  8. #include "nsCycleCollectionParticipant.h"
  9. #include "jsapi.h"
  10. class nsIURI;
  11. namespace mozilla {
  12. namespace dom {
  13. class ScriptLoader;
  14. class ModuleScript final : public nsISupports
  15. {
  16. RefPtr<ScriptLoader> mLoader;
  17. nsCOMPtr<nsIURI> mBaseURL;
  18. JS::Heap<JSObject*> mModuleRecord;
  19. JS::Heap<JS::Value> mParseError;
  20. JS::Heap<JS::Value> mErrorToRethrow;
  21. ~ModuleScript();
  22. public:
  23. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  24. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ModuleScript)
  25. ModuleScript(ScriptLoader* aLoader,
  26. nsIURI* aBaseURL);
  27. void SetModuleRecord(JS::Handle<JSObject*> aModuleRecord);
  28. void SetParseError(const JS::Value& aError);
  29. void SetErrorToRethrow(const JS::Value& aError);
  30. ScriptLoader* Loader() const { return mLoader; }
  31. JSObject* ModuleRecord() const { return mModuleRecord; }
  32. nsIURI* BaseURL() const { return mBaseURL; }
  33. JS::Value ParseError() const { return mParseError; }
  34. JS::Value ErrorToRethrow() const { return mErrorToRethrow; }
  35. bool HasParseError() const { return !mParseError.isUndefined(); }
  36. bool HasErrorToRethrow() const { return !mErrorToRethrow.isUndefined(); }
  37. void UnlinkModuleRecord();
  38. };
  39. } // dom namespace
  40. } // mozilla namespace
  41. #endif // mozilla_dom_ModuleScript_h