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 HeaderMap_h | 5 #ifndef Headers_h |
6 #define HeaderMap_h | 6 #define Headers_h |
7 | 7 |
8 #include "bindings/v8/ScriptWrappable.h" | 8 #include "bindings/v8/ScriptWrappable.h" |
9 #include "modules/serviceworkers/FetchHeaderList.h" | |
9 #include "wtf/Forward.h" | 10 #include "wtf/Forward.h" |
10 #include "wtf/HashMap.h" | 11 #include "wtf/PassOwnPtr.h" |
11 #include "wtf/RefCounted.h" | 12 #include "wtf/RefCounted.h" |
12 #include "wtf/text/StringHash.h" | |
13 | 13 |
14 namespace WebCore { | 14 namespace WebCore { |
15 | 15 |
16 class HeaderMapForEachCallback; | 16 class Dictionary; |
17 class ExceptionState; | |
18 class HeadersForEachCallback; | |
17 class ScriptValue; | 19 class ScriptValue; |
18 | 20 |
19 class HeaderMap FINAL : public ScriptWrappable, public RefCounted<HeaderMap> { | 21 // http://fetch.spec.whatwg.org/#headers-class |
22 class Headers FINAL : public ScriptWrappable, public RefCounted<Headers> { | |
20 public: | 23 public: |
21 static PassRefPtr<HeaderMap> create(); | 24 enum Guard { ImmutableGuard, RequestGuard, RequestNoCORSGuard, ResponseGuard , NoneGuard }; |
22 static PassRefPtr<HeaderMap> create(const HashMap<String, String>& headers); | 25 typedef std::pair<String, String> Header; |
yhirano
2014/06/26 07:22:13
Do you need this typedef?
horo
2014/06/26 08:30:08
Done.
| |
23 | 26 |
24 // HeaderMap.idl implementation. | 27 static PassRefPtr<Headers> create(); |
28 static PassRefPtr<Headers> create(ExceptionState&); | |
29 static PassRefPtr<Headers> create(const Headers*, ExceptionState&); | |
30 static PassRefPtr<Headers> create(const Dictionary&, ExceptionState&); | |
31 | |
32 ~Headers(); | |
33 | |
34 // Shares the FetchHeaderList. Called when creating a Request or Response. | |
35 static PassRefPtr<Headers> create(FetchHeaderList*); | |
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&); | |
25 unsigned long size() const; | 44 unsigned long size() const; |
26 void clear(); | 45 void forEach(PassOwnPtr<HeadersForEachCallback>, ScriptValue&); |
27 bool remove(const String& key); | 46 void forEach(PassOwnPtr<HeadersForEachCallback>); |
28 String get(const String& key); | |
29 bool has(const String& key); | |
30 void set(const String& key, const String& value); | |
31 void forEach(PassOwnPtr<HeaderMapForEachCallback>, ScriptValue&); | |
32 void forEach(PassOwnPtr<HeaderMapForEachCallback>); | |
33 | 47 |
34 const HashMap<String, String>& headerMap() const { return m_headers; } | 48 void clearHeaderList(); |
yhirano
2014/06/26 07:22:13
This function is never called.
horo
2014/06/26 08:30:08
deleted.
| |
49 void fillWith(const Headers*, ExceptionState&); | |
yhirano
2014/06/26 07:22:13
I think these two fillWith functions can be privat
horo
2014/06/26 08:30:08
moved to private
| |
50 void fillWith(const Dictionary&, ExceptionState&); | |
51 | |
52 void setGuard(Guard guard) { m_guard = guard; } | |
53 Guard guard() const { return m_guard; } | |
54 PassRefPtr<FetchHeaderList> list() const { return m_headerList; } | |
yhirano
2014/06/26 07:22:13
I'm not sure if we need this function.
horo
2014/06/26 08:30:08
deleted.
| |
35 | 55 |
36 private: | 56 private: |
37 HeaderMap(); | 57 Headers(); |
38 explicit HeaderMap(const HashMap<String, String>& headers); | 58 // Shares the FetchHeaderList. Called when creating a Request or Response. |
39 void forEachInternal(PassOwnPtr<HeaderMapForEachCallback>, ScriptValue* this Arg); | 59 Headers(FetchHeaderList*); |
60 void forEachInternal(PassOwnPtr<HeadersForEachCallback>, ScriptValue*); | |
40 | 61 |
41 // FIXME: this doesn't preserve ordering while ES6 Map type requires it. | 62 RefPtr<FetchHeaderList> m_headerList; |
42 HashMap<String, String> m_headers; | 63 Guard m_guard; |
43 }; | 64 }; |
44 | 65 |
45 } // namespace WebCore | 66 } // namespace WebCore |
46 | 67 |
47 #endif // HeaderMap_h | 68 #endif // Headers_h |
OLD | NEW |