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 "remoting/jingle_glue/chromium_socket_factory.h" | 5 #include "remoting/jingle_glue/chromium_socket_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "jingle/glue/utils.h" | 10 #include "jingle/glue/utils.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 void UdpPacketSocket::SetError(int error) { | 250 void UdpPacketSocket::SetError(int error) { |
251 error_ = error; | 251 error_ = error; |
252 } | 252 } |
253 | 253 |
254 void UdpPacketSocket::DoSend() { | 254 void UdpPacketSocket::DoSend() { |
255 if (send_pending_ || send_queue_.empty()) | 255 if (send_pending_ || send_queue_.empty()) |
256 return; | 256 return; |
257 | 257 |
258 PendingPacket& packet = send_queue_.front(); | 258 PendingPacket& packet = send_queue_.front(); |
259 int result = socket_->SendTo( | 259 int result = socket_->SendTo( |
260 packet.data, packet.data->size(), packet.address, | 260 packet.data.get(), |
261 base::Bind(&UdpPacketSocket::OnSendCompleted, | 261 packet.data->size(), |
262 base::Unretained(this))); | 262 packet.address, |
| 263 base::Bind(&UdpPacketSocket::OnSendCompleted, base::Unretained(this))); |
263 if (result == net::ERR_IO_PENDING) { | 264 if (result == net::ERR_IO_PENDING) { |
264 send_pending_ = true; | 265 send_pending_ = true; |
265 } else { | 266 } else { |
266 OnSendCompleted(result); | 267 OnSendCompleted(result); |
267 } | 268 } |
268 } | 269 } |
269 | 270 |
270 void UdpPacketSocket::OnSendCompleted(int result) { | 271 void UdpPacketSocket::OnSendCompleted(int result) { |
271 send_pending_ = false; | 272 send_pending_ = false; |
272 | 273 |
(...skipping 10 matching lines...) Expand all Loading... |
283 send_queue_size_ -= send_queue_.front().data->size(); | 284 send_queue_size_ -= send_queue_.front().data->size(); |
284 send_queue_.pop_front(); | 285 send_queue_.pop_front(); |
285 DoSend(); | 286 DoSend(); |
286 } | 287 } |
287 | 288 |
288 void UdpPacketSocket::DoRead() { | 289 void UdpPacketSocket::DoRead() { |
289 int result = 0; | 290 int result = 0; |
290 while (result >= 0) { | 291 while (result >= 0) { |
291 receive_buffer_ = new net::IOBuffer(kReceiveBufferSize); | 292 receive_buffer_ = new net::IOBuffer(kReceiveBufferSize); |
292 result = socket_->RecvFrom( | 293 result = socket_->RecvFrom( |
293 receive_buffer_, kReceiveBufferSize, &receive_address_, | 294 receive_buffer_.get(), |
| 295 kReceiveBufferSize, |
| 296 &receive_address_, |
294 base::Bind(&UdpPacketSocket::OnReadCompleted, base::Unretained(this))); | 297 base::Bind(&UdpPacketSocket::OnReadCompleted, base::Unretained(this))); |
295 HandleReadResult(result); | 298 HandleReadResult(result); |
296 } | 299 } |
297 } | 300 } |
298 | 301 |
299 void UdpPacketSocket::OnReadCompleted(int result) { | 302 void UdpPacketSocket::OnReadCompleted(int result) { |
300 HandleReadResult(result); | 303 HandleReadResult(result); |
301 if (result >= 0) { | 304 if (result >= 0) { |
302 DoRead(); | 305 DoRead(); |
303 } | 306 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 const talk_base::SocketAddress& remote_address, | 357 const talk_base::SocketAddress& remote_address, |
355 const talk_base::ProxyInfo& proxy_info, | 358 const talk_base::ProxyInfo& proxy_info, |
356 const std::string& user_agent, | 359 const std::string& user_agent, |
357 int opts) { | 360 int opts) { |
358 // We don't use TCP sockets for remoting connections. | 361 // We don't use TCP sockets for remoting connections. |
359 NOTREACHED(); | 362 NOTREACHED(); |
360 return NULL; | 363 return NULL; |
361 } | 364 } |
362 | 365 |
363 } // namespace remoting | 366 } // namespace remoting |
OLD | NEW |