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_browsing_data_remover.h" | |
6 | |
7 #include <vector> | |
8 | |
9 #include "net/reporting/reporting_cache.h" | |
10 #include "net/reporting/reporting_context.h" | |
11 #include "net/reporting/reporting_report.h" | |
12 | |
13 namespace net { | |
14 | |
15 // static | |
16 void ReportingBrowsingDataRemover::RemoveBrowsingData( | |
17 ReportingContext* context, | |
18 bool remove_reports, | |
19 bool remove_clients, | |
shivanisha
2017/04/07 15:10:30
nit: Enum in place of two boolean arguments.
Julia Tuttle
2017/04/07 16:25:10
Done.
| |
20 base::Callback<bool(const GURL&)> origin_filter) { | |
21 ReportingCache* cache = context->cache(); | |
22 | |
23 if (origin_filter.is_null()) { | |
24 if (remove_reports) | |
25 cache->RemoveAllReports(); | |
26 if (remove_clients) | |
27 cache->RemoveAllClients(); | |
28 return; | |
29 } | |
30 | |
31 if (remove_reports) { | |
32 std::vector<const ReportingReport*> all_reports; | |
33 cache->GetReports(&all_reports); | |
34 | |
35 std::vector<const ReportingReport*> reports_to_remove; | |
36 for (const ReportingReport* report : all_reports) { | |
37 if (origin_filter.Run(report->url)) | |
38 reports_to_remove.push_back(report); | |
39 } | |
40 | |
41 cache->RemoveReports(reports_to_remove); | |
42 } | |
43 | |
44 if (remove_clients) { | |
45 std::vector<const ReportingClient*> all_clients; | |
46 cache->GetClients(&all_clients); | |
47 | |
48 std::vector<const ReportingClient*> clients_to_remove; | |
49 for (const ReportingClient* client : all_clients) { | |
50 if (origin_filter.Run(client->origin.GetURL())) | |
51 clients_to_remove.push_back(client); | |
52 } | |
53 | |
54 cache->RemoveClients(clients_to_remove); | |
55 } | |
56 } | |
57 | |
58 } // namespace net | |
OLD | NEW |