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

Side by Side Diff: chrome/common/net/x509_certificate_model.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/common/net/x509_certificate_model.h" 5 #include "chrome/common/net/x509_certificate_model.h"
6 6
7 #include <unicode/uidna.h> 7 #include <unicode/uidna.h>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 char hex_separator, 54 char hex_separator,
55 char line_separator) { 55 char line_separator) {
56 static const char kHexChars[] = "0123456789ABCDEF"; 56 static const char kHexChars[] = "0123456789ABCDEF";
57 57
58 // Each input byte creates two output hex characters + a space or newline, 58 // Each input byte creates two output hex characters + a space or newline,
59 // except for the last byte. 59 // except for the last byte.
60 std::string ret; 60 std::string ret;
61 size_t kMin = 0U; 61 size_t kMin = 0U;
62 62
63 if (!data_length) 63 if (!data_length)
64 return ""; 64 return std::string();
65 65
66 ret.reserve(std::max(kMin, data_length * 3 - 1)); 66 ret.reserve(std::max(kMin, data_length * 3 - 1));
67 67
68 for (size_t i = 0; i < data_length; ++i) { 68 for (size_t i = 0; i < data_length; ++i) {
69 unsigned char b = data[i]; 69 unsigned char b = data[i];
70 ret.push_back(kHexChars[(b >> 4) & 0xf]); 70 ret.push_back(kHexChars[(b >> 4) & 0xf]);
71 ret.push_back(kHexChars[b & 0xf]); 71 ret.push_back(kHexChars[b & 0xf]);
72 if (i + 1 < data_length) { 72 if (i + 1 < data_length) {
73 if ((i + 1) % 16 == 0) 73 if ((i + 1) % 16 == 0)
74 ret.push_back(line_separator); 74 ret.push_back(line_separator);
75 else 75 else
76 ret.push_back(hex_separator); 76 ret.push_back(hex_separator);
77 } 77 }
78 } 78 }
79 return ret; 79 return ret;
80 } 80 }
81 81
82 std::string ProcessRawBytes(const unsigned char* data, size_t data_length) { 82 std::string ProcessRawBytes(const unsigned char* data, size_t data_length) {
83 return ProcessRawBytesWithSeparators(data, data_length, ' ', '\n'); 83 return ProcessRawBytesWithSeparators(data, data_length, ' ', '\n');
84 } 84 }
85 85
86 #if defined(USE_NSS) 86 #if defined(USE_NSS)
87 std::string ProcessRawBits(const unsigned char* data, size_t data_length) { 87 std::string ProcessRawBits(const unsigned char* data, size_t data_length) {
88 return ProcessRawBytes(data, (data_length + 7) / 8); 88 return ProcessRawBytes(data, (data_length + 7) / 8);
89 } 89 }
90 #endif // USE_NSS 90 #endif // USE_NSS
91 91
92 } // x509_certificate_model 92 } // x509_certificate_model
93 93
OLDNEW
« no previous file with comments | « chrome/common/metrics/entropy_provider_unittest.cc ('k') | chrome/common/net/x509_certificate_model_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698