| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 return scheduler_->nudge_tracker_.GetThrottledTypes(); |
| 230 } | 231 } |
| 231 | 232 |
| 233 ModelTypeSet GetBackedOffTypes() { |
| 234 return scheduler_->nudge_tracker_.GetBackedOffTypes(); |
| 235 } |
| 236 |
| 237 bool IsAnyTypeThrottled() { |
| 238 return scheduler_->nudge_tracker_.IsAnyTypeThrottled(); |
| 239 } |
| 240 |
| 241 bool IsAnyTypeBackedOff() { |
| 242 return scheduler_->nudge_tracker_.IsAnyTypeBackedOff(); |
| 243 } |
| 244 |
| 232 base::TimeDelta GetRetryTimerDelay() { | 245 base::TimeDelta GetRetryTimerDelay() { |
| 233 EXPECT_TRUE(scheduler_->retry_timer_.IsRunning()); | 246 EXPECT_TRUE(scheduler_->retry_timer_.IsRunning()); |
| 234 return scheduler_->retry_timer_.GetCurrentDelay(); | 247 return scheduler_->retry_timer_.GetCurrentDelay(); |
| 235 } | 248 } |
| 236 | 249 |
| 237 static std::unique_ptr<InvalidationInterface> BuildInvalidation( | 250 static std::unique_ptr<InvalidationInterface> BuildInvalidation( |
| 238 int64_t version, | 251 int64_t version, |
| 239 const std::string& payload) { | 252 const std::string& payload) { |
| 240 return MockInvalidation::Build(version, payload); | 253 return MockInvalidation::Build(version, payload); |
| 241 } | 254 } |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 EXPECT_EQ(1, retry_counter.times_called()); | 811 EXPECT_EQ(1, retry_counter.times_called()); |
| 799 EXPECT_TRUE(scheduler()->IsCurrentlyThrottled()); | 812 EXPECT_TRUE(scheduler()->IsCurrentlyThrottled()); |
| 800 | 813 |
| 801 RunLoop(); | 814 RunLoop(); |
| 802 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); | 815 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 803 | 816 |
| 804 StopSyncScheduler(); | 817 StopSyncScheduler(); |
| 805 } | 818 } |
| 806 | 819 |
| 807 TEST_F(SyncSchedulerImplTest, TypeThrottlingBlocksNudge) { | 820 TEST_F(SyncSchedulerImplTest, TypeThrottlingBlocksNudge) { |
| 808 UseMockDelayProvider(); | |
| 809 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(default_delay())); | |
| 810 | |
| 811 TimeDelta poll(TimeDelta::FromDays(1)); | 821 TimeDelta poll(TimeDelta::FromDays(1)); |
| 812 TimeDelta throttle1(TimeDelta::FromSeconds(60)); | 822 TimeDelta throttle1(TimeDelta::FromSeconds(60)); |
| 813 scheduler()->OnReceivedLongPollIntervalUpdate(poll); | 823 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 814 | 824 |
| 815 const ModelTypeSet types(THEMES); | 825 const ModelTypeSet types(THEMES); |
| 816 | 826 |
| 817 ::testing::InSequence seq; | 827 ::testing::InSequence seq; |
| 818 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) | 828 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 819 .WillOnce( | 829 .WillOnce( |
| 820 DoAll(WithArg<2>(test_util::SimulateTypesThrottled(types, throttle1)), | 830 DoAll(WithArg<2>(test_util::SimulateTypesThrottled(types, throttle1)), |
| 821 Return(false))) | 831 Return(true))) |
| 822 .RetiresOnSaturation(); | 832 .RetiresOnSaturation(); |
| 823 | 833 |
| 824 StartSyncScheduler(base::Time()); | 834 StartSyncScheduler(base::Time()); |
| 825 scheduler()->ScheduleLocalNudge(types, FROM_HERE); | 835 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 826 PumpLoop(); // To get PerformDelayedNudge called. | 836 PumpLoop(); // To get PerformDelayedNudge called. |
| 827 PumpLoop(); // To get TrySyncCycleJob called | 837 PumpLoop(); // To get TrySyncCycleJob called |
| 828 EXPECT_TRUE(GetThrottledTypes().HasAll(types)); | 838 EXPECT_TRUE(GetThrottledTypes().HasAll(types)); |
| 839 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 840 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 829 | 841 |
| 830 // This won't cause a sync cycle because the types are throttled. | 842 // This won't cause a sync cycle because the types are throttled. |
| 831 scheduler()->ScheduleLocalNudge(types, FROM_HERE); | 843 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 832 PumpLoop(); | 844 PumpLoop(); |
| 833 | 845 |
| 834 StopSyncScheduler(); | 846 StopSyncScheduler(); |
| 835 } | 847 } |
| 836 | 848 |
| 849 TEST_F(SyncSchedulerImplTest, TypeBackingOffBlocksNudge) { |
| 850 UseMockDelayProvider(); |
| 851 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(long_delay())); |
| 852 |
| 853 TimeDelta poll(TimeDelta::FromDays(1)); |
| 854 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 855 |
| 856 const ModelTypeSet types(THEMES); |
| 857 |
| 858 ::testing::InSequence seq; |
| 859 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 860 .WillOnce(DoAll(WithArg<2>(test_util::SimulatePartialFailure(types)), |
| 861 Return(true))) |
| 862 .RetiresOnSaturation(); |
| 863 |
| 864 StartSyncScheduler(base::Time()); |
| 865 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 866 PumpLoop(); // To get PerformDelayedNudge called. |
| 867 PumpLoop(); // To get TrySyncCycleJob called |
| 868 EXPECT_TRUE(GetBackedOffTypes().HasAll(types)); |
| 869 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 870 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 871 |
| 872 // This won't cause a sync cycle because the types are backed off. |
| 873 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 874 PumpLoop(); |
| 875 |
| 876 StopSyncScheduler(); |
| 877 } |
| 878 |
| 879 TEST_F(SyncSchedulerImplTest, TypeBackingOffWillExpire) { |
| 880 UseMockDelayProvider(); |
| 881 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(default_delay())); |
| 882 |
| 883 TimeDelta poll(TimeDelta::FromDays(1)); |
| 884 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 885 |
| 886 const ModelTypeSet types(THEMES); |
| 887 |
| 888 ::testing::InSequence seq; |
| 889 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 890 .WillOnce(DoAll(WithArg<2>(test_util::SimulatePartialFailure(types)), |
| 891 Return(true))) |
| 892 .RetiresOnSaturation(); |
| 893 |
| 894 StartSyncScheduler(base::Time()); |
| 895 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 896 PumpLoop(); // To get PerformDelayedNudge called. |
| 897 PumpLoop(); // To get TrySyncCycleJob called |
| 898 EXPECT_TRUE(GetBackedOffTypes().HasAll(types)); |
| 899 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 900 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 901 |
| 902 SyncShareTimes times; |
| 903 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 904 .WillRepeatedly(DoAll(Invoke(test_util::SimulateNormalSuccess), |
| 905 RecordSyncShare(×, true))); |
| 906 PumpLoop(); // To get PerformDelayedNudge called. |
| 907 PumpLoop(); // To get TrySyncCycleJob called |
| 908 EXPECT_FALSE(IsAnyTypeBackedOff()); |
| 909 EXPECT_FALSE(IsAnyTypeThrottled()); |
| 910 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 911 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 912 |
| 913 StopSyncScheduler(); |
| 914 } |
| 915 |
| 916 TEST_F(SyncSchedulerImplTest, TypeBackingOffAndThrottling) { |
| 917 UseMockDelayProvider(); |
| 918 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(long_delay())); |
| 919 |
| 920 TimeDelta poll(TimeDelta::FromDays(1)); |
| 921 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 922 |
| 923 const ModelTypeSet types(THEMES); |
| 924 |
| 925 ::testing::InSequence seq; |
| 926 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 927 .WillOnce(DoAll(WithArg<2>(test_util::SimulatePartialFailure(types)), |
| 928 Return(true))) |
| 929 .RetiresOnSaturation(); |
| 930 |
| 931 StartSyncScheduler(base::Time()); |
| 932 scheduler()->ScheduleLocalNudge(types, FROM_HERE); |
| 933 PumpLoop(); // To get PerformDelayedNudge called. |
| 934 PumpLoop(); // To get TrySyncCycleJob called |
| 935 EXPECT_TRUE(GetBackedOffTypes().HasAll(types)); |
| 936 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 937 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 938 |
| 939 TimeDelta throttle1(TimeDelta::FromMilliseconds(150)); |
| 940 |
| 941 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 942 .WillOnce(DoAll(WithArg<2>(test_util::SimulateThrottled(throttle1)), |
| 943 Return(false))) |
| 944 .RetiresOnSaturation(); |
| 945 |
| 946 // Sync still can throttle. |
| 947 const ModelTypeSet unbacked_off_types(TYPED_URLS); |
| 948 scheduler()->ScheduleLocalNudge(unbacked_off_types, FROM_HERE); |
| 949 PumpLoop(); // TO get TypesUnblock called. |
| 950 PumpLoop(); // To get TrySyncCycleJob called. |
| 951 |
| 952 EXPECT_TRUE(GetBackedOffTypes().HasAll(types)); |
| 953 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 954 EXPECT_TRUE(scheduler()->IsCurrentlyThrottled()); |
| 955 |
| 956 StopSyncScheduler(); |
| 957 } |
| 958 |
| 959 TEST_F(SyncSchedulerImplTest, TypeThrottlingBackingOffBlocksNudge) { |
| 960 UseMockDelayProvider(); |
| 961 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(long_delay())); |
| 962 |
| 963 TimeDelta poll(TimeDelta::FromDays(1)); |
| 964 TimeDelta throttle(TimeDelta::FromSeconds(60)); |
| 965 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 966 |
| 967 const ModelTypeSet throttled_types(THEMES); |
| 968 |
| 969 ::testing::InSequence seq; |
| 970 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 971 .WillOnce(DoAll(WithArg<2>(test_util::SimulateTypesThrottled( |
| 972 throttled_types, throttle)), |
| 973 Return(true))) |
| 974 .RetiresOnSaturation(); |
| 975 |
| 976 StartSyncScheduler(base::Time()); |
| 977 scheduler()->ScheduleLocalNudge(throttled_types, FROM_HERE); |
| 978 PumpLoop(); // To get PerformDelayedNudge called. |
| 979 PumpLoop(); // To get TrySyncCycleJob called |
| 980 |
| 981 const ModelTypeSet backed_off_types(TYPED_URLS); |
| 982 |
| 983 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 984 .WillOnce( |
| 985 DoAll(WithArg<2>(test_util::SimulatePartialFailure(backed_off_types)), |
| 986 Return(true))) |
| 987 .RetiresOnSaturation(); |
| 988 |
| 989 scheduler()->ScheduleLocalNudge(backed_off_types, FROM_HERE); |
| 990 |
| 991 PumpLoop(); // To get PerformDelayedNudge called. |
| 992 PumpLoop(); // To get TrySyncCycleJob called |
| 993 |
| 994 EXPECT_TRUE(GetThrottledTypes().HasAll(throttled_types)); |
| 995 EXPECT_TRUE(GetBackedOffTypes().HasAll(backed_off_types)); |
| 996 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 997 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 998 |
| 999 // This won't cause a sync cycle because the types are throttled or backed |
| 1000 // off. |
| 1001 scheduler()->ScheduleLocalNudge(Union(throttled_types, backed_off_types), |
| 1002 FROM_HERE); |
| 1003 PumpLoop(); |
| 1004 |
| 1005 StopSyncScheduler(); |
| 1006 } |
| 1007 |
| 837 TEST_F(SyncSchedulerImplTest, TypeThrottlingDoesBlockOtherSources) { | 1008 TEST_F(SyncSchedulerImplTest, TypeThrottlingDoesBlockOtherSources) { |
| 838 UseMockDelayProvider(); | 1009 UseMockDelayProvider(); |
| 839 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(default_delay())); | 1010 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(default_delay())); |
| 840 | 1011 |
| 841 SyncShareTimes times; | 1012 SyncShareTimes times; |
| 842 TimeDelta poll(TimeDelta::FromDays(1)); | 1013 TimeDelta poll(TimeDelta::FromDays(1)); |
| 843 TimeDelta throttle1(TimeDelta::FromSeconds(60)); | 1014 TimeDelta throttle1(TimeDelta::FromSeconds(60)); |
| 844 scheduler()->OnReceivedLongPollIntervalUpdate(poll); | 1015 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 845 | 1016 |
| 846 const ModelTypeSet throttled_types(THEMES); | 1017 const ModelTypeSet throttled_types(THEMES); |
| 847 const ModelTypeSet unthrottled_types(PREFERENCES); | 1018 const ModelTypeSet unthrottled_types(PREFERENCES); |
| 848 | 1019 |
| 849 ::testing::InSequence seq; | 1020 ::testing::InSequence seq; |
| 850 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) | 1021 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 851 .WillOnce(DoAll(WithArg<2>(test_util::SimulateTypesThrottled( | 1022 .WillOnce(DoAll(WithArg<2>(test_util::SimulateTypesThrottled( |
| 852 throttled_types, throttle1)), | 1023 throttled_types, throttle1)), |
| 853 Return(false))) | 1024 Return(true))) |
| 854 .RetiresOnSaturation(); | 1025 .RetiresOnSaturation(); |
| 855 | 1026 |
| 856 StartSyncScheduler(base::Time()); | 1027 StartSyncScheduler(base::Time()); |
| 857 scheduler()->ScheduleLocalNudge(throttled_types, FROM_HERE); | 1028 scheduler()->ScheduleLocalNudge(throttled_types, FROM_HERE); |
| 858 PumpLoop(); // To get PerformDelayedNudge called. | 1029 PumpLoop(); // To get PerformDelayedNudge called. |
| 859 PumpLoop(); // To get TrySyncCycleJob called | 1030 PumpLoop(); // To get TrySyncCycleJob called |
| 860 EXPECT_TRUE(GetThrottledTypes().HasAll(throttled_types)); | 1031 EXPECT_TRUE(GetThrottledTypes().HasAll(throttled_types)); |
| 1032 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 1033 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 861 | 1034 |
| 862 // Ignore invalidations for throttled types. | 1035 // Ignore invalidations for throttled types. |
| 863 scheduler()->ScheduleInvalidationNudge(THEMES, BuildInvalidation(10, "test"), | 1036 scheduler()->ScheduleInvalidationNudge(THEMES, BuildInvalidation(10, "test"), |
| 864 FROM_HERE); | 1037 FROM_HERE); |
| 865 PumpLoop(); | 1038 PumpLoop(); |
| 866 | 1039 |
| 867 // Ignore refresh requests for throttled types. | 1040 // Ignore refresh requests for throttled types. |
| 868 scheduler()->ScheduleLocalRefreshRequest(throttled_types, FROM_HERE); | 1041 scheduler()->ScheduleLocalRefreshRequest(throttled_types, FROM_HERE); |
| 869 PumpLoop(); | 1042 PumpLoop(); |
| 870 | 1043 |
| 871 Mock::VerifyAndClearExpectations(syncer()); | 1044 Mock::VerifyAndClearExpectations(syncer()); |
| 872 | 1045 |
| 873 // Local nudges for non-throttled types will trigger a sync. | 1046 // Local nudges for non-throttled types will trigger a sync. |
| 874 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) | 1047 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 875 .WillRepeatedly(DoAll(Invoke(test_util::SimulateNormalSuccess), | 1048 .WillRepeatedly(DoAll(Invoke(test_util::SimulateNormalSuccess), |
| 876 RecordSyncShare(×, true))); | 1049 RecordSyncShare(×, true))); |
| 877 scheduler()->ScheduleLocalNudge(unthrottled_types, FROM_HERE); | 1050 scheduler()->ScheduleLocalNudge(unthrottled_types, FROM_HERE); |
| 878 RunLoop(); | 1051 RunLoop(); |
| 879 Mock::VerifyAndClearExpectations(syncer()); | 1052 Mock::VerifyAndClearExpectations(syncer()); |
| 880 | 1053 |
| 881 StopSyncScheduler(); | 1054 StopSyncScheduler(); |
| 882 } | 1055 } |
| 883 | 1056 |
| 1057 TEST_F(SyncSchedulerImplTest, TypeBackingOffDoesBlockOtherSources) { |
| 1058 UseMockDelayProvider(); |
| 1059 EXPECT_CALL(*delay(), GetDelay(_)).WillRepeatedly(Return(long_delay())); |
| 1060 |
| 1061 SyncShareTimes times; |
| 1062 TimeDelta poll(TimeDelta::FromDays(1)); |
| 1063 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 1064 |
| 1065 const ModelTypeSet backed_off_types(THEMES); |
| 1066 const ModelTypeSet unbacked_off_types(PREFERENCES); |
| 1067 |
| 1068 ::testing::InSequence seq; |
| 1069 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 1070 .WillOnce( |
| 1071 DoAll(WithArg<2>(test_util::SimulatePartialFailure(backed_off_types)), |
| 1072 Return(true))) |
| 1073 .RetiresOnSaturation(); |
| 1074 |
| 1075 StartSyncScheduler(base::Time()); |
| 1076 scheduler()->ScheduleLocalNudge(backed_off_types, FROM_HERE); |
| 1077 PumpLoop(); // To get PerformDelayedNudge called. |
| 1078 PumpLoop(); // To get TrySyncCycleJob called |
| 1079 EXPECT_TRUE(GetBackedOffTypes().HasAll(backed_off_types)); |
| 1080 EXPECT_FALSE(scheduler()->IsBackingOff()); |
| 1081 EXPECT_FALSE(scheduler()->IsCurrentlyThrottled()); |
| 1082 |
| 1083 // Ignore invalidations for backed off types. |
| 1084 scheduler()->ScheduleInvalidationNudge(THEMES, BuildInvalidation(10, "test"), |
| 1085 FROM_HERE); |
| 1086 PumpLoop(); |
| 1087 |
| 1088 // Ignore refresh requests for backed off types. |
| 1089 scheduler()->ScheduleLocalRefreshRequest(backed_off_types, FROM_HERE); |
| 1090 PumpLoop(); |
| 1091 |
| 1092 Mock::VerifyAndClearExpectations(syncer()); |
| 1093 |
| 1094 // Local nudges for non-backed off types will trigger a sync. |
| 1095 EXPECT_CALL(*syncer(), NormalSyncShare(_, _, _)) |
| 1096 .WillRepeatedly(DoAll(Invoke(test_util::SimulateNormalSuccess), |
| 1097 RecordSyncShare(×, true))); |
| 1098 scheduler()->ScheduleLocalNudge(unbacked_off_types, FROM_HERE); |
| 1099 RunLoop(); |
| 1100 Mock::VerifyAndClearExpectations(syncer()); |
| 1101 |
| 1102 StopSyncScheduler(); |
| 1103 } |
| 1104 |
| 884 // Test nudges / polls don't run in config mode and config tasks do. | 1105 // Test nudges / polls don't run in config mode and config tasks do. |
| 885 TEST_F(SyncSchedulerImplTest, ConfigurationMode) { | 1106 TEST_F(SyncSchedulerImplTest, ConfigurationMode) { |
| 886 TimeDelta poll(TimeDelta::FromMilliseconds(15)); | 1107 TimeDelta poll(TimeDelta::FromMilliseconds(15)); |
| 887 SyncShareTimes times; | 1108 SyncShareTimes times; |
| 888 scheduler()->OnReceivedLongPollIntervalUpdate(poll); | 1109 scheduler()->OnReceivedLongPollIntervalUpdate(poll); |
| 889 | 1110 |
| 890 StartSyncConfiguration(); | 1111 StartSyncConfiguration(); |
| 891 | 1112 |
| 892 const ModelTypeSet nudge_types(TYPED_URLS); | 1113 const ModelTypeSet nudge_types(TYPED_URLS); |
| 893 scheduler()->ScheduleLocalNudge(nudge_types, FROM_HERE); | 1114 scheduler()->ScheduleLocalNudge(nudge_types, FROM_HERE); |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 ASSERT_TRUE(scheduler()->IsBackingOff()); | 1654 ASSERT_TRUE(scheduler()->IsBackingOff()); |
| 1434 | 1655 |
| 1435 // Now succeed. | 1656 // Now succeed. |
| 1436 connection()->SetServerReachable(); | 1657 connection()->SetServerReachable(); |
| 1437 PumpLoopFor(2 * delta); | 1658 PumpLoopFor(2 * delta); |
| 1438 ASSERT_EQ(1, success_counter.times_called()); | 1659 ASSERT_EQ(1, success_counter.times_called()); |
| 1439 ASSERT_FALSE(scheduler()->IsBackingOff()); | 1660 ASSERT_FALSE(scheduler()->IsBackingOff()); |
| 1440 } | 1661 } |
| 1441 | 1662 |
| 1442 } // namespace syncer | 1663 } // namespace syncer |
| OLD | NEW |