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

Side by Side Diff: components/offline_pages/background/request_coordinator.cc

Issue 2440733002: [OfflinePages] Adds TimeToStart UMA for background load requests. (Closed)
Patch Set: Inlined histogram constants Created 4 years, 2 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 | tools/metrics/histograms/histograms.xml » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/offline_pages/background/request_coordinator.h" 5 #include "components/offline_pages/background/request_coordinator.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // one to record samples in seconds rather than milliseconds. 67 // one to record samples in seconds rather than milliseconds.
68 base::HistogramBase* histogram = base::Histogram::FactoryGet( 68 base::HistogramBase* histogram = base::Histogram::FactoryGet(
69 AddHistogramSuffix(client_id, "OfflinePages.Background.TimeToSaved"), 69 AddHistogramSuffix(client_id, "OfflinePages.Background.TimeToSaved"),
70 kMinDurationSeconds, kMaxDurationSeconds, kDurationBuckets, 70 kMinDurationSeconds, kMaxDurationSeconds, kDurationBuckets,
71 base::HistogramBase::kUmaTargetedHistogramFlag); 71 base::HistogramBase::kUmaTargetedHistogramFlag);
72 base::TimeDelta duration = base::Time::Now() - request_creation_time; 72 base::TimeDelta duration = base::Time::Now() - request_creation_time;
73 histogram->Add(duration.InSeconds()); 73 histogram->Add(duration.InSeconds());
74 } 74 }
75 } 75 }
76 76
77 void RecordStartTimeUMA(const SavePageRequest& request) {
78 std::string histogram_name("OfflinePages.Background.TimeToStart");
79 if (base::SysInfo::IsLowEndDevice()) {
80 histogram_name += ".Svelte";
81 }
82
83 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_TIMES
84 // macro adapted to allow for a dynamically suffixed histogram name.
85 // Note: The factory creates and owns the histogram.
86 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet(
87 AddHistogramSuffix(request.client_id(), histogram_name.c_str()),
88 base::TimeDelta::FromMilliseconds(100), base::TimeDelta::FromDays(7), 50,
Dmitry Titov 2016/10/21 18:30:25 This will have second bucket that would take every
dougarnett 2016/10/21 23:16:38 I thought this one would give exponential buckets
dougarnett 2016/10/21 23:28:52 Code doc here: https://cs.chromium.org/chromium/sr
89 base::HistogramBase::kUmaTargetedHistogramFlag);
90 base::TimeDelta duration = base::Time::Now() - request.creation_time();
91 histogram->AddTime(duration);
92 }
93
77 void RecordCancelTimeUMA(const SavePageRequest& canceled_request) { 94 void RecordCancelTimeUMA(const SavePageRequest& canceled_request) {
78 // Using regular histogram (with dynamic suffix) rather than time-oriented 95 // Using regular histogram (with dynamic suffix) rather than time-oriented
79 // one to record samples in seconds rather than milliseconds. 96 // one to record samples in seconds rather than milliseconds.
80 base::HistogramBase* histogram = base::Histogram::FactoryGet( 97 base::HistogramBase* histogram = base::Histogram::FactoryGet(
81 AddHistogramSuffix(canceled_request.client_id(), 98 AddHistogramSuffix(canceled_request.client_id(),
82 "OfflinePages.Background.TimeToCanceled"), 99 "OfflinePages.Background.TimeToCanceled"),
83 kMinDurationSeconds, kMaxDurationSeconds, kDurationBuckets, 100 kMinDurationSeconds, kMaxDurationSeconds, kDurationBuckets,
84 base::HistogramBase::kUmaTargetedHistogramFlag); 101 base::HistogramBase::kUmaTargetedHistogramFlag);
85 base::TimeDelta duration = 102 base::TimeDelta duration =
86 base::Time::Now() - canceled_request.creation_time(); 103 base::Time::Now() - canceled_request.creation_time();
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 GetOffliner(); 557 GetOffliner();
541 if (!offliner_) { 558 if (!offliner_) {
542 DVLOG(0) << "Unable to create Offliner. " 559 DVLOG(0) << "Unable to create Offliner. "
543 << "Cannot background offline page."; 560 << "Cannot background offline page.";
544 return; 561 return;
545 } 562 }
546 563
547 DCHECK(!is_busy_); 564 DCHECK(!is_busy_);
548 is_busy_ = true; 565 is_busy_ = true;
549 566
567 // Record start time if this is first attempt.
568 if (request.started_attempt_count() == 0) {
569 RecordStartTimeUMA(request);
570 }
571
550 // Mark attempt started in the database and start offliner when completed. 572 // Mark attempt started in the database and start offliner when completed.
551 queue_->MarkAttemptStarted( 573 queue_->MarkAttemptStarted(
552 request.request_id(), 574 request.request_id(),
553 base::Bind(&RequestCoordinator::StartOffliner, 575 base::Bind(&RequestCoordinator::StartOffliner,
554 weak_ptr_factory_.GetWeakPtr(), request.request_id(), 576 weak_ptr_factory_.GetWeakPtr(), request.request_id(),
555 request.client_id().name_space)); 577 request.client_id().name_space));
556 } 578 }
557 579
558 void RequestCoordinator::StartOffliner( 580 void RequestCoordinator::StartOffliner(
559 int64_t request_id, 581 int64_t request_id,
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 772
751 ClientPolicyController* RequestCoordinator::GetPolicyController() { 773 ClientPolicyController* RequestCoordinator::GetPolicyController() {
752 return policy_controller_.get(); 774 return policy_controller_.get();
753 } 775 }
754 776
755 void RequestCoordinator::Shutdown() { 777 void RequestCoordinator::Shutdown() {
756 network_quality_estimator_ = nullptr; 778 network_quality_estimator_ = nullptr;
757 } 779 }
758 780
759 } // namespace offline_pages 781 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698