Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/log/net_log_util.h" | 5 #include "net/log/net_log_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 | 151 |
| 152 // Add a dictionary with information on the relationship between event type | 152 // Add a dictionary with information on the relationship between event type |
| 153 // enums and their symbolic names. | 153 // enums and their symbolic names. |
| 154 constants_dict->Set("logEventTypes", NetLog::GetEventTypesAsValue()); | 154 constants_dict->Set("logEventTypes", NetLog::GetEventTypesAsValue()); |
| 155 | 155 |
| 156 // Add a dictionary with information about the relationship between CertStatus | 156 // Add a dictionary with information about the relationship between CertStatus |
| 157 // flags and their symbolic names. | 157 // flags and their symbolic names. |
| 158 { | 158 { |
| 159 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 159 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 160 | 160 |
| 161 for (size_t i = 0; i < arraysize(kCertStatusFlags); i++) | 161 for (StringToConstant flag : kCertStatusFlags) { |
|
eroman
2016/11/03 14:39:43
Please use:
for (const auto& flag : kCertStatus
| |
| 162 dict->SetInteger(kCertStatusFlags[i].name, kCertStatusFlags[i].constant); | 162 dict->SetInteger(flag.name, flag.constant); |
| 163 } | |
| 163 | 164 |
| 164 constants_dict->Set("certStatusFlag", std::move(dict)); | 165 constants_dict->Set("certStatusFlag", std::move(dict)); |
| 165 } | 166 } |
| 166 | 167 |
| 167 // Add a dictionary with information about the relationship between load flag | 168 // Add a dictionary with information about the relationship between load flag |
| 168 // enums and their symbolic names. | 169 // enums and their symbolic names. |
| 169 { | 170 { |
| 170 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 171 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 171 | 172 |
| 172 for (size_t i = 0; i < arraysize(kLoadFlags); i++) | 173 for (StringToConstant flag : kLoadFlags) { |
| 173 dict->SetInteger(kLoadFlags[i].name, kLoadFlags[i].constant); | 174 dict->SetInteger(flag.name, flag.constant); |
| 175 } | |
| 174 | 176 |
| 175 constants_dict->Set("loadFlag", std::move(dict)); | 177 constants_dict->Set("loadFlag", std::move(dict)); |
| 176 } | 178 } |
| 177 | 179 |
| 178 // Add a dictionary with information about the relationship between load state | 180 // Add a dictionary with information about the relationship between load state |
| 179 // enums and their symbolic names. | 181 // enums and their symbolic names. |
| 180 { | 182 { |
| 181 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 183 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 182 | 184 |
| 183 for (size_t i = 0; i < arraysize(kLoadStateTable); i++) | 185 for (StringToConstant flag : kLoadStateTable) { |
| 184 dict->SetInteger(kLoadStateTable[i].name, kLoadStateTable[i].constant); | 186 dict->SetInteger(flag.name, flag.constant); |
| 187 } | |
| 185 | 188 |
| 186 constants_dict->Set("loadState", std::move(dict)); | 189 constants_dict->Set("loadState", std::move(dict)); |
| 187 } | 190 } |
| 188 | 191 |
| 189 { | 192 { |
| 190 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 193 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 191 #define NET_INFO_SOURCE(label, string, value) \ | 194 #define NET_INFO_SOURCE(label, string, value) \ |
| 192 dict->SetInteger(string, NET_INFO_##label); | 195 dict->SetInteger(string, NET_INFO_##label); |
| 193 #include "net/base/net_info_source_list.h" | 196 #include "net/base/net_info_source_list.h" |
| 194 #undef NET_INFO_SOURCE | 197 #undef NET_INFO_SOURCE |
| 195 constants_dict->Set("netInfoSources", std::move(dict)); | 198 constants_dict->Set("netInfoSources", std::move(dict)); |
| 196 } | 199 } |
| 197 | 200 |
| 198 // Add information on the relationship between net error codes and their | 201 // Add information on the relationship between net error codes and their |
| 199 // symbolic names. | 202 // symbolic names. |
| 200 { | 203 { |
| 201 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 204 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 202 | 205 |
| 203 for (size_t i = 0; i < arraysize(kNetErrors); i++) | 206 for (short error : kNetErrors) { |
|
eroman
2016/11/03 14:39:43
(Side-note: kNetErrors should probably be defined
| |
| 204 dict->SetInteger(ErrorToShortString(kNetErrors[i]), kNetErrors[i]); | 207 dict->SetInteger(ErrorToShortString(error), error); |
| 208 } | |
| 205 | 209 |
| 206 constants_dict->Set("netError", std::move(dict)); | 210 constants_dict->Set("netError", std::move(dict)); |
| 207 } | 211 } |
| 208 | 212 |
| 209 // Add information on the relationship between QUIC error codes and their | 213 // Add information on the relationship between QUIC error codes and their |
| 210 // symbolic names. | 214 // symbolic names. |
| 211 { | 215 { |
| 212 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 216 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 213 | 217 |
| 214 for (QuicErrorCode error = QUIC_NO_ERROR; error < QUIC_LAST_ERROR; | 218 for (QuicErrorCode error = QUIC_NO_ERROR; error < QUIC_LAST_ERROR; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 233 } | 237 } |
| 234 | 238 |
| 235 constants_dict->Set("quicRstStreamError", std::move(dict)); | 239 constants_dict->Set("quicRstStreamError", std::move(dict)); |
| 236 } | 240 } |
| 237 | 241 |
| 238 // Add information on the relationship between SDCH problem codes and their | 242 // Add information on the relationship between SDCH problem codes and their |
| 239 // symbolic names. | 243 // symbolic names. |
| 240 { | 244 { |
| 241 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 245 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 242 | 246 |
| 243 for (size_t i = 0; i < arraysize(kSdchProblems); i++) | 247 for (StringToConstant problem : kSdchProblems) { |
| 244 dict->SetInteger(kSdchProblems[i].name, kSdchProblems[i].constant); | 248 dict->SetInteger(problem.name, problem.constant); |
| 249 } | |
| 245 | 250 |
| 246 constants_dict->Set("sdchProblemCode", std::move(dict)); | 251 constants_dict->Set("sdchProblemCode", std::move(dict)); |
| 247 } | 252 } |
| 248 | 253 |
| 249 // Information about the relationship between event phase enums and their | 254 // Information about the relationship between event phase enums and their |
| 250 // symbolic names. | 255 // symbolic names. |
| 251 { | 256 { |
| 252 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 257 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 253 | 258 |
| 254 dict->SetInteger("PHASE_BEGIN", static_cast<int>(NetLogEventPhase::BEGIN)); | 259 dict->SetInteger("PHASE_BEGIN", static_cast<int>(NetLogEventPhase::BEGIN)); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 // fine, since GetRequestStateAsValue() ignores the capture mode. | 535 // fine, since GetRequestStateAsValue() ignores the capture mode. |
| 531 NetLogEntryData entry_data( | 536 NetLogEntryData entry_data( |
| 532 NetLogEventType::REQUEST_ALIVE, request->net_log().source(), | 537 NetLogEventType::REQUEST_ALIVE, request->net_log().source(), |
| 533 NetLogEventPhase::BEGIN, request->creation_time(), &callback); | 538 NetLogEventPhase::BEGIN, request->creation_time(), &callback); |
| 534 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default()); | 539 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default()); |
| 535 observer->OnAddEntry(entry); | 540 observer->OnAddEntry(entry); |
| 536 } | 541 } |
| 537 } | 542 } |
| 538 | 543 |
| 539 } // namespace net | 544 } // namespace net |
| OLD | NEW |