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

Side by Side Diff: net/base/x509_cert_types.cc

Issue 8921006: Standardize StringToInt{,64} interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix namespace issues. 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
OLDNEW
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 #include "net/base/x509_cert_types.h" 5 #include "net/base/x509_cert_types.h"
6 6
7 #include "net/base/x509_certificate.h" 7 #include "net/base/x509_certificate.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 12
13 using base::StringPiece;
cbentzel 2011/12/14 18:15:03 Remove this using declaration.
14
13 namespace net { 15 namespace net {
14 16
15 namespace { 17 namespace {
16 18
17 // Helper for ParseCertificateDate. |*field| must contain at least 19 // Helper for ParseCertificateDate. |*field| must contain at least
18 // |field_len| characters. |*field| will be advanced by |field_len| on exit. 20 // |field_len| characters. |*field| will be advanced by |field_len| on exit.
19 // |*ok| is set to false if there is an error in parsing the number, but left 21 // |*ok| is set to false if there is an error in parsing the number, but left
20 // untouched otherwise. Returns the parsed integer. 22 // untouched otherwise. Returns the parsed integer.
21 int ParseIntAndAdvance(const char** field, size_t field_len, bool* ok) { 23 int ParseIntAndAdvance(const char** field, size_t field_len, bool* ok) {
22 int result = 0; 24 int result = 0;
23 *ok &= base::StringToInt(*field, *field + field_len, &result); 25 *ok &= base::StringToInt(StringPiece(*field, field_len), &result);
24 *field += field_len; 26 *field += field_len;
25 return result; 27 return result;
26 } 28 }
27 29
28 } // namespace 30 } // namespace
29 31
30 CertPrincipal::CertPrincipal() { 32 CertPrincipal::CertPrincipal() {
31 } 33 }
32 34
33 CertPrincipal::CertPrincipal(const std::string& name) : common_name(name) {} 35 CertPrincipal::CertPrincipal(const std::string& name) : common_name(name) {}
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 valid &= exploded.HasValidValues(); 119 valid &= exploded.HasValidValues();
118 120
119 if (!valid) 121 if (!valid)
120 return false; 122 return false;
121 123
122 *time = base::Time::FromUTCExploded(exploded); 124 *time = base::Time::FromUTCExploded(exploded);
123 return true; 125 return true;
124 } 126 }
125 127
126 } // namespace net 128 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698