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

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

Issue 1171183002: Use struct AlternativeService in OnAltSvc() and OnSpdyAltSvc() methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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/mock_spdy_framer_visitor.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://tools.ietf.org/id/draft-ietf-httpbis-alt-svc-06.html 8 // https://tools.ietf.org/id/draft-ietf-httpbis-alt-svc-06.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 "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
16 16
17 using base::StringPiece; 17 using base::StringPiece;
18 18
19 namespace net { 19 namespace net {
20 20
21 namespace test { 21 namespace test {
22 class SpdyAltSvcWireFormatPeer; 22 class SpdyAltSvcWireFormatPeer;
23 } // namespace test 23 } // namespace test
24 24
25 class NET_EXPORT_PRIVATE SpdyAltSvcWireFormat { 25 class NET_EXPORT_PRIVATE SpdyAltSvcWireFormat {
26 public: 26 public:
27 struct AlternativeService {
28 std::string protocol_id;
29 std::string host;
30 uint16 port = 0;
31 uint32 max_age = 0;
32 double p = 1.0;
33
34 bool operator==(const AlternativeService& other) const {
35 return protocol_id == other.protocol_id && host == other.host &&
36 port == other.port && max_age == other.max_age && p == other.p;
37 }
38 };
39
27 friend class test::SpdyAltSvcWireFormatPeer; 40 friend class test::SpdyAltSvcWireFormatPeer;
28 static bool ParseHeaderFieldValue(StringPiece value, 41 static bool ParseHeaderFieldValue(StringPiece value,
29 std::string* protocol_id, 42 AlternativeService* altsvc);
30 std::string* host, 43 static std::string SerializeHeaderFieldValue(
31 uint16* port, 44 const AlternativeService& altsvc);
32 uint32* max_age,
33 double* p);
34 static std::string SerializeHeaderFieldValue(const std::string& protocol_id,
35 const std::string& host,
36 uint16 port,
37 uint32 max_age,
38 double p);
39 45
40 private: 46 private:
41 static void SkipWhiteSpace(StringPiece::const_iterator* c, 47 static void SkipWhiteSpace(StringPiece::const_iterator* c,
42 StringPiece::const_iterator end); 48 StringPiece::const_iterator end);
43 static bool PercentDecode(StringPiece::const_iterator c, 49 static bool PercentDecode(StringPiece::const_iterator c,
44 StringPiece::const_iterator end, 50 StringPiece::const_iterator end,
45 std::string* output); 51 std::string* output);
46 static bool ParseAltAuthority(StringPiece::const_iterator c, 52 static bool ParseAltAuthority(StringPiece::const_iterator c,
47 StringPiece::const_iterator end, 53 StringPiece::const_iterator end,
48 std::string* host, 54 std::string* host,
49 uint16* port); 55 uint16* port);
50 static bool ParsePositiveInteger16(StringPiece::const_iterator c, 56 static bool ParsePositiveInteger16(StringPiece::const_iterator c,
51 StringPiece::const_iterator end, 57 StringPiece::const_iterator end,
52 uint16* value); 58 uint16* value);
53 static bool ParsePositiveInteger32(StringPiece::const_iterator c, 59 static bool ParsePositiveInteger32(StringPiece::const_iterator c,
54 StringPiece::const_iterator end, 60 StringPiece::const_iterator end,
55 uint32* value); 61 uint32* value);
56 static bool ParseProbability(StringPiece::const_iterator c, 62 static bool ParseProbability(StringPiece::const_iterator c,
57 StringPiece::const_iterator end, 63 StringPiece::const_iterator end,
58 double* p); 64 double* p);
59 }; 65 };
60 66
61 } // namespace net 67 } // namespace net
62 68
63 #endif // NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_ 69 #endif // NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_
OLDNEW
« no previous file with comments | « net/spdy/mock_spdy_framer_visitor.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