Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/net_log_logger.h" | 5 #include "net/base/net_log_logger.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 base::DictionaryValue* NetLogLogger::GetConstants() { | 70 base::DictionaryValue* NetLogLogger::GetConstants() { |
| 71 base::DictionaryValue* constants_dict = new base::DictionaryValue(); | 71 base::DictionaryValue* constants_dict = new base::DictionaryValue(); |
| 72 | 72 |
| 73 // Version of the file format. | 73 // Version of the file format. |
| 74 constants_dict->SetInteger("logFormatVersion", kLogFormatVersion); | 74 constants_dict->SetInteger("logFormatVersion", kLogFormatVersion); |
| 75 | 75 |
| 76 // Add a dictionary with information on the relationship between event type | 76 // Add a dictionary with information on the relationship between event type |
| 77 // enums and their symbolic names. | 77 // enums and their symbolic names. |
| 78 constants_dict->Set("logEventTypes", net::NetLog::GetEventTypesAsValue()); | 78 constants_dict->Set("logEventTypes", net::NetLog::GetEventTypesAsValue()); |
| 79 | 79 |
| 80 struct StringToConstantTable { | |
| 81 const char* name; | |
| 82 const int constant; | |
| 83 }; | |
|
mmenke
2014/09/15 14:06:08
nit: -2 indent, and blank line after struct defin
| |
| 80 // Add a dictionary with information about the relationship between CertStatus | 84 // Add a dictionary with information about the relationship between CertStatus |
| 81 // flags and their symbolic names. | 85 // flags and their symbolic names. |
| 82 { | 86 { |
| 83 base::DictionaryValue* dict = new base::DictionaryValue(); | 87 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 84 | 88 |
| 85 #define CERT_STATUS_FLAG(label, value) dict->SetInteger(#label, value); | 89 #define CERT_STATUS_FLAG(label, value) \ |
| 90 { #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
| |
| 91 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
| |
| 86 #include "net/cert/cert_status_flags_list.h" | 92 #include "net/cert/cert_status_flags_list.h" |
| 93 }; | |
| 87 #undef CERT_STATUS_FLAG | 94 #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!
| |
| 95 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(certStatusFlags); i++) | |
| 96 dict->SetInteger(certStatusFlags[i].name, certStatusFlags[i].constant); | |
| 88 | 97 |
| 89 constants_dict->Set("certStatusFlag", dict); | 98 constants_dict->Set("certStatusFlag", dict); |
| 90 } | 99 } |
| 91 | 100 |
| 92 // Add a dictionary with information about the relationship between load flag | 101 // Add a dictionary with information about the relationship between load flag |
| 93 // enums and their symbolic names. | 102 // enums and their symbolic names. |
| 94 { | 103 { |
| 95 base::DictionaryValue* dict = new base::DictionaryValue(); | 104 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 96 | 105 |
| 97 #define LOAD_FLAG(label, value) \ | 106 #define LOAD_FLAG(label, value) \ |
| 98 dict->SetInteger(# label, static_cast<int>(value)); | 107 { #label, value }, |
| 108 static const StringToConstantTable loadFlags[] = { | |
| 99 #include "net/base/load_flags_list.h" | 109 #include "net/base/load_flags_list.h" |
| 110 }; // End loadFlags. | |
| 100 #undef LOAD_FLAG | 111 #undef LOAD_FLAG |
| 112 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
| |
| 113 dict->SetInteger(loadFlags[i].name, loadFlags[i].constant); | |
| 101 | 114 |
| 102 constants_dict->Set("loadFlag", dict); | 115 constants_dict->Set("loadFlag", dict); |
| 103 } | 116 } |
| 104 | 117 |
| 105 // Add a dictionary with information about the relationship between load state | 118 // Add a dictionary with information about the relationship between load state |
| 106 // enums and their symbolic names. | 119 // enums and their symbolic names. |
| 107 { | 120 { |
| 108 base::DictionaryValue* dict = new base::DictionaryValue(); | 121 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 109 | 122 |
| 110 #define LOAD_STATE(label) \ | 123 #define LOAD_STATE(label) \ |
| 111 dict->SetInteger(# label, net::LOAD_STATE_ ## label); | 124 { # 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.
| |
| 125 static const StringToConstantTable loadStateTable[] = { | |
| 112 #include "net/base/load_states_list.h" | 126 #include "net/base/load_states_list.h" |
| 127 }; // End loadStateTable. | |
|
mmenke
2014/09/15 14:06:08
optional nit: I don't think this comment adds any
| |
| 113 #undef LOAD_STATE | 128 #undef LOAD_STATE |
| 129 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(loadStateTable); i++) | |
| 130 dict->SetInteger(loadStateTable[i].name, loadStateTable[i].constant); | |
| 114 | 131 |
| 115 constants_dict->Set("loadState", dict); | 132 constants_dict->Set("loadState", dict); |
| 116 } | 133 } |
| 117 | 134 |
| 118 // Add information on the relationship between net error codes and their | 135 // Add information on the relationship between net error codes and their |
| 119 // symbolic names. | 136 // symbolic names. |
| 120 { | 137 { |
| 121 base::DictionaryValue* dict = new base::DictionaryValue(); | 138 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 122 | 139 |
| 123 #define NET_ERROR(label, value) \ | 140 #define NET_ERROR(label, value) value, |
| 124 dict->SetInteger(ErrorToShortString(value), static_cast<int>(value)); | 141 static const int errorList[] = { |
| 125 #include "net/base/net_error_list.h" | 142 #include "net/base/net_error_list.h" |
| 143 }; // end errorList. | |
| 126 #undef NET_ERROR | 144 #undef NET_ERROR |
| 145 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(errorList); i++) | |
| 146 dict->SetInteger(ErrorToShortString(errorList[i]), errorList[i]); | |
| 127 | 147 |
| 128 constants_dict->Set("netError", dict); | 148 constants_dict->Set("netError", dict); |
| 129 } | 149 } |
| 130 | 150 |
| 131 // Add information on the relationship between QUIC error codes and their | 151 // Add information on the relationship between QUIC error codes and their |
| 132 // symbolic names. | 152 // symbolic names. |
| 133 { | 153 { |
| 134 base::DictionaryValue* dict = new base::DictionaryValue(); | 154 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 135 | 155 |
| 136 for (net::QuicErrorCode error = net::QUIC_NO_ERROR; | 156 for (net::QuicErrorCode error = net::QUIC_NO_ERROR; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 } | 247 } |
| 228 | 248 |
| 229 // "clientInfo" key is required for some NetLogLogger log readers. | 249 // "clientInfo" key is required for some NetLogLogger log readers. |
| 230 // Provide a default empty value for compatibility. | 250 // Provide a default empty value for compatibility. |
| 231 constants_dict->Set("clientInfo", new base::DictionaryValue()); | 251 constants_dict->Set("clientInfo", new base::DictionaryValue()); |
| 232 | 252 |
| 233 return constants_dict; | 253 return constants_dict; |
| 234 } | 254 } |
| 235 | 255 |
| 236 } // namespace net | 256 } // namespace net |
| OLD | NEW |