Re-land: C++ readability review
[chromium-blink-merge.git] / net / quic / quic_socket_address_coder.h
blob36ad1d03620facc083045948c9649d65c58e4626
1 // Copyright 2014 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 #ifndef NET_QUIC_QUIC_SOCKET_ADDRESS_CODER_H_
6 #define NET_QUIC_QUIC_SOCKET_ADDRESS_CODER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "net/base/ip_endpoint.h"
12 #include "net/base/net_export.h"
14 namespace net {
16 // Serializes and parses a socket address (IP address and port), to be used in
17 // the kCADR tag in the ServerHello handshake message and the Public Reset
18 // packet.
19 class NET_EXPORT_PRIVATE QuicSocketAddressCoder {
20 public:
21 QuicSocketAddressCoder();
22 explicit QuicSocketAddressCoder(const IPEndPoint& address);
23 ~QuicSocketAddressCoder();
25 std::string Encode() const;
27 bool Decode(const char* data, size_t length);
29 IPAddressNumber ip() const {
30 return address_.address();
33 uint16 port() const {
34 return address_.port();
37 private:
38 IPEndPoint address_;
40 DISALLOW_COPY_AND_ASSIGN(QuicSocketAddressCoder);
43 } // namespace net
45 #endif // NET_QUIC_QUIC_SOCKET_ADDRESS_CODER_H_