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

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

Issue 8921006: Standardize StringToInt{,64} interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix call syntax of StringToInt() in Chrome OS code. Created 9 years 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/base/x509_cert_types.cc ('k') | net/ftp/ftp_util.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) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // source code is governed by a BSD-style license that can be found in the 2 // Use of this source code is governed by a BSD-style license that can be
3 // LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/ftp/ftp_ctrl_response_buffer.h" 5 #include "net/ftp/ftp_ctrl_response_buffer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_piece.h"
9 //#include "base/string_util.h" 10 //#include "base/string_util.h"
10 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
11 12
12 namespace net { 13 namespace net {
13 14
14 // static 15 // static
15 const int FtpCtrlResponse::kInvalidStatusCode = -1; 16 const int FtpCtrlResponse::kInvalidStatusCode = -1;
16 17
17 FtpCtrlResponse::FtpCtrlResponse() : status_code(kInvalidStatusCode) {} 18 FtpCtrlResponse::FtpCtrlResponse() : status_code(kInvalidStatusCode) {}
18 19
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 is_complete(false), 85 is_complete(false),
85 status_code(FtpCtrlResponse::kInvalidStatusCode) { 86 status_code(FtpCtrlResponse::kInvalidStatusCode) {
86 } 87 }
87 88
88 // static 89 // static
89 FtpCtrlResponseBuffer::ParsedLine FtpCtrlResponseBuffer::ParseLine( 90 FtpCtrlResponseBuffer::ParsedLine FtpCtrlResponseBuffer::ParseLine(
90 const std::string& line) { 91 const std::string& line) {
91 ParsedLine result; 92 ParsedLine result;
92 93
93 if (line.length() >= 3) { 94 if (line.length() >= 3) {
94 if (base::StringToInt(line.begin(), line.begin() + 3, &result.status_code)) 95 if (base::StringToInt(base::StringPiece(line.begin(), line.begin() + 3),
96 &result.status_code))
95 result.has_status_code = (100 <= result.status_code && 97 result.has_status_code = (100 <= result.status_code &&
96 result.status_code <= 599); 98 result.status_code <= 599);
97 if (result.has_status_code && line.length() >= 4 && line[3] == ' ') { 99 if (result.has_status_code && line.length() >= 4 && line[3] == ' ') {
98 result.is_complete = true; 100 result.is_complete = true;
99 } else if (result.has_status_code && line.length() >= 4 && line[3] == '-') { 101 } else if (result.has_status_code && line.length() >= 4 && line[3] == '-') {
100 result.is_complete = true; 102 result.is_complete = true;
101 result.is_multiline = true; 103 result.is_multiline = true;
102 } 104 }
103 } 105 }
104 106
(...skipping 13 matching lines...) Expand all
118 for (size_t i = 0; i < buffer_.length(); i++) { 120 for (size_t i = 0; i < buffer_.length(); i++) {
119 if (i >= 1 && buffer_[i - 1] == '\r' && buffer_[i] == '\n') { 121 if (i >= 1 && buffer_[i - 1] == '\r' && buffer_[i] == '\n') {
120 lines_.push(ParseLine(buffer_.substr(cut_pos, i - cut_pos - 1))); 122 lines_.push(ParseLine(buffer_.substr(cut_pos, i - cut_pos - 1)));
121 cut_pos = i + 1; 123 cut_pos = i + 1;
122 } 124 }
123 } 125 }
124 buffer_.erase(0, cut_pos); 126 buffer_.erase(0, cut_pos);
125 } 127 }
126 128
127 } // namespace net 129 } // namespace net
OLDNEW
« no previous file with comments | « net/base/x509_cert_types.cc ('k') | net/ftp/ftp_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698