Chromium Code Reviews| Index: net/base/net_log_logger.cc |
| diff --git a/net/base/net_log_logger.cc b/net/base/net_log_logger.cc |
| index f6ac5dd7188c0c8e49f0eb105baa666c92264dec..fc4041d096ce44035ddbdac30ca8d90ae1c02979 100644 |
| --- a/net/base/net_log_logger.cc |
| +++ b/net/base/net_log_logger.cc |
| @@ -77,14 +77,23 @@ base::DictionaryValue* NetLogLogger::GetConstants() { |
| // enums and their symbolic names. |
| constants_dict->Set("logEventTypes", net::NetLog::GetEventTypesAsValue()); |
| + struct StringToConstantTable { |
| + const char* name; |
| + const int constant; |
| + }; |
|
mmenke
2014/09/15 14:06:08
nit: -2 indent, and blank line after struct defin
|
| // Add a dictionary with information about the relationship between CertStatus |
| // flags and their symbolic names. |
| { |
| base::DictionaryValue* dict = new base::DictionaryValue(); |
| -#define CERT_STATUS_FLAG(label, value) dict->SetInteger(#label, value); |
| +#define CERT_STATUS_FLAG(label, value) \ |
| + { #label, (value) }, |
|
mmenke
2014/09/15 14:06:08
Can these defines all fit on one row? (Except per
mmenke
2014/09/15 14:06:08
Any reason value is in parentheses here, but not e
Daniel Bratell
2014/09/15 16:11:51
I had a compiler error I thought was because of th
|
| + static const StringToConstantTable certStatusFlags[] = { |
|
mmenke
2014/09/15 14:06:08
constants should use kConstantNamingScheme
mmenke
2014/09/15 14:06:08
Don't use static: It makes this code potentially
|
| #include "net/cert/cert_status_flags_list.h" |
| + }; |
| #undef CERT_STATUS_FLAG |
|
mmenke
2014/09/15 14:06:08
optional: I think these are little more readable
Daniel Bratell
2014/09/15 16:11:51
Good suggestion! It did make it more readable!
|
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(certStatusFlags); i++) |
| + dict->SetInteger(certStatusFlags[i].name, certStatusFlags[i].constant); |
| constants_dict->Set("certStatusFlag", dict); |
| } |
| @@ -95,9 +104,13 @@ base::DictionaryValue* NetLogLogger::GetConstants() { |
| base::DictionaryValue* dict = new base::DictionaryValue(); |
| #define LOAD_FLAG(label, value) \ |
| - dict->SetInteger(# label, static_cast<int>(value)); |
| + { #label, value }, |
| + static const StringToConstantTable loadFlags[] = { |
| #include "net/base/load_flags_list.h" |
| + }; // End loadFlags. |
| #undef LOAD_FLAG |
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(loadFlags); i++) |
|
mmenke
2014/09/15 14:06:08
Looks like we aren't including the header for ARRA
|
| + dict->SetInteger(loadFlags[i].name, loadFlags[i].constant); |
| constants_dict->Set("loadFlag", dict); |
| } |
| @@ -108,9 +121,13 @@ base::DictionaryValue* NetLogLogger::GetConstants() { |
| base::DictionaryValue* dict = new base::DictionaryValue(); |
| #define LOAD_STATE(label) \ |
| - dict->SetInteger(# label, net::LOAD_STATE_ ## label); |
| + { # label, net::LOAD_STATE_ ## label }, |
|
mmenke
2014/09/15 14:06:08
Believe this should use a 2-space indent, like the
mmenke
2014/09/15 14:37:41
Sorry, that should have been 4-space indent.
|
| + static const StringToConstantTable loadStateTable[] = { |
| #include "net/base/load_states_list.h" |
| + }; // End loadStateTable. |
|
mmenke
2014/09/15 14:06:08
optional nit: I don't think this comment adds any
|
| #undef LOAD_STATE |
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(loadStateTable); i++) |
| + dict->SetInteger(loadStateTable[i].name, loadStateTable[i].constant); |
| constants_dict->Set("loadState", dict); |
| } |
| @@ -120,10 +137,13 @@ base::DictionaryValue* NetLogLogger::GetConstants() { |
| { |
| base::DictionaryValue* dict = new base::DictionaryValue(); |
| -#define NET_ERROR(label, value) \ |
| - dict->SetInteger(ErrorToShortString(value), static_cast<int>(value)); |
| +#define NET_ERROR(label, value) value, |
| + static const int errorList[] = { |
| #include "net/base/net_error_list.h" |
| + }; // end errorList. |
| #undef NET_ERROR |
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(errorList); i++) |
| + dict->SetInteger(ErrorToShortString(errorList[i]), errorList[i]); |
| constants_dict->Set("netError", dict); |
| } |