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/v8/ScriptWrappable.h" |
| 9 #include "modules/serviceworkers/FetchHeaderList.h" |
| 10 #include "wtf/Forward.h" |
| 11 #include "wtf/PassOwnPtr.h" |
| 12 #include "wtf/RefCounted.h" |
| 13 |
| 14 namespace WebCore { |
| 15 |
| 16 class Dictionary; |
| 17 class ExceptionState; |
| 18 class HeadersForEachCallback; |
| 19 class ScriptValue; |
| 20 |
| 21 // http://fetch.spec.whatwg.org/#headers-class |
| 22 class Headers FINAL : public RefCounted<Headers>, public ScriptWrappable { |
| 23 public: |
| 24 enum Guard { ImmutableGuard, RequestGuard, RequestNoCORSGuard, ResponseGuard
, NoneGuard }; |
| 25 |
| 26 static PassRefPtr<Headers> create(); |
| 27 static PassRefPtr<Headers> create(ExceptionState&); |
| 28 static PassRefPtr<Headers> create(const Headers*, ExceptionState&); |
| 29 static PassRefPtr<Headers> create(const Dictionary&, ExceptionState&); |
| 30 |
| 31 ~Headers(); |
| 32 |
| 33 // Shares the FetchHeaderList. Called when creating a Request or Response. |
| 34 static PassRefPtr<Headers> create(FetchHeaderList*); |
| 35 |
| 36 // Headers.idl implementation. |
| 37 void append(const String& name, const String& value, ExceptionState&); |
| 38 void remove(const String& key, ExceptionState&); |
| 39 String get(const String& key, ExceptionState&); |
| 40 Vector<String> getAll(const String& key, ExceptionState&); |
| 41 bool has(const String& key, ExceptionState&); |
| 42 void set(const String& key, const String& value, ExceptionState&); |
| 43 unsigned long size() const; |
| 44 void forEach(PassOwnPtr<HeadersForEachCallback>, ScriptValue&); |
| 45 void forEach(PassOwnPtr<HeadersForEachCallback>); |
| 46 |
| 47 void setGuard(Guard guard) { m_guard = guard; } |
| 48 Guard guard() const { return m_guard; } |
| 49 |
| 50 private: |
| 51 Headers(); |
| 52 // Shares the FetchHeaderList. Called when creating a Request or Response. |
| 53 explicit Headers(FetchHeaderList*); |
| 54 void forEachInternal(PassOwnPtr<HeadersForEachCallback>, ScriptValue*); |
| 55 |
| 56 void fillWith(const Headers*, ExceptionState&); |
| 57 void fillWith(const Dictionary&, ExceptionState&); |
| 58 |
| 59 RefPtr<FetchHeaderList> m_headerList; |
| 60 Guard m_guard; |
| 61 }; |
| 62 |
| 63 } // namespace WebCore |
| 64 |
| 65 #endif // Headers_h |
OLD | NEW |