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

Side by Side Diff: net/reporting/reporting_garbage_collector.cc

Issue 2740833004: Reporting: Implement garbage collector. (Closed)
Patch Set: rebase Created 3 years, 9 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
OLDNEW
(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
OLDNEW
« no previous file with comments | « net/reporting/reporting_garbage_collector.h ('k') | net/reporting/reporting_garbage_collector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698