OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "net/reporting/reporting_garbage_collector.h" | |
6 | |
7 #include <vector> | |
8 | |
9 #include "base/time/time.h" | |
10 #include "net/reporting/reporting_cache.h" | |
11 | |
12 namespace net { | |
13 | |
14 using Report = ReportingCache::Report; | |
15 | |
16 // static | |
17 void ReportingGarbageCollector::CollectGarbage(ReportingCache* cache, | |
18 const Policy& policy, | |
19 base::TimeTicks now, | |
20 bool network_changed) { | |
shivanisha
2017/03/16 00:22:45
DCHECK(cache)
Julia Tuttle
2017/03/21 19:26:57
Done.
| |
21 std::vector<const Report*> all_reports; | |
22 cache->GetReports(&all_reports); | |
23 | |
24 if (network_changed && !policy.report_persist_across_network_changes) { | |
25 cache->RemoveReports(all_reports); | |
shivanisha
2017/03/16 00:22:45
Since this policy is for all the reports, how abou
Julia Tuttle
2017/03/21 19:26:57
Done.
| |
26 return; | |
27 } | |
28 | |
29 std::vector<const Report*> reports_to_remove; | |
30 for (const Report* report : all_reports) { | |
31 if (now - report->queued >= policy.report_max_age || | |
32 report->attempts >= policy.report_max_attempts) { | |
33 reports_to_remove.push_back(report); | |
34 } | |
35 } | |
36 cache->RemoveReports(reports_to_remove); | |
37 } | |
38 | |
39 } // namespace net | |
OLD | NEW |