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

Unified Diff: net/base/net_errors.cc

Issue 432553003: Remove redundant mapping of net errors to strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to comments Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/net_errors.h ('k') | net/base/net_log_logger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_errors.cc
diff --git a/net/base/net_errors.cc b/net/base/net_errors.cc
index a9d1443c913003615f2d4742deb06ecc6bf8d512..7c219afbf9015b47497ca693ad6e617f94634d7a 100644
--- a/net/base/net_errors.cc
+++ b/net/base/net_errors.cc
@@ -24,19 +24,36 @@ namespace net {
const char kErrorDomain[] = "net";
-const char* ErrorToString(int error) {
+std::string ErrorToString(int error) {
+ return "net::" + ErrorToShortString(error);
+}
+
+std::string ErrorToShortString(int error) {
if (error == 0)
- return "net::OK";
+ return "OK";
+ const char* error_string;
switch (error) {
#define NET_ERROR(label, value) \
case ERR_ ## label: \
- return "net::" STRINGIZE_NO_EXPANSION(ERR_ ## label);
+ error_string = # label; \
+ break;
#include "net/base/net_error_list.h"
#undef NET_ERROR
default:
- return "net::<unknown>";
+ NOTREACHED();
+ error_string = "<unknown>";
}
+ return std::string("ERR_") + error_string;
+}
+
+bool IsCertificateError(int error) {
+ // Certificate errors are negative integers from net::ERR_CERT_BEGIN
+ // (inclusive) to net::ERR_CERT_END (exclusive) in *decreasing* order.
+ // ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN is currently an exception to this
+ // rule.
+ return (error <= ERR_CERT_BEGIN && error > ERR_CERT_END) ||
+ (error == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN);
}
std::vector<int> GetAllErrorCodesForUma() {
« no previous file with comments | « net/base/net_errors.h ('k') | net/base/net_log_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698