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 FetchHeaderList_h | 5 #ifndef FetchHeaderList_h |
6 #define FetchHeaderList_h | 6 #define FetchHeaderList_h |
7 | 7 |
| 8 #include <map> |
| 9 #include <utility> |
8 #include "modules/ModulesExport.h" | 10 #include "modules/ModulesExport.h" |
9 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
10 #include "wtf/PassRefPtr.h" | |
11 #include "wtf/Vector.h" | 12 #include "wtf/Vector.h" |
12 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
13 #include <memory> | |
14 #include <utility> | |
15 | 14 |
16 namespace blink { | 15 namespace blink { |
17 | 16 |
18 class Header; | 17 class Header; |
19 | 18 |
20 // http://fetch.spec.whatwg.org/#terminology-headers | 19 // http://fetch.spec.whatwg.org/#terminology-headers |
21 class MODULES_EXPORT FetchHeaderList final | 20 class MODULES_EXPORT FetchHeaderList final |
22 : public GarbageCollectedFinalized<FetchHeaderList> { | 21 : public GarbageCollectedFinalized<FetchHeaderList> { |
23 public: | 22 public: |
| 23 struct ByteCaseInsensitiveCompare { |
| 24 bool operator()(const String& lhs, const String& rhs) const { |
| 25 return codePointCompareLessThan(lhs.upperASCII(), rhs.upperASCII()); |
| 26 } |
| 27 }; |
| 28 |
24 typedef std::pair<String, String> Header; | 29 typedef std::pair<String, String> Header; |
25 static FetchHeaderList* create(); | 30 static FetchHeaderList* create(); |
26 FetchHeaderList* clone() const; | 31 FetchHeaderList* clone() const; |
27 | 32 |
28 ~FetchHeaderList(); | 33 ~FetchHeaderList(); |
29 void append(const String&, const String&); | 34 void append(const String&, const String&); |
30 void set(const String&, const String&); | 35 void set(const String&, const String&); |
31 // FIXME: Implement parse() | 36 // FIXME: Implement parse() |
32 String extractMIMEType() const; | 37 String extractMIMEType() const; |
33 | 38 |
34 size_t size() const; | 39 size_t size() const; |
35 void remove(const String&); | 40 void remove(const String&); |
36 bool get(const String&, String&) const; | 41 bool get(const String&, String&) const; |
37 void getAll(const String&, Vector<String>&) const; | 42 void getAll(const String&, Vector<String>&) const; |
38 bool has(const String&) const; | 43 bool has(const String&) const; |
39 void clearList(); | 44 void clearList(); |
40 | 45 |
41 bool containsNonSimpleHeader() const; | 46 bool containsNonSimpleHeader() const; |
42 void sortAndCombine(); | 47 Vector<Header> sortAndCombine() const; |
43 | 48 |
44 const Vector<std::unique_ptr<Header>>& list() const { return m_headerList; } | 49 const std::multimap<String, String, ByteCaseInsensitiveCompare>& list() |
45 const Header& entry(size_t index) const { | 50 const { |
46 return *(m_headerList[index].get()); | 51 return m_headerList; |
47 } | 52 } |
48 | 53 |
49 static bool isValidHeaderName(const String&); | 54 static bool isValidHeaderName(const String&); |
50 static bool isValidHeaderValue(const String&); | 55 static bool isValidHeaderValue(const String&); |
51 | 56 |
52 DEFINE_INLINE_TRACE() {} | 57 DEFINE_INLINE_TRACE() {} |
53 | 58 |
54 private: | 59 private: |
55 FetchHeaderList(); | 60 FetchHeaderList(); |
56 Vector<std::unique_ptr<Header>> m_headerList; | 61 std::multimap<String, String, ByteCaseInsensitiveCompare> m_headerList; |
57 }; | 62 }; |
58 | 63 |
59 } // namespace blink | 64 } // namespace blink |
60 | 65 |
61 #endif // FetchHeaderList_h | 66 #endif // FetchHeaderList_h |
OLD | NEW |