dom/workers/URL.h

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

mercurial