Chromium Code Reviews| 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 next_state_ = STATE_CTRL_READ; |
| 626 // Store the socket address that we connected to. | |
| 627 AddressList address; | |
| 628 if (ctrl_socket_->GetPeerAddress(&address) == OK) { | |
| 629 response_.socket_address = NetAddressToStringWithPort(address.head()); | |
| 630 } else { | |
| 631 response_.socket_address.clear(); | |
|
Paweł Hajdan Jr.
2011/02/11 19:34:54
Do we really want it to be a silent failure? That
Brian Ryner
2011/02/11 23:01:07
GetPeerAddress does seem to occasionally return er
Paweł Hajdan Jr.
2011/02/14 09:10:03
The response seems to be missing the point. Maybe
| |
| 632 } | |
| 633 } | |
| 625 return result; | 634 return result; |
| 626 } | 635 } |
| 627 | 636 |
| 628 int FtpNetworkTransaction::DoCtrlRead() { | 637 int FtpNetworkTransaction::DoCtrlRead() { |
| 629 next_state_ = STATE_CTRL_READ_COMPLETE; | 638 next_state_ = STATE_CTRL_READ_COMPLETE; |
| 630 return ctrl_socket_->Read( | 639 return ctrl_socket_->Read( |
| 631 read_ctrl_buf_, | 640 read_ctrl_buf_, |
| 632 kCtrlBufLen, | 641 kCtrlBufLen, |
| 633 &io_callback_); | 642 &io_callback_); |
| 634 } | 643 } |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1291 if (!had_error_type[type]) { | 1300 if (!had_error_type[type]) { |
| 1292 had_error_type[type] = true; | 1301 had_error_type[type] = true; |
| 1293 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", | 1302 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", |
| 1294 type, NUM_OF_NET_ERROR_TYPES); | 1303 type, NUM_OF_NET_ERROR_TYPES); |
| 1295 } | 1304 } |
| 1296 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", | 1305 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", |
| 1297 type, NUM_OF_NET_ERROR_TYPES); | 1306 type, NUM_OF_NET_ERROR_TYPES); |
| 1298 } | 1307 } |
| 1299 | 1308 |
| 1300 } // namespace net | 1309 } // namespace net |
| OLD | NEW |