Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Side by Side Diff: net/spdy/spdy_alt_svc_wire_format.h

Issue 2801603003: Add SpdyString alias for std::string in net/spdy. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/platform/impl/spdy_string_utils_impl.h ('k') | net/spdy/spdy_alt_svc_wire_format.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 // This file contains data structures and utility functions used for serializing 5 // This file contains data structures and utility functions used for serializing
6 // and parsing alternative service header values, common to HTTP/1.1 header 6 // and parsing alternative service header values, common to HTTP/1.1 header
7 // fields and HTTP/2 and QUIC ALTSVC frames. See specification at 7 // fields and HTTP/2 and QUIC ALTSVC frames. See specification at
8 // https://httpwg.github.io/http-extensions/alt-svc.html. 8 // https://httpwg.github.io/http-extensions/alt-svc.html.
9 9
10 #ifndef NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ 10 #ifndef NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_
11 #define NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ 11 #define NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_
12 12
13 #include <stdint.h> 13 #include <cstdint>
14
15 #include <vector> 14 #include <vector>
16 15
17 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
17 #include "net/spdy/platform/api/spdy_string.h"
18 #include "net/spdy/platform/api/spdy_string_piece.h" 18 #include "net/spdy/platform/api/spdy_string_piece.h"
19 19
20 namespace net { 20 namespace net {
21 21
22 namespace test { 22 namespace test {
23 class SpdyAltSvcWireFormatPeer; 23 class SpdyAltSvcWireFormatPeer;
24 } // namespace test 24 } // namespace test
25 25
26 class NET_EXPORT_PRIVATE SpdyAltSvcWireFormat { 26 class NET_EXPORT_PRIVATE SpdyAltSvcWireFormat {
27 public: 27 public:
28 using VersionVector = std::vector<uint16_t>; 28 using VersionVector = std::vector<uint16_t>;
29 29
30 struct NET_EXPORT_PRIVATE AlternativeService { 30 struct NET_EXPORT_PRIVATE AlternativeService {
31 std::string protocol_id; 31 SpdyString protocol_id;
32 std::string host; 32 SpdyString host;
33 33
34 // Default is 0: invalid port. 34 // Default is 0: invalid port.
35 uint16_t port = 0; 35 uint16_t port = 0;
36 // Default is one day. 36 // Default is one day.
37 uint32_t max_age = 86400; 37 uint32_t max_age = 86400;
38 // Default is empty: unspecified version. 38 // Default is empty: unspecified version.
39 VersionVector version; 39 VersionVector version;
40 40
41 AlternativeService(); 41 AlternativeService();
42 AlternativeService(const std::string& protocol_id, 42 AlternativeService(const SpdyString& protocol_id,
43 const std::string& host, 43 const SpdyString& host,
44 uint16_t port, 44 uint16_t port,
45 uint32_t max_age, 45 uint32_t max_age,
46 VersionVector version); 46 VersionVector version);
47 AlternativeService(const AlternativeService& other); 47 AlternativeService(const AlternativeService& other);
48 ~AlternativeService(); 48 ~AlternativeService();
49 49
50 bool operator==(const AlternativeService& other) const { 50 bool operator==(const AlternativeService& other) const {
51 return protocol_id == other.protocol_id && host == other.host && 51 return protocol_id == other.protocol_id && host == other.host &&
52 port == other.port && version == other.version && 52 port == other.port && version == other.version &&
53 max_age == other.max_age; 53 max_age == other.max_age;
54 } 54 }
55 }; 55 };
56 // An empty vector means alternative services should be cleared for given 56 // An empty vector means alternative services should be cleared for given
57 // origin. Note that the wire format for this is the string "clear", not an 57 // origin. Note that the wire format for this is the string "clear", not an
58 // empty value (which is invalid). 58 // empty value (which is invalid).
59 typedef std::vector<AlternativeService> AlternativeServiceVector; 59 typedef std::vector<AlternativeService> AlternativeServiceVector;
60 60
61 friend class test::SpdyAltSvcWireFormatPeer; 61 friend class test::SpdyAltSvcWireFormatPeer;
62 static bool ParseHeaderFieldValue(SpdyStringPiece value, 62 static bool ParseHeaderFieldValue(SpdyStringPiece value,
63 AlternativeServiceVector* altsvc_vector); 63 AlternativeServiceVector* altsvc_vector);
64 static std::string SerializeHeaderFieldValue( 64 static SpdyString SerializeHeaderFieldValue(
65 const AlternativeServiceVector& altsvc_vector); 65 const AlternativeServiceVector& altsvc_vector);
66 66
67 private: 67 private:
68 static void SkipWhiteSpace(SpdyStringPiece::const_iterator* c, 68 static void SkipWhiteSpace(SpdyStringPiece::const_iterator* c,
69 SpdyStringPiece::const_iterator end); 69 SpdyStringPiece::const_iterator end);
70 static bool PercentDecode(SpdyStringPiece::const_iterator c, 70 static bool PercentDecode(SpdyStringPiece::const_iterator c,
71 SpdyStringPiece::const_iterator end, 71 SpdyStringPiece::const_iterator end,
72 std::string* output); 72 SpdyString* output);
73 static bool ParseAltAuthority(SpdyStringPiece::const_iterator c, 73 static bool ParseAltAuthority(SpdyStringPiece::const_iterator c,
74 SpdyStringPiece::const_iterator end, 74 SpdyStringPiece::const_iterator end,
75 std::string* host, 75 SpdyString* host,
76 uint16_t* port); 76 uint16_t* port);
77 static bool ParsePositiveInteger16(SpdyStringPiece::const_iterator c, 77 static bool ParsePositiveInteger16(SpdyStringPiece::const_iterator c,
78 SpdyStringPiece::const_iterator end, 78 SpdyStringPiece::const_iterator end,
79 uint16_t* value); 79 uint16_t* value);
80 static bool ParsePositiveInteger32(SpdyStringPiece::const_iterator c, 80 static bool ParsePositiveInteger32(SpdyStringPiece::const_iterator c,
81 SpdyStringPiece::const_iterator end, 81 SpdyStringPiece::const_iterator end,
82 uint32_t* value); 82 uint32_t* value);
83 }; 83 };
84 84
85 } // namespace net 85 } // namespace net
86 86
87 #endif // NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ 87 #endif // NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_
OLDNEW
« no previous file with comments | « net/spdy/platform/impl/spdy_string_utils_impl.h ('k') | net/spdy/spdy_alt_svc_wire_format.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698