| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/sync/engine_impl/sync_scheduler_impl.h" | 5 #include "components/sync/engine_impl/sync_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 syncer_); | 162 syncer_); |
| 163 scheduler_->SetDefaultNudgeDelay(default_delay()); | 163 scheduler_->SetDefaultNudgeDelay(default_delay()); |
| 164 } | 164 } |
| 165 | 165 |
| 166 SyncSchedulerImpl* scheduler() { return scheduler_.get(); } | 166 SyncSchedulerImpl* scheduler() { return scheduler_.get(); } |
| 167 const ModelSafeRoutingInfo& routing_info() { return routing_info_; } | 167 const ModelSafeRoutingInfo& routing_info() { return routing_info_; } |
| 168 MockSyncer* syncer() { return syncer_; } | 168 MockSyncer* syncer() { return syncer_; } |
| 169 MockDelayProvider* delay() { return delay_; } | 169 MockDelayProvider* delay() { return delay_; } |
| 170 MockConnectionManager* connection() { return connection_.get(); } | 170 MockConnectionManager* connection() { return connection_.get(); } |
| 171 TimeDelta default_delay() { return TimeDelta::FromSeconds(0); } | 171 TimeDelta default_delay() { return TimeDelta::FromSeconds(0); } |
| 172 TimeDelta long_delay() { return TimeDelta::FromSeconds(60); } |
| 172 TimeDelta timeout() { return TestTimeouts::action_timeout(); } | 173 TimeDelta timeout() { return TestTimeouts::action_timeout(); } |
| 173 | 174 |
| 174 void TearDown() override { | 175 void TearDown() override { |
| 175 PumpLoop(); | 176 PumpLoop(); |
| 176 scheduler_.reset(); | 177 scheduler_.reset(); |
| 177 PumpLoop(); | 178 PumpLoop(); |
| 178 test_user_share_.TearDown(); | 179 test_user_share_.TearDown(); |
| 179 } | 180 } |
| 180 | 181 |
| 181 void AnalyzePollRun(const SyncShareTimes& times, | 182 void AnalyzePollRun(const SyncShareTimes& times, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 220 } |
| 220 | 221 |
| 221 void UseMockDelayProvider() { | 222 void UseMockDelayProvider() { |
| 222 delay_ = new MockDelayProvider(); | 223 delay_ = new MockDelayProvider(); |
| 223 scheduler_->delay_provider_.reset(delay_); | 224 scheduler_->delay_provider_.reset(delay_); |
| 224 } | 225 } |
| 225 | 226 |
| 226 SyncCycleContext* context() { return context_.get(); } | 227 SyncCycleContext* context() { return context_.get(); } |
| 227 | 228 |
| 228 ModelTypeSet GetThrottledTypes() { | 229 ModelTypeSet GetThrottledTypes() { |
| 229 return scheduler_->nudge_tracker_.GetThrottledTypes(); | 230 ModelTypeSet throttled_types; |
| 231 ModelTypeSet blocked_types = scheduler_->nudge_tracker_.GetBlockedTypes(); |
| 232 for (ModelTypeSet::Iterator type_it = blocked_types.First(); type_it.Good(); |
| 233 type_it.Inc()) { |
| 234 if (scheduler_->nudge_tracker_.GetTypeBlockingMode(type_it.Get()) == |
| 235 WaitInterval::THROTTLED) { |
| 236 throttled_types.Put(type_it.Get()); |
| 237 } |
| 238 } |
| 239 return throttled_types; |
| 240 } |
| 241 |
| 242 ModelTypeSet GetBackedOffTypes() { |
| 243 ModelTypeSet backed_off_types; |
| 244 ModelTypeSet blocked_types = scheduler_->nudge_tracker_.GetBlockedTypes(); |
| 245 for (ModelTypeSet::Iterator type_it = blocked_types.First(); type_it.Good(); |
| 246 type_it.Inc()) { |
| 247 if (scheduler_->nudge_tracker_.GetTypeBlockingMode(type_it.Get()) == |
| 248 WaitInterval::EXPONENTIAL_BACKOFF) { |
| 249 backed_off_types.Put(type_it.Get()); |
| 250 } |
| 251 } |
| 252 return backed_off_types; |
| 253 } |
| 254 |
| 255 bool IsAnyTypeBlocked() { |
| 256 return scheduler_->nudge_tracker_.IsAnyTypeBlocked(); |
| 230 } | 257 } |
| 231 | 258 |
| 232 base::TimeDelta GetRetryTimerDelay() { | 259 base::TimeDelta GetRetryTimerDelay() { |
| 233 EXPECT_TRUE(scheduler_->retry_timer_.IsRunning()); | 260 EXPECT_TRUE(scheduler_->retry_timer_.IsRunning()); |
| 234 return scheduler_->retry_timer_.GetCurrentDelay(); | 261 return scheduler_->retry_timer_.GetCurrentDelay(); |
| 235 } | 262 } |
| 236 | 263 |
| 237 static std::unique_ptr<InvalidationInterface> BuildInvalidation( | 264 static std::unique_ptr<InvalidationInterface> BuildInvalidation( |
| 238 int64_t version, | 265 int64_t version, |
| 239 const std::string& payload) { | 266 const std::string& payload) { |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 EXPECT_EQ(1, retry_counter.times_called()); | 825 EXPECT_EQ(1, retry_counter.times_called()); |
| 799 EXPECT_TRUE(scheduler()->IsCurrentlyThrottled()); | 826 EXPECT_TRUE(scheduler()->IsCurrentlyThrottled()); |
| 800 | 827 |
| 801 RunLoop(); | 828 RunLoop(); |
| 802 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); | 829 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 803 | 830 |
| 804 StopSyncScheduler(); | 831 StopSyncScheduler(); |
| 805 } | 832 } |
| 806 | 833 |
| 807 TEST_F(SyncSchedulerImplTest, TypeThrottlingBlocksNudge) { | 834 TEST_F(SyncSchedulerImplTest, TypeThrottlingBlocksNudge) { |
| 808 UseMockDelayProvider(); | |
| 809 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(default_delay())); | |
| 810 | |
| 811 TimeDelta poll(TimeDelta::FromDays(1)); | 835 TimeDelta poll(TimeDelta::FromDays(1)); |
| 812 TimeDelta throttle1(TimeDelta::FromSeconds(60)); | 836 TimeDelta throttle1(TimeDelta::FromSeconds(60)); |
| 813 scheduler()->OnReceivedLongPollIntervalUpdate(poll); | 837 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 814 | 838 |
| 815 const ModelTypeSet types(THEMES); | 839 const ModelTypeSet types(THEMES); |
| 816 | 840 |
| 817 ::testing::InSequence seq; | 841 ::testing::InSequence seq; |
| 818 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) | 842 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 819 .WillOnce( | 843 .WillOnce( |
| 820 DoAll(WithArg<2>(test_util::SimulateTypesThrottled(types, throttle1)), | 844 DoAll(WithArg<2>(test_util::SimulateTypesThrottled(types, throttle1)), |
| 821 Return(false))) | 845 Return(true))) |
| 822 .RetiresOnSaturation(); | 846 .RetiresOnSaturation(); |
| 823 | 847 |
| 824 StartSyncScheduler(base::Time()); | 848 StartSyncScheduler(base::Time()); |
| 825 scheduler()->ScheduleLocalNudge(types, FROM_HERE); | 849 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 826 PumpLoop(); // To get PerformDelayedNudge called. | 850 PumpLoop(); // To get PerformDelayedNudge called. |
| 827 PumpLoop(); // To get TrySyncCycleJob called | 851 PumpLoop(); // To get TrySyncCycleJob called |
| 828 EXPECT_TRUE(GetThrottledTypes().HasAll(types)); | 852 EXPECT_TRUE(GetThrottledTypes().HasAll(types)); |
| 853 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 854 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 829 | 855 |
| 830 // This won't cause a sync cycle because the types are throttled. | 856 // This won't cause a sync cycle because the types are throttled. |
| 831 scheduler()->ScheduleLocalNudge(types, FROM_HERE); | 857 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 832 PumpLoop(); | 858 PumpLoop(); |
| 833 | 859 |
| 834 StopSyncScheduler(); | 860 StopSyncScheduler(); |
| 835 } | 861 } |
| 836 | 862 |
| 863 TEST_F(SyncSchedulerImplTest, TypeBackingOffBlocksNudge) { |
| 864 UseMockDelayProvider(); |
| 865 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(long_delay())); |
| 866 |
| 867 TimeDelta poll(TimeDelta::FromDays(1)); |
| 868 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 869 |
| 870 const ModelTypeSet types(THEMES); |
| 871 |
| 872 ::testing::InSequence seq; |
| 873 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 874 .WillOnce(DoAll(WithArg<2>(test_util::SimulatePartialFailure(types)), |
| 875 Return(true))) |
| 876 .RetiresOnSaturation(); |
| 877 |
| 878 StartSyncScheduler(base::Time()); |
| 879 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 880 PumpLoop(); // To get PerformDelayedNudge called. |
| 881 PumpLoop(); // To get TrySyncCycleJob called |
| 882 EXPECT_TRUE(GetBackedOffTypes().HasAll(types)); |
| 883 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 884 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 885 |
| 886 // This won't cause a sync cycle because the types are backed off. |
| 887 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 888 PumpLoop(); |
| 889 |
| 890 StopSyncScheduler(); |
| 891 } |
| 892 |
| 893 TEST_F(SyncSchedulerImplTest, TypeBackingOffWillExpire) { |
| 894 UseMockDelayProvider(); |
| 895 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(default_delay())); |
| 896 |
| 897 TimeDelta poll(TimeDelta::FromDays(1)); |
| 898 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 899 |
| 900 const ModelTypeSet types(THEMES); |
| 901 |
| 902 ::testing::InSequence seq; |
| 903 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 904 .WillOnce(DoAll(WithArg<2>(test_util::SimulatePartialFailure(types)), |
| 905 Return(true))) |
| 906 .RetiresOnSaturation(); |
| 907 |
| 908 StartSyncScheduler(base::Time()); |
| 909 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 910 PumpLoop(); // To get PerformDelayedNudge called. |
| 911 PumpLoop(); // To get TrySyncCycleJob called |
| 912 EXPECT_TRUE(GetBackedOffTypes().HasAll(types)); |
| 913 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 914 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 915 |
| 916 SyncShareTimes times; |
| 917 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 918 .WillRepeatedly(DoAll(Invoke(test_util::SimulateNormalSuccess), |
| 919 RecordSyncShare(×, true))); |
| 920 PumpLoop(); // To get PerformDelayedNudge called. |
| 921 PumpLoop(); // To get TrySyncCycleJob called |
| 922 EXPECT_FALSE(IsAnyTypeBlocked()); |
| 923 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 924 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 925 |
| 926 StopSyncScheduler(); |
| 927 } |
| 928 |
| 929 TEST_F(SyncSchedulerImplTest, TypeBackingOffAndThrottling) { |
| 930 UseMockDelayProvider(); |
| 931 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(long_delay())); |
| 932 |
| 933 TimeDelta poll(TimeDelta::FromDays(1)); |
| 934 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 935 |
| 936 const ModelTypeSet types(THEMES); |
| 937 |
| 938 ::testing::InSequence seq; |
| 939 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 940 .WillOnce(DoAll(WithArg<2>(test_util::SimulatePartialFailure(types)), |
| 941 Return(true))) |
| 942 .RetiresOnSaturation(); |
| 943 |
| 944 StartSyncScheduler(base::Time()); |
| 945 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 946 PumpLoop(); // To get PerformDelayedNudge called. |
| 947 PumpLoop(); // To get TrySyncCycleJob called |
| 948 EXPECT_TRUE(GetBackedOffTypes().HasAll(types)); |
| 949 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 950 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 951 |
| 952 TimeDelta throttle1(TimeDelta::FromMilliseconds(150)); |
| 953 |
| 954 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 955 .WillOnce(DoAll(WithArg<2>(test_util::SimulateThrottled(throttle1)), |
| 956 Return(false))) |
| 957 .RetiresOnSaturation(); |
| 958 |
| 959 // Sync still can throttle. |
| 960 const ModelTypeSet unbacked_off_types(TYPED_URLS); |
| 961 scheduler()->ScheduleLocalNudge(unbacked_off_types, FROM_HERE); |
| 962 PumpLoop(); // TO get TypesUnblock called. |
| 963 PumpLoop(); // To get TrySyncCycleJob called. |
| 964 |
| 965 EXPECT_TRUE(GetBackedOffTypes().HasAll(types)); |
| 966 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 967 EXPECT_TRUE(scheduler()->IsCurrentlyThrottled()); |
| 968 |
| 969 StopSyncScheduler(); |
| 970 } |
| 971 |
| 972 TEST_F(SyncSchedulerImplTest, TypeThrottlingBackingOffBlocksNudge) { |
| 973 UseMockDelayProvider(); |
| 974 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(long_delay())); |
| 975 |
| 976 TimeDelta poll(TimeDelta::FromDays(1)); |
| 977 TimeDelta throttle(TimeDelta::FromSeconds(60)); |
| 978 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 979 |
| 980 const ModelTypeSet throttled_types(THEMES); |
| 981 |
| 982 ::testing::InSequence seq; |
| 983 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 984 .WillOnce(DoAll(WithArg<2>(test_util::SimulateTypesThrottled( |
| 985 throttled_types, throttle)), |
| 986 Return(true))) |
| 987 .RetiresOnSaturation(); |
| 988 |
| 989 StartSyncScheduler(base::Time()); |
| 990 scheduler()->ScheduleLocalNudge(throttled_types, FROM_HERE); |
| 991 PumpLoop(); // To get PerformDelayedNudge called. |
| 992 PumpLoop(); // To get TrySyncCycleJob called |
| 993 |
| 994 const ModelTypeSet backed_off_types(TYPED_URLS); |
| 995 |
| 996 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 997 .WillOnce( |
| 998 DoAll(WithArg<2>(test_util::SimulatePartialFailure(backed_off_types)), |
| 999 Return(true))) |
| 1000 .RetiresOnSaturation(); |
| 1001 |
| 1002 scheduler()->ScheduleLocalNudge(backed_off_types, FROM_HERE); |
| 1003 |
| 1004 PumpLoop(); // To get PerformDelayedNudge called. |
| 1005 PumpLoop(); // To get TrySyncCycleJob called |
| 1006 |
| 1007 EXPECT_TRUE(GetThrottledTypes().HasAll(throttled_types)); |
| 1008 EXPECT_TRUE(GetBackedOffTypes().HasAll(backed_off_types)); |
| 1009 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 1010 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 1011 |
| 1012 // This won't cause a sync cycle because the types are throttled or backed |
| 1013 // off. |
| 1014 scheduler()->ScheduleLocalNudge(Union(throttled_types, backed_off_types), |
| 1015 FROM_HERE); |
| 1016 PumpLoop(); |
| 1017 |
| 1018 StopSyncScheduler(); |
| 1019 } |
| 1020 |
| 837 TEST_F(SyncSchedulerImplTest, TypeThrottlingDoesBlockOtherSources) { | 1021 TEST_F(SyncSchedulerImplTest, TypeThrottlingDoesBlockOtherSources) { |
| 838 UseMockDelayProvider(); | 1022 UseMockDelayProvider(); |
| 839 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(default_delay())); | 1023 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(default_delay())); |
| 840 | 1024 |
| 841 SyncShareTimes times; | 1025 SyncShareTimes times; |
| 842 TimeDelta poll(TimeDelta::FromDays(1)); | 1026 TimeDelta poll(TimeDelta::FromDays(1)); |
| 843 TimeDelta throttle1(TimeDelta::FromSeconds(60)); | 1027 TimeDelta throttle1(TimeDelta::FromSeconds(60)); |
| 844 scheduler()->OnReceivedLongPollIntervalUpdate(poll); | 1028 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 845 | 1029 |
| 846 const ModelTypeSet throttled_types(THEMES); | 1030 const ModelTypeSet throttled_types(THEMES); |
| 847 const ModelTypeSet unthrottled_types(PREFERENCES); | 1031 const ModelTypeSet unthrottled_types(PREFERENCES); |
| 848 | 1032 |
| 849 ::testing::InSequence seq; | 1033 ::testing::InSequence seq; |
| 850 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) | 1034 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 851 .WillOnce(DoAll(WithArg<2>(test_util::SimulateTypesThrottled( | 1035 .WillOnce(DoAll(WithArg<2>(test_util::SimulateTypesThrottled( |
| 852 throttled_types, throttle1)), | 1036 throttled_types, throttle1)), |
| 853 Return(false))) | 1037 Return(true))) |
| 854 .RetiresOnSaturation(); | 1038 .RetiresOnSaturation(); |
| 855 | 1039 |
| 856 StartSyncScheduler(base::Time()); | 1040 StartSyncScheduler(base::Time()); |
| 857 scheduler()->ScheduleLocalNudge(throttled_types, FROM_HERE); | 1041 scheduler()->ScheduleLocalNudge(throttled_types, FROM_HERE); |
| 858 PumpLoop(); // To get PerformDelayedNudge called. | 1042 PumpLoop(); // To get PerformDelayedNudge called. |
| 859 PumpLoop(); // To get TrySyncCycleJob called | 1043 PumpLoop(); // To get TrySyncCycleJob called |
| 860 EXPECT_TRUE(GetThrottledTypes().HasAll(throttled_types)); | 1044 EXPECT_TRUE(GetThrottledTypes().HasAll(throttled_types)); |
| 1045 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 1046 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 861 | 1047 |
| 862 // Ignore invalidations for throttled types. | 1048 // Ignore invalidations for throttled types. |
| 863 scheduler()->ScheduleInvalidationNudge(THEMES, BuildInvalidation(10, "test"), | 1049 scheduler()->ScheduleInvalidationNudge(THEMES, BuildInvalidation(10, "test"), |
| 864 FROM_HERE); | 1050 FROM_HERE); |
| 865 PumpLoop(); | 1051 PumpLoop(); |
| 866 | 1052 |
| 867 // Ignore refresh requests for throttled types. | 1053 // Ignore refresh requests for throttled types. |
| 868 scheduler()->ScheduleLocalRefreshRequest(throttled_types, FROM_HERE); | 1054 scheduler()->ScheduleLocalRefreshRequest(throttled_types, FROM_HERE); |
| 869 PumpLoop(); | 1055 PumpLoop(); |
| 870 | 1056 |
| 871 Mock::VerifyAndClearExpectations(syncer()); | 1057 Mock::VerifyAndClearExpectations(syncer()); |
| 872 | 1058 |
| 873 // Local nudges for non-throttled types will trigger a sync. | 1059 // Local nudges for non-throttled types will trigger a sync. |
| 874 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) | 1060 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 875 .WillRepeatedly(DoAll(Invoke(test_util::SimulateNormalSuccess), | 1061 .WillRepeatedly(DoAll(Invoke(test_util::SimulateNormalSuccess), |
| 876 RecordSyncShare(×, true))); | 1062 RecordSyncShare(×, true))); |
| 877 scheduler()->ScheduleLocalNudge(unthrottled_types, FROM_HERE); | 1063 scheduler()->ScheduleLocalNudge(unthrottled_types, FROM_HERE); |
| 878 RunLoop(); | 1064 RunLoop(); |
| 879 Mock::VerifyAndClearExpectations(syncer()); | 1065 Mock::VerifyAndClearExpectations(syncer()); |
| 880 | 1066 |
| 881 StopSyncScheduler(); | 1067 StopSyncScheduler(); |
| 882 } | 1068 } |
| 883 | 1069 |
| 1070 TEST_F(SyncSchedulerImplTest, TypeBackingOffDoesBlockOtherSources) { |
| 1071 UseMockDelayProvider(); |
| 1072 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(long_delay())); |
| 1073 |
| 1074 SyncShareTimes times; |
| 1075 TimeDelta poll(TimeDelta::FromDays(1)); |
| 1076 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 1077 |
| 1078 const ModelTypeSet backed_off_types(THEMES); |
| 1079 const ModelTypeSet unbacked_off_types(PREFERENCES); |
| 1080 |
| 1081 ::testing::InSequence seq; |
| 1082 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 1083 .WillOnce( |
| 1084 DoAll(WithArg<2>(test_util::SimulatePartialFailure(backed_off_types)), |
| 1085 Return(true))) |
| 1086 .RetiresOnSaturation(); |
| 1087 |
| 1088 StartSyncScheduler(base::Time()); |
| 1089 scheduler()->ScheduleLocalNudge(backed_off_types, FROM_HERE); |
| 1090 PumpLoop(); // To get PerformDelayedNudge called. |
| 1091 PumpLoop(); // To get TrySyncCycleJob called |
| 1092 EXPECT_TRUE(GetBackedOffTypes().HasAll(backed_off_types)); |
| 1093 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 1094 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 1095 |
| 1096 // Ignore invalidations for backed off types. |
| 1097 scheduler()->ScheduleInvalidationNudge(THEMES, BuildInvalidation(10, "test"), |
| 1098 FROM_HERE); |
| 1099 PumpLoop(); |
| 1100 |
| 1101 // Ignore refresh requests for backed off types. |
| 1102 scheduler()->ScheduleLocalRefreshRequest(backed_off_types, FROM_HERE); |
| 1103 PumpLoop(); |
| 1104 |
| 1105 Mock::VerifyAndClearExpectations(syncer()); |
| 1106 |
| 1107 // Local nudges for non-backed off types will trigger a sync. |
| 1108 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 1109 .WillRepeatedly(DoAll(Invoke(test_util::SimulateNormalSuccess), |
| 1110 RecordSyncShare(×, true))); |
| 1111 scheduler()->ScheduleLocalNudge(unbacked_off_types, FROM_HERE); |
| 1112 RunLoop(); |
| 1113 Mock::VerifyAndClearExpectations(syncer()); |
| 1114 |
| 1115 StopSyncScheduler(); |
| 1116 } |
| 1117 |
| 884 // Test nudges / polls don't run in config mode and config tasks do. | 1118 // Test nudges / polls don't run in config mode and config tasks do. |
| 885 TEST_F(SyncSchedulerImplTest, ConfigurationMode) { | 1119 TEST_F(SyncSchedulerImplTest, ConfigurationMode) { |
| 886 TimeDelta poll(TimeDelta::FromMilliseconds(15)); | 1120 TimeDelta poll(TimeDelta::FromMilliseconds(15)); |
| 887 SyncShareTimes times; | 1121 SyncShareTimes times; |
| 888 scheduler()->OnReceivedLongPollIntervalUpdate(poll); | 1122 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 889 | 1123 |
| 890 StartSyncConfiguration(); | 1124 StartSyncConfiguration(); |
| 891 | 1125 |
| 892 const ModelTypeSet nudge_types(TYPED_URLS); | 1126 const ModelTypeSet nudge_types(TYPED_URLS); |
| 893 scheduler()->ScheduleLocalNudge(nudge_types, FROM_HERE); | 1127 scheduler()->ScheduleLocalNudge(nudge_types, FROM_HERE); |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 ASSERT_TRUE(scheduler()->IsBackingOff()); | 1667 ASSERT_TRUE(scheduler()->IsBackingOff()); |
| 1434 | 1668 |
| 1435 // Now succeed. | 1669 // Now succeed. |
| 1436 connection()->SetServerReachable(); | 1670 connection()->SetServerReachable(); |
| 1437 PumpLoopFor(2 * delta); | 1671 PumpLoopFor(2 * delta); |
| 1438 ASSERT_EQ(1, success_counter.times_called()); | 1672 ASSERT_EQ(1, success_counter.times_called()); |
| 1439 ASSERT_FALSE(scheduler()->IsBackingOff()); | 1673 ASSERT_FALSE(scheduler()->IsBackingOff()); |
| 1440 } | 1674 } |
| 1441 | 1675 |
| 1442 } // namespace syncer | 1676 } // namespace syncer |
| OLD | NEW |