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

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

Issue 238863005: Domain Reliability: Remove browsing data when requested. (Closed) Base URL: http://git.chromium.org/chromium/src.git@domrel_bakedin
Patch Set: ...and fix BrowsingDataRemoverTet Created 6 years, 7 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 | « components/domain_reliability/context.h ('k') | components/domain_reliability/monitor.h » ('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 "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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 reported = true; 162 reported = true;
163 UMA_HISTOGRAM_SPARSE_SLOWLY("DomainReliability.ReportedBeaconError", 163 UMA_HISTOGRAM_SPARSE_SLOWLY("DomainReliability.ReportedBeaconError",
164 -beacon.chrome_error); 164 -beacon.chrome_error);
165 // TODO(ttuttle): Histogram HTTP response code? 165 // TODO(ttuttle): Histogram HTTP response code?
166 } 166 }
167 167
168 UMA_HISTOGRAM_BOOLEAN("DomainReliability.BeaconReported", reported); 168 UMA_HISTOGRAM_BOOLEAN("DomainReliability.BeaconReported", reported);
169 UMA_HISTOGRAM_BOOLEAN("DomainReliability.OnBeaconDidEvict", evicted); 169 UMA_HISTOGRAM_BOOLEAN("DomainReliability.OnBeaconDidEvict", evicted);
170 } 170 }
171 171
172 void DomainReliabilityContext::ClearBeacons() {
173 ResourceStateVector::iterator it;
174 for (it = states_.begin(); it != states_.end(); ++it) {
175 ResourceState* state = *it;
176 state->beacons.clear();
177 state->successful_requests = 0;
178 state->failed_requests = 0;
179 state->uploading_beacons_size = 0;
180 state->uploading_successful_requests = 0;
181 state->uploading_failed_requests = 0;
182 }
183 beacon_count_ = 0;
184 uploading_beacon_count_ = 0;
185 }
186
172 void DomainReliabilityContext::GetQueuedDataForTesting( 187 void DomainReliabilityContext::GetQueuedDataForTesting(
173 size_t resource_index, 188 size_t resource_index,
174 std::vector<DomainReliabilityBeacon>* beacons_out, 189 std::vector<DomainReliabilityBeacon>* beacons_out,
175 uint32* successful_requests_out, 190 uint32* successful_requests_out,
176 uint32* failed_requests_out) const { 191 uint32* failed_requests_out) const {
177 DCHECK_NE(DomainReliabilityConfig::kInvalidResourceIndex, resource_index); 192 DCHECK_NE(DomainReliabilityConfig::kInvalidResourceIndex, resource_index);
178 DCHECK_GT(states_.size(), resource_index); 193 DCHECK_GT(states_.size(), resource_index);
179 const ResourceState& state = *states_[resource_index]; 194 const ResourceState& state = *states_[resource_index];
180 if (beacons_out) 195 if (beacons_out)
181 beacons_out->assign(state.beacons.begin(), state.beacons.end()); 196 beacons_out->assign(state.beacons.begin(), state.beacons.end());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 302
288 min_resource->RemoveOldestBeacon(); 303 min_resource->RemoveOldestBeacon();
289 --beacon_count_; 304 --beacon_count_;
290 // If that just removed a beacon counted in uploading_beacon_count_, decrement 305 // If that just removed a beacon counted in uploading_beacon_count_, decrement
291 // that. 306 // that.
292 if (uploading_beacon_count_ > 0) 307 if (uploading_beacon_count_ > 0)
293 --uploading_beacon_count_; 308 --uploading_beacon_count_;
294 } 309 }
295 310
296 } // namespace domain_reliability 311 } // namespace domain_reliability
OLDNEW
« no previous file with comments | « components/domain_reliability/context.h ('k') | components/domain_reliability/monitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698