diff options
Diffstat (limited to 'sync/sessions')
-rw-r--r-- | sync/sessions/nudge_tracker.cc | 14 | ||||
-rw-r--r-- | sync/sessions/nudge_tracker.h | 5 | ||||
-rw-r--r-- | sync/sessions/test_util.cc | 12 | ||||
-rw-r--r-- | sync/sessions/test_util.h | 8 |
4 files changed, 36 insertions, 3 deletions
diff --git a/sync/sessions/nudge_tracker.cc b/sync/sessions/nudge_tracker.cc index 7eae5ec..b481a39 100644 --- a/sync/sessions/nudge_tracker.cc +++ b/sync/sessions/nudge_tracker.cc @@ -21,12 +21,20 @@ NudgeTracker::NudgeTracker() NudgeTracker::~NudgeTracker() { } +bool NudgeTracker::IsGetUpdatesRequired() { + if (!refresh_requested_counts_.empty()) { + return true; + } else if (!payload_list_map_.empty()) { + return true; + } else { + return false; + } +} + bool NudgeTracker::IsSyncRequired() { if (!local_nudge_counts_.empty()) { return true; - } else if (!refresh_requested_counts_.empty()) { - return true; - } else if (!payload_list_map_.empty()) { + } else if (IsGetUpdatesRequired()) { return true; } else { return false; diff --git a/sync/sessions/nudge_tracker.h b/sync/sessions/nudge_tracker.h index c093250..0e557f3 100644 --- a/sync/sessions/nudge_tracker.h +++ b/sync/sessions/nudge_tracker.h @@ -28,6 +28,11 @@ class SYNC_EXPORT_PRIVATE NudgeTracker { NudgeTracker(); ~NudgeTracker(); + // Returns true if one of the main reasons for performing the sync cycle is to + // fetch updates. This is true when we have pending invalidations or refresh + // requests. + bool IsGetUpdatesRequired(); + // Returns true if there is a good reason for performing a sync cycle. // This does not take into account whether or not this is a good *time* to // perform a sync cycle; that's the scheduler's job. diff --git a/sync/sessions/test_util.cc b/sync/sessions/test_util.cc index 3b4b6c9..03f6de2 100644 --- a/sync/sessions/test_util.cc +++ b/sync/sessions/test_util.cc @@ -4,6 +4,8 @@ #include "sync/sessions/test_util.h" +#include "sync/engine/throttled_data_type_tracker.h" + namespace syncer { namespace sessions { namespace test_util { @@ -64,6 +66,16 @@ void SimulateThrottledImpl(sessions::SyncSession* session, session->delegate()->OnSilencedUntil(base::TimeTicks::Now() + delta); } +void SimulateTypesThrottledImpl( + sessions::SyncSession* session, + ModelTypeSet types, + const base::TimeDelta& delta) { + session->mutable_status_controller()->set_last_download_updates_result( + SERVER_RETURN_THROTTLED); + session->context()->throttled_data_type_tracker()-> + SetUnthrottleTime(types, base::TimeTicks::Now() + delta); +} + void SimulatePollIntervalUpdateImpl(sessions::SyncSession* session, const base::TimeDelta& new_poll) { SimulateSuccess(session, SYNCER_BEGIN, SYNCER_END); diff --git a/sync/sessions/test_util.h b/sync/sessions/test_util.h index 38638e1..6ab32b1 100644 --- a/sync/sessions/test_util.h +++ b/sync/sessions/test_util.h @@ -27,6 +27,10 @@ void SimulateSuccess(sessions::SyncSession* session, SyncerStep begin, SyncerStep end); void SimulateThrottledImpl(sessions::SyncSession* session, const base::TimeDelta& delta); +void SimulateTypesThrottledImpl( + sessions::SyncSession* session, + ModelTypeSet types, + const base::TimeDelta& delta); void SimulatePollIntervalUpdateImpl(sessions::SyncSession* session, const base::TimeDelta& new_poll); void SimulateSessionsCommitDelayUpdateImpl(sessions::SyncSession* session, @@ -36,6 +40,10 @@ ACTION_P(SimulateThrottled, throttle) { SimulateThrottledImpl(arg0, throttle); } +ACTION_P2(SimulateTypesThrottled, types, throttle) { + SimulateTypesThrottledImpl(arg0, types, throttle); +} + ACTION_P(SimulatePollIntervalUpdate, poll) { SimulatePollIntervalUpdateImpl(arg0, poll); } |