Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 NET_HTTP2_HPACK_HPACK_STRING_H_ | 5 #ifndef NET_HTTP2_HPACK_HPACK_STRING_H_ |
| 6 #define NET_HTTP2_HPACK_HPACK_STRING_H_ | 6 #define NET_HTTP2_HPACK_HPACK_STRING_H_ |
| 7 | 7 |
| 8 // HpackString is currently a very simple container for a string, but allows us | 8 // HpackString is currently a very simple container for a string, but allows us |
| 9 // to relatively easily experiment with alternate string storage mechanisms for | 9 // to relatively easily experiment with alternate string storage mechanisms for |
| 10 // handling strings to be encoded with HPACK, or decoded from HPACK, such as | 10 // handling strings to be encoded with HPACK, or decoded from HPACK, such as |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 class NET_EXPORT_PRIVATE HpackString { | 23 class NET_EXPORT_PRIVATE HpackString { |
| 24 public: | 24 public: |
| 25 explicit HpackString(const char* data); | 25 explicit HpackString(const char* data); |
| 26 explicit HpackString(base::StringPiece str); | 26 explicit HpackString(base::StringPiece str); |
| 27 explicit HpackString(std::string str); | 27 explicit HpackString(std::string str); |
| 28 HpackString(const HpackString& other); | 28 HpackString(const HpackString& other); |
| 29 | 29 |
| 30 // Not sure yet whether this move ctor is required/sensible. | 30 // Not sure yet whether this move ctor is required/sensible. |
| 31 HpackString(HpackString&& other) = default; | 31 HpackString(HpackString&& other) = default; |
| 32 | 32 |
| 33 HpackString& operator=(const HpackString& other) = default; | |
|
James Synge
2017/01/03 19:11:29
Shouldn't operators come after ctor/dtor?
Bence
2017/01/04 16:15:20
Assignment operators seem to preceed the destructo
| |
| 34 | |
| 33 ~HpackString(); | 35 ~HpackString(); |
| 34 | 36 |
| 35 size_t size() const { return str_.size(); } | 37 size_t size() const { return str_.size(); } |
| 36 const std::string& ToString() const { return str_; } | 38 const std::string& ToString() const { return str_; } |
| 37 operator base::StringPiece() const; | 39 operator base::StringPiece() const; |
| 38 | 40 |
| 39 bool operator==(const HpackString& other) const; | 41 bool operator==(const HpackString& other) const; |
| 40 | 42 |
| 41 bool operator==(base::StringPiece str) const; | 43 bool operator==(base::StringPiece str) const; |
| 42 | 44 |
| 43 private: | 45 private: |
| 44 std::string str_; | 46 std::string str_; |
| 45 }; | 47 }; |
| 46 | 48 |
| 47 NET_EXPORT_PRIVATE bool operator==(base::StringPiece a, const HpackString& b); | 49 NET_EXPORT_PRIVATE bool operator==(base::StringPiece a, const HpackString& b); |
| 48 NET_EXPORT_PRIVATE bool operator!=(base::StringPiece a, const HpackString& b); | 50 NET_EXPORT_PRIVATE bool operator!=(base::StringPiece a, const HpackString& b); |
| 49 NET_EXPORT_PRIVATE bool operator!=(const HpackString& a, const HpackString& b); | 51 NET_EXPORT_PRIVATE bool operator!=(const HpackString& a, const HpackString& b); |
| 50 NET_EXPORT_PRIVATE bool operator!=(const HpackString& a, base::StringPiece b); | 52 NET_EXPORT_PRIVATE bool operator!=(const HpackString& a, base::StringPiece b); |
| 51 NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, | 53 NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, |
| 52 const HpackString& v); | 54 const HpackString& v); |
| 53 | 55 |
| 56 struct NET_EXPORT_PRIVATE HpackStringPair { | |
| 57 HpackStringPair(const HpackString& name, const HpackString& value); | |
| 58 HpackStringPair(base::StringPiece name, base::StringPiece value); | |
| 59 ~HpackStringPair(); | |
| 60 | |
| 61 // Returns the size of a header entry with this name and value, per the RFC: | |
| 62 // http://httpwg.org/specs/rfc7541.html#calculating.table.size | |
| 63 size_t size() const { return 32 + name.size() + value.size(); } | |
| 64 | |
| 65 std::string DebugString() const; | |
| 66 | |
| 67 HpackString name; | |
| 68 HpackString value; | |
| 69 }; | |
| 70 | |
| 71 NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | |
| 72 const HpackStringPair& p); | |
| 73 | |
| 54 } // namespace net | 74 } // namespace net |
| 55 | 75 |
| 56 #endif // NET_HTTP2_HPACK_HPACK_STRING_H_ | 76 #endif // NET_HTTP2_HPACK_HPACK_STRING_H_ |
| OLD | NEW |