OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef BLIMP_NET_PACKET_READER_H_ | 5 #ifndef BLIMP_NET_PACKET_READER_H_ |
6 #define BLIMP_NET_PACKET_READER_H_ | 6 #define BLIMP_NET_PACKET_READER_H_ |
7 | 7 |
| 8 #include "blimp/net/blimp_connection_details.h" |
8 #include "blimp/net/blimp_net_export.h" | 9 #include "blimp/net/blimp_net_export.h" |
9 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
10 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
11 | 12 |
12 namespace blimp { | 13 namespace blimp { |
13 | 14 |
14 // Interface to describe a reader which can read variable-length data packets | 15 // Interface to describe a reader which can read variable-length data packets |
15 // from a connection. | 16 // from a connection. |
16 class BLIMP_NET_EXPORT PacketReader { | 17 class BLIMP_NET_EXPORT PacketReader { |
17 public: | 18 public: |
18 virtual ~PacketReader() {} | 19 virtual ~PacketReader() {} |
19 | 20 |
20 // Reads a packet from the connection. | 21 // Reads a packet from the connection. |
21 // Passes the packet size to |cb| if the read operation executed | 22 // Passes the packet size to |cb| if the read operation executed |
22 // successfully. | 23 // successfully. |
23 // Passes the error code to |cb| if an error occurred. | 24 // Passes the error code to |cb| if an error occurred. |
24 // All other values indicate errors. | 25 // All other values indicate errors. |
25 // |callback| will not be invoked if |this| is deleted. | 26 // |callback| will not be invoked if |this| is deleted. |
26 virtual void ReadPacket(const scoped_refptr<net::GrowableIOBuffer>& buf, | 27 virtual void ReadPacket(const scoped_refptr<net::GrowableIOBuffer>& buf, |
27 const net::CompletionCallback& cb) = 0; | 28 const net::CompletionCallback& cb) = 0; |
| 29 |
| 30 void SetBlimpConnectionDetails(BlimpConnectionDetails* details) { |
| 31 connection_details_ = details; |
| 32 } |
| 33 |
| 34 protected: |
| 35 BlimpConnectionDetails* connection_details_ = nullptr; |
28 }; | 36 }; |
29 | 37 |
30 } // namespace blimp | 38 } // namespace blimp |
31 | 39 |
32 #endif // BLIMP_NET_PACKET_READER_H_ | 40 #endif // BLIMP_NET_PACKET_READER_H_ |
OLD | NEW |