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

Unified Diff: sync/engine/sync_scheduler_whitebox_unittest.cc

Issue 10917234: sync: make scheduling logic and job ownership more obvious. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review Created 8 years, 2 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
Index: sync/engine/sync_scheduler_whitebox_unittest.cc
diff --git a/sync/engine/sync_scheduler_whitebox_unittest.cc b/sync/engine/sync_scheduler_whitebox_unittest.cc
index 8cf4a37b0c821f3ace86f0b98788e5de01884f01..d016da101cfc1387efc81f3027fe57bfab1d6273 100644
--- a/sync/engine/sync_scheduler_whitebox_unittest.cc
+++ b/sync/engine/sync_scheduler_whitebox_unittest.cc
@@ -92,8 +92,8 @@ class SyncSchedulerWhiteboxTest : public testing::Test {
}
SyncSchedulerImpl::JobProcessDecision DecideOnJob(
- const SyncSchedulerImpl::SyncSessionJob& job) {
- return scheduler_->DecideOnJob(job);
+ const SyncSessionJob* job) {
akalin 2012/10/26 06:52:29 const ref please
+ return scheduler_->DecideOnJob(*job);
}
void InitializeSyncerOnNormalMode() {
@@ -102,14 +102,11 @@ class SyncSchedulerWhiteboxTest : public testing::Test {
}
SyncSchedulerImpl::JobProcessDecision CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::SyncSessionJobPurpose purpose) {
- SyncSession* s = scheduler_->CreateSyncSession(SyncSourceInfo());
- SyncSchedulerImpl::SyncSessionJob job(purpose, TimeTicks::Now(),
- make_linked_ptr(s),
- false,
- ConfigurationParams(),
- FROM_HERE);
- return DecideOnJob(job);
+ SyncSessionJob::Purpose purpose) {
+ scoped_ptr<SyncSession> s(scheduler_->CreateSyncSession(SyncSourceInfo()));
+ SyncSessionJob job(purpose, TimeTicks::Now(), s.Pass(),
+ ConfigurationParams(), FROM_HERE);
+ return DecideOnJob(&job);
}
SyncSessionContext* context() { return context_.get(); }
@@ -135,7 +132,7 @@ TEST_F(SyncSchedulerWhiteboxTest, SaveNudge) {
SetMode(SyncScheduler::CONFIGURATION_MODE);
SyncSchedulerImpl::JobProcessDecision decision =
- CreateAndDecideJob(SyncSchedulerImpl::SyncSessionJob::NUDGE);
+ CreateAndDecideJob(SyncSessionJob::NUDGE);
EXPECT_EQ(decision, SyncSchedulerImpl::SAVE);
}
@@ -153,18 +150,15 @@ TEST_F(SyncSchedulerWhiteboxTest, SaveNudgeWhileTypeThrottled) {
ModelTypeSetToInvalidationMap(types, std::string());
SyncSourceInfo info(GetUpdatesCallerInfo::LOCAL, invalidation_map);
- SyncSession* s = scheduler_->CreateSyncSession(info);
+ scoped_ptr<SyncSession> s(scheduler_->CreateSyncSession(info));
// Now schedule a nudge with just bookmarks and the change is local.
- SyncSchedulerImpl::SyncSessionJob job(
- SyncSchedulerImpl::SyncSessionJob::NUDGE,
- TimeTicks::Now(),
- make_linked_ptr(s),
- false,
- ConfigurationParams(),
- FROM_HERE);
-
- SyncSchedulerImpl::JobProcessDecision decision = DecideOnJob(job);
+ SyncSessionJob job(SyncSessionJob::NUDGE,
+ TimeTicks::Now(),
+ s.Pass(),
+ ConfigurationParams(),
+ FROM_HERE);
+ SyncSchedulerImpl::JobProcessDecision decision = DecideOnJob(&job);
EXPECT_EQ(decision, SyncSchedulerImpl::SAVE);
}
@@ -172,7 +166,7 @@ TEST_F(SyncSchedulerWhiteboxTest, ContinueNudge) {
InitializeSyncerOnNormalMode();
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::NUDGE);
+ SyncSessionJob::NUDGE);
EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE);
}
@@ -182,7 +176,7 @@ TEST_F(SyncSchedulerWhiteboxTest, DropPoll) {
SetMode(SyncScheduler::CONFIGURATION_MODE);
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::POLL);
+ SyncSessionJob::POLL);
EXPECT_EQ(decision, SyncSchedulerImpl::DROP);
}
@@ -191,7 +185,7 @@ TEST_F(SyncSchedulerWhiteboxTest, ContinuePoll) {
InitializeSyncerOnNormalMode();
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::POLL);
+ SyncSessionJob::POLL);
EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE);
}
@@ -201,7 +195,7 @@ TEST_F(SyncSchedulerWhiteboxTest, ContinueConfiguration) {
SetMode(SyncScheduler::CONFIGURATION_MODE);
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::CONFIGURATION);
+ SyncSessionJob::CONFIGURATION);
EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE);
}
@@ -213,7 +207,7 @@ TEST_F(SyncSchedulerWhiteboxTest, SaveConfigurationWhileThrottled) {
SetWaitIntervalToThrottled();
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::CONFIGURATION);
+ SyncSessionJob::CONFIGURATION);
EXPECT_EQ(decision, SyncSchedulerImpl::SAVE);
}
@@ -225,7 +219,7 @@ TEST_F(SyncSchedulerWhiteboxTest, SaveNudgeWhileThrottled) {
SetWaitIntervalToThrottled();
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::NUDGE);
+ SyncSessionJob::NUDGE);
EXPECT_EQ(decision, SyncSchedulerImpl::SAVE);
}
@@ -236,7 +230,7 @@ TEST_F(SyncSchedulerWhiteboxTest, ContinueNudgeWhileExponentialBackOff) {
SetWaitIntervalToExponentialBackoff();
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::NUDGE);
+ SyncSessionJob::NUDGE);
EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE);
}
@@ -248,7 +242,7 @@ TEST_F(SyncSchedulerWhiteboxTest, DropNudgeWhileExponentialBackOff) {
SetWaitIntervalHadNudge(true);
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::NUDGE);
+ SyncSessionJob::NUDGE);
EXPECT_EQ(decision, SyncSchedulerImpl::DROP);
}
@@ -258,11 +252,12 @@ TEST_F(SyncSchedulerWhiteboxTest, ContinueCanaryJobConfig) {
SetMode(SyncScheduler::CONFIGURATION_MODE);
SetWaitIntervalToExponentialBackoff();
- struct SyncSchedulerImpl::SyncSessionJob job;
- job.purpose = SyncSchedulerImpl::SyncSessionJob::CONFIGURATION;
- job.scheduled_start = TimeTicks::Now();
- job.is_canary_job = true;
- SyncSchedulerImpl::JobProcessDecision decision = DecideOnJob(job);
+ SyncSessionJob job(SyncSessionJob::CONFIGURATION,
+ TimeTicks::Now(), scoped_ptr<SyncSession>(),
+ ConfigurationParams(), FROM_HERE);
+
+ job.GrantCanaryPrivilege();
+ SyncSchedulerImpl::JobProcessDecision decision = DecideOnJob(&job);
EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE);
}

Powered by Google App Engine
This is Rietveld 408576698