OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/socket/socket_posix.h" | 5 #include "net/socket/socket_posix.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <netinet/in.h> | 8 #include <netinet/in.h> |
9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/posix/eintr_wrapper.h" | 15 #include "base/posix/eintr_wrapper.h" |
| 16 #include "base/trace_event/trace_event.h" |
16 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
17 #include "net/base/ip_endpoint.h" | 18 #include "net/base/ip_endpoint.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/base/sockaddr_storage.h" | 20 #include "net/base/sockaddr_storage.h" |
20 | 21 |
21 namespace net { | 22 namespace net { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 int MapAcceptError(int os_error) { | 26 int MapAcceptError(int os_error) { |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 PLOG(ERROR) << "close() returned an error, errno=" << errno; | 342 PLOG(ERROR) << "close() returned an error, errno=" << errno; |
342 socket_fd_ = kInvalidSocket; | 343 socket_fd_ = kInvalidSocket; |
343 } | 344 } |
344 } | 345 } |
345 | 346 |
346 void SocketPosix::DetachFromThread() { | 347 void SocketPosix::DetachFromThread() { |
347 thread_checker_.DetachFromThread(); | 348 thread_checker_.DetachFromThread(); |
348 } | 349 } |
349 | 350 |
350 void SocketPosix::OnFileCanReadWithoutBlocking(int fd) { | 351 void SocketPosix::OnFileCanReadWithoutBlocking(int fd) { |
| 352 TRACE_EVENT0("net", "SocketPosix::OnFileCanReadWithoutBlocking"); |
351 DCHECK(!accept_callback_.is_null() || !read_callback_.is_null()); | 353 DCHECK(!accept_callback_.is_null() || !read_callback_.is_null()); |
352 if (!accept_callback_.is_null()) { | 354 if (!accept_callback_.is_null()) { |
353 AcceptCompleted(); | 355 AcceptCompleted(); |
354 } else { // !read_callback_.is_null() | 356 } else { // !read_callback_.is_null() |
355 ReadCompleted(); | 357 ReadCompleted(); |
356 } | 358 } |
357 } | 359 } |
358 | 360 |
359 void SocketPosix::OnFileCanWriteWithoutBlocking(int fd) { | 361 void SocketPosix::OnFileCanWriteWithoutBlocking(int fd) { |
360 DCHECK(!write_callback_.is_null()); | 362 DCHECK(!write_callback_.is_null()); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 write_buf_ = NULL; | 480 write_buf_ = NULL; |
479 write_buf_len_ = 0; | 481 write_buf_len_ = 0; |
480 write_callback_.Reset(); | 482 write_callback_.Reset(); |
481 } | 483 } |
482 | 484 |
483 waiting_connect_ = false; | 485 waiting_connect_ = false; |
484 peer_address_.reset(); | 486 peer_address_.reset(); |
485 } | 487 } |
486 | 488 |
487 } // namespace net | 489 } // namespace net |
OLD | NEW |