dom/workers/URL.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/workers/URL.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,142 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * url, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_workers_url_h__
    1.11 +#define mozilla_dom_workers_url_h__
    1.12 +
    1.13 +#include "Workers.h"
    1.14 +
    1.15 +#include "mozilla/ErrorResult.h"
    1.16 +#include "mozilla/dom/BindingDeclarations.h"
    1.17 +#include "mozilla/dom/URLSearchParams.h"
    1.18 +
    1.19 +namespace mozilla {
    1.20 +namespace dom {
    1.21 +struct objectURLOptions;
    1.22 +}
    1.23 +}
    1.24 +
    1.25 +BEGIN_WORKERS_NAMESPACE
    1.26 +
    1.27 +class URLProxy;
    1.28 +
    1.29 +class URL MOZ_FINAL : public mozilla::dom::URLSearchParamsObserver
    1.30 +{
    1.31 +  typedef mozilla::dom::URLSearchParams URLSearchParams;
    1.32 +
    1.33 +public:
    1.34 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.35 +  NS_DECL_CYCLE_COLLECTION_CLASS(URL)
    1.36 +
    1.37 +  URL(WorkerPrivate* aWorkerPrivate, URLProxy* aURLProxy);
    1.38 +  ~URL();
    1.39 +
    1.40 +  nsISupports*
    1.41 +  GetParentObject() const
    1.42 +  {
    1.43 +    // There's only one global on a worker, so we don't need to specify.
    1.44 +    return nullptr;
    1.45 +  }
    1.46 +
    1.47 +  JSObject*
    1.48 +  WrapObject(JSContext* aCx);
    1.49 +
    1.50 +  // Methods for WebIDL
    1.51 +
    1.52 +  static URL*
    1.53 +  Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
    1.54 +              URL& aBase, ErrorResult& aRv);
    1.55 +  static URL*
    1.56 +  Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
    1.57 +              const nsAString& aBase, ErrorResult& aRv);
    1.58 +
    1.59 +  static void
    1.60 +  CreateObjectURL(const GlobalObject& aGlobal,
    1.61 +                  JSObject* aArg, const objectURLOptions& aOptions,
    1.62 +                  nsString& aResult, ErrorResult& aRv);
    1.63 +
    1.64 +  static void
    1.65 +  CreateObjectURL(const GlobalObject& aGlobal,
    1.66 +                  JSObject& aArg, const objectURLOptions& aOptions,
    1.67 +                  nsString& aResult, ErrorResult& aRv);
    1.68 +
    1.69 +  static void
    1.70 +  RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aUrl);
    1.71 +
    1.72 +  void GetHref(nsString& aHref) const;
    1.73 +
    1.74 +  void SetHref(const nsAString& aHref, ErrorResult& aRv);
    1.75 +
    1.76 +  void GetOrigin(nsString& aOrigin) const;
    1.77 +
    1.78 +  void GetProtocol(nsString& aProtocol) const;
    1.79 +
    1.80 +  void SetProtocol(const nsAString& aProtocol);
    1.81 +
    1.82 +  void GetUsername(nsString& aUsername) const;
    1.83 +
    1.84 +  void SetUsername(const nsAString& aUsername);
    1.85 +
    1.86 +  void GetPassword(nsString& aPassword) const;
    1.87 +
    1.88 +  void SetPassword(const nsAString& aPassword);
    1.89 +
    1.90 +  void GetHost(nsString& aHost) const;
    1.91 +
    1.92 +  void SetHost(const nsAString& aHost);
    1.93 +
    1.94 +  void GetHostname(nsString& aHostname) const;
    1.95 +
    1.96 +  void SetHostname(const nsAString& aHostname);
    1.97 +
    1.98 +  void GetPort(nsString& aPort) const;
    1.99 +
   1.100 +  void SetPort(const nsAString& aPort);
   1.101 +
   1.102 +  void GetPathname(nsString& aPathname) const;
   1.103 +
   1.104 +  void SetPathname(const nsAString& aPathname);
   1.105 +
   1.106 +  void GetSearch(nsString& aSearch) const;
   1.107 +
   1.108 +  void SetSearch(const nsAString& aSearch);
   1.109 +
   1.110 +  URLSearchParams* SearchParams();
   1.111 +
   1.112 +  void SetSearchParams(URLSearchParams& aSearchParams);
   1.113 +
   1.114 +  void GetHash(nsString& aHost) const;
   1.115 +
   1.116 +  void SetHash(const nsAString& aHash);
   1.117 +
   1.118 +  void Stringify(nsString& aRetval) const
   1.119 +  {
   1.120 +    GetHref(aRetval);
   1.121 +  }
   1.122 +
   1.123 +  // IURLSearchParamsObserver
   1.124 +  void URLSearchParamsUpdated() MOZ_OVERRIDE;
   1.125 +
   1.126 +private:
   1.127 +  URLProxy* GetURLProxy() const
   1.128 +  {
   1.129 +    return mURLProxy;
   1.130 +  }
   1.131 +
   1.132 +  void CreateSearchParamsIfNeeded();
   1.133 +
   1.134 +  void SetSearchInternal(const nsAString& aSearch);
   1.135 +
   1.136 +  void UpdateURLSearchParams();
   1.137 +
   1.138 +  WorkerPrivate* mWorkerPrivate;
   1.139 +  nsRefPtr<URLProxy> mURLProxy;
   1.140 +  nsRefPtr<URLSearchParams> mSearchParams;
   1.141 +};
   1.142 +
   1.143 +END_WORKERS_NAMESPACE
   1.144 +
   1.145 +#endif /* mozilla_dom_workers_url_h__ */

mercurial