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

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

Issue 2910473005: Deprecate NonThreadSafe in net/ in favor of SequenceChecker/ThreadChecker. (Closed)
Patch Set: rebase on r476634 Created 3 years, 6 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/http/transport_security_state.cc ('k') | net/log/write_to_file_net_log_observer.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 <utility>
10 #include <vector> 10 #include <vector>
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 constants_dict->Set("activeFieldTrialGroups", field_trial_groups); 318 constants_dict->Set("activeFieldTrialGroups", field_trial_groups);
319 } 319 }
320 320
321 return constants_dict; 321 return constants_dict;
322 } 322 }
323 323
324 NET_EXPORT std::unique_ptr<base::DictionaryValue> GetNetInfo( 324 NET_EXPORT std::unique_ptr<base::DictionaryValue> GetNetInfo(
325 URLRequestContext* context, 325 URLRequestContext* context,
326 int info_sources) { 326 int info_sources) {
327 // May only be called on the context's thread. 327 // May only be called on the context's thread.
328 DCHECK(context->CalledOnValidThread()); 328 context->AssertCalledOnValidThread();
329 329
330 std::unique_ptr<base::DictionaryValue> net_info_dict( 330 std::unique_ptr<base::DictionaryValue> net_info_dict(
331 new base::DictionaryValue()); 331 new base::DictionaryValue());
332 332
333 // TODO(mmenke): The code for most of these sources should probably be moved 333 // TODO(mmenke): The code for most of these sources should probably be moved
334 // into the sources themselves. 334 // into the sources themselves.
335 if (info_sources & NET_INFO_PROXY_SETTINGS) { 335 if (info_sources & NET_INFO_PROXY_SETTINGS) {
336 ProxyService* proxy_service = context->proxy_service(); 336 ProxyService* proxy_service = context->proxy_service();
337 337
338 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 338 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 return net_info_dict; 475 return net_info_dict;
476 } 476 }
477 477
478 NET_EXPORT void CreateNetLogEntriesForActiveObjects( 478 NET_EXPORT void CreateNetLogEntriesForActiveObjects(
479 const std::set<URLRequestContext*>& contexts, 479 const std::set<URLRequestContext*>& contexts,
480 NetLog::ThreadSafeObserver* observer) { 480 NetLog::ThreadSafeObserver* observer) {
481 // Put together the list of all requests. 481 // Put together the list of all requests.
482 std::vector<const URLRequest*> requests; 482 std::vector<const URLRequest*> requests;
483 for (auto* context : contexts) { 483 for (auto* context : contexts) {
484 // May only be called on the context's thread. 484 // May only be called on the context's thread.
485 DCHECK(context->CalledOnValidThread()); 485 context->AssertCalledOnValidThread();
486 // Contexts should all be using the same NetLog. 486 // Contexts should all be using the same NetLog.
487 DCHECK_EQ((*contexts.begin())->net_log(), context->net_log()); 487 DCHECK_EQ((*contexts.begin())->net_log(), context->net_log());
488 for (auto* request : context->url_requests()) { 488 for (auto* request : context->url_requests()) {
489 requests.push_back(request); 489 requests.push_back(request);
490 } 490 }
491 } 491 }
492 492
493 // Sort by creation time. 493 // Sort by creation time.
494 std::sort(requests.begin(), requests.end(), RequestCreatedBefore); 494 std::sort(requests.begin(), requests.end(), RequestCreatedBefore);
495 495
496 // Create fake events. 496 // Create fake events.
497 for (auto* request : requests) { 497 for (auto* request : requests) {
498 NetLogParametersCallback callback = 498 NetLogParametersCallback callback =
499 base::Bind(&GetRequestStateAsValue, base::Unretained(request)); 499 base::Bind(&GetRequestStateAsValue, base::Unretained(request));
500 500
501 // Note that passing the hardcoded NetLogCaptureMode::Default() below is 501 // Note that passing the hardcoded NetLogCaptureMode::Default() below is
502 // fine, since GetRequestStateAsValue() ignores the capture mode. 502 // fine, since GetRequestStateAsValue() ignores the capture mode.
503 NetLogEntryData entry_data( 503 NetLogEntryData entry_data(
504 NetLogEventType::REQUEST_ALIVE, request->net_log().source(), 504 NetLogEventType::REQUEST_ALIVE, request->net_log().source(),
505 NetLogEventPhase::BEGIN, request->creation_time(), &callback); 505 NetLogEventPhase::BEGIN, request->creation_time(), &callback);
506 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default()); 506 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default());
507 observer->OnAddEntry(entry); 507 observer->OnAddEntry(entry);
508 } 508 }
509 } 509 }
510 510
511 } // namespace net 511 } // namespace net
OLDNEW
« no previous file with comments | « net/http/transport_security_state.cc ('k') | net/log/write_to_file_net_log_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698