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

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

Issue 196793010: Move IsStringASCII/UTF8 to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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/dns/dns_config_service_win.cc ('k') | net/http/http_content_disposition.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.h" 10 #include "base/metrics/histogram.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // (127,0,0,1,23,21) IP address and port encapsulated in (). 145 // (127,0,0,1,23,21) IP address and port encapsulated in ().
146 // 127,0,0,1,23,21 IP address and port without (). 146 // 127,0,0,1,23,21 IP address and port without ().
147 // 147 //
148 // See RFC 959, Section 4.1.2 148 // See RFC 959, Section 4.1.2
149 bool ExtractPortFromPASVResponse(const net::FtpCtrlResponse& response, 149 bool ExtractPortFromPASVResponse(const net::FtpCtrlResponse& response,
150 int* port) { 150 int* port) {
151 if (response.lines.size() != 1) 151 if (response.lines.size() != 1)
152 return false; 152 return false;
153 153
154 std::string line(response.lines[0]); 154 std::string line(response.lines[0]);
155 if (!IsStringASCII(line)) 155 if (!base::IsStringASCII(line))
156 return false; 156 return false;
157 if (line.length() < 2) 157 if (line.length() < 2)
158 return false; 158 return false;
159 159
160 size_t paren_pos = line.find('('); 160 size_t paren_pos = line.find('(');
161 if (paren_pos == std::string::npos) { 161 if (paren_pos == std::string::npos) {
162 // Find the first comma and use it to locate the beginning 162 // Find the first comma and use it to locate the beginning
163 // of the response data. 163 // of the response data.
164 size_t comma_pos = line.find(','); 164 size_t comma_pos = line.find(',');
165 if (comma_pos == std::string::npos) 165 if (comma_pos == std::string::npos)
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 const FtpCtrlResponse& response) { 823 const FtpCtrlResponse& response) {
824 switch (GetErrorClass(response.status_code)) { 824 switch (GetErrorClass(response.status_code)) {
825 case ERROR_CLASS_INITIATED: 825 case ERROR_CLASS_INITIATED:
826 return Stop(ERR_INVALID_RESPONSE); 826 return Stop(ERR_INVALID_RESPONSE);
827 case ERROR_CLASS_OK: { 827 case ERROR_CLASS_OK: {
828 // All important info should be on the first line. 828 // All important info should be on the first line.
829 std::string line = response.lines[0]; 829 std::string line = response.lines[0];
830 // The response should be ASCII, which allows us to do case-insensitive 830 // The response should be ASCII, which allows us to do case-insensitive
831 // comparisons easily. If it is not ASCII, we leave the system type 831 // comparisons easily. If it is not ASCII, we leave the system type
832 // as unknown. 832 // as unknown.
833 if (IsStringASCII(line)) { 833 if (base::IsStringASCII(line)) {
834 line = StringToLowerASCII(line); 834 line = StringToLowerASCII(line);
835 835
836 // Remove all whitespace, to correctly handle cases like fancy "V M S" 836 // Remove all whitespace, to correctly handle cases like fancy "V M S"
837 // response instead of "VMS". 837 // response instead of "VMS".
838 base::RemoveChars(line, base::kWhitespaceASCII, &line); 838 base::RemoveChars(line, base::kWhitespaceASCII, &line);
839 839
840 // The "magic" strings we test for below have been gathered by an 840 // The "magic" strings we test for below have been gathered by an
841 // empirical study. VMS needs to come first because some VMS systems 841 // empirical study. VMS needs to come first because some VMS systems
842 // also respond with "UNIX emulation", which is not perfect. It is much 842 // also respond with "UNIX emulation", which is not perfect. It is much
843 // more reliable to talk to these servers in their native language. 843 // more reliable to talk to these servers in their native language.
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 if (!had_error_type[type]) { 1393 if (!had_error_type[type]) {
1394 had_error_type[type] = true; 1394 had_error_type[type] = true;
1395 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", 1395 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened",
1396 type, NUM_OF_NET_ERROR_TYPES); 1396 type, NUM_OF_NET_ERROR_TYPES);
1397 } 1397 }
1398 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", 1398 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount",
1399 type, NUM_OF_NET_ERROR_TYPES); 1399 type, NUM_OF_NET_ERROR_TYPES);
1400 } 1400 }
1401 1401
1402 } // namespace net 1402 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_config_service_win.cc ('k') | net/http/http_content_disposition.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698