Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_PROTOCOL_P2P_DATAGRAM_SOCKET_H_ | |
| 6 #define REMOTING_PROTOCOL_P2P_DATAGRAM_SOCKET_H_ | |
| 7 | |
| 8 #include "net/base/completion_callback.h" | |
| 9 | |
| 10 namespace net { | |
| 11 class IOBuffer; | |
| 12 } // namespace net | |
| 13 | |
| 14 namespace remoting { | |
| 15 namespace protocol { | |
| 16 | |
| 17 // Peer-to-peer socket with datagram semantics. | |
| 18 class P2PDatagramSocket { | |
| 19 public: | |
| 20 virtual ~P2PDatagramSocket() {}; | |
| 21 | |
| 22 // Receives a packet, up to |buf_len| bytes, from the socket. The number of | |
| 23 // bytes read is returned, or an error is returned upon failure. | |
| 24 // ERR_IO_PENDING is returned if the operation could not be completed | |
| 25 // synchronously, in which case the result will be passed to the callback when | |
| 26 // available. If the operation is not completed immediately, the socket | |
| 27 // acquires a reference to the provided buffer until the callback is invoked | |
| 28 // or the socket is closed. If the socket is destroyed before the read | |
| 29 // completes, the callback will not be invoked. | |
| 30 virtual int Recv(const scoped_refptr<net::IOBuffer>& buf, int buf_len, | |
| 31 const net::CompletionCallback& callback) = 0; | |
| 32 | |
| 33 // Sends a packet. Size of the incoming packet is returned in case of success. | |
|
Wez
2015/07/14 18:28:09
nit: This is send; the packet is outgoing, not inc
Sergey Ulanov
2015/07/14 21:07:54
Done.
| |
| 34 // If the packet is larger than |buf_len| then it's truncated, i.e. only the | |
|
Wez
2015/07/14 18:28:09
nit: it's -> it is
Sergey Ulanov
2015/07/14 21:07:54
Done.
| |
| 35 // first |buf_len| bytes are stored in the buffer. In case of a failure an | |
|
Wez
2015/07/14 18:28:09
nit: "In case of failure a net error code is retur
Wez
2015/07/14 18:28:09
You mean that only |buf_len| bytes are written?
Sergey Ulanov
2015/07/14 21:07:54
Done.
Sergey Ulanov
2015/07/14 21:07:54
Done.
| |
| 36 // error is returned. ERR_IO_PENDING is returned if the operation could not be | |
| 37 // completed synchronously, in which case the result will be passed to the | |
| 38 // callback when available. If the operation is not completed immediately, the | |
| 39 // socket acquires a reference to the provided buffer until the callback is | |
| 40 // invoked or the socket is closed. Implementations of this method should not | |
| 41 // modify the contents of the actual buffer that is written to the socket. | |
| 42 virtual int Send(const scoped_refptr<net::IOBuffer>& buf, int buf_len, | |
| 43 const net::CompletionCallback& callback) = 0; | |
| 44 }; | |
| 45 | |
| 46 } // namespace protocol | |
| 47 } // namespace remoting | |
| 48 | |
| 49 #endif // REMOTING_PROTOCOL_P2P_DATAGRAM_SOCKET_H_ | |
| OLD | NEW |