Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Unified Diff: ppapi/cpp/dev/udp_socket_dev.h

Issue 16938011: Update comments of the Pepper networking APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/cpp/dev/udp_socket_dev.h
diff --git a/ppapi/cpp/dev/udp_socket_dev.h b/ppapi/cpp/dev/udp_socket_dev.h
index 9f46f0a39ee8fb453b4065ce24c4393564464af5..1ee770064ad19b7552800ea0f0d53af77f9e4eb1 100644
--- a/ppapi/cpp/dev/udp_socket_dev.h
+++ b/ppapi/cpp/dev/udp_socket_dev.h
@@ -18,35 +18,138 @@ class Var;
template <typename T> class CompletionCallbackWithOutput;
+/// The <code>UDPSocket_Dev</code> class provides UDP socket operations.
+///
+/// Permissions: Apps permission <code>socket</code> with subrule
+/// <code>udp-bind</code> is required for <code>Bind()</code>; subrule
+/// <code>udp-send-to</code> is required for <code>SendTo()</code>.
+/// For more details about network communication permissions, please see:
+/// http://developer.chrome.com/apps/app_network.html
class UDPSocket_Dev: public Resource {
public:
+ /// Default constructor for creating an is_null() <code>UDPSocket_Dev</code>
+ /// object.
UDPSocket_Dev();
+ /// A contructor used to create a <code>UDPSocket_Dev</code> object.
bbudge 2013/06/20 21:02:32 s/contructor/constructor
yzshen1 2013/06/20 22:20:48 Done.
+ ///
+ /// @param[in] instance The instance with which this resource will be
+ /// associated.
explicit UDPSocket_Dev(const InstanceHandle& instance);
+ /// A constructor used when you have received a <code>PP_Resource</code> as a
+ /// return value that has already been added 1 ref for you.
+ ///
+ /// @param[in] resource A <code>PPB_UDPSocket_Dev</code> resource.
UDPSocket_Dev(PassRef, PP_Resource resource);
+ /// The copy constructor for <code>UDPSocket_Dev</code>.
+ ///
+ /// @param[in] other A reference to another <code>UDPSocket_Dev</code>.
UDPSocket_Dev(const UDPSocket_Dev& other);
+ /// The destructor.
virtual ~UDPSocket_Dev();
+ /// The assign operator for <code>UDPSocket_Dev</code>.
bbudge 2013/06/20 21:02:32 s/assign/assignment
yzshen1 2013/06/20 22:20:48 Done.
+ ///
+ /// @param[in] other A reference to another <code>UDPSocket_Dev</code>.
+ ///
+ /// @return A reference to this <code>UDPSocket_Dev</code> object.
UDPSocket_Dev& operator=(const UDPSocket_Dev& other);
- // Returns true if the required interface is available.
+ /// Static function for determining whether the browser supports the required
bbudge 2013/06/20 21:02:32 s/required//
yzshen1 2013/06/20 22:20:48 Done.
+ /// <code>PPB_UDPSocket_Dev</code> interface.
+ ///
+ /// @return true if the interface is available, false otherwise.
static bool IsAvailable();
+ /// Binds the socket to the given address.
+ ///
+ /// @param[in] addr A <code>NetAddress_Dev</code> object.
+ /// @param[in] callback A <code>CompletionCallback</code> to be called upon
+ /// completion.
+ ///
+ /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
+ /// <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have
+ /// required permissions. <code>PP_ERROR_ADDRESS_IN_USE</code> will be
+ /// returned if the address is already in use.
int32_t Bind(const NetAddress_Dev& addr,
const CompletionCallback& callback);
+
+ /// Get the address that the socket has bound to. The socket must be bound.
bbudge 2013/06/20 21:02:32 nit s/has/is
yzshen1 2013/06/20 22:20:48 Done.
+ ///
+ /// @return A <code>NetAddress_Dev</code> object. The object will be null
+ /// (i.e., is_null() returns true) on failure.
NetAddress_Dev GetBoundAddress();
+
+ /// Receives data from the socket and stores the source address. The socket
+ /// must be bound.
+ ///
+ /// <strong>Caveat:</strong> You should be careful about the lifetime of
+ /// <code>buffer</code>. Typically you will use a
+ /// <code>CompletionCallbackFactory</code> to scope callbacks to the lifetime
+ /// of your class. When your class goes out of scope, the callback factory
+ /// will not actually cancel the operation, but will rather just skip issuing
+ /// the callback on your class. This means that if the underlying
+ /// <code>PPB_UDPSocket_Dev</code> resource outlives your class, the browser
+ /// will still try to write into your buffer when the operation completes.
+ /// The buffer must be kept valid until then to avoid memory corruption.
+ /// If you want to release the buffer while the <code>RecvFrom()</code> call
+ /// is still pending, you should call <code>Close()</code> to ensure that the
+ /// buffer won't be accessed in the future.
+ ///
+ /// @param[out] buffer The buffer to store the received data on success. It
+ /// must be at least <code>num_bytes</code> big.
bbudge 2013/06/20 21:02:32 I prefer the tcp socket comment: /// @param[out] b
yzshen1 2013/06/20 22:20:48 Done.
+ /// @param[in] num_bytes The number of bytes to receive.
+ /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
+ /// called upon completion.
+ ///
+ /// @return A non-negative number on success to indicate how many bytes have
+ /// been received; otherwise, an error code from <code>pp_errors.h</code>.
int32_t RecvFrom(
char* buffer,
int32_t num_bytes,
const CompletionCallbackWithOutput<NetAddress_Dev>& callback);
+
+ /// Sends data to a specific destination. The socket must be bound.
+ ///
+ /// @param[in] buffer The buffer containing the data to send.
+ /// @param[in] num_bytes The number of bytes to send.
+ /// @param[in] addr A <code>NetAddress_Dev</code> object holding the
+ /// destination address.
+ /// @param[in] callback A <code>CompletionCallback</code> to be called upon
+ /// completion.
+ ///
+ /// @return A non-negative number on success to indicate how many bytes have
+ /// been sent; otherwise, an error code from <code>pp_errors.h</code>.
+ /// <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have
+ /// required permissions.
int32_t SendTo(const char* buffer,
int32_t num_bytes,
const NetAddress_Dev& addr,
const CompletionCallback& callback);
+
+ /// Cancels all pending reads and writes, and closes the socket. Any pending
+ /// callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> if
+ /// pending IO was interrupted. After a call to this method, no output
+ /// paramters passed into previous <code>RecvFrom()</code> calls will be
+ /// accessed. It is not valid to call <code>Bind()</code> again.
+ ///
+ /// The socket is implicitly closed if it is destroyed, so you are not
+ /// required to call this method.
void Close();
+
+ /// Sets a socket option on the UDP socket.
+ /// Please see the <code>PP_UDPSocket_Option_Dev</code> description for option
+ /// names, value types and allowed values.
+ ///
+ /// @param[in] name The option type to set.
bbudge 2013/06/20 21:02:32 nit s/option type/option
yzshen1 2013/06/20 22:20:48 Done.
+ /// @param[in] value The option value to set.
+ /// @param[in] callback A <code>CompletionCallback</code> to be called upon
+ /// completion.
+ ///
+ /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
int32_t SetOption(PP_UDPSocket_Option_Dev name,
const Var& value,
const CompletionCallback& callback);

Powered by Google App Engine
This is Rietveld 408576698