OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/reporting/reporting_browsing_data_remover.h" | 5 #include "net/reporting/reporting_browsing_data_remover.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "net/reporting/reporting_cache.h" | 10 #include "net/reporting/reporting_cache.h" |
11 #include "net/reporting/reporting_client.h" | 11 #include "net/reporting/reporting_client.h" |
12 #include "net/reporting/reporting_context.h" | 12 #include "net/reporting/reporting_context.h" |
13 #include "net/reporting/reporting_report.h" | 13 #include "net/reporting/reporting_report.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 // static | 17 // static |
18 void ReportingBrowsingDataRemover::RemoveBrowsingData( | 18 void ReportingBrowsingDataRemover::RemoveBrowsingData( |
19 ReportingCache* cache, | 19 ReportingCache* cache, |
20 int data_type_mask, | 20 int data_type_mask, |
21 base::Callback<bool(const GURL&)> origin_filter) { | 21 base::Callback<bool(const GURL&)> origin_filter) { |
22 bool remove_reports = (data_type_mask & DATA_TYPE_REPORTS) != 0; | 22 bool remove_reports = (data_type_mask & DATA_TYPE_REPORTS) != 0; |
23 bool remove_clients = (data_type_mask & DATA_TYPE_CLIENTS) != 0; | 23 bool remove_clients = (data_type_mask & DATA_TYPE_CLIENTS) != 0; |
24 | 24 |
25 if (origin_filter.is_null()) { | 25 if (origin_filter.is_null()) { |
26 if (remove_reports) | 26 if (remove_reports) { |
27 cache->RemoveAllReports(); | 27 cache->RemoveAllReports( |
| 28 ReportingReport::Outcome::ERASED_BROWSING_DATA_REMOVED); |
| 29 } |
28 if (remove_clients) | 30 if (remove_clients) |
29 cache->RemoveAllClients(); | 31 cache->RemoveAllClients(); |
30 return; | 32 return; |
31 } | 33 } |
32 | 34 |
33 if (remove_reports) { | 35 if (remove_reports) { |
34 std::vector<const ReportingReport*> all_reports; | 36 std::vector<const ReportingReport*> all_reports; |
35 cache->GetReports(&all_reports); | 37 cache->GetReports(&all_reports); |
36 | 38 |
37 std::vector<const ReportingReport*> reports_to_remove; | 39 std::vector<const ReportingReport*> reports_to_remove; |
38 for (const ReportingReport* report : all_reports) { | 40 for (const ReportingReport* report : all_reports) { |
39 if (origin_filter.Run(report->url)) | 41 if (origin_filter.Run(report->url)) |
40 reports_to_remove.push_back(report); | 42 reports_to_remove.push_back(report); |
41 } | 43 } |
42 | 44 |
43 cache->RemoveReports(reports_to_remove); | 45 cache->RemoveReports( |
| 46 reports_to_remove, |
| 47 ReportingReport::Outcome::ERASED_BROWSING_DATA_REMOVED); |
44 } | 48 } |
45 | 49 |
46 if (remove_clients) { | 50 if (remove_clients) { |
47 std::vector<const ReportingClient*> all_clients; | 51 std::vector<const ReportingClient*> all_clients; |
48 cache->GetClients(&all_clients); | 52 cache->GetClients(&all_clients); |
49 | 53 |
50 std::vector<const ReportingClient*> clients_to_remove; | 54 std::vector<const ReportingClient*> clients_to_remove; |
51 for (const ReportingClient* client : all_clients) { | 55 for (const ReportingClient* client : all_clients) { |
52 // TODO(juliatuttle): Examine client endpoint as well? | 56 // TODO(juliatuttle): Examine client endpoint as well? |
53 if (origin_filter.Run(client->origin.GetURL())) | 57 if (origin_filter.Run(client->origin.GetURL())) |
54 clients_to_remove.push_back(client); | 58 clients_to_remove.push_back(client); |
55 } | 59 } |
56 | 60 |
57 cache->RemoveClients(clients_to_remove); | 61 cache->RemoveClients(clients_to_remove); |
58 } | 62 } |
59 } | 63 } |
60 | 64 |
61 } // namespace net | 65 } // namespace net |
OLD | NEW |