| OLD | NEW |
| 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 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // Helper for ParseCertificateDate. |*field| must contain at least | 17 // Helper for ParseCertificateDate. |*field| must contain at least |
| 18 // |field_len| characters. |*field| will be advanced by |field_len| on exit. | 18 // |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 | 19 // |*ok| is set to false if there is an error in parsing the number, but left |
| 20 // untouched otherwise. Returns the parsed integer. | 20 // untouched otherwise. Returns the parsed integer. |
| 21 int ParseIntAndAdvance(const char** field, size_t field_len, bool* ok) { | 21 int ParseIntAndAdvance(const char** field, size_t field_len, bool* ok) { |
| 22 int result = 0; | 22 int result = 0; |
| 23 *ok &= base::StringToInt(*field, *field + field_len, &result); | 23 *ok &= base::StringToInt(base::StringPiece(*field, field_len), &result); |
| 24 *field += field_len; | 24 *field += field_len; |
| 25 return result; | 25 return result; |
| 26 } | 26 } |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 CertPrincipal::CertPrincipal() { | 30 CertPrincipal::CertPrincipal() { |
| 31 } | 31 } |
| 32 | 32 |
| 33 CertPrincipal::CertPrincipal(const std::string& name) : common_name(name) {} | 33 CertPrincipal::CertPrincipal(const std::string& name) : common_name(name) {} |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 valid &= exploded.HasValidValues(); | 117 valid &= exploded.HasValidValues(); |
| 118 | 118 |
| 119 if (!valid) | 119 if (!valid) |
| 120 return false; | 120 return false; |
| 121 | 121 |
| 122 *time = base::Time::FromUTCExploded(exploded); | 122 *time = base::Time::FromUTCExploded(exploded); |
| 123 return true; | 123 return true; |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace net | 126 } // namespace net |
| OLD | NEW |