Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(924)

Unified Diff: net/reporting/reporting_cache.cc

Issue 2778373003: Reporting: Add Observer interface to observe cache updates. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/BUILD.gn ('k') | net/reporting/reporting_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/reporting/reporting_cache.cc
diff --git a/net/reporting/reporting_cache.cc b/net/reporting/reporting_cache.cc
index 613d3e647e39f2427b3ecaec5dea3cda86f0f501..9e43153b4f96556ec8017a29a9d3d2365ef90943 100644
--- a/net/reporting/reporting_cache.cc
+++ b/net/reporting/reporting_cache.cc
@@ -14,6 +14,7 @@
#include "base/stl_util.h"
#include "base/time/time.h"
#include "net/reporting/reporting_client.h"
+#include "net/reporting/reporting_context.h"
#include "net/reporting/reporting_report.h"
#include "url/gurl.h"
@@ -37,6 +38,8 @@ void ReportingCache::AddReport(const GURL& url,
auto inserted =
reports_.insert(std::make_pair(report.get(), std::move(report)));
DCHECK(inserted.second);
+
+ context_->NotifyCacheUpdated();
}
void ReportingCache::GetReports(
@@ -78,6 +81,8 @@ void ReportingCache::IncrementReportsAttempts(
DCHECK(base::ContainsKey(reports_, report));
reports_[report]->attempts++;
}
+
+ context_->NotifyCacheUpdated();
}
void ReportingCache::RemoveReports(
@@ -91,6 +96,8 @@ void ReportingCache::RemoveReports(
reports_.erase(report);
}
}
+
+ context_->NotifyCacheUpdated();
}
void ReportingCache::RemoveAllReports() {
@@ -107,6 +114,8 @@ void ReportingCache::RemoveAllReports() {
for (auto& it : reports_to_remove)
reports_.erase(it);
+
+ context_->NotifyCacheUpdated();
}
void ReportingCache::GetClients(
@@ -142,6 +151,8 @@ void ReportingCache::SetClient(const url::Origin& origin,
clients_[origin][endpoint] = base::MakeUnique<ReportingClient>(
origin, endpoint, subdomains, group, expires);
+
+ context_->NotifyCacheUpdated();
}
void ReportingCache::RemoveClients(
@@ -151,6 +162,8 @@ void ReportingCache::RemoveClients(
DCHECK(clients_[client->origin][client->endpoint].get() == client);
clients_[client->origin].erase(client->endpoint);
}
+
+ context_->NotifyCacheUpdated();
}
void ReportingCache::RemoveClientForOriginAndEndpoint(const url::Origin& origin,
@@ -158,15 +171,21 @@ void ReportingCache::RemoveClientForOriginAndEndpoint(const url::Origin& origin,
DCHECK(base::ContainsKey(clients_, origin));
DCHECK(base::ContainsKey(clients_[origin], endpoint));
clients_[origin].erase(endpoint);
+
+ context_->NotifyCacheUpdated();
}
void ReportingCache::RemoveClientsForEndpoint(const GURL& endpoint) {
for (auto& it : clients_)
it.second.erase(endpoint);
+
+ context_->NotifyCacheUpdated();
}
void ReportingCache::RemoveAllClients() {
clients_.clear();
+
+ context_->NotifyCacheUpdated();
}
} // namespace net
« no previous file with comments | « net/BUILD.gn ('k') | net/reporting/reporting_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698