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