OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 12 matching lines...) Expand all Loading... |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #ifndef HTTPHeaderMap_h | 27 #ifndef HTTPHeaderMap_h |
28 #define HTTPHeaderMap_h | 28 #define HTTPHeaderMap_h |
29 | 29 |
30 #include "platform/PlatformExport.h" | 30 #include "platform/PlatformExport.h" |
31 #include "wtf/Allocator.h" | 31 #include "wtf/Allocator.h" |
32 #include "wtf/HashMap.h" | 32 #include "wtf/HashMap.h" |
33 #include "wtf/PassOwnPtr.h" | |
34 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
35 #include "wtf/text/AtomicString.h" | 34 #include "wtf/text/AtomicString.h" |
36 #include "wtf/text/AtomicStringHash.h" | 35 #include "wtf/text/AtomicStringHash.h" |
37 #include "wtf/text/StringHash.h" | 36 #include "wtf/text/StringHash.h" |
| 37 #include <memory> |
38 #include <utility> | 38 #include <utility> |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 typedef Vector<std::pair<String, String>> CrossThreadHTTPHeaderMapData; | 42 typedef Vector<std::pair<String, String>> CrossThreadHTTPHeaderMapData; |
43 | 43 |
44 // FIXME: Not every header fits into a map. Notably, multiple Set-Cookie header
fields are needed to set multiple cookies. | 44 // FIXME: Not every header fits into a map. Notably, multiple Set-Cookie header
fields are needed to set multiple cookies. |
45 class PLATFORM_EXPORT HTTPHeaderMap final { | 45 class PLATFORM_EXPORT HTTPHeaderMap final { |
46 DISALLOW_NEW(); | 46 DISALLOW_NEW(); |
47 public: | 47 public: |
48 HTTPHeaderMap(); | 48 HTTPHeaderMap(); |
49 ~HTTPHeaderMap(); | 49 ~HTTPHeaderMap(); |
50 | 50 |
51 // Gets a copy of the data suitable for passing to another thread. | 51 // Gets a copy of the data suitable for passing to another thread. |
52 PassOwnPtr<CrossThreadHTTPHeaderMapData> copyData() const; | 52 std::unique_ptr<CrossThreadHTTPHeaderMapData> copyData() const; |
53 | 53 |
54 void adopt(PassOwnPtr<CrossThreadHTTPHeaderMapData>); | 54 void adopt(std::unique_ptr<CrossThreadHTTPHeaderMapData>); |
55 | 55 |
56 typedef HashMap<AtomicString, AtomicString, CaseFoldingHash> MapType; | 56 typedef HashMap<AtomicString, AtomicString, CaseFoldingHash> MapType; |
57 typedef MapType::AddResult AddResult; | 57 typedef MapType::AddResult AddResult; |
58 typedef MapType::const_iterator const_iterator; | 58 typedef MapType::const_iterator const_iterator; |
59 | 59 |
60 size_t size() const { return m_headers.size(); } | 60 size_t size() const { return m_headers.size(); } |
61 const_iterator begin() const { return m_headers.begin(); } | 61 const_iterator begin() const { return m_headers.begin(); } |
62 const_iterator end() const { return m_headers.end(); } | 62 const_iterator end() const { return m_headers.end(); } |
63 const_iterator find(const AtomicString &k) const { return m_headers.find(k);
} | 63 const_iterator find(const AtomicString &k) const { return m_headers.find(k);
} |
64 void clear() { m_headers.clear(); } | 64 void clear() { m_headers.clear(); } |
65 bool contains(const AtomicString& k) const { return m_headers.contains(k); } | 65 bool contains(const AtomicString& k) const { return m_headers.contains(k); } |
66 const AtomicString& get(const AtomicString& k) const { return m_headers.get(
k); } | 66 const AtomicString& get(const AtomicString& k) const { return m_headers.get(
k); } |
67 AddResult set(const AtomicString& k, const AtomicString& v) { return m_heade
rs.set(k, v); } | 67 AddResult set(const AtomicString& k, const AtomicString& v) { return m_heade
rs.set(k, v); } |
68 AddResult add(const AtomicString& k, const AtomicString& v) { return m_heade
rs.add(k, v); } | 68 AddResult add(const AtomicString& k, const AtomicString& v) { return m_heade
rs.add(k, v); } |
69 void remove(const AtomicString& k) { m_headers.remove(k); } | 69 void remove(const AtomicString& k) { m_headers.remove(k); } |
70 bool operator!=(const HTTPHeaderMap& rhs) const { return m_headers != rhs.m_
headers; } | 70 bool operator!=(const HTTPHeaderMap& rhs) const { return m_headers != rhs.m_
headers; } |
71 bool operator==(const HTTPHeaderMap& rhs) const { return m_headers == rhs.m_
headers; } | 71 bool operator==(const HTTPHeaderMap& rhs) const { return m_headers == rhs.m_
headers; } |
72 | 72 |
73 private: | 73 private: |
74 HashMap<AtomicString, AtomicString, CaseFoldingHash> m_headers; | 74 HashMap<AtomicString, AtomicString, CaseFoldingHash> m_headers; |
75 }; | 75 }; |
76 | 76 |
77 } // namespace blink | 77 } // namespace blink |
78 | 78 |
79 #endif // HTTPHeaderMap_h | 79 #endif // HTTPHeaderMap_h |
OLD | NEW |