Index: net/reporting/reporting_persister.cc |
diff --git a/net/reporting/reporting_persister.cc b/net/reporting/reporting_persister.cc |
index ec2a37b7e48c633b9b3dda03da8d936d582378a0..4dcc032bb4836870be0bf81b303d7f6ec3df8294 100644 |
--- a/net/reporting/reporting_persister.cc |
+++ b/net/reporting/reporting_persister.cc |
@@ -16,7 +16,6 @@ |
#include "net/reporting/reporting_cache.h" |
#include "net/reporting/reporting_client.h" |
#include "net/reporting/reporting_context.h" |
-#include "net/reporting/reporting_delegate.h" |
#include "net/reporting/reporting_observer.h" |
#include "net/reporting/reporting_policy.h" |
#include "net/reporting/reporting_report.h" |
@@ -61,49 +60,15 @@ bool DeserializeOrigin(const base::DictionaryValue& serialized, |
return true; |
} |
-class ReportingPersisterImpl : public ReportingPersister, |
- public ReportingObserver { |
+class ReportingPersisterImpl : public ReportingPersister { |
public: |
- ReportingPersisterImpl(ReportingContext* context) |
- : context_(context), timer_(base::MakeUnique<base::OneShotTimer>()) {} |
+ ReportingPersisterImpl(ReportingContext* context) : context_(context) {} |
// ReportingPersister implementation: |
- ~ReportingPersisterImpl() override { |
- DCHECK(context_->initialized()); |
- context_->RemoveObserver(this); |
- } |
- |
- void Initialize() override { |
- std::unique_ptr<const base::Value> persisted_data = |
- context_->delegate()->GetPersistedData(); |
- if (persisted_data) |
- Deserialize(*persisted_data); |
- context_->AddObserver(this); |
- } |
- |
- void SetTimerForTesting(std::unique_ptr<base::Timer> timer) override { |
- DCHECK(!context_->initialized()); |
- timer_ = std::move(timer); |
- } |
- |
- // ReportingObserver implementation: |
- |
- void OnCacheUpdated() override { |
- DCHECK(context_->initialized()); |
- if (!timer_->IsRunning()) |
- StartTimer(); |
- } |
+ ~ReportingPersisterImpl() override {} |
private: |
- void StartTimer() { |
- timer_->Start( |
- FROM_HERE, context_->policy().persistence_interval, |
- base::Bind(&ReportingPersisterImpl::Persist, base::Unretained(this))); |
- } |
- |
- void Persist() { delegate()->PersistData(Serialize()); } |
- |
std::string SerializeTicks(base::TimeTicks time_ticks) { |
base::Time time = time_ticks - tick_clock()->NowTicks() + clock()->Now(); |
return base::Int64ToString(time.ToInternalValue()); |
@@ -336,13 +301,11 @@ class ReportingPersisterImpl : public ReportingPersister, |
} |
const ReportingPolicy& policy() { return context_->policy(); } |
- ReportingDelegate* delegate() { return context_->delegate(); } |
base::Clock* clock() { return context_->clock(); } |
base::TickClock* tick_clock() { return context_->tick_clock(); } |
ReportingCache* cache() { return context_->cache(); } |
ReportingContext* context_; |
- std::unique_ptr<base::Timer> timer_; |
}; |
} // namespace |