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

Side by Side Diff: net/log/net_log_util.cc

Issue 2470273003: Replace for each loop (Closed)
Patch Set: Replace for each loop with const auto& Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 (const auto& flag : kCertStatusFlags)
162 dict->SetInteger(kCertStatusFlags[i].name, kCertStatusFlags[i].constant); 162 dict->SetInteger(flag.name, flag.constant);
163 163
164 constants_dict->Set("certStatusFlag", std::move(dict)); 164 constants_dict->Set("certStatusFlag", std::move(dict));
165 } 165 }
166 166
167 // Add a dictionary with information about the relationship between load flag 167 // Add a dictionary with information about the relationship between load flag
168 // enums and their symbolic names. 168 // enums and their symbolic names.
169 { 169 {
170 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 170 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
171 171
172 for (size_t i = 0; i < arraysize(kLoadFlags); i++) 172 for (const auto& flag : kLoadFlags)
173 dict->SetInteger(kLoadFlags[i].name, kLoadFlags[i].constant); 173 dict->SetInteger(flag.name, flag.constant);
174 174
175 constants_dict->Set("loadFlag", std::move(dict)); 175 constants_dict->Set("loadFlag", std::move(dict));
176 } 176 }
177 177
178 // Add a dictionary with information about the relationship between load state 178 // Add a dictionary with information about the relationship between load state
179 // enums and their symbolic names. 179 // enums and their symbolic names.
180 { 180 {
181 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 181 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
182 182
183 for (size_t i = 0; i < arraysize(kLoadStateTable); i++) 183 for (const auto& state : kLoadStateTable)
184 dict->SetInteger(kLoadStateTable[i].name, kLoadStateTable[i].constant); 184 dict->SetInteger(state.name, state.constant);
185 185
186 constants_dict->Set("loadState", std::move(dict)); 186 constants_dict->Set("loadState", std::move(dict));
187 } 187 }
188 188
189 { 189 {
190 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 190 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
191 #define NET_INFO_SOURCE(label, string, value) \ 191 #define NET_INFO_SOURCE(label, string, value) \
192 dict->SetInteger(string, NET_INFO_##label); 192 dict->SetInteger(string, NET_INFO_##label);
193 #include "net/base/net_info_source_list.h" 193 #include "net/base/net_info_source_list.h"
194 #undef NET_INFO_SOURCE 194 #undef NET_INFO_SOURCE
195 constants_dict->Set("netInfoSources", std::move(dict)); 195 constants_dict->Set("netInfoSources", std::move(dict));
196 } 196 }
197 197
198 // Add information on the relationship between net error codes and their 198 // Add information on the relationship between net error codes and their
199 // symbolic names. 199 // symbolic names.
200 { 200 {
201 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 201 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
202 202
203 for (size_t i = 0; i < arraysize(kNetErrors); i++) 203 for (const auto& error : kNetErrors)
204 dict->SetInteger(ErrorToShortString(kNetErrors[i]), kNetErrors[i]); 204 dict->SetInteger(ErrorToShortString(error), error);
205 205
206 constants_dict->Set("netError", std::move(dict)); 206 constants_dict->Set("netError", std::move(dict));
207 } 207 }
208 208
209 // Add information on the relationship between QUIC error codes and their 209 // Add information on the relationship between QUIC error codes and their
210 // symbolic names. 210 // symbolic names.
211 { 211 {
212 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 212 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
213 213
214 for (QuicErrorCode error = QUIC_NO_ERROR; error < QUIC_LAST_ERROR; 214 for (QuicErrorCode error = QUIC_NO_ERROR; error < QUIC_LAST_ERROR;
(...skipping 18 matching lines...) Expand all
233 } 233 }
234 234
235 constants_dict->Set("quicRstStreamError", std::move(dict)); 235 constants_dict->Set("quicRstStreamError", std::move(dict));
236 } 236 }
237 237
238 // Add information on the relationship between SDCH problem codes and their 238 // Add information on the relationship between SDCH problem codes and their
239 // symbolic names. 239 // symbolic names.
240 { 240 {
241 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 241 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
242 242
243 for (size_t i = 0; i < arraysize(kSdchProblems); i++) 243 for (const auto& problem : kSdchProblems)
244 dict->SetInteger(kSdchProblems[i].name, kSdchProblems[i].constant); 244 dict->SetInteger(problem.name, problem.constant);
245 245
246 constants_dict->Set("sdchProblemCode", std::move(dict)); 246 constants_dict->Set("sdchProblemCode", std::move(dict));
247 } 247 }
248 248
249 // Information about the relationship between event phase enums and their 249 // Information about the relationship between event phase enums and their
250 // symbolic names. 250 // symbolic names.
251 { 251 {
252 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 252 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
253 253
254 dict->SetInteger("PHASE_BEGIN", static_cast<int>(NetLogEventPhase::BEGIN)); 254 dict->SetInteger("PHASE_BEGIN", static_cast<int>(NetLogEventPhase::BEGIN));
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // fine, since GetRequestStateAsValue() ignores the capture mode. 530 // fine, since GetRequestStateAsValue() ignores the capture mode.
531 NetLogEntryData entry_data( 531 NetLogEntryData entry_data(
532 NetLogEventType::REQUEST_ALIVE, request->net_log().source(), 532 NetLogEventType::REQUEST_ALIVE, request->net_log().source(),
533 NetLogEventPhase::BEGIN, request->creation_time(), &callback); 533 NetLogEventPhase::BEGIN, request->creation_time(), &callback);
534 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default()); 534 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default());
535 observer->OnAddEntry(entry); 535 observer->OnAddEntry(entry);
536 } 536 }
537 } 537 }
538 538
539 } // namespace net 539 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698