OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 PPAPI_CPP_DEV_TCP_SOCKET_DEV_H_ | 5 #ifndef PPAPI_CPP_DEV_TCP_SOCKET_DEV_H_ |
6 #define PPAPI_CPP_DEV_TCP_SOCKET_DEV_H_ | 6 #define PPAPI_CPP_DEV_TCP_SOCKET_DEV_H_ |
7 | 7 |
8 #include "ppapi/c/dev/ppb_tcp_socket_dev.h" | 8 #include "ppapi/c/dev/ppb_tcp_socket_dev.h" |
9 #include "ppapi/cpp/dev/net_address_dev.h" | 9 #include "ppapi/cpp/net_address.h" |
10 #include "ppapi/cpp/pass_ref.h" | 10 #include "ppapi/cpp/pass_ref.h" |
11 #include "ppapi/cpp/resource.h" | 11 #include "ppapi/cpp/resource.h" |
12 | 12 |
13 namespace pp { | 13 namespace pp { |
14 | 14 |
15 class CompletionCallback; | 15 class CompletionCallback; |
16 class InstanceHandle; | 16 class InstanceHandle; |
17 | 17 |
18 /// The <code>TCPSocket_Dev</code> class provides TCP socket operations. | 18 /// The <code>TCPSocket_Dev</code> class provides TCP socket operations. |
19 /// | 19 /// |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 TCPSocket_Dev& operator=(const TCPSocket_Dev& other); | 55 TCPSocket_Dev& operator=(const TCPSocket_Dev& other); |
56 | 56 |
57 /// Static function for determining whether the browser supports the required | 57 /// Static function for determining whether the browser supports the required |
58 /// <code>PPB_TCPSocket_Dev</code> interface. | 58 /// <code>PPB_TCPSocket_Dev</code> interface. |
59 /// | 59 /// |
60 /// @return true if the interface is available, false otherwise. | 60 /// @return true if the interface is available, false otherwise. |
61 static bool IsAvailable(); | 61 static bool IsAvailable(); |
62 | 62 |
63 /// Connects to the given address. | 63 /// Connects to the given address. |
64 /// | 64 /// |
65 /// @param[in] addr A <code>NetAddress_Dev</code> object. | 65 /// @param[in] addr A <code>NetAddress</code> object. |
66 /// @param[in] callback A <code>CompletionCallback</code> to be called upon | 66 /// @param[in] callback A <code>CompletionCallback</code> to be called upon |
67 /// completion. | 67 /// completion. |
68 /// | 68 /// |
69 /// @return An int32_t containing an error code from <code>pp_errors.h</code>, | 69 /// @return An int32_t containing an error code from <code>pp_errors.h</code>, |
70 /// including (but not limited to): | 70 /// including (but not limited to): |
71 /// - <code>PP_ERROR_NOACCESS</code>: the caller doesn't have required | 71 /// - <code>PP_ERROR_NOACCESS</code>: the caller doesn't have required |
72 /// permissions. | 72 /// permissions. |
73 /// - <code>PP_ERROR_ADDRESS_UNREACHABLE</code>: <code>addr</code> is | 73 /// - <code>PP_ERROR_ADDRESS_UNREACHABLE</code>: <code>addr</code> is |
74 /// unreachable. | 74 /// unreachable. |
75 /// - <code>PP_ERROR_CONNECTION_REFUSED</code>: the connection attempt was | 75 /// - <code>PP_ERROR_CONNECTION_REFUSED</code>: the connection attempt was |
76 /// refused. | 76 /// refused. |
77 /// - <code>PP_ERROR_CONNECTION_FAILED</code>: the connection attempt failed. | 77 /// - <code>PP_ERROR_CONNECTION_FAILED</code>: the connection attempt failed. |
78 /// - <code>PP_ERROR_CONNECTION_TIMEDOUT</code>: the connection attempt timed | 78 /// - <code>PP_ERROR_CONNECTION_TIMEDOUT</code>: the connection attempt timed |
79 /// out. | 79 /// out. |
80 int32_t Connect(const NetAddress_Dev& addr, | 80 int32_t Connect(const NetAddress& addr, |
81 const CompletionCallback& callback); | 81 const CompletionCallback& callback); |
82 | 82 |
83 /// Gets the local address of the socket, if it has been connected. | 83 /// Gets the local address of the socket, if it has been connected. |
84 /// | 84 /// |
85 /// @return A <code>NetAddress_Dev</code> object. The object will be null | 85 /// @return A <code>NetAddress</code> object. The object will be null |
86 /// (i.e., is_null() returns true) on failure. | 86 /// (i.e., is_null() returns true) on failure. |
87 NetAddress_Dev GetLocalAddress() const; | 87 NetAddress GetLocalAddress() const; |
88 | 88 |
89 /// Gets the remote address of the socket, if it has been connected. | 89 /// Gets the remote address of the socket, if it has been connected. |
90 /// | 90 /// |
91 /// @return A <code>NetAddress_Dev</code> object. The object will be null | 91 /// @return A <code>NetAddress</code> object. The object will be null |
92 /// (i.e., is_null() returns true) on failure. | 92 /// (i.e., is_null() returns true) on failure. |
93 NetAddress_Dev GetRemoteAddress() const; | 93 NetAddress GetRemoteAddress() const; |
94 | 94 |
95 /// Reads data from the socket. It can only be called after a successful | 95 /// Reads data from the socket. It can only be called after a successful |
96 /// <code>Connect()</code> call. It may perform a partial read. | 96 /// <code>Connect()</code> call. It may perform a partial read. |
97 /// | 97 /// |
98 /// <strong>Caveat:</strong> You should be careful about the lifetime of | 98 /// <strong>Caveat:</strong> You should be careful about the lifetime of |
99 /// <code>buffer</code>. Typically you will use a | 99 /// <code>buffer</code>. Typically you will use a |
100 /// <code>CompletionCallbackFactory</code> to scope callbacks to the lifetime | 100 /// <code>CompletionCallbackFactory</code> to scope callbacks to the lifetime |
101 /// of your class. When your class goes out of scope, the callback factory | 101 /// of your class. When your class goes out of scope, the callback factory |
102 /// will not actually cancel the operation, but will rather just skip issuing | 102 /// will not actually cancel the operation, but will rather just skip issuing |
103 /// the callback on your class. This means that if the underlying | 103 /// the callback on your class. This means that if the underlying |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 /// | 156 /// |
157 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | 157 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
158 //// | 158 //// |
159 int32_t SetOption(PP_TCPSocket_Option_Dev name, | 159 int32_t SetOption(PP_TCPSocket_Option_Dev name, |
160 const Var& value, | 160 const Var& value, |
161 const CompletionCallback& callback); | 161 const CompletionCallback& callback); |
162 }; | 162 }; |
163 | 163 |
164 } // namespace pp | 164 } // namespace pp |
165 | 165 |
166 #endif // PPAPI_CPP_DEV_TCP_SOCKET_DEV_H_ | 166 #endif // PPAPI_CPP_DEV_TCP_SOCKET__DevDEV_H_ |
OLD | NEW |