| 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" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 void RemoveBrowsingData( | 28 void RemoveBrowsingData( |
| 29 int data_type_mask, | 29 int data_type_mask, |
| 30 base::Callback<bool(const GURL&)> origin_filter) override { | 30 base::Callback<bool(const GURL&)> origin_filter) override { |
| 31 ReportingCache* cache = context_->cache(); | 31 ReportingCache* cache = context_->cache(); |
| 32 bool remove_reports = (data_type_mask & DATA_TYPE_REPORTS) != 0; | 32 bool remove_reports = (data_type_mask & DATA_TYPE_REPORTS) != 0; |
| 33 bool remove_clients = (data_type_mask & DATA_TYPE_CLIENTS) != 0; | 33 bool remove_clients = (data_type_mask & DATA_TYPE_CLIENTS) != 0; |
| 34 | 34 |
| 35 if (origin_filter.is_null()) { | 35 if (origin_filter.is_null()) { |
| 36 if (remove_reports) | 36 if (remove_reports) |
| 37 cache->RemoveAllReports(); | 37 cache->RemoveAllReports( |
| 38 ReportingReport::Outcome::ERASED_BROWSING_DATA_REMOVED); |
| 38 if (remove_clients) | 39 if (remove_clients) |
| 39 cache->RemoveAllClients(); | 40 cache->RemoveAllClients(); |
| 40 return; | 41 return; |
| 41 } | 42 } |
| 42 | 43 |
| 43 if (remove_reports) { | 44 if (remove_reports) { |
| 44 std::vector<const ReportingReport*> all_reports; | 45 std::vector<const ReportingReport*> all_reports; |
| 45 cache->GetReports(&all_reports); | 46 cache->GetReports(&all_reports); |
| 46 | 47 |
| 47 std::vector<const ReportingReport*> reports_to_remove; | 48 std::vector<const ReportingReport*> reports_to_remove; |
| 48 for (const ReportingReport* report : all_reports) { | 49 for (const ReportingReport* report : all_reports) { |
| 49 if (origin_filter.Run(report->url)) | 50 if (origin_filter.Run(report->url)) |
| 50 reports_to_remove.push_back(report); | 51 reports_to_remove.push_back(report); |
| 51 } | 52 } |
| 52 | 53 |
| 53 cache->RemoveReports(reports_to_remove); | 54 cache->RemoveReports( |
| 55 reports_to_remove, |
| 56 ReportingReport::Outcome::ERASED_BROWSING_DATA_REMOVED); |
| 54 } | 57 } |
| 55 | 58 |
| 56 if (remove_clients) { | 59 if (remove_clients) { |
| 57 std::vector<const ReportingClient*> all_clients; | 60 std::vector<const ReportingClient*> all_clients; |
| 58 cache->GetClients(&all_clients); | 61 cache->GetClients(&all_clients); |
| 59 | 62 |
| 60 std::vector<const ReportingClient*> clients_to_remove; | 63 std::vector<const ReportingClient*> clients_to_remove; |
| 61 for (const ReportingClient* client : all_clients) { | 64 for (const ReportingClient* client : all_clients) { |
| 62 // TODO(juliatuttle): Examine client endpoint as well? | 65 // TODO(juliatuttle): Examine client endpoint as well? |
| 63 if (origin_filter.Run(client->origin.GetURL())) | 66 if (origin_filter.Run(client->origin.GetURL())) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 78 | 81 |
| 79 // static | 82 // static |
| 80 std::unique_ptr<ReportingBrowsingDataRemover> | 83 std::unique_ptr<ReportingBrowsingDataRemover> |
| 81 ReportingBrowsingDataRemover::Create(ReportingContext* context) { | 84 ReportingBrowsingDataRemover::Create(ReportingContext* context) { |
| 82 return base::MakeUnique<ReportingBrowsingDataRemoverImpl>(context); | 85 return base::MakeUnique<ReportingBrowsingDataRemoverImpl>(context); |
| 83 } | 86 } |
| 84 | 87 |
| 85 ReportingBrowsingDataRemover::~ReportingBrowsingDataRemover() {} | 88 ReportingBrowsingDataRemover::~ReportingBrowsingDataRemover() {} |
| 86 | 89 |
| 87 } // namespace net | 90 } // namespace net |
| OLD | NEW |