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

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

Issue 3968001: Update code that previously constructed strings from string iterators only to... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 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_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_util.h" 9 //#include "base/string_util.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 is_complete(false), 84 is_complete(false),
85 status_code(FtpCtrlResponse::kInvalidStatusCode) { 85 status_code(FtpCtrlResponse::kInvalidStatusCode) {
86 } 86 }
87 87
88 // static 88 // static
89 FtpCtrlResponseBuffer::ParsedLine FtpCtrlResponseBuffer::ParseLine( 89 FtpCtrlResponseBuffer::ParsedLine FtpCtrlResponseBuffer::ParseLine(
90 const std::string& line) { 90 const std::string& line) {
91 ParsedLine result; 91 ParsedLine result;
92 92
93 if (line.length() >= 3) { 93 if (line.length() >= 3) {
94 if (base::StringToInt(line.substr(0, 3), &result.status_code)) 94 if (base::StringToInt(line.begin(), line.begin() + 3, &result.status_code))
95 result.has_status_code = (100 <= result.status_code && 95 result.has_status_code = (100 <= result.status_code &&
96 result.status_code <= 599); 96 result.status_code <= 599);
97 if (result.has_status_code && line.length() >= 4 && line[3] == ' ') { 97 if (result.has_status_code && line.length() >= 4 && line[3] == ' ') {
98 result.is_complete = true; 98 result.is_complete = true;
99 } else if (result.has_status_code && line.length() >= 4 && line[3] == '-') { 99 } else if (result.has_status_code && line.length() >= 4 && line[3] == '-') {
100 result.is_complete = true; 100 result.is_complete = true;
101 result.is_multiline = true; 101 result.is_multiline = true;
102 } 102 }
103 } 103 }
104 104
(...skipping 13 matching lines...) Expand all
118 for (size_t i = 0; i < buffer_.length(); i++) { 118 for (size_t i = 0; i < buffer_.length(); i++) {
119 if (i >= 1 && buffer_[i - 1] == '\r' && buffer_[i] == '\n') { 119 if (i >= 1 && buffer_[i - 1] == '\r' && buffer_[i] == '\n') {
120 lines_.push(ParseLine(buffer_.substr(cut_pos, i - cut_pos - 1))); 120 lines_.push(ParseLine(buffer_.substr(cut_pos, i - cut_pos - 1)));
121 cut_pos = i + 1; 121 cut_pos = i + 1;
122 } 122 }
123 } 123 }
124 buffer_.erase(0, cut_pos); 124 buffer_.erase(0, cut_pos);
125 } 125 }
126 126
127 } // namespace net 127 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698