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

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

Issue 2837313002: Add UMA to track the number of live URLRequests. (Closed)
Patch Set: use mutable Created 3 years, 8 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 | « no previous file | net/url_request/url_request.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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 NET_EXPORT void CreateNetLogEntriesForActiveObjects( 508 NET_EXPORT void CreateNetLogEntriesForActiveObjects(
509 const std::set<URLRequestContext*>& contexts, 509 const std::set<URLRequestContext*>& contexts,
510 NetLog::ThreadSafeObserver* observer) { 510 NetLog::ThreadSafeObserver* observer) {
511 // Put together the list of all requests. 511 // Put together the list of all requests.
512 std::vector<const URLRequest*> requests; 512 std::vector<const URLRequest*> requests;
513 for (auto* context : contexts) { 513 for (auto* context : contexts) {
514 // May only be called on the context's thread. 514 // May only be called on the context's thread.
515 DCHECK(context->CalledOnValidThread()); 515 DCHECK(context->CalledOnValidThread());
516 // Contexts should all be using the same NetLog. 516 // Contexts should all be using the same NetLog.
517 DCHECK_EQ((*contexts.begin())->net_log(), context->net_log()); 517 DCHECK_EQ((*contexts.begin())->net_log(), context->net_log());
518 for (auto* request : *context->url_requests()) { 518 for (auto* request : context->url_requests()) {
519 requests.push_back(request); 519 requests.push_back(request);
520 } 520 }
521 } 521 }
522 522
523 // Sort by creation time. 523 // Sort by creation time.
524 std::sort(requests.begin(), requests.end(), RequestCreatedBefore); 524 std::sort(requests.begin(), requests.end(), RequestCreatedBefore);
525 525
526 // Create fake events. 526 // Create fake events.
527 for (auto* request : requests) { 527 for (auto* request : requests) {
528 NetLogParametersCallback callback = 528 NetLogParametersCallback callback =
529 base::Bind(&GetRequestStateAsValue, base::Unretained(request)); 529 base::Bind(&GetRequestStateAsValue, base::Unretained(request));
530 530
531 // Note that passing the hardcoded NetLogCaptureMode::Default() below is 531 // Note that passing the hardcoded NetLogCaptureMode::Default() below is
532 // fine, since GetRequestStateAsValue() ignores the capture mode. 532 // fine, since GetRequestStateAsValue() ignores the capture mode.
533 NetLogEntryData entry_data( 533 NetLogEntryData entry_data(
534 NetLogEventType::REQUEST_ALIVE, request->net_log().source(), 534 NetLogEventType::REQUEST_ALIVE, request->net_log().source(),
535 NetLogEventPhase::BEGIN, request->creation_time(), &callback); 535 NetLogEventPhase::BEGIN, request->creation_time(), &callback);
536 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default()); 536 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default());
537 observer->OnAddEntry(entry); 537 observer->OnAddEntry(entry);
538 } 538 }
539 } 539 }
540 540
541 } // namespace net 541 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/url_request/url_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698