OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/api/socket/udp_socket.h" | 5 #include "chrome/browser/extensions/api/socket/udp_socket.h" |
6 | 6 |
7 #include "chrome/browser/extensions/api/api_resource.h" | 7 #include "chrome/browser/extensions/api/api_resource.h" |
8 #include "net/base/ip_endpoint.h" | 8 #include "net/base/ip_endpoint.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/udp/datagram_socket.h" | 10 #include "net/udp/datagram_socket.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 return net::ERR_SOCKET_NOT_CONNECTED; | 101 return net::ERR_SOCKET_NOT_CONNECTED; |
102 else | 102 else |
103 return socket_.Write(io_buffer, io_buffer_size, callback); | 103 return socket_.Write(io_buffer, io_buffer_size, callback); |
104 } | 104 } |
105 | 105 |
106 void UDPSocket::RecvFrom(int count, | 106 void UDPSocket::RecvFrom(int count, |
107 const RecvFromCompletionCallback& callback) { | 107 const RecvFromCompletionCallback& callback) { |
108 DCHECK(!callback.is_null()); | 108 DCHECK(!callback.is_null()); |
109 | 109 |
110 if (!recv_from_callback_.is_null()) { | 110 if (!recv_from_callback_.is_null()) { |
111 callback.Run(net::ERR_IO_PENDING, NULL, "", 0); | 111 callback.Run(net::ERR_IO_PENDING, NULL, std::string(), 0); |
112 return; | 112 return; |
113 } else { | 113 } else { |
114 recv_from_callback_ = callback; | 114 recv_from_callback_ = callback; |
115 } | 115 } |
116 | 116 |
117 int result = net::ERR_FAILED; | 117 int result = net::ERR_FAILED; |
118 scoped_refptr<net::IOBuffer> io_buffer; | 118 scoped_refptr<net::IOBuffer> io_buffer; |
119 scoped_refptr<IPEndPoint> address; | 119 scoped_refptr<IPEndPoint> address; |
120 do { | 120 do { |
121 if (count < 0) { | 121 if (count < 0) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 recv_from_callback_.Reset(); | 216 recv_from_callback_.Reset(); |
217 } | 217 } |
218 | 218 |
219 void UDPSocket::OnSendToComplete(int result) { | 219 void UDPSocket::OnSendToComplete(int result) { |
220 DCHECK(!send_to_callback_.is_null()); | 220 DCHECK(!send_to_callback_.is_null()); |
221 send_to_callback_.Run(result); | 221 send_to_callback_.Run(result); |
222 send_to_callback_.Reset(); | 222 send_to_callback_.Reset(); |
223 } | 223 } |
224 | 224 |
225 } // namespace extensions | 225 } // namespace extensions |
OLD | NEW |