| 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/Iterable.h" | 8 #include "bindings/core/v8/Iterable.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
| 11 #include "modules/ModulesExport.h" | 11 #include "modules/ModulesExport.h" |
| 12 #include "modules/fetch/FetchHeaderList.h" | 12 #include "modules/fetch/FetchHeaderList.h" |
| 13 #include "wtf/Forward.h" | 13 #include "wtf/Forward.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class Dictionary; | 17 class ByteStringSequenceSequenceOrByteStringByteStringRecordOrHeaders; |
| 18 class ExceptionState; | 18 class ExceptionState; |
| 19 | 19 |
| 20 // http://fetch.spec.whatwg.org/#headers-class | 20 // http://fetch.spec.whatwg.org/#headers-class |
| 21 class MODULES_EXPORT Headers final : public GarbageCollected<Headers>, | 21 class MODULES_EXPORT Headers final : public GarbageCollected<Headers>, |
| 22 public ScriptWrappable, | 22 public ScriptWrappable, |
| 23 public PairIterable<String, String> { | 23 public PairIterable<String, String> { |
| 24 DEFINE_WRAPPERTYPEINFO(); | 24 DEFINE_WRAPPERTYPEINFO(); |
| 25 | 25 |
| 26 public: | 26 public: |
| 27 enum Guard { | 27 enum Guard { |
| 28 kImmutableGuard, | 28 kImmutableGuard, |
| 29 kRequestGuard, | 29 kRequestGuard, |
| 30 kRequestNoCORSGuard, | 30 kRequestNoCORSGuard, |
| 31 kResponseGuard, | 31 kResponseGuard, |
| 32 kNoneGuard | 32 kNoneGuard |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 static Headers* Create(); | |
| 36 static Headers* Create(ExceptionState&); | 35 static Headers* Create(ExceptionState&); |
| 37 static Headers* Create(const Headers*, ExceptionState&); | 36 static Headers* Create( |
| 38 static Headers* Create(const Vector<Vector<String>>&, ExceptionState&); | 37 const ByteStringSequenceSequenceOrByteStringByteStringRecordOrHeaders&, |
| 39 static Headers* Create(const Dictionary&, ExceptionState&); | 38 ExceptionState&); |
| 40 | 39 |
| 41 // Shares the FetchHeaderList. Called when creating a Request or Response. | 40 // Shares the FetchHeaderList. Called when creating a Request or Response. |
| 42 static Headers* Create(FetchHeaderList*); | 41 static Headers* Create(FetchHeaderList*); |
| 43 | 42 |
| 44 Headers* Clone() const; | 43 Headers* Clone() const; |
| 45 | 44 |
| 46 // Headers.idl implementation. | 45 // Headers.idl implementation. |
| 47 void append(const String& name, const String& value, ExceptionState&); | 46 void append(const String& name, const String& value, ExceptionState&); |
| 48 void remove(const String& key, ExceptionState&); | 47 void remove(const String& key, ExceptionState&); |
| 49 String get(const String& key, ExceptionState&); | 48 String get(const String& key, ExceptionState&); |
| 50 Vector<String> getAll(const String& key, ExceptionState&); | 49 Vector<String> getAll(const String& key, ExceptionState&); |
| 51 bool has(const String& key, ExceptionState&); | 50 bool has(const String& key, ExceptionState&); |
| 52 void set(const String& key, const String& value, ExceptionState&); | 51 void set(const String& key, const String& value, ExceptionState&); |
| 53 | 52 |
| 54 void SetGuard(Guard guard) { guard_ = guard; } | 53 void SetGuard(Guard guard) { guard_ = guard; } |
| 55 Guard GetGuard() const { return guard_; } | 54 Guard GetGuard() const { return guard_; } |
| 56 | 55 |
| 57 // These methods should only be called when size() would return 0. | 56 // These methods should only be called when size() would return 0. |
| 58 void FillWith(const Headers*, ExceptionState&); | 57 void FillWith(const Headers*, ExceptionState&); |
| 59 void FillWith(const Vector<Vector<String>>&, ExceptionState&); | 58 void FillWith(const Vector<Vector<String>>&, ExceptionState&); |
| 60 void FillWith(const Dictionary&, ExceptionState&); | 59 void FillWith(const Vector<std::pair<String, String>>&, ExceptionState&); |
| 61 | 60 |
| 62 FetchHeaderList* HeaderList() const { return header_list_; } | 61 FetchHeaderList* HeaderList() const { return header_list_; } |
| 63 DECLARE_TRACE(); | 62 DECLARE_TRACE(); |
| 64 | 63 |
| 65 private: | 64 private: |
| 66 Headers(); | 65 Headers(); |
| 67 // Shares the FetchHeaderList. Called when creating a Request or Response. | 66 // Shares the FetchHeaderList. Called when creating a Request or Response. |
| 68 explicit Headers(FetchHeaderList*); | 67 explicit Headers(FetchHeaderList*); |
| 69 | 68 |
| 70 Member<FetchHeaderList> header_list_; | 69 Member<FetchHeaderList> header_list_; |
| 71 Guard guard_; | 70 Guard guard_; |
| 72 | 71 |
| 73 IterationSource* StartIteration(ScriptState*, ExceptionState&) override; | 72 IterationSource* StartIteration(ScriptState*, ExceptionState&) override; |
| 74 }; | 73 }; |
| 75 | 74 |
| 76 } // namespace blink | 75 } // namespace blink |
| 77 | 76 |
| 78 #endif // Headers_h | 77 #endif // Headers_h |
| OLD | NEW |