Update comments of TabObserver#onLoadStarted and rename onContentChanged
[chromium-blink-merge.git] / net / spdy / spdy_alt_svc_wire_format.h
blobeb79f8afa60d3829c37a7cf25784d3adb9a0a762
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
3 // found in the LICENSE file.
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
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
10 #ifndef NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_
11 #define NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_
13 #include "base/basictypes.h"
14 #include "base/strings/string_piece.h"
15 #include "net/base/net_export.h"
17 using base::StringPiece;
19 namespace net {
21 namespace test {
22 class SpdyAltSvcWireFormatPeer;
23 } // namespace test
25 class NET_EXPORT_PRIVATE SpdyAltSvcWireFormat {
26 public:
27 friend class test::SpdyAltSvcWireFormatPeer;
28 static bool ParseHeaderFieldValue(StringPiece value,
29 std::string* protocol_id,
30 std::string* host,
31 uint16* port,
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);
40 private:
41 static void SkipWhiteSpace(StringPiece::const_iterator* c,
42 StringPiece::const_iterator end);
43 static bool PercentDecode(StringPiece::const_iterator c,
44 StringPiece::const_iterator end,
45 std::string* output);
46 static bool ParseAltAuthority(StringPiece::const_iterator c,
47 StringPiece::const_iterator end,
48 std::string* host,
49 uint16* port);
50 static bool ParsePositiveInteger16(StringPiece::const_iterator c,
51 StringPiece::const_iterator end,
52 uint16* value);
53 static bool ParsePositiveInteger32(StringPiece::const_iterator c,
54 StringPiece::const_iterator end,
55 uint32* value);
56 static bool ParseProbability(StringPiece::const_iterator c,
57 StringPiece::const_iterator end,
58 double* p);
61 } // namespace net
63 #endif // NET_SPDY_SPDY_ALT_SVC_WIRE_FORMAT_H_