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 23 matching lines...) Expand all Loading... |
34 #include "wtf/text/AtomicString.h" | 34 #include "wtf/text/AtomicString.h" |
35 #include "wtf/text/AtomicStringHash.h" | 35 #include "wtf/text/AtomicStringHash.h" |
36 #include "wtf/text/StringHash.h" | 36 #include "wtf/text/StringHash.h" |
37 #include <utility> | 37 #include <utility> |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 typedef Vector<std::pair<String, String> > CrossThreadHTTPHeaderMapData; | 41 typedef Vector<std::pair<String, String> > CrossThreadHTTPHeaderMapData; |
42 | 42 |
43 // FIXME: Not every header fits into a map. Notably, multiple Set-Cookie header
fields are needed to set multiple cookies. | 43 // FIXME: Not every header fits into a map. Notably, multiple Set-Cookie header
fields are needed to set multiple cookies. |
44 class PLATFORM_EXPORT HTTPHeaderMap : public HashMap<AtomicString, AtomicString,
CaseFoldingHash> { | 44 class PLATFORM_EXPORT HTTPHeaderMap { |
45 public: | 45 public: |
46 HTTPHeaderMap(); | 46 HTTPHeaderMap(); |
47 ~HTTPHeaderMap(); | 47 ~HTTPHeaderMap(); |
48 | 48 |
49 // Gets a copy of the data suitable for passing to another thread. | 49 // Gets a copy of the data suitable for passing to another thread. |
50 PassOwnPtr<CrossThreadHTTPHeaderMapData> copyData() const; | 50 PassOwnPtr<CrossThreadHTTPHeaderMapData> copyData() const; |
51 | 51 |
52 void adopt(PassOwnPtr<CrossThreadHTTPHeaderMapData>); | 52 void adopt(PassOwnPtr<CrossThreadHTTPHeaderMapData>); |
53 | 53 |
54 const AtomicString& get(const AtomicString& name) const; | 54 typedef HashMap<AtomicString, AtomicString, CaseFoldingHash> MapType; |
| 55 typedef MapType::AddResult AddResult; |
| 56 typedef MapType::const_iterator const_iterator; |
55 | 57 |
56 AddResult add(const AtomicString& name, const AtomicString& value); | 58 size_t size() const { return m_headers.size(); } |
| 59 const_iterator begin() const { return m_headers.begin(); } |
| 60 const_iterator end() const { return m_headers.end(); } |
| 61 const_iterator find(const AtomicString &k) const { return m_headers.find(k);
} |
| 62 void clear() { m_headers.clear(); } |
| 63 const AtomicString& get(const AtomicString& k) const { return m_headers.get(
k); } |
| 64 AddResult set(const AtomicString& k, const AtomicString& v) { return m_heade
rs.set(k, v); } |
| 65 AddResult add(const AtomicString& k, const AtomicString& v) { return m_heade
rs.add(k, v); } |
| 66 void remove(const AtomicString& k) { m_headers.remove(k); } |
| 67 bool operator!=(const HTTPHeaderMap &rhs) const { return m_headers != rhs.m_
headers; } |
57 | 68 |
58 // Alternate accessors that are faster than converting the char* to AtomicSt
ring first. | 69 // Alternate accessors that are faster than converting the char* to AtomicSt
ring first. |
59 bool contains(const char*) const; | 70 bool contains(const char*) const; |
60 const AtomicString& get(const char*) const; | 71 const AtomicString& get(const char*) const; |
61 AddResult add(const char* name, const AtomicString& value); | 72 AddResult add(const char* name, const AtomicString& value); |
62 | 73 |
| 74 private: |
| 75 HashMap<AtomicString, AtomicString, CaseFoldingHash> m_headers; |
63 }; | 76 }; |
64 | 77 |
65 } // namespace blink | 78 } // namespace blink |
66 | 79 |
67 #endif // HTTPHeaderMap_h | 80 #endif // HTTPHeaderMap_h |
OLD | NEW |