diff options
author | lipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 01:39:04 +0000 |
---|---|---|
committer | lipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 01:39:04 +0000 |
commit | b38db788ee896f842abac933ae6641568a16afb2 (patch) | |
tree | 6bfa9115d967c46ec1bc20c36f0631c29fbccbe6 | |
parent | 87896ecd561ed8597cc667bd191321e65e0128e4 (diff) | |
download | chromium_src-b38db788ee896f842abac933ae6641568a16afb2.zip chromium_src-b38db788ee896f842abac933ae6641568a16afb2.tar.gz chromium_src-b38db788ee896f842abac933ae6641568a16afb2.tar.bz2 |
Showing the location of where nudges came from.
BUG=77006
TEST=
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=80251
Review URL: http://codereview.chromium.org/6764019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80402 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/sync/engine/syncapi.cc | 16 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncapi.h | 3 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncer_thread2.cc | 46 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncer_thread2.h | 12 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncer_thread2_unittest.cc | 66 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncer_thread_adapter.cc | 19 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncer_thread_adapter.h | 10 | ||||
-rw-r--r-- | chrome/browser/sync/glue/sync_backend_host.cc | 14 | ||||
-rw-r--r-- | chrome/browser/sync/glue/sync_backend_host.h | 4 | ||||
-rw-r--r-- | chrome/browser/sync/test_profile_sync_service.cc | 8 | ||||
-rw-r--r-- | chrome/browser/sync/test_profile_sync_service.h | 5 |
11 files changed, 128 insertions, 75 deletions
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc index e1f35f0..89a9ded 100644 --- a/chrome/browser/sync/engine/syncapi.cc +++ b/chrome/browser/sync/engine/syncapi.cc @@ -1641,14 +1641,15 @@ bool SyncManager::RequestResume() { return false; } -void SyncManager::RequestNudge() { +void SyncManager::RequestNudge(const tracked_objects::Location& location) { if (data_->syncer_thread()) - data_->syncer_thread()->NudgeSyncer(0, SyncerThread::kLocal); + data_->syncer_thread()->NudgeSyncer(0, SyncerThread::kLocal, location); } void SyncManager::RequestClearServerData() { if (data_->syncer_thread()) - data_->syncer_thread()->NudgeSyncer(0, SyncerThread::kClearPrivateData); + data_->syncer_thread()->NudgeSyncer(0, SyncerThread::kClearPrivateData, + FROM_HERE); } void SyncManager::RequestConfig(const syncable::ModelTypeBitSet& types) { @@ -1952,7 +1953,7 @@ void SyncManager::SyncInternal::SetPassphrase( // Nudge the syncer so that encrypted datatype updates that were waiting for // this passphrase get applied as soon as possible. - sync_manager_->RequestNudge(); + sync_manager_->RequestNudge(FROM_HERE); } else { VLOG(1) << "No pending keys, adding provided passphrase."; WriteNode node(&trans); @@ -2191,7 +2192,7 @@ void SyncManager::SyncInternal::OnIPAddressChangedImpl() { // TODO(akalin): CheckServerReachable() can block, which may cause // jank if we try to shut down sync. Fix this. connection_manager()->CheckServerReachable(); - sync_manager_->RequestNudge(); + sync_manager_->RequestNudge(FROM_HERE); } // Listen to model changes, filter out ones initiated by the sync API, and @@ -2337,7 +2338,8 @@ void SyncManager::SyncInternal::HandleCalculateChangesChangeEventFromSyncApi( syncer_thread()->NudgeSyncerWithDataTypes( nudge_delay, SyncerThread::kLocal, - model_types); + model_types, + FROM_HERE); } } @@ -2664,7 +2666,7 @@ void SyncManager::SyncInternal::OnIncomingNotification( syncer_thread()->NudgeSyncerWithPayloads( kSyncerThreadDelayMsec, SyncerThread::kNotification, - type_payloads); + type_payloads, FROM_HERE); } allstatus_.IncrementNotificationsReceived(); UpdateNotificationInfo(type_payloads); diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h index 88e30fd..18da106 100644 --- a/chrome/browser/sync/engine/syncapi.h +++ b/chrome/browser/sync/engine/syncapi.h @@ -46,6 +46,7 @@ #include "base/callback.h" #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" +#include "base/tracked.h" #include "build/build_config.h" #include "chrome/browser/sync/protocol/password_specifics.pb.h" #include "chrome/browser/sync/syncable/autofill_migration.h" @@ -940,7 +941,7 @@ class SyncManager { // Request a nudge of the syncer, which will cause the syncer thread // to run at the next available opportunity. - void RequestNudge(); + void RequestNudge(const tracked_objects::Location& nudge_location); // Request a clearing of all data on the server void RequestClearServerData(); diff --git a/chrome/browser/sync/engine/syncer_thread2.cc b/chrome/browser/sync/engine/syncer_thread2.cc index 639f518..e94215e 100644 --- a/chrome/browser/sync/engine/syncer_thread2.cc +++ b/chrome/browser/sync/engine/syncer_thread2.cc @@ -47,6 +47,11 @@ struct SyncerThread::SyncSessionJob { SyncSessionJobPurpose purpose; base::TimeTicks scheduled_start; linked_ptr<sessions::SyncSession> session; + + // This is the location the nudge came from. used for debugging purpose. + // In case of multiple nudges getting coalesced this stores the first nudge + // that came in. + tracked_objects::Location nudge_location; }; SyncerThread::DelayProvider::DelayProvider() {} @@ -225,7 +230,8 @@ void SyncerThread::ScheduleClearUserData() { } void SyncerThread::ScheduleNudge(const TimeDelta& delay, - NudgeSource source, const ModelTypeBitSet& types) { + NudgeSource source, const ModelTypeBitSet& types, + const tracked_objects::Location& nudge_location) { if (!thread_.IsRunning()) { NOTREACHED(); return; @@ -235,11 +241,12 @@ void SyncerThread::ScheduleNudge(const TimeDelta& delay, syncable::ModelTypePayloadMapFromBitSet(types, std::string()); thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod( this, &SyncerThread::ScheduleNudgeImpl, delay, source, - types_with_payloads)); + types_with_payloads, nudge_location)); } void SyncerThread::ScheduleNudgeWithPayloads(const TimeDelta& delay, - NudgeSource source, const ModelTypePayloadMap& types_with_payloads) { + NudgeSource source, const ModelTypePayloadMap& types_with_payloads, + const tracked_objects::Location& nudge_location) { if (!thread_.IsRunning()) { NOTREACHED(); return; @@ -247,7 +254,7 @@ void SyncerThread::ScheduleNudgeWithPayloads(const TimeDelta& delay, thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod( this, &SyncerThread::ScheduleNudgeImpl, delay, source, - types_with_payloads)); + types_with_payloads, nudge_location)); } void SyncerThread::ScheduleClearUserDataImpl() { @@ -255,11 +262,13 @@ void SyncerThread::ScheduleClearUserDataImpl() { SyncSession* session = new SyncSession(session_context_.get(), this, SyncSourceInfo(), ModelSafeRoutingInfo(), std::vector<ModelSafeWorker*>()); - ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), CLEAR_USER_DATA, session); + ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), CLEAR_USER_DATA, session, + FROM_HERE); } void SyncerThread::ScheduleNudgeImpl(const TimeDelta& delay, - NudgeSource source, const ModelTypePayloadMap& types_with_payloads) { + NudgeSource source, const ModelTypePayloadMap& types_with_payloads, + const tracked_objects::Location& nudge_location) { DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); TimeTicks rough_start = TimeTicks::Now() + delay; if (!ShouldRunJob(NUDGE, rough_start)) { @@ -286,6 +295,7 @@ void SyncerThread::ScheduleNudgeImpl(const TimeDelta& delay, return; pending_nudge_->session->Coalesce(*session.get()); + if (!IsBackingOff()) { return; } else { @@ -296,7 +306,7 @@ void SyncerThread::ScheduleNudgeImpl(const TimeDelta& delay, pending_nudge_.reset(); } } - ScheduleSyncSessionJob(delay, NUDGE, session.release()); + ScheduleSyncSessionJob(delay, NUDGE, session.release(), nudge_location); } // Helper to extract the routing info and workers corresponding to types in @@ -357,20 +367,24 @@ void SyncerThread::ScheduleConfigImpl(const ModelSafeRoutingInfo& routing_info, syncable::ModelTypePayloadMapFromRoutingInfo( routing_info, std::string())), routing_info, workers); - ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), CONFIGURATION, session); + ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), CONFIGURATION, session, + FROM_HERE); } void SyncerThread::ScheduleSyncSessionJob(const base::TimeDelta& delay, - SyncSessionJobPurpose purpose, sessions::SyncSession* session) { + SyncSessionJobPurpose purpose, sessions::SyncSession* session, + const tracked_objects::Location& nudge_location) { DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); + SyncSessionJob job = {purpose, TimeTicks::Now() + delay, - make_linked_ptr(session)}; + make_linked_ptr(session), nudge_location}; if (purpose == NUDGE) { DCHECK(!pending_nudge_.get() || pending_nudge_->session.get() == session); pending_nudge_.reset(new SyncSessionJob(job)); } MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod(this, - &SyncerThread::DoSyncSessionJob, job), delay.InMilliseconds()); + &SyncerThread::DoSyncSessionJob, job), + delay.InMilliseconds()); } void SyncerThread::SetSyncerStepsForPurpose(SyncSessionJobPurpose purpose, @@ -506,7 +520,7 @@ void SyncerThread::ScheduleNextSync(const SyncSessionJob& old_job) { // We weren't continuing and we aren't in backoff. Schedule a normal // continuation. ScheduleNudgeImpl(TimeDelta::FromSeconds(0), NUDGE_SOURCE_CONTINUATION, - old_job.session->source().types); + old_job.session->source().types, FROM_HERE); } } @@ -543,7 +557,7 @@ void SyncerThread::HandleConsecutiveContinuationError( wait_interval_.reset(new WaitInterval(WaitInterval::EXPONENTIAL_BACKOFF, length)); SyncSessionJob job = {NUDGE, TimeTicks::Now() + length, - make_linked_ptr(s)}; + make_linked_ptr(s), FROM_HERE}; pending_nudge_.reset(new SyncSessionJob(job)); wait_interval_->timer.Start(length, this, &SyncerThread::DoCanaryJob); } @@ -581,9 +595,7 @@ void SyncerThread::Stop() { void SyncerThread::DoCanaryJob() { DCHECK(pending_nudge_.get()); wait_interval_->had_nudge = false; - SyncSessionJob copy = {pending_nudge_->purpose, - pending_nudge_->scheduled_start, - pending_nudge_->session}; + SyncSessionJob copy = *pending_nudge_; DoSyncSessionJob(copy); } @@ -597,7 +609,7 @@ void SyncerThread::PollTimerCallback() { syncable::ModelTypePayloadMapFromRoutingInfo(r, std::string()); SyncSourceInfo info(GetUpdatesCallerInfo::PERIODIC, types_with_payloads); SyncSession* s = new SyncSession(session_context_.get(), this, info, r, w); - ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), POLL, s); + ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), POLL, s, FROM_HERE); } void SyncerThread::Unthrottle() { diff --git a/chrome/browser/sync/engine/syncer_thread2.h b/chrome/browser/sync/engine/syncer_thread2.h index 3768456..3fbdd7f 100644 --- a/chrome/browser/sync/engine/syncer_thread2.h +++ b/chrome/browser/sync/engine/syncer_thread2.h @@ -68,10 +68,12 @@ class SyncerThread : public sessions::SyncSession::Delegate, // The meat and potatoes. void ScheduleNudge(const base::TimeDelta& delay, NudgeSource source, - const syncable::ModelTypeBitSet& types); + const syncable::ModelTypeBitSet& types, + const tracked_objects::Location& nudge_location); void ScheduleNudgeWithPayloads( const base::TimeDelta& delay, NudgeSource source, - const syncable::ModelTypePayloadMap& types_with_payloads); + const syncable::ModelTypePayloadMap& types_with_payloads, + const tracked_objects::Location& nudge_location); void ScheduleConfig(const syncable::ModelTypeBitSet& types); void ScheduleClearUserData(); @@ -136,7 +138,8 @@ class SyncerThread : public sessions::SyncSession::Delegate, // Helper to assemble a job and post a delayed task to sync. void ScheduleSyncSessionJob(const base::TimeDelta& delay, SyncSessionJobPurpose purpose, - sessions::SyncSession* session); + sessions::SyncSession* session, + const tracked_objects::Location& nudge_location); // Invoke the Syncer to perform a sync. void DoSyncSessionJob(const SyncSessionJob& job); @@ -170,7 +173,8 @@ class SyncerThread : public sessions::SyncSession::Delegate, void ScheduleNudgeImpl( const base::TimeDelta& delay, NudgeSource source, - const syncable::ModelTypePayloadMap& types_with_payloads); + const syncable::ModelTypePayloadMap& types_with_payloads, + const tracked_objects::Location& nudge_location); void ScheduleConfigImpl(const ModelSafeRoutingInfo& routing_info, const std::vector<ModelSafeWorker*>& workers); void ScheduleClearUserDataImpl(); diff --git a/chrome/browser/sync/engine/syncer_thread2_unittest.cc b/chrome/browser/sync/engine/syncer_thread2_unittest.cc index ac03cfb..02514677 100644 --- a/chrome/browser/sync/engine/syncer_thread2_unittest.cc +++ b/chrome/browser/sync/engine/syncer_thread2_unittest.cc @@ -99,7 +99,8 @@ class SyncerThread2Test : public testing::Test { bool GetBackoffAndResetTest(base::WaitableEvent* done) { syncable::ModelTypeBitSet nudge_types; syncer_thread()->Start(SyncerThread::NORMAL_MODE, NULL); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, nudge_types); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, nudge_types, + FROM_HERE); done->TimedWait(timeout()); TearDown(); done->Reset(); @@ -198,7 +199,8 @@ TEST_F(SyncerThread2Test, Nudge) { .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), WithArg<0>(RecordSyncShare(&records, 1U, &done)))) .RetiresOnSaturation(); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, model_types); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, model_types, + FROM_HERE); done.TimedWait(timeout()); EXPECT_EQ(1U, records.snapshots.size()); @@ -214,7 +216,8 @@ TEST_F(SyncerThread2Test, Nudge) { EXPECT_CALL(*syncer(), SyncShare(_,_,_)) .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), WithArg<0>(RecordSyncShare(&records2, 1U, &done)))); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, model_types); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, model_types, + FROM_HERE); done.TimedWait(timeout()); EXPECT_EQ(1U, records2.snapshots.size()); @@ -238,9 +241,12 @@ TEST_F(SyncerThread2Test, NudgeCoalescing) { types3[syncable::THEMES] = true; TimeDelta delay = TimeDelta::FromMilliseconds(20); TimeTicks optimal_time = TimeTicks::Now() + delay; - syncer_thread()->ScheduleNudge(delay, NUDGE_SOURCE_UNKNOWN, types1); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, types2); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_NOTIFICATION, types3); + syncer_thread()->ScheduleNudge(delay, NUDGE_SOURCE_UNKNOWN, types1, + FROM_HERE); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, types2, + FROM_HERE); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_NOTIFICATION, types3, + FROM_HERE); done.TimedWait(timeout()); EXPECT_EQ(1U, r.snapshots.size()); @@ -255,7 +261,8 @@ TEST_F(SyncerThread2Test, NudgeCoalescing) { EXPECT_CALL(*syncer(), SyncShare(_,_,_)) .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), WithArg<0>(RecordSyncShare(&r2, 1U, &done)))); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_NOTIFICATION, types3); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_NOTIFICATION, types3, + FROM_HERE); done.TimedWait(timeout()); EXPECT_EQ(1U, r2.snapshots.size()); EXPECT_TRUE(CompareModelTypeBitSetToModelTypePayloadMap(types3, @@ -277,7 +284,7 @@ TEST_F(SyncerThread2Test, NudgeWithPayloads) { WithArg<0>(RecordSyncShare(&records, 1U, &done)))) .RetiresOnSaturation(); syncer_thread()->ScheduleNudgeWithPayloads(zero(), NUDGE_SOURCE_LOCAL, - model_types_with_payloads); + model_types_with_payloads, FROM_HERE); done.TimedWait(timeout()); EXPECT_EQ(1U, records.snapshots.size()); @@ -293,7 +300,7 @@ TEST_F(SyncerThread2Test, NudgeWithPayloads) { .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), WithArg<0>(RecordSyncShare(&records2, 1U, &done)))); syncer_thread()->ScheduleNudgeWithPayloads(zero(), NUDGE_SOURCE_LOCAL, - model_types_with_payloads); + model_types_with_payloads, FROM_HERE); done.TimedWait(timeout()); EXPECT_EQ(1U, records2.snapshots.size()); @@ -317,11 +324,11 @@ TEST_F(SyncerThread2Test, NudgeWithPayloadsCoalescing) { TimeDelta delay = TimeDelta::FromMilliseconds(20); TimeTicks optimal_time = TimeTicks::Now() + delay; syncer_thread()->ScheduleNudgeWithPayloads(delay, NUDGE_SOURCE_UNKNOWN, - types1); + types1, FROM_HERE); syncer_thread()->ScheduleNudgeWithPayloads(zero(), NUDGE_SOURCE_LOCAL, - types2); + types2, FROM_HERE); syncer_thread()->ScheduleNudgeWithPayloads(zero(), NUDGE_SOURCE_NOTIFICATION, - types3); + types3, FROM_HERE); done.TimedWait(timeout()); EXPECT_EQ(1U, r.snapshots.size()); @@ -339,7 +346,7 @@ TEST_F(SyncerThread2Test, NudgeWithPayloadsCoalescing) { .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), WithArg<0>(RecordSyncShare(&r2, 1U, &done)))); syncer_thread()->ScheduleNudgeWithPayloads(zero(), NUDGE_SOURCE_NOTIFICATION, - types3); + types3, FROM_HERE); done.TimedWait(timeout()); EXPECT_EQ(1U, r2.snapshots.size()); EXPECT_EQ(types3, r2.snapshots[0]->source.types); @@ -413,7 +420,8 @@ TEST_F(SyncerThread2Test, HasMoreToSync) { .WillOnce(Invoke(sessions::test_util::SimulateHasMoreToSync)) .WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess), SignalEvent(&done))); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet()); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), + FROM_HERE); done.TimedWait(timeout()); // If more nudges are scheduled, they'll be waited on by TearDown, and would // cause our expectation to break. @@ -431,7 +439,8 @@ TEST_F(SyncerThread2Test, ThrottlingDoesThrottle) { .WillOnce(WithArg<0>(sessions::test_util::SimulateThrottled(throttle))); syncer_thread()->Start(SyncerThread::NORMAL_MODE, NULL); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, types); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, types, + FROM_HERE); FlushLastTask(&done); syncer_thread()->Start(SyncerThread::CONFIGURATION_MODE, NULL); @@ -476,8 +485,10 @@ TEST_F(SyncerThread2Test, ConfigurationMode) { syncer_thread()->Start(SyncerThread::CONFIGURATION_MODE, NULL); syncable::ModelTypeBitSet nudge_types; nudge_types[syncable::AUTOFILL] = true; - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, nudge_types); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, nudge_types); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, nudge_types, + FROM_HERE); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, nudge_types, + FROM_HERE); syncable::ModelTypeBitSet config_types; config_types[syncable::BOOKMARKS] = true; @@ -566,7 +577,8 @@ TEST_F(SyncerThread2Test, BackoffDropsJobs) { // We schedule a nudge with enough delay (10X poll interval) that at least // one or two polls would have taken place. The nudge should succeed. - syncer_thread()->ScheduleNudge(poll * 10, NUDGE_SOURCE_LOCAL, types); + syncer_thread()->ScheduleNudge(poll * 10, NUDGE_SOURCE_LOCAL, types, + FROM_HERE); ASSERT_TRUE(done.TimedWait(timeout())); done.Reset(); @@ -584,8 +596,10 @@ TEST_F(SyncerThread2Test, BackoffDropsJobs) { FlushLastTask(&done); syncer_thread()->Start(SyncerThread::NORMAL_MODE, NULL); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, types); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, types); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, types, + FROM_HERE); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, types, + FROM_HERE); FlushLastTask(&done); } @@ -683,7 +697,8 @@ TEST_F(SyncerThread2Test, SyncerSteps) { EXPECT_CALL(*syncer(), SyncShare(_, SYNCER_BEGIN, SYNCER_END)) .Times(1); syncer_thread()->Start(SyncerThread::NORMAL_MODE, NULL); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet()); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), + FROM_HERE); FlushLastTask(&done); syncer_thread()->Stop(); Mock::VerifyAndClearExpectations(syncer()); @@ -729,7 +744,8 @@ TEST_F(SyncerThread2Test, StartWhenNotConnected) { MessageLoop cur; connection()->SetServerNotReachable(); syncer_thread()->Start(SyncerThread::NORMAL_MODE, NULL); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet()); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), + FROM_HERE); FlushLastTask(&done); connection()->SetServerReachable(); @@ -741,7 +757,8 @@ TEST_F(SyncerThread2Test, StartWhenNotConnected) { // SyncerThread. FlushLastTask(&done); EXPECT_CALL(*syncer(), SyncShare(_,_,_)).WillOnce(SignalEvent(&done)); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet()); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), + FROM_HERE); done.TimedWait(timeout()); } @@ -755,7 +772,8 @@ TEST_F(SyncerThread2Test, SetsPreviousRoutingInfo) { EXPECT_CALL(*syncer(), SyncShare(_,_,_)).Times(1); syncer_thread()->Start(SyncerThread::NORMAL_MODE, NULL); - syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet()); + syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, ModelTypeBitSet(), + FROM_HERE); FlushLastTask(&done); syncer_thread()->Stop(); diff --git a/chrome/browser/sync/engine/syncer_thread_adapter.cc b/chrome/browser/sync/engine/syncer_thread_adapter.cc index 0383b47..8a513e9 100644 --- a/chrome/browser/sync/engine/syncer_thread_adapter.cc +++ b/chrome/browser/sync/engine/syncer_thread_adapter.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/time.h" +#include "base/tracked.h" #include "chrome/browser/sync/engine/syncer_thread_adapter.h" #include "chrome/browser/sync/syncable/model_type.h" @@ -77,7 +78,8 @@ s3::NudgeSource LegacyToNewSyncerThreadSource(SyncerThread::NudgeSource s) { } void SyncerThreadAdapter::NudgeSyncer(int milliseconds_from_now, - SyncerThread::NudgeSource source) { + SyncerThread::NudgeSource source, + const tracked_objects::Location& nudge_location) { if (using_new_impl_) { if (source == SyncerThread::kClearPrivateData) { new_impl_->ScheduleClearUserData(); @@ -85,7 +87,8 @@ void SyncerThreadAdapter::NudgeSyncer(int milliseconds_from_now, } new_impl_->ScheduleNudge( TimeDelta::FromMilliseconds(milliseconds_from_now), - LegacyToNewSyncerThreadSource(source), ModelTypeBitSet()); + LegacyToNewSyncerThreadSource(source), ModelTypeBitSet(), + nudge_location); } else { legacy_->NudgeSyncer(milliseconds_from_now, source); } @@ -94,12 +97,14 @@ void SyncerThreadAdapter::NudgeSyncer(int milliseconds_from_now, void SyncerThreadAdapter::NudgeSyncerWithDataTypes( int milliseconds_from_now, SyncerThread::NudgeSource source, - const syncable::ModelTypeBitSet& model_types) { + const syncable::ModelTypeBitSet& model_types, + const tracked_objects::Location& nudge_location) { DCHECK_NE(SyncerThread::kClearPrivateData, source); if (using_new_impl_) { new_impl_->ScheduleNudge( TimeDelta::FromMilliseconds(milliseconds_from_now), - LegacyToNewSyncerThreadSource(source), model_types); + LegacyToNewSyncerThreadSource(source), model_types, + nudge_location); } else { legacy_->NudgeSyncerWithDataTypes(milliseconds_from_now, source, model_types); @@ -109,12 +114,14 @@ void SyncerThreadAdapter::NudgeSyncerWithDataTypes( void SyncerThreadAdapter::NudgeSyncerWithPayloads( int milliseconds_from_now, SyncerThread::NudgeSource source, - const syncable::ModelTypePayloadMap& model_types_with_payloads) { + const syncable::ModelTypePayloadMap& model_types_with_payloads, + const tracked_objects::Location& nudge_location) { DCHECK_NE(SyncerThread::kClearPrivateData, source); if (using_new_impl_) { new_impl_->ScheduleNudgeWithPayloads( TimeDelta::FromMilliseconds(milliseconds_from_now), - LegacyToNewSyncerThreadSource(source), model_types_with_payloads); + LegacyToNewSyncerThreadSource(source), model_types_with_payloads, + nudge_location); } else { legacy_->NudgeSyncerWithPayloads(milliseconds_from_now, source, model_types_with_payloads); diff --git a/chrome/browser/sync/engine/syncer_thread_adapter.h b/chrome/browser/sync/engine/syncer_thread_adapter.h index 5cae8e2..6b234e9 100644 --- a/chrome/browser/sync/engine/syncer_thread_adapter.h +++ b/chrome/browser/sync/engine/syncer_thread_adapter.h @@ -7,6 +7,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/tracked.h" #include "chrome/browser/sync/engine/net/server_connection_manager.h" #include "chrome/browser/sync/engine/syncer_thread.h" #include "chrome/browser/sync/engine/syncer_thread2.h" @@ -29,15 +30,18 @@ class SyncerThreadAdapter { bool RequestPause(); bool RequestResume(); void NudgeSyncer(int milliseconds_from_now, - SyncerThread::NudgeSource source); + SyncerThread::NudgeSource source, + const tracked_objects::Location& nudge_location); void NudgeSyncerWithDataTypes( int milliseconds_from_now, SyncerThread::NudgeSource source, - const syncable::ModelTypeBitSet& model_types); + const syncable::ModelTypeBitSet& model_types, + const tracked_objects::Location& nudge_location); void NudgeSyncerWithPayloads( int milliseconds_from_now, SyncerThread::NudgeSource source, - const syncable::ModelTypePayloadMap& model_types_with_payloads); + const syncable::ModelTypePayloadMap& model_types_with_payloads, + const tracked_objects::Location& nudge_location); void SetNotificationsEnabled(bool enabled); void CreateSyncer(const std::string& dirname); diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc index 302724f..a69a12c 100644 --- a/chrome/browser/sync/glue/sync_backend_host.cc +++ b/chrome/browser/sync/glue/sync_backend_host.cc @@ -456,7 +456,7 @@ void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop() { // TODO(tim): Remove this when we get rid of the old syncer thread. if (request_nudge) { CHECK(!using_new_syncer_thread_); - RequestNudge(); + RequestNudge(FROM_HERE); } pending_config_mode_state_.reset(); @@ -475,9 +475,10 @@ void SyncBackendHost::EncryptDataTypes( encrypted_types)); } -void SyncBackendHost::RequestNudge() { +void SyncBackendHost::RequestNudge(const tracked_objects::Location& location) { core_thread_.message_loop()->PostTask(FROM_HERE, - NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoRequestNudge)); + NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoRequestNudge, + location)); } void SyncBackendHost::RequestConfig( @@ -780,7 +781,7 @@ void SyncBackendHost::Core::DoStartSyncing() { DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); syncapi_->StartSyncing(); if (deferred_nudge_for_cleanup_requested_) - syncapi_->RequestNudge(); + syncapi_->RequestNudge(FROM_HERE); deferred_nudge_for_cleanup_requested_ = false; } @@ -1095,8 +1096,9 @@ void SyncBackendHost::Core::StartSavingChanges() { this, &Core::SaveChanges); } -void SyncBackendHost::Core::DoRequestNudge() { - syncapi_->RequestNudge(); +void SyncBackendHost::Core::DoRequestNudge( + const tracked_objects::Location& nudge_location) { + syncapi_->RequestNudge(nudge_location); } void SyncBackendHost::Core::DoRequestClearServerData() { diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h index a6e6acf..b53ed05 100644 --- a/chrome/browser/sync/glue/sync_backend_host.h +++ b/chrome/browser/sync/glue/sync_backend_host.h @@ -336,7 +336,7 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { // Called on the SyncBackendHost core_thread_ to nudge/pause/resume the // syncer. - void DoRequestNudge(); + void DoRequestNudge(const tracked_objects::Location& location); void DoRequestPause(); void DoRequestResume(); void DoRequestClearServerData(); @@ -522,7 +522,7 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { virtual void HandleInitializationCompletedOnFrontendLoop(); // Posts a nudge request on the core thread. - virtual void RequestNudge(); + virtual void RequestNudge(const tracked_objects::Location& location); // Posts a config request on the core thread. virtual void RequestConfig(const syncable::ModelTypeBitSet& added_types); diff --git a/chrome/browser/sync/test_profile_sync_service.cc b/chrome/browser/sync/test_profile_sync_service.cc index 2d122cc..02b44ef 100644 --- a/chrome/browser/sync/test_profile_sync_service.cc +++ b/chrome/browser/sync/test_profile_sync_service.cc @@ -34,6 +34,7 @@ ACTION_P(CallOnResumed, core) { namespace browser_sync { +using ::testing::_; SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( Profile* profile, bool set_initial_sync_ended_on_init, @@ -48,14 +49,14 @@ SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( ON_CALL(*this, RequestResume()). WillByDefault(testing::DoAll(CallOnResumed(core_), testing::Return(true))); - ON_CALL(*this, RequestNudge()).WillByDefault( + ON_CALL(*this, RequestNudge(_)).WillByDefault( testing::Invoke(this, &SyncBackendHostForProfileSyncTest:: SimulateSyncCycleCompletedInitialSyncEnded)); EXPECT_CALL(*this, RequestPause()).Times(testing::AnyNumber()); EXPECT_CALL(*this, RequestResume()).Times(testing::AnyNumber()); - EXPECT_CALL(*this, RequestNudge()).Times(testing::AnyNumber()); + EXPECT_CALL(*this, RequestNudge(_)).Times(testing::AnyNumber()); } SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} @@ -70,7 +71,8 @@ void SyncBackendHostForProfileSyncTest::ConfigureDataTypes( } void SyncBackendHostForProfileSyncTest:: - SimulateSyncCycleCompletedInitialSyncEnded() { + SimulateSyncCycleCompletedInitialSyncEnded( + const tracked_objects::Location& location) { syncable::ModelTypeBitSet sync_ended; ModelSafeRoutingInfo enabled_types; GetModelSafeRoutingInfo(&enabled_types); diff --git a/chrome/browser/sync/test_profile_sync_service.h b/chrome/browser/sync/test_profile_sync_service.h index 1af5d85..bbe1d14 100644 --- a/chrome/browser/sync/test_profile_sync_service.h +++ b/chrome/browser/sync/test_profile_sync_service.h @@ -42,7 +42,7 @@ class SyncBackendHostForProfileSyncTest MOCK_METHOD0(RequestPause, bool()); MOCK_METHOD0(RequestResume, bool()); - MOCK_METHOD0(RequestNudge, void()); + MOCK_METHOD1(RequestNudge, void(const tracked_objects::Location&)); virtual void ConfigureDataTypes( const DataTypeController::TypeMap& data_type_controllers, @@ -50,7 +50,8 @@ class SyncBackendHostForProfileSyncTest CancelableTask* ready_task); // Called when a nudge comes in. - void SimulateSyncCycleCompletedInitialSyncEnded(); + void SimulateSyncCycleCompletedInitialSyncEnded( + const tracked_objects::Location&); virtual sync_api::HttpPostProviderFactory* MakeHttpBridgeFactory( net::URLRequestContextGetter* getter); |