| Index: net/reporting/reporting_browsing_data_remover.cc
|
| diff --git a/net/reporting/reporting_browsing_data_remover.cc b/net/reporting/reporting_browsing_data_remover.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5041a47487c62a1425c26a1d776753cf6186dc82
|
| --- /dev/null
|
| +++ b/net/reporting/reporting_browsing_data_remover.cc
|
| @@ -0,0 +1,59 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "net/reporting/reporting_browsing_data_remover.h"
|
| +
|
| +#include <vector>
|
| +
|
| +#include "net/reporting/reporting_cache.h"
|
| +#include "net/reporting/reporting_context.h"
|
| +#include "net/reporting/reporting_report.h"
|
| +
|
| +namespace net {
|
| +
|
| +// static
|
| +void ReportingBrowsingDataRemover::RemoveBrowsingData(
|
| + ReportingContext* context,
|
| + int data_type_mask,
|
| + base::Callback<bool(const GURL&)> origin_filter) {
|
| + ReportingCache* cache = context->cache();
|
| + bool remove_reports = (data_type_mask & DATA_TYPE_REPORTS) != 0;
|
| + bool remove_clients = (data_type_mask & DATA_TYPE_CLIENTS) != 0;
|
| +
|
| + if (origin_filter.is_null()) {
|
| + if (remove_reports)
|
| + cache->RemoveAllReports();
|
| + if (remove_clients)
|
| + cache->RemoveAllClients();
|
| + return;
|
| + }
|
| +
|
| + if (remove_reports) {
|
| + std::vector<const ReportingReport*> all_reports;
|
| + cache->GetReports(&all_reports);
|
| +
|
| + std::vector<const ReportingReport*> reports_to_remove;
|
| + for (const ReportingReport* report : all_reports) {
|
| + if (origin_filter.Run(report->url))
|
| + reports_to_remove.push_back(report);
|
| + }
|
| +
|
| + cache->RemoveReports(reports_to_remove);
|
| + }
|
| +
|
| + if (remove_clients) {
|
| + std::vector<const ReportingClient*> all_clients;
|
| + cache->GetClients(&all_clients);
|
| +
|
| + std::vector<const ReportingClient*> clients_to_remove;
|
| + for (const ReportingClient* client : all_clients) {
|
| + if (origin_filter.Run(client->origin.GetURL()))
|
| + clients_to_remove.push_back(client);
|
| + }
|
| +
|
| + cache->RemoveClients(clients_to_remove);
|
| + }
|
| +}
|
| +
|
| +} // namespace net
|
|
|