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

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

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 unified diff | Download patch
« no previous file with comments | « net/log/net_log_unittest.cc ('k') | net/log/test_net_log_entry.cc » ('j') | 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 <vector> 10 #include <vector>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
14 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "base/values.h" 19 #include "base/values.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 constants_dict->Set("logEventTypes", NetLog::GetEventTypesAsValue()); 147 constants_dict->Set("logEventTypes", NetLog::GetEventTypesAsValue());
147 148
148 // Add a dictionary with information about the relationship between CertStatus 149 // Add a dictionary with information about the relationship between CertStatus
149 // flags and their symbolic names. 150 // flags and their symbolic names.
150 { 151 {
151 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 152 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
152 153
153 for (size_t i = 0; i < arraysize(kCertStatusFlags); i++) 154 for (size_t i = 0; i < arraysize(kCertStatusFlags); i++)
154 dict->SetInteger(kCertStatusFlags[i].name, kCertStatusFlags[i].constant); 155 dict->SetInteger(kCertStatusFlags[i].name, kCertStatusFlags[i].constant);
155 156
156 constants_dict->Set("certStatusFlag", dict.Pass()); 157 constants_dict->Set("certStatusFlag", std::move(dict));
157 } 158 }
158 159
159 // Add a dictionary with information about the relationship between load flag 160 // Add a dictionary with information about the relationship between load flag
160 // enums and their symbolic names. 161 // enums and their symbolic names.
161 { 162 {
162 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 163 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
163 164
164 for (size_t i = 0; i < arraysize(kLoadFlags); i++) 165 for (size_t i = 0; i < arraysize(kLoadFlags); i++)
165 dict->SetInteger(kLoadFlags[i].name, kLoadFlags[i].constant); 166 dict->SetInteger(kLoadFlags[i].name, kLoadFlags[i].constant);
166 167
167 constants_dict->Set("loadFlag", dict.Pass()); 168 constants_dict->Set("loadFlag", std::move(dict));
168 } 169 }
169 170
170 // Add a dictionary with information about the relationship between load state 171 // Add a dictionary with information about the relationship between load state
171 // enums and their symbolic names. 172 // enums and their symbolic names.
172 { 173 {
173 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 174 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
174 175
175 for (size_t i = 0; i < arraysize(kLoadStateTable); i++) 176 for (size_t i = 0; i < arraysize(kLoadStateTable); i++)
176 dict->SetInteger(kLoadStateTable[i].name, kLoadStateTable[i].constant); 177 dict->SetInteger(kLoadStateTable[i].name, kLoadStateTable[i].constant);
177 178
178 constants_dict->Set("loadState", dict.Pass()); 179 constants_dict->Set("loadState", std::move(dict));
179 } 180 }
180 181
181 { 182 {
182 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 183 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
183 #define NET_INFO_SOURCE(label, string, value) \ 184 #define NET_INFO_SOURCE(label, string, value) \
184 dict->SetInteger(string, NET_INFO_##label); 185 dict->SetInteger(string, NET_INFO_##label);
185 #include "net/base/net_info_source_list.h" 186 #include "net/base/net_info_source_list.h"
186 #undef NET_INFO_SOURCE 187 #undef NET_INFO_SOURCE
187 constants_dict->Set("netInfoSources", dict.Pass()); 188 constants_dict->Set("netInfoSources", std::move(dict));
188 } 189 }
189 190
190 // Add information on the relationship between net error codes and their 191 // Add information on the relationship between net error codes and their
191 // symbolic names. 192 // symbolic names.
192 { 193 {
193 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 194 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
194 195
195 for (size_t i = 0; i < arraysize(kNetErrors); i++) 196 for (size_t i = 0; i < arraysize(kNetErrors); i++)
196 dict->SetInteger(ErrorToShortString(kNetErrors[i]), kNetErrors[i]); 197 dict->SetInteger(ErrorToShortString(kNetErrors[i]), kNetErrors[i]);
197 198
198 constants_dict->Set("netError", dict.Pass()); 199 constants_dict->Set("netError", std::move(dict));
199 } 200 }
200 201
201 // Add information on the relationship between QUIC error codes and their 202 // Add information on the relationship between QUIC error codes and their
202 // symbolic names. 203 // symbolic names.
203 { 204 {
204 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 205 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
205 206
206 for (QuicErrorCode error = QUIC_NO_ERROR; error < QUIC_LAST_ERROR; 207 for (QuicErrorCode error = QUIC_NO_ERROR; error < QUIC_LAST_ERROR;
207 error = static_cast<QuicErrorCode>(error + 1)) { 208 error = static_cast<QuicErrorCode>(error + 1)) {
208 dict->SetInteger(QuicUtils::ErrorToString(error), 209 dict->SetInteger(QuicUtils::ErrorToString(error),
209 static_cast<int>(error)); 210 static_cast<int>(error));
210 } 211 }
211 212
212 constants_dict->Set("quicError", dict.Pass()); 213 constants_dict->Set("quicError", std::move(dict));
213 } 214 }
214 215
215 // Add information on the relationship between QUIC RST_STREAM error codes 216 // Add information on the relationship between QUIC RST_STREAM error codes
216 // and their symbolic names. 217 // and their symbolic names.
217 { 218 {
218 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 219 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
219 220
220 for (QuicRstStreamErrorCode error = QUIC_STREAM_NO_ERROR; 221 for (QuicRstStreamErrorCode error = QUIC_STREAM_NO_ERROR;
221 error < QUIC_STREAM_LAST_ERROR; 222 error < QUIC_STREAM_LAST_ERROR;
222 error = static_cast<QuicRstStreamErrorCode>(error + 1)) { 223 error = static_cast<QuicRstStreamErrorCode>(error + 1)) {
223 dict->SetInteger(QuicUtils::StreamErrorToString(error), 224 dict->SetInteger(QuicUtils::StreamErrorToString(error),
224 static_cast<int>(error)); 225 static_cast<int>(error));
225 } 226 }
226 227
227 constants_dict->Set("quicRstStreamError", dict.Pass()); 228 constants_dict->Set("quicRstStreamError", std::move(dict));
228 } 229 }
229 230
230 // Add information on the relationship between SDCH problem codes and their 231 // Add information on the relationship between SDCH problem codes and their
231 // symbolic names. 232 // symbolic names.
232 { 233 {
233 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 234 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
234 235
235 for (size_t i = 0; i < arraysize(kSdchProblems); i++) 236 for (size_t i = 0; i < arraysize(kSdchProblems); i++)
236 dict->SetInteger(kSdchProblems[i].name, kSdchProblems[i].constant); 237 dict->SetInteger(kSdchProblems[i].name, kSdchProblems[i].constant);
237 238
238 constants_dict->Set("sdchProblemCode", dict.Pass()); 239 constants_dict->Set("sdchProblemCode", std::move(dict));
239 } 240 }
240 241
241 // Information about the relationship between event phase enums and their 242 // Information about the relationship between event phase enums and their
242 // symbolic names. 243 // symbolic names.
243 { 244 {
244 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 245 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
245 246
246 dict->SetInteger("PHASE_BEGIN", NetLog::PHASE_BEGIN); 247 dict->SetInteger("PHASE_BEGIN", NetLog::PHASE_BEGIN);
247 dict->SetInteger("PHASE_END", NetLog::PHASE_END); 248 dict->SetInteger("PHASE_END", NetLog::PHASE_END);
248 dict->SetInteger("PHASE_NONE", NetLog::PHASE_NONE); 249 dict->SetInteger("PHASE_NONE", NetLog::PHASE_NONE);
249 250
250 constants_dict->Set("logEventPhase", dict.Pass()); 251 constants_dict->Set("logEventPhase", std::move(dict));
251 } 252 }
252 253
253 // Information about the relationship between source type enums and 254 // Information about the relationship between source type enums and
254 // their symbolic names. 255 // their symbolic names.
255 constants_dict->Set("logSourceType", NetLog::GetSourceTypesAsValue()); 256 constants_dict->Set("logSourceType", NetLog::GetSourceTypesAsValue());
256 257
257 // TODO(eroman): This is here for compatibility in loading new log files with 258 // TODO(eroman): This is here for compatibility in loading new log files with
258 // older builds of Chrome. Safe to remove this once M45 is on the stable 259 // older builds of Chrome. Safe to remove this once M45 is on the stable
259 // channel. 260 // channel.
260 constants_dict->Set("logLevelType", new base::DictionaryValue()); 261 constants_dict->Set("logLevelType", new base::DictionaryValue());
261 262
262 // Information about the relationship between address family enums and 263 // Information about the relationship between address family enums and
263 // their symbolic names. 264 // their symbolic names.
264 { 265 {
265 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 266 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
266 267
267 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", ADDRESS_FAMILY_UNSPECIFIED); 268 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", ADDRESS_FAMILY_UNSPECIFIED);
268 dict->SetInteger("ADDRESS_FAMILY_IPV4", ADDRESS_FAMILY_IPV4); 269 dict->SetInteger("ADDRESS_FAMILY_IPV4", ADDRESS_FAMILY_IPV4);
269 dict->SetInteger("ADDRESS_FAMILY_IPV6", ADDRESS_FAMILY_IPV6); 270 dict->SetInteger("ADDRESS_FAMILY_IPV6", ADDRESS_FAMILY_IPV6);
270 271
271 constants_dict->Set("addressFamily", dict.Pass()); 272 constants_dict->Set("addressFamily", std::move(dict));
272 } 273 }
273 274
274 // Information about how the "time ticks" values we have given it relate to 275 // Information about how the "time ticks" values we have given it relate to
275 // actual system times. Time ticks are used throughout since they are stable 276 // actual system times. Time ticks are used throughout since they are stable
276 // across system clock changes. 277 // across system clock changes.
277 { 278 {
278 int64_t tick_to_unix_time_ms = 279 int64_t tick_to_unix_time_ms =
279 (base::TimeTicks() - base::TimeTicks::UnixEpoch()).InMilliseconds(); 280 (base::TimeTicks() - base::TimeTicks::UnixEpoch()).InMilliseconds();
280 281
281 // Pass it as a string, since it may be too large to fit in an integer. 282 // Pass it as a string, since it may be too large to fit in an integer.
(...skipping 11 matching lines...) Expand all
293 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups); 294 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups);
294 base::ListValue* field_trial_groups = new base::ListValue(); 295 base::ListValue* field_trial_groups = new base::ListValue();
295 for (base::FieldTrial::ActiveGroups::const_iterator it = 296 for (base::FieldTrial::ActiveGroups::const_iterator it =
296 active_groups.begin(); 297 active_groups.begin();
297 it != active_groups.end(); ++it) { 298 it != active_groups.end(); ++it) {
298 field_trial_groups->AppendString(it->trial_name + ":" + it->group_name); 299 field_trial_groups->AppendString(it->trial_name + ":" + it->group_name);
299 } 300 }
300 constants_dict->Set("activeFieldTrialGroups", field_trial_groups); 301 constants_dict->Set("activeFieldTrialGroups", field_trial_groups);
301 } 302 }
302 303
303 return constants_dict.Pass(); 304 return constants_dict;
304 } 305 }
305 306
306 NET_EXPORT scoped_ptr<base::DictionaryValue> GetNetInfo( 307 NET_EXPORT scoped_ptr<base::DictionaryValue> GetNetInfo(
307 URLRequestContext* context, 308 URLRequestContext* context,
308 int info_sources) { 309 int info_sources) {
309 // May only be called on the context's thread. 310 // May only be called on the context's thread.
310 DCHECK(context->CalledOnValidThread()); 311 DCHECK(context->CalledOnValidThread());
311 312
312 scoped_ptr<base::DictionaryValue> net_info_dict(new base::DictionaryValue()); 313 scoped_ptr<base::DictionaryValue> net_info_dict(new base::DictionaryValue());
313 314
314 // TODO(mmenke): The code for most of these sources should probably be moved 315 // TODO(mmenke): The code for most of these sources should probably be moved
315 // into the sources themselves. 316 // into the sources themselves.
316 if (info_sources & NET_INFO_PROXY_SETTINGS) { 317 if (info_sources & NET_INFO_PROXY_SETTINGS) {
317 ProxyService* proxy_service = context->proxy_service(); 318 ProxyService* proxy_service = context->proxy_service();
318 319
319 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 320 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
320 if (proxy_service->fetched_config().is_valid()) 321 if (proxy_service->fetched_config().is_valid())
321 dict->Set("original", proxy_service->fetched_config().ToValue()); 322 dict->Set("original", proxy_service->fetched_config().ToValue());
322 if (proxy_service->config().is_valid()) 323 if (proxy_service->config().is_valid())
323 dict->Set("effective", proxy_service->config().ToValue()); 324 dict->Set("effective", proxy_service->config().ToValue());
324 325
325 net_info_dict->Set(NetInfoSourceToString(NET_INFO_PROXY_SETTINGS), 326 net_info_dict->Set(NetInfoSourceToString(NET_INFO_PROXY_SETTINGS),
326 dict.Pass()); 327 std::move(dict));
327 } 328 }
328 329
329 if (info_sources & NET_INFO_BAD_PROXIES) { 330 if (info_sources & NET_INFO_BAD_PROXIES) {
330 const ProxyRetryInfoMap& bad_proxies_map = 331 const ProxyRetryInfoMap& bad_proxies_map =
331 context->proxy_service()->proxy_retry_info(); 332 context->proxy_service()->proxy_retry_info();
332 333
333 base::ListValue* list = new base::ListValue(); 334 base::ListValue* list = new base::ListValue();
334 335
335 for (ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin(); 336 for (ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin();
336 it != bad_proxies_map.end(); ++it) { 337 it != bad_proxies_map.end(); ++it) {
337 const std::string& proxy_uri = it->first; 338 const std::string& proxy_uri = it->first;
338 const ProxyRetryInfo& retry_info = it->second; 339 const ProxyRetryInfo& retry_info = it->second;
339 340
340 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 341 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
341 dict->SetString("proxy_uri", proxy_uri); 342 dict->SetString("proxy_uri", proxy_uri);
342 dict->SetString("bad_until", 343 dict->SetString("bad_until",
343 NetLog::TickCountToString(retry_info.bad_until)); 344 NetLog::TickCountToString(retry_info.bad_until));
344 345
345 list->Append(dict.Pass()); 346 list->Append(std::move(dict));
346 } 347 }
347 348
348 net_info_dict->Set(NetInfoSourceToString(NET_INFO_BAD_PROXIES), list); 349 net_info_dict->Set(NetInfoSourceToString(NET_INFO_BAD_PROXIES), list);
349 } 350 }
350 351
351 if (info_sources & NET_INFO_HOST_RESOLVER) { 352 if (info_sources & NET_INFO_HOST_RESOLVER) {
352 HostResolver* host_resolver = context->host_resolver(); 353 HostResolver* host_resolver = context->host_resolver();
353 DCHECK(host_resolver); 354 DCHECK(host_resolver);
354 HostCache* cache = host_resolver->GetHostCache(); 355 HostCache* cache = host_resolver->GetHostCache();
355 if (cache) { 356 if (cache) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 389 }
389 entry_dict->Set("addresses", address_list); 390 entry_dict->Set("addresses", address_list);
390 } 391 }
391 392
392 entry_list->Append(entry_dict); 393 entry_list->Append(entry_dict);
393 } 394 }
394 395
395 cache_info_dict->Set("entries", entry_list); 396 cache_info_dict->Set("entries", entry_list);
396 dict->Set("cache", cache_info_dict); 397 dict->Set("cache", cache_info_dict);
397 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HOST_RESOLVER), 398 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HOST_RESOLVER),
398 dict.Pass()); 399 std::move(dict));
399 } 400 }
400 } 401 }
401 402
402 HttpNetworkSession* http_network_session = 403 HttpNetworkSession* http_network_session =
403 context->http_transaction_factory()->GetSession(); 404 context->http_transaction_factory()->GetSession();
404 405
405 if (info_sources & NET_INFO_SOCKET_POOL) { 406 if (info_sources & NET_INFO_SOCKET_POOL) {
406 net_info_dict->Set(NetInfoSourceToString(NET_INFO_SOCKET_POOL), 407 net_info_dict->Set(NetInfoSourceToString(NET_INFO_SOCKET_POOL),
407 http_network_session->SocketPoolInfoToValue()); 408 http_network_session->SocketPoolInfoToValue());
408 } 409 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 } 483 }
483 484
484 if (info_sources & NET_INFO_SDCH) { 485 if (info_sources & NET_INFO_SDCH) {
485 scoped_ptr<base::Value> info_dict; 486 scoped_ptr<base::Value> info_dict;
486 SdchManager* sdch_manager = context->sdch_manager(); 487 SdchManager* sdch_manager = context->sdch_manager();
487 if (sdch_manager) { 488 if (sdch_manager) {
488 info_dict = sdch_manager->SdchInfoToValue(); 489 info_dict = sdch_manager->SdchInfoToValue();
489 } else { 490 } else {
490 info_dict.reset(new base::DictionaryValue()); 491 info_dict.reset(new base::DictionaryValue());
491 } 492 }
492 net_info_dict->Set(NetInfoSourceToString(NET_INFO_SDCH), info_dict.Pass()); 493 net_info_dict->Set(NetInfoSourceToString(NET_INFO_SDCH),
494 std::move(info_dict));
493 } 495 }
494 496
495 return net_info_dict.Pass(); 497 return net_info_dict;
496 } 498 }
497 499
498 NET_EXPORT void CreateNetLogEntriesForActiveObjects( 500 NET_EXPORT void CreateNetLogEntriesForActiveObjects(
499 const std::set<URLRequestContext*>& contexts, 501 const std::set<URLRequestContext*>& contexts,
500 NetLog::ThreadSafeObserver* observer) { 502 NetLog::ThreadSafeObserver* observer) {
501 // Put together the list of all requests. 503 // Put together the list of all requests.
502 std::vector<const URLRequest*> requests; 504 std::vector<const URLRequest*> requests;
503 for (const auto& context : contexts) { 505 for (const auto& context : contexts) {
504 // May only be called on the context's thread. 506 // May only be called on the context's thread.
505 DCHECK(context->CalledOnValidThread()); 507 DCHECK(context->CalledOnValidThread());
(...skipping 16 matching lines...) Expand all
522 // fine, since GetRequestStateAsValue() ignores the capture mode. 524 // fine, since GetRequestStateAsValue() ignores the capture mode.
523 NetLog::EntryData entry_data( 525 NetLog::EntryData entry_data(
524 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), 526 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(),
525 NetLog::PHASE_BEGIN, request->creation_time(), &callback); 527 NetLog::PHASE_BEGIN, request->creation_time(), &callback);
526 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); 528 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default());
527 observer->OnAddEntry(entry); 529 observer->OnAddEntry(entry);
528 } 530 }
529 } 531 }
530 532
531 } // namespace net 533 } // namespace net
OLDNEW
« no previous file with comments | « net/log/net_log_unittest.cc ('k') | net/log/test_net_log_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698