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