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

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

Issue 2481923002: [WIP] make GURL::path() return a StringPiece (Closed)
Patch Set: thanks asan Created 4 years, 1 month 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
« no previous file with comments | « net/cookies/canonical_cookie.cc ('k') | net/http/http_auth_controller.cc » ('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) 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 NetLog::StringCallback("command", &command_for_log)); 468 NetLog::StringCallback("command", &command_for_log));
469 469
470 next_state_ = STATE_CTRL_WRITE; 470 next_state_ = STATE_CTRL_WRITE;
471 return OK; 471 return OK;
472 } 472 }
473 473
474 std::string FtpNetworkTransaction::GetRequestPathForFtpCommand( 474 std::string FtpNetworkTransaction::GetRequestPathForFtpCommand(
475 bool is_directory) const { 475 bool is_directory) const {
476 std::string path(current_remote_directory_); 476 std::string path(current_remote_directory_);
477 if (request_->url.has_path()) { 477 if (request_->url.has_path()) {
478 std::string gurl_path(request_->url.path()); 478 std::string gurl_path(request_->url.path().as_string());
479 479
480 // Get rid of the typecode, see RFC 1738 section 3.2.2. FTP url-path. 480 // Get rid of the typecode, see RFC 1738 section 3.2.2. FTP url-path.
481 std::string::size_type pos = gurl_path.rfind(';'); 481 std::string::size_type pos = gurl_path.rfind(';');
482 if (pos != std::string::npos) 482 if (pos != std::string::npos)
483 gurl_path.resize(pos); 483 gurl_path.resize(pos);
484 484
485 path.append(gurl_path); 485 path.append(gurl_path);
486 } 486 }
487 // Make sure that if the path is expected to be a file, it won't end 487 // Make sure that if the path is expected to be a file, it won't end
488 // with a trailing slash. 488 // with a trailing slash.
(...skipping 13 matching lines...) Expand all
502 path = FtpUtil::UnixFilePathToVMS(path); 502 path = FtpUtil::UnixFilePathToVMS(path);
503 } 503 }
504 504
505 DCHECK(IsValidFTPCommandString(path)); 505 DCHECK(IsValidFTPCommandString(path));
506 return path; 506 return path;
507 } 507 }
508 508
509 void FtpNetworkTransaction::DetectTypecode() { 509 void FtpNetworkTransaction::DetectTypecode() {
510 if (!request_->url.has_path()) 510 if (!request_->url.has_path())
511 return; 511 return;
512 std::string gurl_path(request_->url.path()); 512 std::string gurl_path(request_->url.path().as_string());
513 513
514 // Extract the typecode, see RFC 1738 section 3.2.2. FTP url-path. 514 // Extract the typecode, see RFC 1738 section 3.2.2. FTP url-path.
515 std::string::size_type pos = gurl_path.rfind(';'); 515 std::string::size_type pos = gurl_path.rfind(';');
516 if (pos == std::string::npos) 516 if (pos == std::string::npos)
517 return; 517 return;
518 std::string typecode_string(gurl_path.substr(pos)); 518 std::string typecode_string(gurl_path.substr(pos));
519 if (typecode_string == ";type=a") { 519 if (typecode_string == ";type=a") {
520 data_type_ = DATA_TYPE_ASCII; 520 data_type_ = DATA_TYPE_ASCII;
521 resource_type_ = RESOURCE_TYPE_FILE; 521 resource_type_ = RESOURCE_TYPE_FILE;
522 } else if (typecode_string == ";type=i") { 522 } else if (typecode_string == ";type=i") {
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 if (!had_error_type[type]) { 1372 if (!had_error_type[type]) {
1373 had_error_type[type] = true; 1373 had_error_type[type] = true;
1374 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", 1374 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened",
1375 type, NUM_OF_NET_ERROR_TYPES); 1375 type, NUM_OF_NET_ERROR_TYPES);
1376 } 1376 }
1377 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", 1377 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount",
1378 type, NUM_OF_NET_ERROR_TYPES); 1378 type, NUM_OF_NET_ERROR_TYPES);
1379 } 1379 }
1380 1380
1381 } // namespace net 1381 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/canonical_cookie.cc ('k') | net/http/http_auth_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698