Chromium Code Reviews| 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_net_export.h" | 8 #include "blimp/net/blimp_net_export.h" |
| 9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| 11 | 11 |
| 12 namespace blimp { | 12 namespace blimp { |
| 13 | 13 |
| 14 // Interface to describe a reader which can read variable-length data packets | 14 // Interface to describe a reader which can read variable-length data packets |
| 15 // from a connection. | 15 // from a connection. |
| 16 class BLIMP_NET_EXPORT PacketReader { | 16 class BLIMP_NET_EXPORT PacketReader { |
| 17 public: | 17 public: |
| 18 virtual ~PacketReader() {} | 18 virtual ~PacketReader() {} |
| 19 | 19 |
| 20 // Reads a packet from the connection. | 20 // Reads a packet from the connection. |
| 21 // Returns the size of the packet, in bytes, if the read operation executed | 21 // Invokes |cb| with the size of the packet, in bytes, if the read operation |
| 22 // successfully. | 22 // executed successfully. All other values indicate errors. |
|
Wez
2015/11/20 23:42:13
nit: Could we have it invoke w/ net::OK on success
Kevin M
2015/11/24 21:34:36
Yes, we can advance |offset| to the end.
| |
| 23 // Returns ERR_IO_PENDING if the operation will be executed asynchronously. | 23 virtual void ReadPacket(const scoped_refptr<net::GrowableIOBuffer>& buf, |
| 24 // |cb| is later invoked with the packet size or an error code. | 24 const net::CompletionCallback& cb) = 0; |
| 25 // All other return values indicate errors. | |
| 26 virtual int ReadPacket(const scoped_refptr<net::GrowableIOBuffer>& buf, | |
| 27 const net::CompletionCallback& cb) = 0; | |
| 28 }; | 25 }; |
| 29 | 26 |
| 30 } // namespace blimp | 27 } // namespace blimp |
| 31 | 28 |
| 32 #endif // BLIMP_NET_PACKET_READER_H_ | 29 #endif // BLIMP_NET_PACKET_READER_H_ |
| OLD | NEW |