Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 base::TimeDelta duration = base::Time::Now() - request.creation_time(); | |
| 84 UMA_HISTOGRAM_CUSTOM_TIMES( | |
|
Steven Holte
2016/10/20 20:51:11
Also you shouldn't use this macro with a computed
dougarnett
2016/10/21 16:13:48
Done. Thanks
| |
| 85 AddHistogramSuffix(request.client_id(), histogram_name.c_str()), duration, | |
| 86 base::TimeDelta::FromMilliseconds(100), | |
| 87 base::TimeDelta::FromSeconds(kMaxDurationSeconds), kDurationBuckets); | |
|
Steven Holte
2016/10/20 20:46:31
You don't want this bound to change even if you ch
dougarnett
2016/10/21 16:13:48
Done.
| |
| 88 } | |
| 89 | |
| 77 void RecordCancelTimeUMA(const SavePageRequest& canceled_request) { | 90 void RecordCancelTimeUMA(const SavePageRequest& canceled_request) { |
| 78 // Using regular histogram (with dynamic suffix) rather than time-oriented | 91 // Using regular histogram (with dynamic suffix) rather than time-oriented |
| 79 // one to record samples in seconds rather than milliseconds. | 92 // one to record samples in seconds rather than milliseconds. |
| 80 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 93 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
| 81 AddHistogramSuffix(canceled_request.client_id(), | 94 AddHistogramSuffix(canceled_request.client_id(), |
| 82 "OfflinePages.Background.TimeToCanceled"), | 95 "OfflinePages.Background.TimeToCanceled"), |
| 83 kMinDurationSeconds, kMaxDurationSeconds, kDurationBuckets, | 96 kMinDurationSeconds, kMaxDurationSeconds, kDurationBuckets, |
| 84 base::HistogramBase::kUmaTargetedHistogramFlag); | 97 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 85 base::TimeDelta duration = | 98 base::TimeDelta duration = |
| 86 base::Time::Now() - canceled_request.creation_time(); | 99 base::Time::Now() - canceled_request.creation_time(); |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 GetOffliner(); | 553 GetOffliner(); |
| 541 if (!offliner_) { | 554 if (!offliner_) { |
| 542 DVLOG(0) << "Unable to create Offliner. " | 555 DVLOG(0) << "Unable to create Offliner. " |
| 543 << "Cannot background offline page."; | 556 << "Cannot background offline page."; |
| 544 return; | 557 return; |
| 545 } | 558 } |
| 546 | 559 |
| 547 DCHECK(!is_busy_); | 560 DCHECK(!is_busy_); |
| 548 is_busy_ = true; | 561 is_busy_ = true; |
| 549 | 562 |
| 563 // Record start time if this is first attempt. | |
| 564 if (request.started_attempt_count() == 0) { | |
| 565 RecordStartTimeUMA(request); | |
| 566 } | |
| 567 | |
| 550 // Mark attempt started in the database and start offliner when completed. | 568 // Mark attempt started in the database and start offliner when completed. |
| 551 queue_->MarkAttemptStarted( | 569 queue_->MarkAttemptStarted( |
| 552 request.request_id(), | 570 request.request_id(), |
| 553 base::Bind(&RequestCoordinator::StartOffliner, | 571 base::Bind(&RequestCoordinator::StartOffliner, |
| 554 weak_ptr_factory_.GetWeakPtr(), request.request_id(), | 572 weak_ptr_factory_.GetWeakPtr(), request.request_id(), |
| 555 request.client_id().name_space)); | 573 request.client_id().name_space)); |
| 556 } | 574 } |
| 557 | 575 |
| 558 void RequestCoordinator::StartOffliner( | 576 void RequestCoordinator::StartOffliner( |
| 559 int64_t request_id, | 577 int64_t request_id, |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 750 | 768 |
| 751 ClientPolicyController* RequestCoordinator::GetPolicyController() { | 769 ClientPolicyController* RequestCoordinator::GetPolicyController() { |
| 752 return policy_controller_.get(); | 770 return policy_controller_.get(); |
| 753 } | 771 } |
| 754 | 772 |
| 755 void RequestCoordinator::Shutdown() { | 773 void RequestCoordinator::Shutdown() { |
| 756 network_quality_estimator_ = nullptr; | 774 network_quality_estimator_ = nullptr; |
| 757 } | 775 } |
| 758 | 776 |
| 759 } // namespace offline_pages | 777 } // namespace offline_pages |
| OLD | NEW |