Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 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_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 break; | 410 break; |
| 411 case COMMAND_QUIT: | 411 case COMMAND_QUIT: |
| 412 rv = ProcessResponseQUIT(response); | 412 rv = ProcessResponseQUIT(response); |
| 413 break; | 413 break; |
| 414 default: | 414 default: |
| 415 LOG(DFATAL) << "Unexpected value of command_sent_: " << command_sent_; | 415 LOG(DFATAL) << "Unexpected value of command_sent_: " << command_sent_; |
| 416 return ERR_UNEXPECTED; | 416 return ERR_UNEXPECTED; |
| 417 } | 417 } |
| 418 | 418 |
| 419 // We may get multiple responses for some commands, | 419 // We may get multiple responses for some commands, |
| 420 // see http://crbug.com/18036. | 420 // see http://crbug.com/18036. Consume all responses, regardless of whether |
| 421 // they make sense. On unexpected responses, SendFtpCommand expects all data | |
| 422 // to have already been consumed, even when sending the QUIT command. | |
|
mmenke
2016/11/28 17:28:22
Another option would be to skip that DCHECK in cas
| |
| 421 while (ctrl_response_buffer_->ResponseAvailable() && rv == OK) { | 423 while (ctrl_response_buffer_->ResponseAvailable() && rv == OK) { |
| 422 response = ctrl_response_buffer_->PopResponse(); | 424 response = ctrl_response_buffer_->PopResponse(); |
| 423 | 425 |
| 424 switch (command_sent_) { | 426 switch (command_sent_) { |
| 425 case COMMAND_RETR: | 427 case COMMAND_RETR: |
| 426 rv = ProcessResponseRETR(response); | 428 rv = ProcessResponseRETR(response); |
| 427 break; | 429 break; |
| 428 case COMMAND_LIST: | 430 case COMMAND_LIST: |
| 429 rv = ProcessResponseLIST(response); | 431 rv = ProcessResponseLIST(response); |
| 430 break; | 432 break; |
| 431 default: | 433 default: |
| 432 // Multiple responses for other commands are invalid. | 434 // Multiple responses for other commands are invalid. |
| 433 return Stop(ERR_INVALID_RESPONSE); | 435 rv = Stop(ERR_INVALID_RESPONSE); |
|
eroman
2016/11/28 17:51:24
I am not sure I understand this code flow.
rv wil
mmenke
2016/11/28 18:21:01
Stop sets the next state to send the quit message,
| |
| 436 break; | |
| 434 } | 437 } |
| 435 } | 438 } |
| 436 | 439 |
| 437 return rv; | 440 return rv; |
| 438 } | 441 } |
| 439 | 442 |
| 440 // Used to prepare and send FTP command. | 443 // Used to prepare and send FTP command. |
| 441 int FtpNetworkTransaction::SendFtpCommand(const std::string& command, | 444 int FtpNetworkTransaction::SendFtpCommand(const std::string& command, |
| 442 const std::string& command_for_log, | 445 const std::string& command_for_log, |
| 443 Command cmd) { | 446 Command cmd) { |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1343 if (!had_error_type[type]) { | 1346 if (!had_error_type[type]) { |
| 1344 had_error_type[type] = true; | 1347 had_error_type[type] = true; |
| 1345 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", | 1348 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", |
| 1346 type, NUM_OF_NET_ERROR_TYPES); | 1349 type, NUM_OF_NET_ERROR_TYPES); |
| 1347 } | 1350 } |
| 1348 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", | 1351 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", |
| 1349 type, NUM_OF_NET_ERROR_TYPES); | 1352 type, NUM_OF_NET_ERROR_TYPES); |
| 1350 } | 1353 } |
| 1351 | 1354 |
| 1352 } // namespace net | 1355 } // namespace net |
| OLD | NEW |