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

Unified Diff: net/reporting/reporting_context.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/reporting/reporting_context.h ('k') | net/reporting/reporting_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/reporting/reporting_context.cc
diff --git a/net/reporting/reporting_context.cc b/net/reporting/reporting_context.cc
index 79235e63747aa46267fe2848d0194cf9381af841..cc50dc7aef2456a6f7725b8141790ae38724c2fd 100644
--- a/net/reporting/reporting_context.cc
+++ b/net/reporting/reporting_context.cc
@@ -7,6 +7,7 @@
#include <memory>
#include "base/memory/ptr_util.h"
+#include "base/observer_list.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/time/default_tick_clock.h"
@@ -17,6 +18,7 @@
#include "net/reporting/reporting_delegate.h"
#include "net/reporting/reporting_delivery_agent.h"
#include "net/reporting/reporting_endpoint_manager.h"
+#include "net/reporting/reporting_observer.h"
#include "net/reporting/reporting_policy.h"
namespace net {
@@ -50,6 +52,21 @@ std::unique_ptr<ReportingContext> ReportingContext::Create(
ReportingContext::~ReportingContext() {}
+void ReportingContext::AddObserver(ReportingObserver* observer) {
+ DCHECK(!observers_.HasObserver(observer));
+ observers_.AddObserver(observer);
+}
+
+void ReportingContext::RemoveObserver(ReportingObserver* observer) {
+ DCHECK(observers_.HasObserver(observer));
+ observers_.RemoveObserver(observer);
+}
+
+void ReportingContext::NotifyCacheUpdated() {
+ for (auto& observer : observers_)
+ observer.OnCacheUpdated();
+}
+
ReportingContext::ReportingContext(const ReportingPolicy& policy,
std::unique_ptr<ReportingDelegate> delegate,
std::unique_ptr<base::Clock> clock,
« no previous file with comments | « net/reporting/reporting_context.h ('k') | net/reporting/reporting_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698