Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Side by Side Diff: net/ftp/ftp_network_transaction.cc

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_EXPORT to *PortOnAddressList. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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/ftp/ftp_network_transaction.h" 5 #include "net/ftp/ftp_network_transaction.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 addresses_, net_log_.net_log(), net_log_.source())); 647 addresses_, net_log_.net_log(), net_log_.source()));
648 return ctrl_socket_->Connect(io_callback_); 648 return ctrl_socket_->Connect(io_callback_);
649 } 649 }
650 650
651 int FtpNetworkTransaction::DoCtrlConnectComplete(int result) { 651 int FtpNetworkTransaction::DoCtrlConnectComplete(int result) {
652 if (result == OK) { 652 if (result == OK) {
653 // Put the peer's IP address and port into the response. 653 // Put the peer's IP address and port into the response.
654 AddressList address; 654 AddressList address;
655 result = ctrl_socket_->GetPeerAddress(&address); 655 result = ctrl_socket_->GetPeerAddress(&address);
656 if (result == OK) { 656 if (result == OK) {
657 response_.socket_address = HostPortPair::FromAddrInfo(address.head()); 657 response_.socket_address = HostPortPair::FromIPEndPoint(address[0]);
eroman 2012/05/04 01:08:41 Here for instance code assumes that on success Add
szym 2012/05/04 02:38:29 Both HostResolverImpl and its tests assume that OK
658 next_state_ = STATE_CTRL_READ; 658 next_state_ = STATE_CTRL_READ;
659 } 659 }
660 } 660 }
661 return result; 661 return result;
662 } 662 }
663 663
664 int FtpNetworkTransaction::DoCtrlRead() { 664 int FtpNetworkTransaction::DoCtrlRead() {
665 next_state_ = STATE_CTRL_READ_COMPLETE; 665 next_state_ = STATE_CTRL_READ_COMPLETE;
666 return ctrl_socket_->Read(read_ctrl_buf_, kCtrlBufLen, io_callback_); 666 return ctrl_socket_->Read(read_ctrl_buf_, kCtrlBufLen, io_callback_);
667 } 667 }
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 // Data Connection 1187 // Data Connection
1188 1188
1189 int FtpNetworkTransaction::DoDataConnect() { 1189 int FtpNetworkTransaction::DoDataConnect() {
1190 next_state_ = STATE_DATA_CONNECT_COMPLETE; 1190 next_state_ = STATE_DATA_CONNECT_COMPLETE;
1191 AddressList data_address; 1191 AddressList data_address;
1192 // Connect to the same host as the control socket to prevent PASV port 1192 // Connect to the same host as the control socket to prevent PASV port
1193 // scanning attacks. 1193 // scanning attacks.
1194 int rv = ctrl_socket_->GetPeerAddress(&data_address); 1194 int rv = ctrl_socket_->GetPeerAddress(&data_address);
1195 if (rv != OK) 1195 if (rv != OK)
1196 return Stop(rv); 1196 return Stop(rv);
1197 data_address.SetPort(data_connection_port_); 1197 data_address = AddressList::CreateFromIPAddress(
eroman 2012/05/04 01:08:41 This is a bit awkward. How about just calling the
szym 2012/05/04 02:38:29 The awkwardness comes from the immutability of IPE
eroman 2012/05/04 04:20:22 Ah. In that case I agree this is fine; no point ch
1198 data_address[0].address(), data_connection_port_);
1198 data_socket_.reset(socket_factory_->CreateTransportClientSocket( 1199 data_socket_.reset(socket_factory_->CreateTransportClientSocket(
1199 data_address, net_log_.net_log(), net_log_.source())); 1200 data_address, net_log_.net_log(), net_log_.source()));
1200 return data_socket_->Connect(io_callback_); 1201 return data_socket_->Connect(io_callback_);
1201 } 1202 }
1202 1203
1203 int FtpNetworkTransaction::DoDataConnectComplete(int result) { 1204 int FtpNetworkTransaction::DoDataConnectComplete(int result) {
1204 if (result != OK && use_epsv_) { 1205 if (result != OK && use_epsv_) {
1205 // It's possible we hit a broken server, sadly. They can break in different 1206 // It's possible we hit a broken server, sadly. They can break in different
1206 // ways. Some time out, some reset a connection. Fall back to PASV. 1207 // ways. Some time out, some reset a connection. Fall back to PASV.
1207 // TODO(phajdan.jr): remember it for future transactions with this server. 1208 // TODO(phajdan.jr): remember it for future transactions with this server.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 if (!had_error_type[type]) { 1334 if (!had_error_type[type]) {
1334 had_error_type[type] = true; 1335 had_error_type[type] = true;
1335 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", 1336 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened",
1336 type, NUM_OF_NET_ERROR_TYPES); 1337 type, NUM_OF_NET_ERROR_TYPES);
1337 } 1338 }
1338 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", 1339 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount",
1339 type, NUM_OF_NET_ERROR_TYPES); 1340 type, NUM_OF_NET_ERROR_TYPES);
1340 } 1341 }
1341 1342
1342 } // namespace net 1343 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698