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

Side by Side Diff: net/http/http_chunked_decoder.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/ftp/ftp_util.cc ('k') | net/http/http_response_headers.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // Derived from: 5 // Derived from:
6 // mozilla/netwerk/protocol/http/src/nsHttpChunkedDecoder.cpp 6 // mozilla/netwerk/protocol/http/src/nsHttpChunkedDecoder.cpp
7 // The license block is: 7 // The license block is:
8 /* ***** BEGIN LICENSE BLOCK ***** 8 /* ***** BEGIN LICENSE BLOCK *****
9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
10 * 10 *
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Us: ^\X+[ ]*$ 180 // Us: ^\X+[ ]*$
181 bool HttpChunkedDecoder::ParseChunkSize(const char* start, int len, int* out) { 181 bool HttpChunkedDecoder::ParseChunkSize(const char* start, int len, int* out) {
182 DCHECK(len >= 0); 182 DCHECK(len >= 0);
183 183
184 // Strip trailing spaces 184 // Strip trailing spaces
185 while (len && start[len - 1] == ' ') 185 while (len && start[len - 1] == ' ')
186 len--; 186 len--;
187 187
188 // Be more restrictive than HexStringToInt; 188 // Be more restrictive than HexStringToInt;
189 // don't allow inputs with leading "-", "+", "0x", "0X" 189 // don't allow inputs with leading "-", "+", "0x", "0X"
190 if (base::StringPiece(start, len).find_first_not_of("0123456789abcdefABCDEF") 190 base::StringPiece chunk_size(start, len);
191 != base::StringPiece::npos) 191 if (chunk_size.find_first_not_of("0123456789abcdefABCDEF")
192 != base::StringPiece::npos) {
192 return false; 193 return false;
194 }
193 195
194 int parsed_number; 196 int parsed_number;
195 bool ok = base::HexStringToInt(start, start + len, &parsed_number); 197 bool ok = base::HexStringToInt(chunk_size, &parsed_number);
196 if (ok && parsed_number >= 0) { 198 if (ok && parsed_number >= 0) {
197 *out = parsed_number; 199 *out = parsed_number;
198 return true; 200 return true;
199 } 201 }
200 return false; 202 return false;
201 } 203 }
202 204
203 } // namespace net 205 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_util.cc ('k') | net/http/http_response_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698