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 "net/udp/udp_socket_win.h" | 5 #include "net/udp/udp_socket_win.h" |
6 | 6 |
7 #include <mstcpip.h> | 7 #include <mstcpip.h> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 const CompletionCallback& callback) { | 338 const CompletionCallback& callback) { |
339 return RecvFrom(buf, buf_len, NULL, callback); | 339 return RecvFrom(buf, buf_len, NULL, callback); |
340 } | 340 } |
341 | 341 |
342 int UDPSocketWin::RecvFrom(IOBuffer* buf, | 342 int UDPSocketWin::RecvFrom(IOBuffer* buf, |
343 int buf_len, | 343 int buf_len, |
344 IPEndPoint* address, | 344 IPEndPoint* address, |
345 const CompletionCallback& callback) { | 345 const CompletionCallback& callback) { |
346 DCHECK(CalledOnValidThread()); | 346 DCHECK(CalledOnValidThread()); |
347 DCHECK_NE(INVALID_SOCKET, socket_); | 347 DCHECK_NE(INVALID_SOCKET, socket_); |
348 DCHECK(read_callback_.is_null()); | 348 CHECK(read_callback_.is_null()); |
349 DCHECK(!recv_from_address_); | 349 DCHECK(!recv_from_address_); |
350 DCHECK(!callback.is_null()); // Synchronous operation not supported. | 350 DCHECK(!callback.is_null()); // Synchronous operation not supported. |
351 DCHECK_GT(buf_len, 0); | 351 DCHECK_GT(buf_len, 0); |
352 | 352 |
353 int nread = InternalRecvFrom(buf, buf_len, address); | 353 int nread = InternalRecvFrom(buf, buf_len, address); |
354 if (nread != ERR_IO_PENDING) | 354 if (nread != ERR_IO_PENDING) |
355 return nread; | 355 return nread; |
356 | 356 |
357 read_callback_ = callback; | 357 read_callback_ = callback; |
358 recv_from_address_ = address; | 358 recv_from_address_ = address; |
(...skipping 12 matching lines...) Expand all Loading... |
371 const CompletionCallback& callback) { | 371 const CompletionCallback& callback) { |
372 return SendToOrWrite(buf, buf_len, &address, callback); | 372 return SendToOrWrite(buf, buf_len, &address, callback); |
373 } | 373 } |
374 | 374 |
375 int UDPSocketWin::SendToOrWrite(IOBuffer* buf, | 375 int UDPSocketWin::SendToOrWrite(IOBuffer* buf, |
376 int buf_len, | 376 int buf_len, |
377 const IPEndPoint* address, | 377 const IPEndPoint* address, |
378 const CompletionCallback& callback) { | 378 const CompletionCallback& callback) { |
379 DCHECK(CalledOnValidThread()); | 379 DCHECK(CalledOnValidThread()); |
380 DCHECK_NE(INVALID_SOCKET, socket_); | 380 DCHECK_NE(INVALID_SOCKET, socket_); |
381 DCHECK(write_callback_.is_null()); | 381 CHECK(write_callback_.is_null()); |
382 DCHECK(!callback.is_null()); // Synchronous operation not supported. | 382 DCHECK(!callback.is_null()); // Synchronous operation not supported. |
383 DCHECK_GT(buf_len, 0); | 383 DCHECK_GT(buf_len, 0); |
384 DCHECK(!send_to_address_.get()); | 384 DCHECK(!send_to_address_.get()); |
385 | 385 |
386 int nwrite = InternalSendTo(buf, buf_len, address); | 386 int nwrite = InternalSendTo(buf, buf_len, address); |
387 if (nwrite != ERR_IO_PENDING) | 387 if (nwrite != ERR_IO_PENDING) |
388 return nwrite; | 388 return nwrite; |
389 | 389 |
390 if (address) | 390 if (address) |
391 send_to_address_.reset(new IPEndPoint(*address)); | 391 send_to_address_.reset(new IPEndPoint(*address)); |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 NULL); | 1005 NULL); |
1006 | 1006 |
1007 return OK; | 1007 return OK; |
1008 } | 1008 } |
1009 | 1009 |
1010 void UDPSocketWin::DetachFromThread() { | 1010 void UDPSocketWin::DetachFromThread() { |
1011 base::NonThreadSafe::DetachFromThread(); | 1011 base::NonThreadSafe::DetachFromThread(); |
1012 } | 1012 } |
1013 | 1013 |
1014 } // namespace net | 1014 } // namespace net |
OLD | NEW |