Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * url, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_workers_url_h__ |
michael@0 | 8 | #define mozilla_dom_workers_url_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "Workers.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "mozilla/ErrorResult.h" |
michael@0 | 13 | #include "mozilla/dom/BindingDeclarations.h" |
michael@0 | 14 | #include "mozilla/dom/URLSearchParams.h" |
michael@0 | 15 | |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | namespace dom { |
michael@0 | 18 | struct objectURLOptions; |
michael@0 | 19 | } |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | BEGIN_WORKERS_NAMESPACE |
michael@0 | 23 | |
michael@0 | 24 | class URLProxy; |
michael@0 | 25 | |
michael@0 | 26 | class URL MOZ_FINAL : public mozilla::dom::URLSearchParamsObserver |
michael@0 | 27 | { |
michael@0 | 28 | typedef mozilla::dom::URLSearchParams URLSearchParams; |
michael@0 | 29 | |
michael@0 | 30 | public: |
michael@0 | 31 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 32 | NS_DECL_CYCLE_COLLECTION_CLASS(URL) |
michael@0 | 33 | |
michael@0 | 34 | URL(WorkerPrivate* aWorkerPrivate, URLProxy* aURLProxy); |
michael@0 | 35 | ~URL(); |
michael@0 | 36 | |
michael@0 | 37 | nsISupports* |
michael@0 | 38 | GetParentObject() const |
michael@0 | 39 | { |
michael@0 | 40 | // There's only one global on a worker, so we don't need to specify. |
michael@0 | 41 | return nullptr; |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | JSObject* |
michael@0 | 45 | WrapObject(JSContext* aCx); |
michael@0 | 46 | |
michael@0 | 47 | // Methods for WebIDL |
michael@0 | 48 | |
michael@0 | 49 | static URL* |
michael@0 | 50 | Constructor(const GlobalObject& aGlobal, const nsAString& aUrl, |
michael@0 | 51 | URL& aBase, ErrorResult& aRv); |
michael@0 | 52 | static URL* |
michael@0 | 53 | Constructor(const GlobalObject& aGlobal, const nsAString& aUrl, |
michael@0 | 54 | const nsAString& aBase, ErrorResult& aRv); |
michael@0 | 55 | |
michael@0 | 56 | static void |
michael@0 | 57 | CreateObjectURL(const GlobalObject& aGlobal, |
michael@0 | 58 | JSObject* aArg, const objectURLOptions& aOptions, |
michael@0 | 59 | nsString& aResult, ErrorResult& aRv); |
michael@0 | 60 | |
michael@0 | 61 | static void |
michael@0 | 62 | CreateObjectURL(const GlobalObject& aGlobal, |
michael@0 | 63 | JSObject& aArg, const objectURLOptions& aOptions, |
michael@0 | 64 | nsString& aResult, ErrorResult& aRv); |
michael@0 | 65 | |
michael@0 | 66 | static void |
michael@0 | 67 | RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aUrl); |
michael@0 | 68 | |
michael@0 | 69 | void GetHref(nsString& aHref) const; |
michael@0 | 70 | |
michael@0 | 71 | void SetHref(const nsAString& aHref, ErrorResult& aRv); |
michael@0 | 72 | |
michael@0 | 73 | void GetOrigin(nsString& aOrigin) const; |
michael@0 | 74 | |
michael@0 | 75 | void GetProtocol(nsString& aProtocol) const; |
michael@0 | 76 | |
michael@0 | 77 | void SetProtocol(const nsAString& aProtocol); |
michael@0 | 78 | |
michael@0 | 79 | void GetUsername(nsString& aUsername) const; |
michael@0 | 80 | |
michael@0 | 81 | void SetUsername(const nsAString& aUsername); |
michael@0 | 82 | |
michael@0 | 83 | void GetPassword(nsString& aPassword) const; |
michael@0 | 84 | |
michael@0 | 85 | void SetPassword(const nsAString& aPassword); |
michael@0 | 86 | |
michael@0 | 87 | void GetHost(nsString& aHost) const; |
michael@0 | 88 | |
michael@0 | 89 | void SetHost(const nsAString& aHost); |
michael@0 | 90 | |
michael@0 | 91 | void GetHostname(nsString& aHostname) const; |
michael@0 | 92 | |
michael@0 | 93 | void SetHostname(const nsAString& aHostname); |
michael@0 | 94 | |
michael@0 | 95 | void GetPort(nsString& aPort) const; |
michael@0 | 96 | |
michael@0 | 97 | void SetPort(const nsAString& aPort); |
michael@0 | 98 | |
michael@0 | 99 | void GetPathname(nsString& aPathname) const; |
michael@0 | 100 | |
michael@0 | 101 | void SetPathname(const nsAString& aPathname); |
michael@0 | 102 | |
michael@0 | 103 | void GetSearch(nsString& aSearch) const; |
michael@0 | 104 | |
michael@0 | 105 | void SetSearch(const nsAString& aSearch); |
michael@0 | 106 | |
michael@0 | 107 | URLSearchParams* SearchParams(); |
michael@0 | 108 | |
michael@0 | 109 | void SetSearchParams(URLSearchParams& aSearchParams); |
michael@0 | 110 | |
michael@0 | 111 | void GetHash(nsString& aHost) const; |
michael@0 | 112 | |
michael@0 | 113 | void SetHash(const nsAString& aHash); |
michael@0 | 114 | |
michael@0 | 115 | void Stringify(nsString& aRetval) const |
michael@0 | 116 | { |
michael@0 | 117 | GetHref(aRetval); |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | // IURLSearchParamsObserver |
michael@0 | 121 | void URLSearchParamsUpdated() MOZ_OVERRIDE; |
michael@0 | 122 | |
michael@0 | 123 | private: |
michael@0 | 124 | URLProxy* GetURLProxy() const |
michael@0 | 125 | { |
michael@0 | 126 | return mURLProxy; |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | void CreateSearchParamsIfNeeded(); |
michael@0 | 130 | |
michael@0 | 131 | void SetSearchInternal(const nsAString& aSearch); |
michael@0 | 132 | |
michael@0 | 133 | void UpdateURLSearchParams(); |
michael@0 | 134 | |
michael@0 | 135 | WorkerPrivate* mWorkerPrivate; |
michael@0 | 136 | nsRefPtr<URLProxy> mURLProxy; |
michael@0 | 137 | nsRefPtr<URLSearchParams> mSearchParams; |
michael@0 | 138 | }; |
michael@0 | 139 | |
michael@0 | 140 | END_WORKERS_NAMESPACE |
michael@0 | 141 | |
michael@0 | 142 | #endif /* mozilla_dom_workers_url_h__ */ |