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

Unified Diff: components/domain_reliability/context.cc

Issue 2464163003: Domain Reliability: Expire queued beacons after 1 hour. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/domain_reliability/context.h ('k') | components/domain_reliability/context_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/domain_reliability/context.cc
diff --git a/components/domain_reliability/context.cc b/components/domain_reliability/context.cc
index 8cae5a7fbd2d021add2e5ae8552d260944a562f9..a5c0e1977983ecc91cd571ae2b719aa76cd083ac 100644
--- a/components/domain_reliability/context.cc
+++ b/components/domain_reliability/context.cc
@@ -154,6 +154,10 @@ void DomainReliabilityContext::ScheduleUpload(
}
void DomainReliabilityContext::StartUpload() {
+ RemoveExpiredBeacons();
+ if (beacons_.empty())
+ return;
+
MarkUpload();
size_t collector_index = scheduler_.OnUploadStart();
@@ -266,4 +270,11 @@ void DomainReliabilityContext::RemoveOldestBeacon() {
--uploading_beacons_size_;
}
+void DomainReliabilityContext::RemoveExpiredBeacons() {
+ base::TimeTicks now = time_->NowTicks();
+ const base::TimeDelta kMaxAge = base::TimeDelta::FromHours(1);
Randy Smith (Not in Mondays) 2016/11/04 16:06:29 Defined constant somewhere?
+ while (!beacons_.empty() && now - beacons_.front()->start_time >= kMaxAge)
+ beacons_.pop_front();
+}
+
} // namespace domain_reliability
« no previous file with comments | « components/domain_reliability/context.h ('k') | components/domain_reliability/context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698