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

Unified Diff: net/reporting/reporting_test_util.cc

Issue 2835923005: Reporting: Remove persistence for now. (Closed)
Patch Set: 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_test_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/reporting/reporting_test_util.cc
diff --git a/net/reporting/reporting_test_util.cc b/net/reporting/reporting_test_util.cc
index 74d0cb4d6aad69e1ef882bf278cdaa48091ec821..2a7d1e0c8b61f8680d984c18b5a611ea3e0af51b 100644
--- a/net/reporting/reporting_test_util.cc
+++ b/net/reporting/reporting_test_util.cc
@@ -17,7 +17,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_delivery_agent.h"
#include "net/reporting/reporting_garbage_collector.h"
#include "net/reporting/reporting_persister.h"
@@ -91,20 +90,6 @@ const ReportingClient* FindClientInCache(const ReportingCache* cache,
return nullptr;
}
-TestReportingDelegate::TestReportingDelegate() {}
-TestReportingDelegate::~TestReportingDelegate() {}
-
-void TestReportingDelegate::PersistData(
- std::unique_ptr<const base::Value> persisted_data) {
- persisted_data_ = std::move(persisted_data);
-}
-
-std::unique_ptr<const base::Value> TestReportingDelegate::GetPersistedData() {
- if (!persisted_data_)
- return std::unique_ptr<const base::Value>();
- return persisted_data_->CreateDeepCopy();
-}
-
TestReportingUploader::PendingUpload::~PendingUpload() {}
TestReportingUploader::PendingUpload::PendingUpload() {}
@@ -120,18 +105,14 @@ void TestReportingUploader::StartUpload(const GURL& url,
TestReportingContext::TestReportingContext(const ReportingPolicy& policy)
: ReportingContext(policy,
- base::MakeUnique<TestReportingDelegate>(),
base::MakeUnique<base::SimpleTestClock>(),
base::MakeUnique<base::SimpleTestTickClock>(),
base::MakeUnique<TestReportingUploader>()),
delivery_timer_(new base::MockTimer(/* retain_user_task= */ false,
/* is_repeating= */ false)),
- persistence_timer_(new base::MockTimer(/* retain_user_task= */ false,
- /* is_repeating= */ false)),
garbage_collection_timer_(
new base::MockTimer(/* retain_user_task= */ false,
/* is_repeating= */ false)) {
- persister()->SetTimerForTesting(base::WrapUnique(persistence_timer_));
garbage_collector()->SetTimerForTesting(
base::WrapUnique(garbage_collection_timer_));
delivery_agent()->SetTimerForTesting(base::WrapUnique(delivery_timer_));
@@ -139,7 +120,6 @@ TestReportingContext::TestReportingContext(const ReportingPolicy& policy)
TestReportingContext::~TestReportingContext() {
delivery_timer_ = nullptr;
- persistence_timer_ = nullptr;
garbage_collection_timer_ = nullptr;
}
@@ -148,34 +128,27 @@ ReportingTestBase::ReportingTestBase() {
ReportingPolicy policy;
policy.endpoint_backoff_policy.jitter_factor = 0.0;
- CreateAndInitializeContext(policy, std::unique_ptr<const base::Value>(),
- base::Time::Now(), base::TimeTicks::Now());
+ CreateContext(policy, base::Time::Now(), base::TimeTicks::Now());
}
ReportingTestBase::~ReportingTestBase() {}
void ReportingTestBase::UsePolicy(const ReportingPolicy& new_policy) {
- CreateAndInitializeContext(new_policy, delegate()->GetPersistedData(),
- clock()->Now(), tick_clock()->NowTicks());
+ CreateContext(new_policy, clock()->Now(), tick_clock()->NowTicks());
}
void ReportingTestBase::SimulateRestart(base::TimeDelta delta,
base::TimeDelta delta_ticks) {
- CreateAndInitializeContext(policy(), delegate()->GetPersistedData(),
- clock()->Now() + delta,
- tick_clock()->NowTicks() + delta_ticks);
+ CreateContext(policy(), clock()->Now() + delta,
+ tick_clock()->NowTicks() + delta_ticks);
}
-void ReportingTestBase::CreateAndInitializeContext(
- const ReportingPolicy& policy,
- std::unique_ptr<const base::Value> persisted_data,
- base::Time now,
- base::TimeTicks now_ticks) {
+void ReportingTestBase::CreateContext(const ReportingPolicy& policy,
+ base::Time now,
+ base::TimeTicks now_ticks) {
context_ = base::MakeUnique<TestReportingContext>(policy);
- delegate()->PersistData(std::move(persisted_data));
clock()->SetNow(now);
tick_clock()->SetNowTicks(now_ticks);
- context_->Initialize();
}
base::TimeTicks ReportingTestBase::yesterday() {
« no previous file with comments | « net/reporting/reporting_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698