Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / base / URLSearchParams.h
blobe141f53ddd2aa1f0ae8afb76cd06555f4bab83e2
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_dom_URLSearchParams_h
7 #define mozilla_dom_URLSearchParams_h
9 #include "mozilla/dom/BindingDeclarations.h"
10 #include "mozilla/ErrorResult.h"
11 #include "nsCycleCollectionParticipant.h"
12 #include "nsWrapperCache.h"
13 #include "nsClassHashtable.h"
14 #include "nsHashKeys.h"
15 #include "nsISupports.h"
16 #include "nsIUnicodeDecoder.h"
18 namespace mozilla {
19 namespace dom {
21 class URLSearchParams;
23 class URLSearchParamsObserver : public nsISupports
25 public:
26 virtual ~URLSearchParamsObserver() {}
28 virtual void URLSearchParamsUpdated(URLSearchParams* aFromThis) = 0;
31 class URLSearchParams MOZ_FINAL : public nsISupports,
32 public nsWrapperCache
34 ~URLSearchParams();
36 public:
37 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
38 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(URLSearchParams)
40 URLSearchParams();
42 // WebIDL methods
43 nsISupports* GetParentObject() const
45 return nullptr;
48 virtual JSObject*
49 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
51 static already_AddRefed<URLSearchParams>
52 Constructor(const GlobalObject& aGlobal, const nsAString& aInit,
53 ErrorResult& aRv);
55 static already_AddRefed<URLSearchParams>
56 Constructor(const GlobalObject& aGlobal, URLSearchParams& aInit,
57 ErrorResult& aRv);
59 void ParseInput(const nsACString& aInput,
60 URLSearchParamsObserver* aObserver);
62 void AddObserver(URLSearchParamsObserver* aObserver);
63 void RemoveObserver(URLSearchParamsObserver* aObserver);
64 void RemoveObservers();
66 void Serialize(nsAString& aValue) const;
68 void Get(const nsAString& aName, nsString& aRetval);
70 void GetAll(const nsAString& aName, nsTArray<nsString >& aRetval);
72 void Set(const nsAString& aName, const nsAString& aValue);
74 void Append(const nsAString& aName, const nsAString& aValue);
76 bool Has(const nsAString& aName);
78 void Delete(const nsAString& aName);
80 void Stringify(nsString& aRetval)
82 Serialize(aRetval);
85 private:
86 void AppendInternal(const nsAString& aName, const nsAString& aValue);
88 void DeleteAll();
90 void DecodeString(const nsACString& aInput, nsAString& aOutput);
91 void ConvertString(const nsACString& aInput, nsAString& aOutput);
93 void NotifyObservers(URLSearchParamsObserver* aExceptObserver);
95 static PLDHashOperator
96 CopyEnumerator(const nsAString& aName, nsTArray<nsString>* aArray,
97 void *userData);
99 static PLDHashOperator
100 SerializeEnumerator(const nsAString& aName, nsTArray<nsString>* aArray,
101 void *userData);
103 nsClassHashtable<nsStringHashKey, nsTArray<nsString>> mSearchParams;
105 nsTArray<nsRefPtr<URLSearchParamsObserver>> mObservers;
106 nsCOMPtr<nsIUnicodeDecoder> mDecoder;
109 } // namespace dom
110 } // namespace mozilla
112 #endif /* mozilla_dom_URLSearchParams_h */