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

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: test + comment + rebase Created 8 years, 3 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 0a9c73e6740c521bafb47f98259cbe162960b0e3..cf36a4296a244789563441638acfe8e4cdf1bc2c 100644
--- a/sync/engine/sync_scheduler_whitebox_unittest.cc
+++ b/sync/engine/sync_scheduler_whitebox_unittest.cc
@@ -92,7 +92,7 @@ class SyncSchedulerWhiteboxTest : public testing::Test {
}
SyncSchedulerImpl::JobProcessDecision DecideOnJob(
- const SyncSchedulerImpl::SyncSessionJob& job) {
+ const SyncSessionJob* job) {
return scheduler_->DecideOnJob(job);
}
@@ -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);
}
@@ -154,18 +151,15 @@ TEST_F(SyncSchedulerWhiteboxTest, SaveNudgeWhileTypeThrottled) {
type_state_map.insert(std::make_pair(BOOKMARKS, InvalidationState()));
SyncSourceInfo info(GetUpdatesCallerInfo::LOCAL, type_state_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);
}
@@ -173,7 +167,7 @@ TEST_F(SyncSchedulerWhiteboxTest, ContinueNudge) {
InitializeSyncerOnNormalMode();
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::NUDGE);
+ SyncSessionJob::NUDGE);
EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE);
}
@@ -183,7 +177,7 @@ TEST_F(SyncSchedulerWhiteboxTest, DropPoll) {
SetMode(SyncScheduler::CONFIGURATION_MODE);
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::POLL);
+ SyncSessionJob::POLL);
EXPECT_EQ(decision, SyncSchedulerImpl::DROP);
}
@@ -192,7 +186,7 @@ TEST_F(SyncSchedulerWhiteboxTest, ContinuePoll) {
InitializeSyncerOnNormalMode();
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::POLL);
+ SyncSessionJob::POLL);
EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE);
}
@@ -202,7 +196,7 @@ TEST_F(SyncSchedulerWhiteboxTest, ContinueConfiguration) {
SetMode(SyncScheduler::CONFIGURATION_MODE);
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::CONFIGURATION);
+ SyncSessionJob::CONFIGURATION);
EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE);
}
@@ -214,7 +208,7 @@ TEST_F(SyncSchedulerWhiteboxTest, SaveConfigurationWhileThrottled) {
SetWaitIntervalToThrottled();
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::CONFIGURATION);
+ SyncSessionJob::CONFIGURATION);
EXPECT_EQ(decision, SyncSchedulerImpl::SAVE);
}
@@ -226,7 +220,7 @@ TEST_F(SyncSchedulerWhiteboxTest, SaveNudgeWhileThrottled) {
SetWaitIntervalToThrottled();
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::NUDGE);
+ SyncSessionJob::NUDGE);
EXPECT_EQ(decision, SyncSchedulerImpl::SAVE);
}
@@ -237,7 +231,7 @@ TEST_F(SyncSchedulerWhiteboxTest, ContinueNudgeWhileExponentialBackOff) {
SetWaitIntervalToExponentialBackoff();
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::NUDGE);
+ SyncSessionJob::NUDGE);
EXPECT_EQ(decision, SyncSchedulerImpl::CONTINUE);
}
@@ -249,7 +243,7 @@ TEST_F(SyncSchedulerWhiteboxTest, DropNudgeWhileExponentialBackOff) {
SetWaitIntervalHadNudge(true);
SyncSchedulerImpl::JobProcessDecision decision = CreateAndDecideJob(
- SyncSchedulerImpl::SyncSessionJob::NUDGE);
+ SyncSessionJob::NUDGE);
EXPECT_EQ(decision, SyncSchedulerImpl::DROP);
}
@@ -259,11 +253,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