Index: third_party/WebKit/Source/modules/fetch/FetchHeaderList.h |
diff --git a/third_party/WebKit/Source/modules/fetch/FetchHeaderList.h b/third_party/WebKit/Source/modules/fetch/FetchHeaderList.h |
index 28bdd3fc1e6e11adf8db13745325d92010024362..3942fd3e7c2a0470e42a8769e2bcaea44dcbf4ae 100644 |
--- a/third_party/WebKit/Source/modules/fetch/FetchHeaderList.h |
+++ b/third_party/WebKit/Source/modules/fetch/FetchHeaderList.h |
@@ -5,11 +5,10 @@ |
#ifndef FetchHeaderList_h |
#define FetchHeaderList_h |
-#include <memory> |
+#include <map> |
#include <utility> |
#include "modules/ModulesExport.h" |
#include "platform/heap/Handle.h" |
-#include "platform/wtf/PassRefPtr.h" |
#include "platform/wtf/Vector.h" |
#include "platform/wtf/text/WTFString.h" |
@@ -21,6 +20,12 @@ class Header; |
class MODULES_EXPORT FetchHeaderList final |
: public GarbageCollectedFinalized<FetchHeaderList> { |
public: |
+ struct ByteCaseInsensitiveCompare { |
+ bool operator()(const String& lhs, const String& rhs) const { |
+ return CodePointCompareLessThan(lhs.LowerASCII(), rhs.LowerASCII()); |
+ } |
+ }; |
+ |
typedef std::pair<String, String> Header; |
static FetchHeaderList* Create(); |
FetchHeaderList* Clone() const; |
@@ -39,11 +44,11 @@ class MODULES_EXPORT FetchHeaderList final |
void ClearList(); |
bool ContainsNonSimpleHeader() const; |
- void SortAndCombine(); |
+ Vector<Header> SortAndCombine() const; |
- const Vector<std::unique_ptr<Header>>& List() const { return header_list_; } |
- const Header& Entry(size_t index) const { |
- return *(header_list_[index].get()); |
+ const std::multimap<String, String, ByteCaseInsensitiveCompare>& List() |
+ const { |
+ return header_list_; |
} |
static bool IsValidHeaderName(const String&); |
@@ -53,7 +58,20 @@ class MODULES_EXPORT FetchHeaderList final |
private: |
FetchHeaderList(); |
- Vector<std::unique_ptr<Header>> header_list_; |
+ |
+ // While using STL data structures in Blink is not very common or |
+ // encouraged, we do need a multimap here. The closest WTF structure |
+ // comparable to what we need would be a |
+ // HashMap<String, Vector<String>> |
+ // but it is not a "flat" data structure like std::multimap is. The |
+ // size() of the HashMap is the number of distinct header names, not |
+ // the total number of headers and values on the list. |
+ // This would cause FetchHeaderList::size() to have to manually |
+ // iterate through all keys and vectors in the HashMap. Similarly, |
+ // list() would require callers to manually iterate through the |
+ // HashMap's keys and value vector, and so would |
+ // containsNonSimpleHeader(). |
+ std::multimap<String, String, ByteCaseInsensitiveCompare> header_list_; |
}; |
} // namespace blink |