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

Unified Diff: net/reporting/reporting_context.cc

Issue 2751883003: Reporting: Implement serializer. (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_garbage_collector.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 c16604618f79b3fedeeacaf554d166fe2e4d7f7e..1dd255bcb1b8759b97bfc6a9be75fc2ebcd1d3ce 100644
--- a/net/reporting/reporting_context.cc
+++ b/net/reporting/reporting_context.cc
@@ -21,6 +21,7 @@
#include "net/reporting/reporting_endpoint_manager.h"
#include "net/reporting/reporting_garbage_collector.h"
#include "net/reporting/reporting_observer.h"
+#include "net/reporting/reporting_persister.h"
#include "net/reporting/reporting_policy.h"
namespace net {
@@ -54,6 +55,15 @@ std::unique_ptr<ReportingContext> ReportingContext::Create(
ReportingContext::~ReportingContext() {}
+void ReportingContext::Initialize() {
+ DCHECK(!initialized_);
+
+ persister_->Initialize();
+ garbage_collector_->Initialize();
+
+ initialized_ = true;
+}
+
void ReportingContext::AddObserver(ReportingObserver* observer) {
DCHECK(!observers_.HasObserver(observer));
observers_.AddObserver(observer);
@@ -65,6 +75,9 @@ void ReportingContext::RemoveObserver(ReportingObserver* observer) {
}
void ReportingContext::NotifyCacheUpdated() {
+ if (!initialized_)
+ return;
+
for (auto& observer : observers_)
observer.OnCacheUpdated();
}
@@ -79,9 +92,11 @@ ReportingContext::ReportingContext(const ReportingPolicy& policy,
clock_(std::move(clock)),
tick_clock_(std::move(tick_clock)),
uploader_(std::move(uploader)),
+ initialized_(false),
cache_(base::MakeUnique<ReportingCache>(this)),
endpoint_manager_(base::MakeUnique<ReportingEndpointManager>(this)),
delivery_agent_(base::MakeUnique<ReportingDeliveryAgent>(this)),
+ persister_(ReportingPersister::Create(this)),
garbage_collector_(ReportingGarbageCollector::Create(this)) {}
} // namespace net
« no previous file with comments | « net/reporting/reporting_context.h ('k') | net/reporting/reporting_garbage_collector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698