| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/ftp/ftp_network_transaction.h" | 5 #include "net/ftp/ftp_network_transaction.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "net/base/address_list.h" |
| 12 #include "net/base/connection_type_histograms.h" | 13 #include "net/base/connection_type_histograms.h" |
| 13 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
| 14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 15 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
| 16 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 17 #include "net/ftp/ftp_network_session.h" | 18 #include "net/ftp/ftp_network_session.h" |
| 18 #include "net/ftp/ftp_request_info.h" | 19 #include "net/ftp/ftp_request_info.h" |
| 19 #include "net/ftp/ftp_util.h" | 20 #include "net/ftp/ftp_util.h" |
| 20 #include "net/socket/client_socket.h" | 21 #include "net/socket/client_socket.h" |
| 21 #include "net/socket/client_socket_factory.h" | 22 #include "net/socket/client_socket_factory.h" |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 } | 614 } |
| 614 | 615 |
| 615 int FtpNetworkTransaction::DoCtrlConnect() { | 616 int FtpNetworkTransaction::DoCtrlConnect() { |
| 616 next_state_ = STATE_CTRL_CONNECT_COMPLETE; | 617 next_state_ = STATE_CTRL_CONNECT_COMPLETE; |
| 617 ctrl_socket_.reset(socket_factory_->CreateTCPClientSocket( | 618 ctrl_socket_.reset(socket_factory_->CreateTCPClientSocket( |
| 618 addresses_, net_log_.net_log(), net_log_.source())); | 619 addresses_, net_log_.net_log(), net_log_.source())); |
| 619 return ctrl_socket_->Connect(&io_callback_); | 620 return ctrl_socket_->Connect(&io_callback_); |
| 620 } | 621 } |
| 621 | 622 |
| 622 int FtpNetworkTransaction::DoCtrlConnectComplete(int result) { | 623 int FtpNetworkTransaction::DoCtrlConnectComplete(int result) { |
| 623 if (result == OK) | 624 if (result == OK) { |
| 624 next_state_ = STATE_CTRL_READ; | 625 // Put the peer's IP address and port into the response. |
| 626 AddressList address; |
| 627 result = ctrl_socket_->GetPeerAddress(&address); |
| 628 if (result == OK) { |
| 629 response_.socket_address = HostPortPair::FromAddrInfo(address.head()); |
| 630 next_state_ = STATE_CTRL_READ; |
| 631 } |
| 632 } |
| 625 return result; | 633 return result; |
| 626 } | 634 } |
| 627 | 635 |
| 628 int FtpNetworkTransaction::DoCtrlRead() { | 636 int FtpNetworkTransaction::DoCtrlRead() { |
| 629 next_state_ = STATE_CTRL_READ_COMPLETE; | 637 next_state_ = STATE_CTRL_READ_COMPLETE; |
| 630 return ctrl_socket_->Read( | 638 return ctrl_socket_->Read( |
| 631 read_ctrl_buf_, | 639 read_ctrl_buf_, |
| 632 kCtrlBufLen, | 640 kCtrlBufLen, |
| 633 &io_callback_); | 641 &io_callback_); |
| 634 } | 642 } |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 if (!had_error_type[type]) { | 1299 if (!had_error_type[type]) { |
| 1292 had_error_type[type] = true; | 1300 had_error_type[type] = true; |
| 1293 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", | 1301 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", |
| 1294 type, NUM_OF_NET_ERROR_TYPES); | 1302 type, NUM_OF_NET_ERROR_TYPES); |
| 1295 } | 1303 } |
| 1296 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", | 1304 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", |
| 1297 type, NUM_OF_NET_ERROR_TYPES); | 1305 type, NUM_OF_NET_ERROR_TYPES); |
| 1298 } | 1306 } |
| 1299 | 1307 |
| 1300 } // namespace net | 1308 } // namespace net |
| OLD | NEW |