| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tcp_socket.h" | 5 #include "net/socket/tcp_socket.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <netinet/tcp.h> | 8 #include <netinet/tcp.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 | 10 |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 } | 492 } |
| 493 | 493 |
| 494 void TCPSocketLibevent::ReadCompleted(const scoped_refptr<IOBuffer>& buf, | 494 void TCPSocketLibevent::ReadCompleted(const scoped_refptr<IOBuffer>& buf, |
| 495 const CompletionCallback& callback, | 495 const CompletionCallback& callback, |
| 496 int rv) { | 496 int rv) { |
| 497 DCHECK_NE(ERR_IO_PENDING, rv); | 497 DCHECK_NE(ERR_IO_PENDING, rv); |
| 498 // Records fast open status regardless of error in asynchronous case. | 498 // Records fast open status regardless of error in asynchronous case. |
| 499 // TODO(rdsmith,jri): Change histogram name to indicate it could be called on | 499 // TODO(rdsmith,jri): Change histogram name to indicate it could be called on |
| 500 // error. | 500 // error. |
| 501 RecordFastOpenStatus(); | 501 RecordFastOpenStatus(); |
| 502 callback.Run(HandleReadCompleted(buf, rv)); | 502 callback.Run(HandleReadCompleted(buf.get(), rv)); |
| 503 } | 503 } |
| 504 | 504 |
| 505 int TCPSocketLibevent::HandleReadCompleted(IOBuffer* buf, int rv) { | 505 int TCPSocketLibevent::HandleReadCompleted(IOBuffer* buf, int rv) { |
| 506 if (rv < 0) { | 506 if (rv < 0) { |
| 507 net_log_.AddEvent(NetLog::TYPE_SOCKET_READ_ERROR, | 507 net_log_.AddEvent(NetLog::TYPE_SOCKET_READ_ERROR, |
| 508 CreateNetLogSocketErrorCallback(rv, errno)); | 508 CreateNetLogSocketErrorCallback(rv, errno)); |
| 509 return rv; | 509 return rv; |
| 510 } | 510 } |
| 511 | 511 |
| 512 base::StatsCounter read_bytes("tcp.read_bytes"); | 512 base::StatsCounter read_bytes("tcp.read_bytes"); |
| 513 read_bytes.Add(rv); | 513 read_bytes.Add(rv); |
| 514 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, rv, | 514 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, rv, |
| 515 buf->data()); | 515 buf->data()); |
| 516 return rv; | 516 return rv; |
| 517 } | 517 } |
| 518 | 518 |
| 519 void TCPSocketLibevent::WriteCompleted(const scoped_refptr<IOBuffer>& buf, | 519 void TCPSocketLibevent::WriteCompleted(const scoped_refptr<IOBuffer>& buf, |
| 520 const CompletionCallback& callback, | 520 const CompletionCallback& callback, |
| 521 int rv) const { | 521 int rv) const { |
| 522 DCHECK_NE(ERR_IO_PENDING, rv); | 522 DCHECK_NE(ERR_IO_PENDING, rv); |
| 523 callback.Run(HandleWriteCompleted(buf, rv)); | 523 callback.Run(HandleWriteCompleted(buf.get(), rv)); |
| 524 } | 524 } |
| 525 | 525 |
| 526 int TCPSocketLibevent::HandleWriteCompleted(IOBuffer* buf, int rv) const { | 526 int TCPSocketLibevent::HandleWriteCompleted(IOBuffer* buf, int rv) const { |
| 527 if (rv < 0) { | 527 if (rv < 0) { |
| 528 net_log_.AddEvent(NetLog::TYPE_SOCKET_WRITE_ERROR, | 528 net_log_.AddEvent(NetLog::TYPE_SOCKET_WRITE_ERROR, |
| 529 CreateNetLogSocketErrorCallback(rv, errno)); | 529 CreateNetLogSocketErrorCallback(rv, errno)); |
| 530 return rv; | 530 return rv; |
| 531 } | 531 } |
| 532 | 532 |
| 533 base::StatsCounter write_bytes("tcp.write_bytes"); | 533 base::StatsCounter write_bytes("tcp.write_bytes"); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 } | 617 } |
| 618 } else { | 618 } else { |
| 619 fast_open_status_ = (fast_open_status_ == FAST_OPEN_FAST_CONNECT_RETURN ? | 619 fast_open_status_ = (fast_open_status_ == FAST_OPEN_FAST_CONNECT_RETURN ? |
| 620 FAST_OPEN_SYN_DATA_FAILED : | 620 FAST_OPEN_SYN_DATA_FAILED : |
| 621 FAST_OPEN_NO_SYN_DATA_FAILED); | 621 FAST_OPEN_NO_SYN_DATA_FAILED); |
| 622 } | 622 } |
| 623 } | 623 } |
| 624 } | 624 } |
| 625 | 625 |
| 626 } // namespace net | 626 } // namespace net |
| OLD | NEW |