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

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: Fix tests Created 6 years, 5 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
Index: net/base/net_errors.cc
diff --git a/net/base/net_errors.cc b/net/base/net_errors.cc
index a9d1443c913003615f2d4742deb06ecc6bf8d512..59c3d1f299732475bf32d05c3700c7c72be2f165 100644
--- a/net/base/net_errors.cc
+++ b/net/base/net_errors.cc
@@ -24,19 +24,35 @@ namespace net {
const char kErrorDomain[] = "net";
-const char* ErrorToString(int 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>";
+ return "<unknown>";
eroman 2014/08/05 22:54:51 Should this be prefixed with ERR_ too?
mmenke 2014/08/06 16:40:56 Done. I did that initially, but it looks kinda we
}
+ return std::string("ERR_").append(error_string);
eroman 2014/08/05 22:54:50 nit: below you use operator+ to concatenate string
mmenke 2014/08/06 16:40:56 Done.
+}
+
+std::string ErrorToString(int error) {
+ return "net::" + ErrorToShortString(error);
+}
+
+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) ||
eroman 2014/08/05 22:54:50 I presume this is unchanged, did not review.
mmenke 2014/08/06 16:40:56 Correct. I just moved it, since it was incorrectl
+ (error == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN);
}
std::vector<int> GetAllErrorCodesForUma() {
« net/base/net_errors.h ('K') | « 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