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 int data_type_mask, | |
19 base::Callback<bool(const GURL&)> origin_filter) { | |
20 ReportingCache* cache = context->cache(); | |
21 bool remove_reports = !!(data_type_mask & DATA_TYPE_REPORTS); | |
shivanisha
2017/04/07 16:42:48
Why the 2 negate signs?
| |
22 bool remove_clients = !!(data_type_mask & DATA_TYPE_CLIENTS); | |
23 | |
24 if (origin_filter.is_null()) { | |
25 if (remove_reports) | |
26 cache->RemoveAllReports(); | |
27 if (remove_clients) | |
28 cache->RemoveAllClients(); | |
29 return; | |
30 } | |
31 | |
32 if (remove_reports) { | |
33 std::vector<const ReportingReport*> all_reports; | |
34 cache->GetReports(&all_reports); | |
35 | |
36 std::vector<const ReportingReport*> reports_to_remove; | |
37 for (const ReportingReport* report : all_reports) { | |
38 if (origin_filter.Run(report->url)) | |
39 reports_to_remove.push_back(report); | |
40 } | |
41 | |
42 cache->RemoveReports(reports_to_remove); | |
43 } | |
44 | |
45 if (remove_clients) { | |
46 std::vector<const ReportingClient*> all_clients; | |
47 cache->GetClients(&all_clients); | |
48 | |
49 std::vector<const ReportingClient*> clients_to_remove; | |
50 for (const ReportingClient* client : all_clients) { | |
51 if (origin_filter.Run(client->origin.GetURL())) | |
52 clients_to_remove.push_back(client); | |
53 } | |
54 | |
55 cache->RemoveClients(clients_to_remove); | |
56 } | |
57 } | |
58 | |
59 } // namespace net | |
OLD | NEW |