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

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

Issue 848006: Generalize the net module's LoadLog facility from a passive container, to an event stream (NetLog). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Split up RequestTracker into ConnectJobTracker+RequestTracker+RequestTrackerBase, address comments Created 10 years, 9 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
« no previous file with comments | « net/ftp/ftp_network_transaction.h ('k') | net/ftp/ftp_transaction.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // 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/histogram.h" 8 #include "base/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "net/base/connection_type_histograms.h" 11 #include "net/base/connection_type_histograms.h"
12 #include "net/base/escape.h" 12 #include "net/base/escape.h"
13 #include "net/base/load_log.h"
14 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/base/net_log.h"
15 #include "net/base/net_util.h" 15 #include "net/base/net_util.h"
16 #include "net/ftp/ftp_network_session.h" 16 #include "net/ftp/ftp_network_session.h"
17 #include "net/ftp/ftp_request_info.h" 17 #include "net/ftp/ftp_request_info.h"
18 #include "net/ftp/ftp_util.h" 18 #include "net/ftp/ftp_util.h"
19 #include "net/socket/client_socket.h" 19 #include "net/socket/client_socket.h"
20 #include "net/socket/client_socket_factory.h" 20 #include "net/socket/client_socket_factory.h"
21 21
22 // TODO(ibrar): Try to avoid sscanf. 22 // TODO(ibrar): Try to avoid sscanf.
23 #if !defined(COMPILER_MSVC) 23 #if !defined(COMPILER_MSVC)
24 #define sscanf_s sscanf 24 #define sscanf_s sscanf
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 data_connection_port_(0), 66 data_connection_port_(0),
67 socket_factory_(socket_factory), 67 socket_factory_(socket_factory),
68 next_state_(STATE_NONE) { 68 next_state_(STATE_NONE) {
69 } 69 }
70 70
71 FtpNetworkTransaction::~FtpNetworkTransaction() { 71 FtpNetworkTransaction::~FtpNetworkTransaction() {
72 } 72 }
73 73
74 int FtpNetworkTransaction::Start(const FtpRequestInfo* request_info, 74 int FtpNetworkTransaction::Start(const FtpRequestInfo* request_info,
75 CompletionCallback* callback, 75 CompletionCallback* callback,
76 LoadLog* load_log) { 76 const BoundNetLog& net_log) {
77 load_log_ = load_log; 77 net_log_ = net_log;
78 request_ = request_info; 78 request_ = request_info;
79 79
80 if (request_->url.has_username()) { 80 if (request_->url.has_username()) {
81 GetIdentityFromURL(request_->url, &username_, &password_); 81 GetIdentityFromURL(request_->url, &username_, &password_);
82 } else { 82 } else {
83 username_ = L"anonymous"; 83 username_ = L"anonymous";
84 password_ = L"chrome@example.com"; 84 password_ = L"chrome@example.com";
85 } 85 }
86 86
87 next_state_ = STATE_CTRL_INIT; 87 next_state_ = STATE_CTRL_INIT;
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 int port; 501 int port;
502 502
503 host = request_->url.host(); 503 host = request_->url.host();
504 port = request_->url.EffectiveIntPort(); 504 port = request_->url.EffectiveIntPort();
505 505
506 HostResolver::RequestInfo info(host, port); 506 HostResolver::RequestInfo info(host, port);
507 // TODO(wtc): Until we support the FTP extensions for IPv6 specified in 507 // TODO(wtc): Until we support the FTP extensions for IPv6 specified in
508 // RFC 2428, we have to turn off IPv6 in FTP. See http://crbug.com/32945. 508 // RFC 2428, we have to turn off IPv6 in FTP. See http://crbug.com/32945.
509 info.set_address_family(ADDRESS_FAMILY_IPV4); 509 info.set_address_family(ADDRESS_FAMILY_IPV4);
510 // No known referrer. 510 // No known referrer.
511 return resolver_.Resolve(info, &addresses_, &io_callback_, load_log_); 511 return resolver_.Resolve(info, &addresses_, &io_callback_, net_log_);
512 } 512 }
513 513
514 int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) { 514 int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) {
515 if (result == OK) 515 if (result == OK)
516 next_state_ = STATE_CTRL_CONNECT; 516 next_state_ = STATE_CTRL_CONNECT;
517 return result; 517 return result;
518 } 518 }
519 519
520 int FtpNetworkTransaction::DoCtrlConnect() { 520 int FtpNetworkTransaction::DoCtrlConnect() {
521 next_state_ = STATE_CTRL_CONNECT_COMPLETE; 521 next_state_ = STATE_CTRL_CONNECT_COMPLETE;
522 ctrl_socket_.reset(socket_factory_->CreateTCPClientSocket(addresses_)); 522 ctrl_socket_.reset(socket_factory_->CreateTCPClientSocket(addresses_));
523 return ctrl_socket_->Connect(&io_callback_, load_log_); 523 return ctrl_socket_->Connect(&io_callback_, net_log_);
524 } 524 }
525 525
526 int FtpNetworkTransaction::DoCtrlConnectComplete(int result) { 526 int FtpNetworkTransaction::DoCtrlConnectComplete(int result) {
527 if (result == OK) 527 if (result == OK)
528 next_state_ = STATE_CTRL_READ; 528 next_state_ = STATE_CTRL_READ;
529 return result; 529 return result;
530 } 530 }
531 531
532 int FtpNetworkTransaction::DoCtrlRead() { 532 int FtpNetworkTransaction::DoCtrlRead() {
533 next_state_ = STATE_CTRL_READ_COMPLETE; 533 next_state_ = STATE_CTRL_READ_COMPLETE;
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 int FtpNetworkTransaction::DoDataConnect() { 1112 int FtpNetworkTransaction::DoDataConnect() {
1113 next_state_ = STATE_DATA_CONNECT_COMPLETE; 1113 next_state_ = STATE_DATA_CONNECT_COMPLETE;
1114 AddressList data_address; 1114 AddressList data_address;
1115 // Connect to the same host as the control socket to prevent PASV port 1115 // Connect to the same host as the control socket to prevent PASV port
1116 // scanning attacks. 1116 // scanning attacks.
1117 int rv = ctrl_socket_->GetPeerAddress(&data_address); 1117 int rv = ctrl_socket_->GetPeerAddress(&data_address);
1118 if (rv != OK) 1118 if (rv != OK)
1119 return Stop(rv); 1119 return Stop(rv);
1120 data_address.SetPort(data_connection_port_); 1120 data_address.SetPort(data_connection_port_);
1121 data_socket_.reset(socket_factory_->CreateTCPClientSocket(data_address)); 1121 data_socket_.reset(socket_factory_->CreateTCPClientSocket(data_address));
1122 return data_socket_->Connect(&io_callback_, load_log_); 1122 return data_socket_->Connect(&io_callback_, net_log_);
1123 } 1123 }
1124 1124
1125 int FtpNetworkTransaction::DoDataConnectComplete(int result) { 1125 int FtpNetworkTransaction::DoDataConnectComplete(int result) {
1126 RecordDataConnectionError(result); 1126 RecordDataConnectionError(result);
1127 if (retr_failed_) { 1127 if (retr_failed_) {
1128 next_state_ = STATE_CTRL_WRITE_CWD; 1128 next_state_ = STATE_CTRL_WRITE_CWD;
1129 } else { 1129 } else {
1130 next_state_ = STATE_CTRL_WRITE_SIZE; 1130 next_state_ = STATE_CTRL_WRITE_SIZE;
1131 } 1131 }
1132 return OK; 1132 return OK;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 if (!had_error_type[type]) { 1243 if (!had_error_type[type]) {
1244 had_error_type[type] = true; 1244 had_error_type[type] = true;
1245 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", 1245 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened",
1246 type, NUM_OF_NET_ERROR_TYPES); 1246 type, NUM_OF_NET_ERROR_TYPES);
1247 } 1247 }
1248 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", 1248 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount",
1249 type, NUM_OF_NET_ERROR_TYPES); 1249 type, NUM_OF_NET_ERROR_TYPES);
1250 } 1250 }
1251 1251
1252 } // namespace net 1252 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_network_transaction.h ('k') | net/ftp/ftp_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698