WorkerLocation.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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_location_h__
  6. #define mozilla_dom_location_h__
  7. #include "Workers.h"
  8. #include "WorkerPrivate.h"
  9. #include "nsWrapperCache.h"
  10. namespace mozilla {
  11. namespace dom {
  12. class WorkerLocation final : public nsWrapperCache
  13. {
  14. nsString mHref;
  15. nsString mProtocol;
  16. nsString mHost;
  17. nsString mHostname;
  18. nsString mPort;
  19. nsString mPathname;
  20. nsString mSearch;
  21. nsString mHash;
  22. nsString mOrigin;
  23. WorkerLocation(const nsAString& aHref,
  24. const nsAString& aProtocol,
  25. const nsAString& aHost,
  26. const nsAString& aHostname,
  27. const nsAString& aPort,
  28. const nsAString& aPathname,
  29. const nsAString& aSearch,
  30. const nsAString& aHash,
  31. const nsAString& aOrigin)
  32. : mHref(aHref)
  33. , mProtocol(aProtocol)
  34. , mHost(aHost)
  35. , mHostname(aHostname)
  36. , mPort(aPort)
  37. , mPathname(aPathname)
  38. , mSearch(aSearch)
  39. , mHash(aHash)
  40. , mOrigin(aOrigin)
  41. {
  42. MOZ_COUNT_CTOR(WorkerLocation);
  43. }
  44. ~WorkerLocation()
  45. {
  46. MOZ_COUNT_DTOR(WorkerLocation);
  47. }
  48. public:
  49. NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerLocation)
  50. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerLocation)
  51. static already_AddRefed<WorkerLocation>
  52. Create(workers::WorkerPrivate::LocationInfo& aInfo);
  53. virtual JSObject*
  54. WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  55. nsISupports* GetParentObject() const {
  56. return nullptr;
  57. }
  58. void Stringify(nsString& aHref) const
  59. {
  60. aHref = mHref;
  61. }
  62. void GetHref(nsString& aHref) const
  63. {
  64. aHref = mHref;
  65. }
  66. void GetProtocol(nsString& aProtocol) const
  67. {
  68. aProtocol = mProtocol;
  69. }
  70. void GetHost(nsString& aHost) const
  71. {
  72. aHost = mHost;
  73. }
  74. void GetHostname(nsString& aHostname) const
  75. {
  76. aHostname = mHostname;
  77. }
  78. void GetPort(nsString& aPort) const
  79. {
  80. aPort = mPort;
  81. }
  82. void GetPathname(nsString& aPathname) const
  83. {
  84. aPathname = mPathname;
  85. }
  86. void GetSearch(nsString& aSearch) const
  87. {
  88. aSearch = mSearch;
  89. }
  90. void GetHash(nsString& aHash) const
  91. {
  92. aHash = mHash;
  93. }
  94. void GetOrigin(nsString& aOrigin) const
  95. {
  96. aOrigin = mOrigin;
  97. }
  98. };
  99. } // namespace dom
  100. } // namespace mozilla
  101. #endif // mozilla_dom_location_h__