| Index: net/reporting/reporting_context.cc
|
| diff --git a/net/reporting/reporting_context.cc b/net/reporting/reporting_context.cc
|
| index cc50dc7aef2456a6f7725b8141790ae38724c2fd..25234c82f0350c2466766d6ed6bd79373bc02000 100644
|
| --- a/net/reporting/reporting_context.cc
|
| +++ b/net/reporting/reporting_context.cc
|
| @@ -13,12 +13,14 @@
|
| #include "base/time/default_tick_clock.h"
|
| #include "base/time/tick_clock.h"
|
| #include "base/time/time.h"
|
| +#include "base/timer/timer.h"
|
| #include "net/base/backoff_entry.h"
|
| #include "net/reporting/reporting_cache.h"
|
| #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_persister.h"
|
| #include "net/reporting/reporting_policy.h"
|
|
|
| namespace net {
|
| @@ -52,6 +54,18 @@ std::unique_ptr<ReportingContext> ReportingContext::Create(
|
|
|
| ReportingContext::~ReportingContext() {}
|
|
|
| +void ReportingContext::Initialize() {
|
| + DCHECK(!initialized_);
|
| +
|
| + for (auto& observer : observers_)
|
| + observer.OnContextInitializing();
|
| +
|
| + initialized_ = true;
|
| +
|
| + for (auto& observer : observers_)
|
| + observer.OnContextInitialized();
|
| +}
|
| +
|
| void ReportingContext::AddObserver(ReportingObserver* observer) {
|
| DCHECK(!observers_.HasObserver(observer));
|
| observers_.AddObserver(observer);
|
| @@ -63,6 +77,9 @@ void ReportingContext::RemoveObserver(ReportingObserver* observer) {
|
| }
|
|
|
| void ReportingContext::NotifyCacheUpdated() {
|
| + if (!initialized_)
|
| + return;
|
| +
|
| for (auto& observer : observers_)
|
| observer.OnCacheUpdated();
|
| }
|
| @@ -77,8 +94,10 @@ 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)) {}
|
| + delivery_agent_(base::MakeUnique<ReportingDeliveryAgent>(this)),
|
| + persister_(ReportingPersister::Create(this)) {}
|
|
|
| } // namespace net
|
|
|