Commit 111df5ad authored by Matthew Denton's avatar Matthew Denton Committed by Commit Bot

Fix object-lifetime comments in net/socket/udp_socket_*.h

Fixes the comments on RecvFrom and SendTo in udp_socket_posix.h and
udp_socket_win.h to more accurately reflect who is responsible for
keeping some of the function parameters alive.

Namely, the sockets always take a reference to the provided IOBuffer
in the case of asynch IO. And the SendTo function also creates a copy
of the provided IPAddress if necessary, while RecvFrom take a raw
pointer to the IPAddress and the caller is in charge of keeping it
alive.

Change-Id: I080557b8c69c9035eace94a0359ec5ce09c4cf0d
Reviewed-on: https://chromium-review.googlesource.com/c/1290089Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Commit-Queue: Matthew Denton <mpdenton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601286}
parent 305d2102
...@@ -234,8 +234,9 @@ class NET_EXPORT UDPSocketPosix { ...@@ -234,8 +234,9 @@ class NET_EXPORT UDPSocketPosix {
// alive by the caller until the callback is placed. // alive by the caller until the callback is placed.
// |callback| is the callback on completion of the RecvFrom. // |callback| is the callback on completion of the RecvFrom.
// Returns a net error code, or ERR_IO_PENDING if the IO is in progress. // Returns a net error code, or ERR_IO_PENDING if the IO is in progress.
// If ERR_IO_PENDING is returned, the caller must keep |buf| and |address| // If ERR_IO_PENDING is returned, this socket takes a ref to |buf| to keep
// alive until the callback is called. // it alive until the data is received. However, the caller must keep
// |address| alive until the callback is called.
int RecvFrom(IOBuffer* buf, int RecvFrom(IOBuffer* buf,
int buf_len, int buf_len,
IPEndPoint* address, IPEndPoint* address,
...@@ -247,8 +248,9 @@ class NET_EXPORT UDPSocketPosix { ...@@ -247,8 +248,9 @@ class NET_EXPORT UDPSocketPosix {
// |address| is the recipient address. // |address| is the recipient address.
// |callback| is the user callback function to call on complete. // |callback| is the user callback function to call on complete.
// Returns a net error code, or ERR_IO_PENDING if the IO is in progress. // Returns a net error code, or ERR_IO_PENDING if the IO is in progress.
// If ERR_IO_PENDING is returned, the caller must keep |buf| and |address| // If ERR_IO_PENDING is returned, this socket copies |address| for
// alive until the callback is called. // asynchronous sending, and takes a ref to |buf| to keep it alive until the
// data is sent.
int SendTo(IOBuffer* buf, int SendTo(IOBuffer* buf,
int buf_len, int buf_len,
const IPEndPoint& address, const IPEndPoint& address,
......
...@@ -205,8 +205,9 @@ class NET_EXPORT UDPSocketWin : public base::win::ObjectWatcher::Delegate { ...@@ -205,8 +205,9 @@ class NET_EXPORT UDPSocketWin : public base::win::ObjectWatcher::Delegate {
// alive by the caller until the callback is placed. // alive by the caller until the callback is placed.
// |callback| is the callback on completion of the RecvFrom. // |callback| is the callback on completion of the RecvFrom.
// Returns a net error code, or ERR_IO_PENDING if the IO is in progress. // Returns a net error code, or ERR_IO_PENDING if the IO is in progress.
// If ERR_IO_PENDING is returned, the caller must keep |buf| and |address|, // If ERR_IO_PENDING is returned, this socket takes a ref to |buf| to keep
// alive until the callback is called. // it alive until the data is received. However, the caller must keep
// |address| alive until the callback is called.
int RecvFrom(IOBuffer* buf, int RecvFrom(IOBuffer* buf,
int buf_len, int buf_len,
IPEndPoint* address, IPEndPoint* address,
...@@ -218,8 +219,9 @@ class NET_EXPORT UDPSocketWin : public base::win::ObjectWatcher::Delegate { ...@@ -218,8 +219,9 @@ class NET_EXPORT UDPSocketWin : public base::win::ObjectWatcher::Delegate {
// |address| is the recipient address. // |address| is the recipient address.
// |callback| is the user callback function to call on complete. // |callback| is the user callback function to call on complete.
// Returns a net error code, or ERR_IO_PENDING if the IO is in progress. // Returns a net error code, or ERR_IO_PENDING if the IO is in progress.
// If ERR_IO_PENDING is returned, the caller must keep |buf| and |address| // If ERR_IO_PENDING is returned, this socket copies |address| for
// alive until the callback is called. // asynchronous sending, and takes a ref to |buf| to keep it alive until the
// data is sent.
int SendTo(IOBuffer* buf, int SendTo(IOBuffer* buf,
int buf_len, int buf_len,
const IPEndPoint& address, const IPEndPoint& address,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment