| 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
|
| index 5041a47487c62a1425c26a1d776753cf6186dc82..a10bcf86b3ece121621b0d561116387fd16dca93 100644
|
| --- a/net/reporting/reporting_browsing_data_remover.cc
|
| +++ b/net/reporting/reporting_browsing_data_remover.cc
|
| @@ -6,54 +6,82 @@
|
|
|
| #include <vector>
|
|
|
| +#include "base/memory/ptr_util.h"
|
| #include "net/reporting/reporting_cache.h"
|
| +#include "net/reporting/reporting_client.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;
|
| - }
|
| +namespace {
|
| +
|
| +class ReportingBrowsingDataRemoverImpl : public ReportingBrowsingDataRemover {
|
| + public:
|
| + ReportingBrowsingDataRemoverImpl(ReportingContext* context)
|
| + : context_(context) {}
|
| +
|
| + // ReportingBrowsingDataRemover implementation:
|
|
|
| - if (remove_reports) {
|
| - std::vector<const ReportingReport*> all_reports;
|
| - cache->GetReports(&all_reports);
|
| + ~ReportingBrowsingDataRemoverImpl() override {}
|
|
|
| - 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);
|
| + void RemoveBrowsingData(
|
| + int data_type_mask,
|
| + base::Callback<bool(const GURL&)> origin_filter) override {
|
| + 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;
|
| }
|
|
|
| - cache->RemoveReports(reports_to_remove);
|
| - }
|
| + if (remove_reports) {
|
| + std::vector<const ReportingReport*> all_reports;
|
| + cache->GetReports(&all_reports);
|
|
|
| - if (remove_clients) {
|
| - std::vector<const ReportingClient*> all_clients;
|
| - cache->GetClients(&all_clients);
|
| + 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);
|
| + }
|
|
|
| - 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->RemoveReports(reports_to_remove);
|
| }
|
|
|
| - cache->RemoveClients(clients_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) {
|
| + // TODO(juliatuttle): Examine client endpoint as well?
|
| + if (origin_filter.Run(client->origin.GetURL()))
|
| + clients_to_remove.push_back(client);
|
| + }
|
| +
|
| + cache->RemoveClients(clients_to_remove);
|
| + }
|
| }
|
| +
|
| + private:
|
| + ReportingContext* context_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ReportingBrowsingDataRemoverImpl);
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +// static
|
| +std::unique_ptr<ReportingBrowsingDataRemover>
|
| +ReportingBrowsingDataRemover::Create(ReportingContext* context) {
|
| + return base::MakeUnique<ReportingBrowsingDataRemoverImpl>(context);
|
| }
|
|
|
| +ReportingBrowsingDataRemover::~ReportingBrowsingDataRemover() {}
|
| +
|
| } // namespace net
|
|
|