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