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

Side by Side Diff: components/domain_reliability/context.cc

Issue 2466093002: Domain Reliability: Add more upload-related histograms. (Closed)
Patch Set: A couple of tweaks. Created 4 years, 1 month 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
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 "components/domain_reliability/context.h" 5 #include "components/domain_reliability/context.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 dispatcher_(dispatcher), 60 dispatcher_(dispatcher),
61 uploader_(uploader), 61 uploader_(uploader),
62 uploading_beacons_size_(0), 62 uploading_beacons_size_(0),
63 last_network_change_time_(last_network_change_time), 63 last_network_change_time_(last_network_change_time),
64 weak_factory_(this) {} 64 weak_factory_(this) {}
65 65
66 DomainReliabilityContext::~DomainReliabilityContext() { 66 DomainReliabilityContext::~DomainReliabilityContext() {
67 ClearBeacons(); 67 ClearBeacons();
68 } 68 }
69 69
70 void DomainReliabilityContext::OnBeacon( 70 bool DomainReliabilityContext::OnBeacon(
71 std::unique_ptr<DomainReliabilityBeacon> beacon) { 71 std::unique_ptr<DomainReliabilityBeacon> beacon) {
72 bool success = (beacon->status == "ok"); 72 bool success = (beacon->status == "ok");
73 double sample_rate = beacon->details.quic_port_migration_detected 73 double sample_rate = beacon->details.quic_port_migration_detected
74 ? 1.0 74 ? 1.0
75 : config().GetSampleRate(success); 75 : config().GetSampleRate(success);
76 bool should_report = base::RandDouble() < sample_rate; 76 bool should_report = base::RandDouble() < sample_rate;
77 UMA_HISTOGRAM_BOOLEAN("DomainReliability.BeaconReported", should_report); 77 UMA_HISTOGRAM_BOOLEAN("DomainReliability.BeaconReported", should_report);
78 if (!should_report) { 78 if (!should_report) {
79 // If the beacon isn't queued to be reported, it definitely cannot evict 79 // If the beacon isn't queued to be reported, it definitely cannot evict
80 // an older beacon. (This histogram is also logged below based on whether 80 // an older beacon. (This histogram is also logged below based on whether
81 // an older beacon was actually evicted.) 81 // an older beacon was actually evicted.)
82 LogOnBeaconDidEvictHistogram(false); 82 LogOnBeaconDidEvictHistogram(false);
83 return; 83 return false;
84 } 84 }
85 beacon->sample_rate = sample_rate; 85 beacon->sample_rate = sample_rate;
86 86
87 UMA_HISTOGRAM_SPARSE_SLOWLY("DomainReliability.ReportedBeaconError", 87 UMA_HISTOGRAM_SPARSE_SLOWLY("DomainReliability.ReportedBeaconError",
88 -beacon->chrome_error); 88 -beacon->chrome_error);
89 if (!beacon->server_ip.empty()) { 89 if (!beacon->server_ip.empty()) {
90 UMA_HISTOGRAM_SPARSE_SLOWLY( 90 UMA_HISTOGRAM_SPARSE_SLOWLY(
91 "DomainReliability.ReportedBeaconError_HasServerIP", 91 "DomainReliability.ReportedBeaconError_HasServerIP",
92 -beacon->chrome_error); 92 -beacon->chrome_error);
93 } 93 }
94 UMA_HISTOGRAM_COUNTS_100("DomainReliability.ReportedBeaconUploadDepth",
95 beacon->upload_depth);
94 // TODO(juliatuttle): Histogram HTTP response code? 96 // TODO(juliatuttle): Histogram HTTP response code?
95 97
96 // Allow beacons about reports, but don't schedule an upload for more than 98 // Allow beacons about reports, but don't schedule an upload for more than
97 // one layer of recursion, to avoid infinite report loops. 99 // one layer of recursion, to avoid infinite report loops.
98 if (beacon->upload_depth <= kMaxUploadDepthToSchedule) 100 if (beacon->upload_depth <= kMaxUploadDepthToSchedule)
99 scheduler_.OnBeaconAdded(); 101 scheduler_.OnBeaconAdded();
100 beacons_.push_back(std::move(beacon)); 102 beacons_.push_back(std::move(beacon));
101 bool should_evict = beacons_.size() > kMaxQueuedBeacons; 103 bool should_evict = beacons_.size() > kMaxQueuedBeacons;
102 if (should_evict) 104 if (should_evict)
103 RemoveOldestBeacon(); 105 RemoveOldestBeacon();
104 106
105 LogOnBeaconDidEvictHistogram(should_evict); 107 LogOnBeaconDidEvictHistogram(should_evict);
108
109 base::TimeTicks now = base::TimeTicks::Now();
110 if (last_queued_beacon_time_ != base::TimeTicks()) {
111 UMA_HISTOGRAM_LONG_TIMES("DomainReliability.BeaconInterval",
112 now - last_queued_beacon_time_);
113 }
114 last_queued_beacon_time_ = now;
115
116 return true;
106 } 117 }
107 118
108 void DomainReliabilityContext::ClearBeacons() { 119 void DomainReliabilityContext::ClearBeacons() {
109 beacons_.clear(); 120 beacons_.clear();
110 uploading_beacons_size_ = 0; 121 uploading_beacons_size_ = 0;
111 } 122 }
112 123
113 std::unique_ptr<Value> DomainReliabilityContext::GetWebUIData() const { 124 std::unique_ptr<Value> DomainReliabilityContext::GetWebUIData() const {
114 DictionaryValue* context_value = new DictionaryValue(); 125 DictionaryValue* context_value = new DictionaryValue();
115 126
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 260
250 beacons_.pop_front(); 261 beacons_.pop_front();
251 262
252 // If that just removed a beacon counted in uploading_beacons_size_, decrement 263 // If that just removed a beacon counted in uploading_beacons_size_, decrement
253 // that. 264 // that.
254 if (uploading_beacons_size_ > 0) 265 if (uploading_beacons_size_ > 0)
255 --uploading_beacons_size_; 266 --uploading_beacons_size_;
256 } 267 }
257 268
258 } // namespace domain_reliability 269 } // namespace domain_reliability
OLDNEW
« no previous file with comments | « components/domain_reliability/context.h ('k') | components/domain_reliability/context_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698