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.
6 #ifndef NET_QUIC_QUIC_PACKET_READER_H_
7 #define NET_QUIC_QUIC_PACKET_READER_H_
9 #include "base/memory/weak_ptr.h"
10 #include "net/base/io_buffer.h"
11 #include "net/base/net_export.h"
12 #include "net/log/net_log.h"
13 #include "net/quic/quic_protocol.h"
14 #include "net/udp/datagram_client_socket.h"
18 class NET_EXPORT_PRIVATE QuicPacketReader
{
20 class NET_EXPORT_PRIVATE Visitor
{
22 virtual ~Visitor() {};
23 virtual void OnReadError(int result
) = 0;
24 virtual bool OnPacket(const QuicEncryptedPacket
& packet
,
25 IPEndPoint local_address
,
26 IPEndPoint peer_address
) = 0;
29 QuicPacketReader(DatagramClientSocket
* socket
,
31 const BoundNetLog
& net_log
);
32 virtual ~QuicPacketReader();
34 // Causes the QuicConnectionHelper to start reading from the socket
35 // and passing the data along to the QuicConnection.
39 // A completion callback invoked when a read completes.
40 void OnReadComplete(int result
);
42 DatagramClientSocket
* socket_
;
45 int num_packets_read_
;
46 scoped_refptr
<IOBufferWithSize
> read_buffer_
;
49 base::WeakPtrFactory
<QuicPacketReader
> weak_factory_
;
51 DISALLOW_COPY_AND_ASSIGN(QuicPacketReader
);
56 #endif // NET_QUIC_QUIC_PACKET_READER_H_