OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef Headers_h | 5 #ifndef Headers_h |
6 #define Headers_h | 6 #define Headers_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
10 #include "core/dom/Iterable.h" | 10 #include "core/dom/Iterable.h" |
11 #include "modules/fetch/FetchHeaderList.h" | 11 #include "modules/fetch/FetchHeaderList.h" |
12 #include "wtf/Forward.h" | 12 #include "wtf/Forward.h" |
13 #include "wtf/PassOwnPtr.h" | 13 #include "wtf/PassOwnPtr.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class Dictionary; | 17 class Dictionary; |
18 class ExceptionState; | 18 class ExceptionState; |
19 class Iterator; | 19 class Iterator; |
20 | 20 |
21 // http://fetch.spec.whatwg.org/#headers-class | 21 // http://fetch.spec.whatwg.org/#headers-class |
22 class Headers final : public GarbageCollected<Headers>, public ScriptWrappable,
public PairIterable<String, String> { | 22 class Headers final : public GarbageCollected<Headers>, public ScriptWrappable,
public PairIterable<String, String> { |
23 DEFINE_WRAPPERTYPEINFO(); | 23 DEFINE_WRAPPERTYPEINFO(); |
24 public: | 24 public: |
25 enum Guard { ImmutableGuard, RequestGuard, RequestNoCORSGuard, ResponseGuard
, NoneGuard }; | 25 enum Guard { ImmutableGuard, RequestGuard, RequestNoCORSGuard, ResponseGuard
, NoneGuard }; |
26 | 26 |
27 static Headers* create(); | 27 static Headers* create(); |
28 static Headers* create(ExceptionState&); | 28 static Headers* create(ExceptionState&); |
29 static Headers* create(const Headers*, ExceptionState&); | 29 static Headers* create(const Headers*, ExceptionState&); |
30 static Headers* create(const Vector<Vector<String> >&, ExceptionState&); | 30 static Headers* create(const Vector<Vector<String>>&, ExceptionState&); |
31 static Headers* create(const Dictionary&, ExceptionState&); | 31 static Headers* create(const Dictionary&, ExceptionState&); |
32 | 32 |
33 // Shares the FetchHeaderList. Called when creating a Request or Response. | 33 // Shares the FetchHeaderList. Called when creating a Request or Response. |
34 static Headers* create(FetchHeaderList*); | 34 static Headers* create(FetchHeaderList*); |
35 | 35 |
36 Headers* createCopy() const; | 36 Headers* createCopy() const; |
37 | 37 |
38 // Headers.idl implementation. | 38 // Headers.idl implementation. |
39 void append(const String& name, const String& value, ExceptionState&); | 39 void append(const String& name, const String& value, ExceptionState&); |
40 void remove(const String& key, ExceptionState&); | 40 void remove(const String& key, ExceptionState&); |
41 String get(const String& key, ExceptionState&); | 41 String get(const String& key, ExceptionState&); |
42 Vector<String> getAll(const String& key, ExceptionState&); | 42 Vector<String> getAll(const String& key, ExceptionState&); |
43 bool has(const String& key, ExceptionState&); | 43 bool has(const String& key, ExceptionState&); |
44 void set(const String& key, const String& value, ExceptionState&); | 44 void set(const String& key, const String& value, ExceptionState&); |
45 | 45 |
46 void setGuard(Guard guard) { m_guard = guard; } | 46 void setGuard(Guard guard) { m_guard = guard; } |
47 Guard guard() const { return m_guard; } | 47 Guard guard() const { return m_guard; } |
48 | 48 |
49 // These methods should only be called when size() would return 0. | 49 // These methods should only be called when size() would return 0. |
50 void fillWith(const Headers*, ExceptionState&); | 50 void fillWith(const Headers*, ExceptionState&); |
51 void fillWith(const Vector<Vector<String> >&, ExceptionState&); | 51 void fillWith(const Vector<Vector<String>>&, ExceptionState&); |
52 void fillWith(const Dictionary&, ExceptionState&); | 52 void fillWith(const Dictionary&, ExceptionState&); |
53 | 53 |
54 FetchHeaderList* headerList() const { return m_headerList; } | 54 FetchHeaderList* headerList() const { return m_headerList; } |
55 void trace(Visitor*); | 55 void trace(Visitor*); |
56 | 56 |
57 private: | 57 private: |
58 Headers(); | 58 Headers(); |
59 // Shares the FetchHeaderList. Called when creating a Request or Response. | 59 // Shares the FetchHeaderList. Called when creating a Request or Response. |
60 explicit Headers(FetchHeaderList*); | 60 explicit Headers(FetchHeaderList*); |
61 | 61 |
62 Member<FetchHeaderList> m_headerList; | 62 Member<FetchHeaderList> m_headerList; |
63 Guard m_guard; | 63 Guard m_guard; |
64 | 64 |
65 IterationSource* startIteration(ScriptState*, ExceptionState&) override; | 65 IterationSource* startIteration(ScriptState*, ExceptionState&) override; |
66 }; | 66 }; |
67 | 67 |
68 } // namespace blink | 68 } // namespace blink |
69 | 69 |
70 #endif // Headers_h | 70 #endif // Headers_h |
OLD | NEW |