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