2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-02-06 03:17:17 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* url, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_workers_url_h__
|
|
|
|
#define mozilla_dom_workers_url_h__
|
|
|
|
|
2013-11-05 18:16:25 +04:00
|
|
|
#include "Workers.h"
|
2013-02-06 03:17:17 +04:00
|
|
|
|
2013-11-05 18:16:25 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2013-12-12 23:30:27 +04:00
|
|
|
#include "mozilla/dom/URLSearchParams.h"
|
2015-06-29 19:03:47 +03:00
|
|
|
#include "nsWrapperCache.h"
|
2013-11-05 18:16:25 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2015-05-12 15:09:51 +03:00
|
|
|
class Blob;
|
2013-11-05 18:16:25 +04:00
|
|
|
struct objectURLOptions;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-02-06 03:17:17 +04:00
|
|
|
|
|
|
|
BEGIN_WORKERS_NAMESPACE
|
|
|
|
|
2013-09-04 21:07:34 +04:00
|
|
|
class URLProxy;
|
2015-05-05 20:38:56 +03:00
|
|
|
class ConstructorRunnable;
|
2013-09-04 21:07:34 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class URL final : public mozilla::dom::URLSearchParamsObserver
|
2015-06-29 19:03:47 +03:00
|
|
|
, public nsWrapperCache
|
2013-02-06 03:17:17 +04:00
|
|
|
{
|
2013-12-12 23:30:27 +04:00
|
|
|
typedef mozilla::dom::URLSearchParams URLSearchParams;
|
|
|
|
|
2014-06-23 23:56:07 +04:00
|
|
|
~URL();
|
|
|
|
|
2013-09-04 21:07:34 +04:00
|
|
|
public:
|
2013-12-12 23:30:27 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2015-07-15 14:50:59 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(URL)
|
2013-09-04 21:07:34 +04:00
|
|
|
|
|
|
|
URL(WorkerPrivate* aWorkerPrivate, URLProxy* aURLProxy);
|
|
|
|
|
2013-11-05 18:16:25 +04:00
|
|
|
nsISupports*
|
|
|
|
GetParentObject() const
|
|
|
|
{
|
|
|
|
// There's only one global on a worker, so we don't need to specify.
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-09-04 21:07:34 +04:00
|
|
|
|
2015-06-29 19:03:47 +03:00
|
|
|
virtual JSObject*
|
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-09-04 21:07:34 +04:00
|
|
|
|
|
|
|
// Methods for WebIDL
|
|
|
|
|
2014-08-28 02:43:55 +04:00
|
|
|
static already_AddRefed<URL>
|
2013-09-04 21:07:21 +04:00
|
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
URL& aBase, ErrorResult& aRv);
|
2014-08-28 02:43:55 +04:00
|
|
|
static already_AddRefed<URL>
|
2015-05-05 20:38:56 +03:00
|
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
const Optional<nsAString>& aBase, ErrorResult& aRv);
|
|
|
|
static already_AddRefed<URL>
|
2013-09-04 21:07:21 +04:00
|
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
const nsAString& aBase, ErrorResult& aRv);
|
|
|
|
|
2013-02-15 12:04:11 +04:00
|
|
|
static void
|
2013-08-23 09:17:08 +04:00
|
|
|
CreateObjectURL(const GlobalObject& aGlobal,
|
2015-05-12 15:09:51 +03:00
|
|
|
Blob& aArg, const objectURLOptions& aOptions,
|
2015-02-27 22:10:20 +03:00
|
|
|
nsAString& aResult, ErrorResult& aRv);
|
2013-02-15 12:04:11 +04:00
|
|
|
|
2013-02-06 03:17:17 +04:00
|
|
|
static void
|
2015-05-07 10:05:43 +03:00
|
|
|
RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetHref(nsAString& aHref, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
|
|
|
void SetHref(const nsAString& aHref, ErrorResult& aRv);
|
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetOrigin(nsAString& aOrigin, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetProtocol(nsAString& aProtocol, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetProtocol(const nsAString& aProtocol, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetUsername(nsAString& aUsername, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetUsername(const nsAString& aUsername, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetPassword(nsAString& aPassword, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetPassword(const nsAString& aPassword, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetHost(nsAString& aHost, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetHost(const nsAString& aHost, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetHostname(nsAString& aHostname, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetHostname(const nsAString& aHostname, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetPort(nsAString& aPort, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetPort(const nsAString& aPort, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetPathname(nsAString& aPathname, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetPathname(const nsAString& aPathname, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetSearch(nsAString& aSearch, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetSearch(const nsAString& aSearch, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-03-19 19:36:46 +04:00
|
|
|
URLSearchParams* SearchParams();
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetHash(nsAString& aHost, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetHash(const nsAString& aHash, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void Stringify(nsAString& aRetval, ErrorResult& aRv) const
|
2014-01-14 02:46:04 +04:00
|
|
|
{
|
2014-07-12 03:30:27 +04:00
|
|
|
GetHref(aRetval, aRv);
|
2014-01-14 02:46:04 +04:00
|
|
|
}
|
|
|
|
|
2013-12-12 23:30:27 +04:00
|
|
|
// IURLSearchParamsObserver
|
2015-03-21 19:28:04 +03:00
|
|
|
void URLSearchParamsUpdated(URLSearchParams* aSearchParams) override;
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2013-09-04 21:07:21 +04:00
|
|
|
private:
|
2013-09-04 21:07:34 +04:00
|
|
|
URLProxy* GetURLProxy() const
|
2013-09-04 21:07:21 +04:00
|
|
|
{
|
2013-09-04 21:07:34 +04:00
|
|
|
return mURLProxy;
|
2013-09-04 21:07:21 +04:00
|
|
|
}
|
|
|
|
|
2015-05-05 20:38:56 +03:00
|
|
|
static already_AddRefed<URL>
|
|
|
|
FinishConstructor(JSContext* aCx, WorkerPrivate* aPrivate,
|
|
|
|
ConstructorRunnable* aRunnable, ErrorResult& aRv);
|
|
|
|
|
2013-12-12 23:30:27 +04:00
|
|
|
void CreateSearchParamsIfNeeded();
|
|
|
|
|
|
|
|
void SetSearchInternal(const nsAString& aSearch);
|
|
|
|
|
2014-02-03 20:48:38 +04:00
|
|
|
void UpdateURLSearchParams();
|
|
|
|
|
2013-09-04 21:07:34 +04:00
|
|
|
WorkerPrivate* mWorkerPrivate;
|
|
|
|
nsRefPtr<URLProxy> mURLProxy;
|
2013-12-12 23:30:27 +04:00
|
|
|
nsRefPtr<URLSearchParams> mSearchParams;
|
2013-02-06 03:17:17 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
END_WORKERS_NAMESPACE
|
|
|
|
|
|
|
|
#endif /* mozilla_dom_workers_url_h__ */
|