WorkerLocation.h (2491B)
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_location_h__ 8 #define mozilla_dom_location_h__ 9 10 #include "WorkerCommon.h" 11 #include "WorkerPrivate.h" 12 #include "nsWrapperCache.h" 13 14 namespace mozilla::dom { 15 16 class WorkerLocation final : public nsWrapperCache { 17 nsString mHref; 18 nsString mProtocol; 19 nsString mHost; 20 nsString mHostname; 21 nsString mPort; 22 nsString mPathname; 23 nsString mSearch; 24 nsString mHash; 25 nsString mOrigin; 26 27 WorkerLocation(const nsAString& aHref, const nsAString& aProtocol, 28 const nsAString& aHost, const nsAString& aHostname, 29 const nsAString& aPort, const nsAString& aPathname, 30 const nsAString& aSearch, 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 MOZ_COUNT_CTOR(WorkerLocation); 42 } 43 44 MOZ_COUNTED_DTOR(WorkerLocation) 45 46 public: 47 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerLocation) 48 NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(WorkerLocation) 49 50 static already_AddRefed<WorkerLocation> Create( 51 WorkerPrivate::LocationInfo& aInfo); 52 53 virtual JSObject* WrapObject(JSContext* aCx, 54 JS::Handle<JSObject*> aGivenProto) override; 55 56 nsISupports* GetParentObject() const { return nullptr; } 57 58 void Stringify(nsString& aHref) const { aHref = mHref; } 59 void GetHref(nsString& aHref) const { aHref = mHref; } 60 void GetProtocol(nsString& aProtocol) const { aProtocol = mProtocol; } 61 void GetHost(nsString& aHost) const { aHost = mHost; } 62 void GetHostname(nsString& aHostname) const { aHostname = mHostname; } 63 void GetPort(nsString& aPort) const { aPort = mPort; } 64 void GetPathname(nsString& aPathname) const { aPathname = mPathname; } 65 void GetSearch(nsString& aSearch) const { aSearch = mSearch; } 66 void GetHash(nsString& aHash) const { aHash = mHash; } 67 void GetOrigin(nsString& aOrigin) const { aOrigin = mOrigin; } 68 }; 69 70 } // namespace mozilla::dom 71 72 #endif // mozilla_dom_location_h__