OLD | NEW |
---|---|
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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 } | 63 } |
64 | 64 |
65 DomainReliabilityContext::~DomainReliabilityContext() { | 65 DomainReliabilityContext::~DomainReliabilityContext() { |
66 ClearBeacons(); | 66 ClearBeacons(); |
67 } | 67 } |
68 | 68 |
69 void DomainReliabilityContext::OnBeacon( | 69 void DomainReliabilityContext::OnBeacon( |
70 scoped_ptr<DomainReliabilityBeacon> beacon) { | 70 scoped_ptr<DomainReliabilityBeacon> beacon) { |
71 bool success = (beacon->status == "ok"); | 71 bool success = (beacon->status == "ok"); |
72 | 72 |
73 bool reported = config().DecideIfShouldReportRequest(success); | 73 double sample_rate; |
74 bool reported = config().DecideIfShouldReportRequest(success, &sample_rate); | |
jkarlin
2015/12/07 14:57:27
DecideIfShouldReportRequest needs to be renamed. I
Deprecated (see juliatuttle)
2015/12/07 20:17:57
Acknowledged.
| |
74 UMA_HISTOGRAM_BOOLEAN("DomainReliability.BeaconReported", reported); | 75 UMA_HISTOGRAM_BOOLEAN("DomainReliability.BeaconReported", reported); |
75 if (!reported) { | 76 if (!reported) { |
76 // If the beacon isn't queued to be reported, it definitely cannot evict | 77 // If the beacon isn't queued to be reported, it definitely cannot evict |
77 // an older beacon. (This histogram is also logged below based on whether | 78 // an older beacon. (This histogram is also logged below based on whether |
78 // an older beacon was actually evicted.) | 79 // an older beacon was actually evicted.) |
79 LogOnBeaconDidEvictHistogram(false); | 80 LogOnBeaconDidEvictHistogram(false); |
80 return; | 81 return; |
81 } | 82 } |
83 beacon->weight = 1.0 / sample_rate; | |
jkarlin
2015/12/07 14:57:27
Division by 0 is possible here. config.cc's IsVali
jkarlin
2015/12/07 18:06:53
I realized you can't actually get here if it's 0.0
Deprecated (see juliatuttle)
2015/12/07 20:17:57
Acknowledged.
Deprecated (see juliatuttle)
2015/12/07 20:17:57
Yes, it's potentially wrong in the case of evicted
| |
82 | 84 |
83 UMA_HISTOGRAM_SPARSE_SLOWLY("DomainReliability.ReportedBeaconError", | 85 UMA_HISTOGRAM_SPARSE_SLOWLY("DomainReliability.ReportedBeaconError", |
84 -beacon->chrome_error); | 86 -beacon->chrome_error); |
85 if (!beacon->server_ip.empty()) { | 87 if (!beacon->server_ip.empty()) { |
86 UMA_HISTOGRAM_SPARSE_SLOWLY( | 88 UMA_HISTOGRAM_SPARSE_SLOWLY( |
87 "DomainReliability.ReportedBeaconError_HasServerIP", | 89 "DomainReliability.ReportedBeaconError_HasServerIP", |
88 -beacon->chrome_error); | 90 -beacon->chrome_error); |
89 } | 91 } |
90 // TODO(ttuttle): Histogram HTTP response code? | 92 // TODO(ttuttle): Histogram HTTP response code? |
91 | 93 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 delete beacons_.front(); | 246 delete beacons_.front(); |
245 beacons_.pop_front(); | 247 beacons_.pop_front(); |
246 | 248 |
247 // If that just removed a beacon counted in uploading_beacons_size_, decrement | 249 // If that just removed a beacon counted in uploading_beacons_size_, decrement |
248 // that. | 250 // that. |
249 if (uploading_beacons_size_ > 0) | 251 if (uploading_beacons_size_ > 0) |
250 --uploading_beacons_size_; | 252 --uploading_beacons_size_; |
251 } | 253 } |
252 | 254 |
253 } // namespace domain_reliability | 255 } // namespace domain_reliability |
OLD | NEW |