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_posix.h" | 5 #include "net/udp/udp_socket_posix.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <net/if.h> | 9 #include <net/if.h> |
10 #include <netdb.h> | 10 #include <netdb.h> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/rand_util.h" | 22 #include "base/rand_util.h" |
23 #include "net/base/io_buffer.h" | 23 #include "net/base/io_buffer.h" |
24 #include "net/base/ip_endpoint.h" | 24 #include "net/base/ip_endpoint.h" |
25 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
26 #include "net/base/network_activity_monitor.h" | 26 #include "net/base/network_activity_monitor.h" |
27 #include "net/base/sockaddr_storage.h" | 27 #include "net/base/sockaddr_storage.h" |
28 #include "net/log/net_log.h" | 28 #include "net/log/net_log.h" |
29 #include "net/socket/socket_descriptor.h" | 29 #include "net/socket/socket_descriptor.h" |
30 #include "net/udp/udp_net_log_parameters.h" | 30 #include "net/udp/udp_net_log_parameters.h" |
31 | 31 |
| 32 #include "base/trace_event/trace_event.h" |
| 33 |
32 #if defined(OS_ANDROID) | 34 #if defined(OS_ANDROID) |
33 #include "base/android/build_info.h" | 35 #include "base/android/build_info.h" |
34 #include "base/native_library.h" | 36 #include "base/native_library.h" |
35 #include "base/strings/utf_string_conversions.h" | 37 #include "base/strings/utf_string_conversions.h" |
36 #endif | 38 #endif |
37 | 39 |
38 namespace net { | 40 namespace net { |
39 | 41 |
40 namespace { | 42 namespace { |
41 | 43 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 // UDP multicast or broadcast datagrams destined for the bound | 407 // UDP multicast or broadcast datagrams destined for the bound |
406 // port. | 408 // port. |
407 rv = setsockopt(socket_, SOL_SOCKET, SO_REUSEPORT, &value, sizeof(value)); | 409 rv = setsockopt(socket_, SOL_SOCKET, SO_REUSEPORT, &value, sizeof(value)); |
408 #else | 410 #else |
409 rv = setsockopt(socket_, SOL_SOCKET, SO_BROADCAST, &value, sizeof(value)); | 411 rv = setsockopt(socket_, SOL_SOCKET, SO_BROADCAST, &value, sizeof(value)); |
410 #endif // defined(OS_MACOSX) | 412 #endif // defined(OS_MACOSX) |
411 return rv == 0 ? OK : MapSystemError(errno); | 413 return rv == 0 ? OK : MapSystemError(errno); |
412 } | 414 } |
413 | 415 |
414 void UDPSocketPosix::ReadWatcher::OnFileCanReadWithoutBlocking(int) { | 416 void UDPSocketPosix::ReadWatcher::OnFileCanReadWithoutBlocking(int) { |
| 417 TRACE_EVENT0( |
| 418 "net", "net::UDPSocketPosix::ReadWatcher::OnFileCanReadWithoutBlocking"); |
415 if (!socket_->read_callback_.is_null()) | 419 if (!socket_->read_callback_.is_null()) |
416 socket_->DidCompleteRead(); | 420 socket_->DidCompleteRead(); |
417 } | 421 } |
418 | 422 |
419 void UDPSocketPosix::WriteWatcher::OnFileCanWriteWithoutBlocking(int) { | 423 void UDPSocketPosix::WriteWatcher::OnFileCanWriteWithoutBlocking(int) { |
420 if (!socket_->write_callback_.is_null()) | 424 if (!socket_->write_callback_.is_null()) |
421 socket_->DidCompleteWrite(); | 425 socket_->DidCompleteWrite(); |
422 } | 426 } |
423 | 427 |
424 void UDPSocketPosix::DoReadCallback(int rv) { | 428 void UDPSocketPosix::DoReadCallback(int rv) { |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 return MapSystemError(errno); | 799 return MapSystemError(errno); |
796 | 800 |
797 return OK; | 801 return OK; |
798 } | 802 } |
799 | 803 |
800 void UDPSocketPosix::DetachFromThread() { | 804 void UDPSocketPosix::DetachFromThread() { |
801 base::NonThreadSafe::DetachFromThread(); | 805 base::NonThreadSafe::DetachFromThread(); |
802 } | 806 } |
803 | 807 |
804 } // namespace net | 808 } // namespace net |
OLD | NEW |