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 "content/browser/loader/resource_scheduler.h" | 5 #include "content/browser/loader/resource_scheduler.h" |
6 | 6 |
7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 : next_request_id_(0), | 142 : next_request_id_(0), |
143 ui_thread_(BrowserThread::UI, &message_loop_), | 143 ui_thread_(BrowserThread::UI, &message_loop_), |
144 io_thread_(BrowserThread::IO, &message_loop_), | 144 io_thread_(BrowserThread::IO, &message_loop_), |
145 mock_timer_(new base::MockTimer(true, true)) { | 145 mock_timer_(new base::MockTimer(true, true)) { |
146 scheduler_.set_timer_for_testing(scoped_ptr<base::Timer>(mock_timer_)); | 146 scheduler_.set_timer_for_testing(scoped_ptr<base::Timer>(mock_timer_)); |
147 | 147 |
148 // TODO(aiolos): Remove when throttling and coalescing have both landed. | 148 // TODO(aiolos): Remove when throttling and coalescing have both landed. |
149 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 149 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
150 false /* should_coalesce */); | 150 false /* should_coalesce */); |
151 | 151 |
152 scheduler_.OnClientCreated(kChildId, kRouteId, true); | 152 scheduler_.OnClientCreated(kChildId, kRouteId, true, false); |
153 scheduler_.OnClientCreated(kBackgroundChildId, kBackgroundRouteId, false); | 153 scheduler_.OnClientCreated( |
| 154 kBackgroundChildId, kBackgroundRouteId, false, false); |
154 context_.set_http_server_properties(http_server_properties_.GetWeakPtr()); | 155 context_.set_http_server_properties(http_server_properties_.GetWeakPtr()); |
155 } | 156 } |
156 | 157 |
157 virtual ~ResourceSchedulerTest() { | 158 virtual ~ResourceSchedulerTest() { |
158 scheduler_.OnClientDeleted(kChildId, kRouteId); | 159 scheduler_.OnClientDeleted(kChildId, kRouteId); |
159 scheduler_.OnClientDeleted(kBackgroundChildId, kBackgroundRouteId); | 160 scheduler_.OnClientDeleted(kBackgroundChildId, kBackgroundRouteId); |
160 } | 161 } |
161 | 162 |
162 scoped_ptr<net::URLRequest> NewURLRequestWithChildAndRoute( | 163 scoped_ptr<net::URLRequest> NewURLRequestWithChildAndRoute( |
163 const char* url, | 164 const char* url, |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 ChangeRequestPriority(low2_spdy.get(), net::LOWEST); | 655 ChangeRequestPriority(low2_spdy.get(), net::LOWEST); |
655 scoped_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); | 656 scoped_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); |
656 EXPECT_TRUE(low2->started()); | 657 EXPECT_TRUE(low2->started()); |
657 } | 658 } |
658 | 659 |
659 TEST_F(ResourceSchedulerTest, ThrottledClientCreation) { | 660 TEST_F(ResourceSchedulerTest, ThrottledClientCreation) { |
660 // TODO(aiolos): remove when throttling and coalescing have both landed | 661 // TODO(aiolos): remove when throttling and coalescing have both landed |
661 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 662 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
662 false /* should_coalesce */); | 663 false /* should_coalesce */); |
663 EXPECT_TRUE(scheduler_.should_throttle()); | 664 EXPECT_TRUE(scheduler_.should_throttle()); |
664 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 665 scheduler_.OnClientCreated( |
| 666 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
665 | 667 |
666 EXPECT_EQ(ResourceScheduler::THROTTLED, | 668 EXPECT_EQ(ResourceScheduler::THROTTLED, |
667 scheduler_.GetClientStateForTesting(kBackgroundChildId2, | 669 scheduler_.GetClientStateForTesting(kBackgroundChildId2, |
668 kBackgroundRouteId2)); | 670 kBackgroundRouteId2)); |
669 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 671 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
670 } | 672 } |
671 | 673 |
672 TEST_F(ResourceSchedulerTest, ActiveClientThrottleUpdateOnLoadingChange) { | 674 TEST_F(ResourceSchedulerTest, ActiveClientThrottleUpdateOnLoadingChange) { |
673 // TODO(aiolos): remove when throttling and coalescing have both landed | 675 // TODO(aiolos): remove when throttling and coalescing have both landed |
674 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 676 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 EXPECT_EQ(ResourceScheduler::UNTHROTTLED, | 1040 EXPECT_EQ(ResourceScheduler::UNTHROTTLED, |
1039 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1041 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1040 kBackgroundRouteId)); | 1042 kBackgroundRouteId)); |
1041 } | 1043 } |
1042 | 1044 |
1043 TEST_F(ResourceSchedulerTest, | 1045 TEST_F(ResourceSchedulerTest, |
1044 UnloadedClientVisibilityChangedCorrectlyUnthrottles) { | 1046 UnloadedClientVisibilityChangedCorrectlyUnthrottles) { |
1045 // TODO(aiolos): remove when throttling and coalescing have both landed | 1047 // TODO(aiolos): remove when throttling and coalescing have both landed |
1046 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1048 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1047 false /* should_coalesce */); | 1049 false /* should_coalesce */); |
1048 scheduler_.OnClientCreated(kChildId2, kRouteId2, false); | 1050 scheduler_.OnClientCreated(kChildId2, kRouteId2, false, false); |
1049 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1051 scheduler_.OnClientCreated( |
| 1052 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1050 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); | 1053 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); |
1051 scheduler_.OnLoadingStateChanged( | 1054 scheduler_.OnLoadingStateChanged( |
1052 kBackgroundChildId2, kBackgroundRouteId2, true); | 1055 kBackgroundChildId2, kBackgroundRouteId2, true); |
1053 | 1056 |
1054 // 1 visible, 3 hidden | 1057 // 1 visible, 3 hidden |
1055 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1058 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1056 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1059 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1057 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1060 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1058 kBackgroundRouteId)); | 1061 kBackgroundRouteId)); |
1059 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1062 EXPECT_EQ(ResourceScheduler::THROTTLED, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 | 1097 |
1095 scheduler_.OnClientDeleted(kChildId2, kRouteId2); | 1098 scheduler_.OnClientDeleted(kChildId2, kRouteId2); |
1096 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1099 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1097 } | 1100 } |
1098 | 1101 |
1099 TEST_F(ResourceSchedulerTest, | 1102 TEST_F(ResourceSchedulerTest, |
1100 UnloadedClientAudibilityChangedCorrectlyUnthrottles) { | 1103 UnloadedClientAudibilityChangedCorrectlyUnthrottles) { |
1101 // TODO(aiolos): remove when throttling and coalescing have both landed | 1104 // TODO(aiolos): remove when throttling and coalescing have both landed |
1102 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1105 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1103 false /* should_coalesce */); | 1106 false /* should_coalesce */); |
1104 scheduler_.OnClientCreated(kChildId2, kRouteId2, false); | 1107 scheduler_.OnClientCreated(kChildId2, kRouteId2, false, false); |
1105 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1108 scheduler_.OnClientCreated( |
| 1109 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1106 scheduler_.OnLoadingStateChanged( | 1110 scheduler_.OnLoadingStateChanged( |
1107 kBackgroundChildId2, kBackgroundRouteId2, true); | 1111 kBackgroundChildId2, kBackgroundRouteId2, true); |
1108 scheduler_.OnVisibilityChanged(kChildId, kRouteId, false); | 1112 scheduler_.OnVisibilityChanged(kChildId, kRouteId, false); |
1109 scheduler_.OnAudibilityChanged(kChildId, kRouteId, true); | 1113 scheduler_.OnAudibilityChanged(kChildId, kRouteId, true); |
1110 | 1114 |
1111 // 1 audible, 3 hidden | 1115 // 1 audible, 3 hidden |
1112 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1116 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1113 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1117 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1114 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1118 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1115 kBackgroundRouteId)); | 1119 kBackgroundRouteId)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 | 1155 |
1152 scheduler_.OnClientDeleted(kChildId2, kRouteId2); | 1156 scheduler_.OnClientDeleted(kChildId2, kRouteId2); |
1153 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1157 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1154 } | 1158 } |
1155 | 1159 |
1156 TEST_F(ResourceSchedulerTest, | 1160 TEST_F(ResourceSchedulerTest, |
1157 LoadedClientVisibilityChangedCorrectlyUnthrottles) { | 1161 LoadedClientVisibilityChangedCorrectlyUnthrottles) { |
1158 // TODO(aiolos): remove when throttling and coalescing have both landed | 1162 // TODO(aiolos): remove when throttling and coalescing have both landed |
1159 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1163 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1160 false /* should_coalesce */); | 1164 false /* should_coalesce */); |
1161 scheduler_.OnClientCreated(kChildId2, kRouteId2, false); | 1165 scheduler_.OnClientCreated(kChildId2, kRouteId2, false, false); |
1162 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1166 scheduler_.OnClientCreated( |
| 1167 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1163 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); | 1168 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); |
1164 scheduler_.OnLoadingStateChanged( | 1169 scheduler_.OnLoadingStateChanged( |
1165 kBackgroundChildId2, kBackgroundRouteId2, true); | 1170 kBackgroundChildId2, kBackgroundRouteId2, true); |
1166 // 1 visible, 3 hidden | 1171 // 1 visible, 3 hidden |
1167 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1172 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1168 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1173 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1169 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1174 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1170 kBackgroundRouteId)); | 1175 kBackgroundRouteId)); |
1171 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1176 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1172 scheduler_.GetClientStateForTesting(kBackgroundChildId2, | 1177 scheduler_.GetClientStateForTesting(kBackgroundChildId2, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 | 1211 |
1207 scheduler_.OnClientDeleted(kChildId2, kRouteId2); | 1212 scheduler_.OnClientDeleted(kChildId2, kRouteId2); |
1208 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1213 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1209 } | 1214 } |
1210 | 1215 |
1211 TEST_F(ResourceSchedulerTest, | 1216 TEST_F(ResourceSchedulerTest, |
1212 LoadedClientAudibilityChangedCorrectlyUnthrottles) { | 1217 LoadedClientAudibilityChangedCorrectlyUnthrottles) { |
1213 // TODO(aiolos): remove when throttling and coalescing have both landed | 1218 // TODO(aiolos): remove when throttling and coalescing have both landed |
1214 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1219 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1215 false /* should_coalesce */); | 1220 false /* should_coalesce */); |
1216 scheduler_.OnClientCreated(kChildId2, kRouteId2, false); | 1221 scheduler_.OnClientCreated(kChildId2, kRouteId2, false, false); |
1217 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1222 scheduler_.OnClientCreated( |
| 1223 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1218 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); | 1224 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); |
1219 scheduler_.OnLoadingStateChanged( | 1225 scheduler_.OnLoadingStateChanged( |
1220 kBackgroundChildId2, kBackgroundRouteId2, true); | 1226 kBackgroundChildId2, kBackgroundRouteId2, true); |
1221 scheduler_.OnVisibilityChanged(kChildId, kRouteId, false); | 1227 scheduler_.OnVisibilityChanged(kChildId, kRouteId, false); |
1222 scheduler_.OnAudibilityChanged(kChildId, kRouteId, true); | 1228 scheduler_.OnAudibilityChanged(kChildId, kRouteId, true); |
1223 // 1 audible, 3 hidden | 1229 // 1 audible, 3 hidden |
1224 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1230 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1225 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1231 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1226 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1232 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1227 kBackgroundRouteId)); | 1233 kBackgroundRouteId)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); | 1268 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); |
1263 | 1269 |
1264 scheduler_.OnClientDeleted(kChildId2, kRouteId2); | 1270 scheduler_.OnClientDeleted(kChildId2, kRouteId2); |
1265 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1271 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1266 } | 1272 } |
1267 | 1273 |
1268 TEST_F(ResourceSchedulerTest, UnloadedClientBecomesHiddenCorrectlyUnthrottles) { | 1274 TEST_F(ResourceSchedulerTest, UnloadedClientBecomesHiddenCorrectlyUnthrottles) { |
1269 // TODO(aiolos): remove when throttling and coalescing have both landed | 1275 // TODO(aiolos): remove when throttling and coalescing have both landed |
1270 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1276 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1271 false /* should_coalesce */); | 1277 false /* should_coalesce */); |
1272 scheduler_.OnClientCreated(kChildId2, kRouteId2, true); | 1278 scheduler_.OnClientCreated(kChildId2, kRouteId2, true, false); |
1273 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1279 scheduler_.OnClientCreated( |
| 1280 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1274 scheduler_.OnLoadingStateChanged( | 1281 scheduler_.OnLoadingStateChanged( |
1275 kBackgroundChildId2, kBackgroundRouteId2, true); | 1282 kBackgroundChildId2, kBackgroundRouteId2, true); |
1276 | 1283 |
1277 // 2 visible, 2 hidden | 1284 // 2 visible, 2 hidden |
1278 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1285 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1279 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1286 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1280 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1287 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1281 kBackgroundRouteId)); | 1288 kBackgroundRouteId)); |
1282 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1289 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1283 scheduler_.GetClientStateForTesting(kBackgroundChildId2, | 1290 scheduler_.GetClientStateForTesting(kBackgroundChildId2, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); | 1337 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); |
1331 | 1338 |
1332 scheduler_.OnClientDeleted(kChildId2, kRouteId2); | 1339 scheduler_.OnClientDeleted(kChildId2, kRouteId2); |
1333 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1340 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1334 } | 1341 } |
1335 | 1342 |
1336 TEST_F(ResourceSchedulerTest, UnloadedClientBecomesSilentCorrectlyUnthrottles) { | 1343 TEST_F(ResourceSchedulerTest, UnloadedClientBecomesSilentCorrectlyUnthrottles) { |
1337 // TODO(aiolos): remove when throttling and coalescing have both landed | 1344 // TODO(aiolos): remove when throttling and coalescing have both landed |
1338 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1345 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1339 false /* should_coalesce */); | 1346 false /* should_coalesce */); |
1340 scheduler_.OnClientCreated(kChildId2, kRouteId2, false); | 1347 scheduler_.OnClientCreated(kChildId2, kRouteId2, false, true); |
1341 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1348 scheduler_.OnClientCreated( |
| 1349 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1342 scheduler_.OnLoadingStateChanged( | 1350 scheduler_.OnLoadingStateChanged( |
1343 kBackgroundChildId2, kBackgroundRouteId2, true); | 1351 kBackgroundChildId2, kBackgroundRouteId2, true); |
1344 scheduler_.OnAudibilityChanged(kChildId, kRouteId, true); | 1352 scheduler_.OnAudibilityChanged(kChildId, kRouteId, true); |
1345 scheduler_.OnVisibilityChanged(kChildId, kRouteId, false); | 1353 scheduler_.OnVisibilityChanged(kChildId, kRouteId, false); |
1346 scheduler_.OnAudibilityChanged(kChildId2, kRouteId2, true); | |
1347 // 2 audible, 2 hidden | 1354 // 2 audible, 2 hidden |
1348 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1355 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1349 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1356 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1350 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1357 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1351 kBackgroundRouteId)); | 1358 kBackgroundRouteId)); |
1352 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1359 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1353 scheduler_.GetClientStateForTesting(kBackgroundChildId2, | 1360 scheduler_.GetClientStateForTesting(kBackgroundChildId2, |
1354 kBackgroundRouteId2)); | 1361 kBackgroundRouteId2)); |
1355 EXPECT_EQ(ResourceScheduler::ACTIVE_AND_LOADING, | 1362 EXPECT_EQ(ResourceScheduler::ACTIVE_AND_LOADING, |
1356 scheduler_.GetClientStateForTesting(kChildId2, kRouteId2)); | 1363 scheduler_.GetClientStateForTesting(kChildId2, kRouteId2)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); | 1407 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); |
1401 | 1408 |
1402 scheduler_.OnClientDeleted(kChildId2, kRouteId2); | 1409 scheduler_.OnClientDeleted(kChildId2, kRouteId2); |
1403 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1410 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1404 } | 1411 } |
1405 | 1412 |
1406 TEST_F(ResourceSchedulerTest, LoadedClientBecomesHiddenCorrectlyThrottles) { | 1413 TEST_F(ResourceSchedulerTest, LoadedClientBecomesHiddenCorrectlyThrottles) { |
1407 // TODO(aiolos): remove when throttling and coalescing have both landed | 1414 // TODO(aiolos): remove when throttling and coalescing have both landed |
1408 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1415 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1409 false /* should_coalesce */); | 1416 false /* should_coalesce */); |
1410 scheduler_.OnClientCreated(kChildId2, kRouteId2, true); | 1417 scheduler_.OnClientCreated(kChildId2, kRouteId2, true, false); |
1411 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1418 scheduler_.OnClientCreated( |
| 1419 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1412 scheduler_.OnLoadingStateChanged( | 1420 scheduler_.OnLoadingStateChanged( |
1413 kBackgroundChildId2, kBackgroundRouteId2, true); | 1421 kBackgroundChildId2, kBackgroundRouteId2, true); |
1414 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); | 1422 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); |
1415 // 2 visible, 2 hidden | 1423 // 2 visible, 2 hidden |
1416 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1424 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1417 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1425 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1418 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1426 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1419 kBackgroundRouteId)); | 1427 kBackgroundRouteId)); |
1420 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1428 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1421 scheduler_.GetClientStateForTesting(kBackgroundChildId2, | 1429 scheduler_.GetClientStateForTesting(kBackgroundChildId2, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); | 1476 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); |
1469 | 1477 |
1470 scheduler_.OnClientDeleted(kChildId2, kRouteId2); | 1478 scheduler_.OnClientDeleted(kChildId2, kRouteId2); |
1471 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1479 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1472 } | 1480 } |
1473 | 1481 |
1474 TEST_F(ResourceSchedulerTest, LoadedClientBecomesSilentCorrectlyThrottles) { | 1482 TEST_F(ResourceSchedulerTest, LoadedClientBecomesSilentCorrectlyThrottles) { |
1475 // TODO(aiolos): remove when throttling and coalescing have both landed | 1483 // TODO(aiolos): remove when throttling and coalescing have both landed |
1476 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1484 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1477 false /* should_coalesce */); | 1485 false /* should_coalesce */); |
1478 scheduler_.OnClientCreated(kChildId2, kRouteId2, false); | 1486 scheduler_.OnClientCreated(kChildId2, kRouteId2, false, true); |
1479 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1487 scheduler_.OnClientCreated( |
| 1488 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1480 scheduler_.OnLoadingStateChanged( | 1489 scheduler_.OnLoadingStateChanged( |
1481 kBackgroundChildId2, kBackgroundRouteId2, true); | 1490 kBackgroundChildId2, kBackgroundRouteId2, true); |
1482 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); | 1491 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); |
1483 scheduler_.OnVisibilityChanged(kChildId, kRouteId, false); | 1492 scheduler_.OnVisibilityChanged(kChildId, kRouteId, false); |
1484 scheduler_.OnAudibilityChanged(kChildId, kRouteId, true); | 1493 scheduler_.OnAudibilityChanged(kChildId, kRouteId, true); |
1485 scheduler_.OnAudibilityChanged(kChildId2, kRouteId2, true); | |
1486 // 2 audible, 2 hidden | 1494 // 2 audible, 2 hidden |
1487 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1495 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1488 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1496 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1489 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1497 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1490 kBackgroundRouteId)); | 1498 kBackgroundRouteId)); |
1491 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1499 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1492 scheduler_.GetClientStateForTesting(kBackgroundChildId2, | 1500 scheduler_.GetClientStateForTesting(kBackgroundChildId2, |
1493 kBackgroundRouteId2)); | 1501 kBackgroundRouteId2)); |
1494 EXPECT_EQ(ResourceScheduler::UNTHROTTLED, | 1502 EXPECT_EQ(ResourceScheduler::UNTHROTTLED, |
1495 scheduler_.GetClientStateForTesting(kChildId2, kRouteId2)); | 1503 scheduler_.GetClientStateForTesting(kChildId2, kRouteId2)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); | 1547 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); |
1540 | 1548 |
1541 scheduler_.OnClientDeleted(kChildId2, kRouteId2); | 1549 scheduler_.OnClientDeleted(kChildId2, kRouteId2); |
1542 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1550 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1543 } | 1551 } |
1544 | 1552 |
1545 TEST_F(ResourceSchedulerTest, HiddenLoadedChangesCorrectlyStayThrottled) { | 1553 TEST_F(ResourceSchedulerTest, HiddenLoadedChangesCorrectlyStayThrottled) { |
1546 // TODO(aiolos): remove when throttling and coalescing have both landed | 1554 // TODO(aiolos): remove when throttling and coalescing have both landed |
1547 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1555 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1548 false /* should_coalesce */); | 1556 false /* should_coalesce */); |
1549 scheduler_.OnClientCreated(kChildId2, kRouteId2, true); | 1557 scheduler_.OnClientCreated(kChildId2, kRouteId2, true, false); |
1550 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1558 scheduler_.OnClientCreated( |
| 1559 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1551 | 1560 |
1552 // 1 visible and 2 hidden loading, 1 visible loaded | 1561 // 1 visible and 2 hidden loading, 1 visible loaded |
1553 scheduler_.OnLoadingStateChanged(kChildId, kRouteId, true); | 1562 scheduler_.OnLoadingStateChanged(kChildId, kRouteId, true); |
1554 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1563 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1555 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1564 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1556 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1565 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1557 kBackgroundRouteId)); | 1566 kBackgroundRouteId)); |
1558 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1567 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1559 scheduler_.GetClientStateForTesting(kBackgroundChildId2, | 1568 scheduler_.GetClientStateForTesting(kBackgroundChildId2, |
1560 kBackgroundRouteId2)); | 1569 kBackgroundRouteId2)); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1609 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); | 1618 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); |
1610 | 1619 |
1611 scheduler_.OnClientDeleted(kChildId2, kRouteId2); | 1620 scheduler_.OnClientDeleted(kChildId2, kRouteId2); |
1612 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1621 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1613 } | 1622 } |
1614 | 1623 |
1615 TEST_F(ResourceSchedulerTest, PartialVisibleClientLoadedDoesNotUnthrottle) { | 1624 TEST_F(ResourceSchedulerTest, PartialVisibleClientLoadedDoesNotUnthrottle) { |
1616 // TODO(aiolos): remove when throttling and coalescing have both landed | 1625 // TODO(aiolos): remove when throttling and coalescing have both landed |
1617 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1626 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1618 false /* should_coalesce */); | 1627 false /* should_coalesce */); |
1619 scheduler_.OnClientCreated(kChildId2, kRouteId2, true); | 1628 scheduler_.OnClientCreated(kChildId2, kRouteId2, true, false); |
1620 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1629 scheduler_.OnClientCreated( |
| 1630 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1621 | 1631 |
1622 // 2 visible loading, 1 hidden loading, 1 hidden loaded | 1632 // 2 visible loading, 1 hidden loading, 1 hidden loaded |
1623 scheduler_.OnLoadingStateChanged( | 1633 scheduler_.OnLoadingStateChanged( |
1624 kBackgroundChildId2, kBackgroundRouteId2, true); | 1634 kBackgroundChildId2, kBackgroundRouteId2, true); |
1625 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1635 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1626 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1636 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1627 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1637 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1628 kBackgroundRouteId)); | 1638 kBackgroundRouteId)); |
1629 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1639 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1630 scheduler_.GetClientStateForTesting(kBackgroundChildId2, | 1640 scheduler_.GetClientStateForTesting(kBackgroundChildId2, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1663 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); | 1673 scheduler_.GetClientStateForTesting(kChildId, kRouteId)); |
1664 | 1674 |
1665 scheduler_.OnClientDeleted(kChildId2, kRouteId2); | 1675 scheduler_.OnClientDeleted(kChildId2, kRouteId2); |
1666 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1676 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1667 } | 1677 } |
1668 | 1678 |
1669 TEST_F(ResourceSchedulerTest, FullVisibleLoadedCorrectlyUnthrottle) { | 1679 TEST_F(ResourceSchedulerTest, FullVisibleLoadedCorrectlyUnthrottle) { |
1670 // TODO(aiolos): remove when throttling and coalescing have both landed | 1680 // TODO(aiolos): remove when throttling and coalescing have both landed |
1671 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1681 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1672 false /* should_coalesce */); | 1682 false /* should_coalesce */); |
1673 scheduler_.OnClientCreated(kChildId2, kRouteId2, true); | 1683 scheduler_.OnClientCreated(kChildId2, kRouteId2, true, false); |
1674 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1684 scheduler_.OnClientCreated( |
| 1685 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1675 | 1686 |
1676 // 1 visible and 1 hidden loaded, 1 visible and 1 hidden loading | 1687 // 1 visible and 1 hidden loaded, 1 visible and 1 hidden loading |
1677 scheduler_.OnLoadingStateChanged( | 1688 scheduler_.OnLoadingStateChanged( |
1678 kBackgroundChildId2, kBackgroundRouteId2, true); | 1689 kBackgroundChildId2, kBackgroundRouteId2, true); |
1679 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); | 1690 scheduler_.OnLoadingStateChanged(kChildId2, kRouteId2, true); |
1680 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1691 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1681 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1692 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1682 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1693 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1683 kBackgroundRouteId)); | 1694 kBackgroundRouteId)); |
1684 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1695 EXPECT_EQ(ResourceScheduler::THROTTLED, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 | 1740 |
1730 scheduler_.OnClientDeleted(kChildId2, kRouteId2); | 1741 scheduler_.OnClientDeleted(kChildId2, kRouteId2); |
1731 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1742 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1732 } | 1743 } |
1733 | 1744 |
1734 TEST_F(ResourceSchedulerTest, | 1745 TEST_F(ResourceSchedulerTest, |
1735 ActiveAndLoadingClientDeletedCorrectlyUnthrottle) { | 1746 ActiveAndLoadingClientDeletedCorrectlyUnthrottle) { |
1736 // TODO(aiolos): remove when throttling and coalescing have both landed | 1747 // TODO(aiolos): remove when throttling and coalescing have both landed |
1737 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1748 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1738 false /* should_coalesce */); | 1749 false /* should_coalesce */); |
1739 scheduler_.OnClientCreated(kChildId2, kRouteId2, true); | 1750 scheduler_.OnClientCreated(kChildId2, kRouteId2, true, false); |
1740 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1751 scheduler_.OnClientCreated( |
| 1752 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1741 | 1753 |
1742 // 1 visible and 1 hidden loaded, 1 visible and 1 hidden loading | 1754 // 1 visible and 1 hidden loaded, 1 visible and 1 hidden loading |
1743 scheduler_.OnLoadingStateChanged( | 1755 scheduler_.OnLoadingStateChanged( |
1744 kBackgroundChildId2, kBackgroundRouteId2, true); | 1756 kBackgroundChildId2, kBackgroundRouteId2, true); |
1745 scheduler_.OnLoadingStateChanged(kChildId, kRouteId, true); | 1757 scheduler_.OnLoadingStateChanged(kChildId, kRouteId, true); |
1746 EXPECT_FALSE(scheduler_.active_clients_loaded()); | 1758 EXPECT_FALSE(scheduler_.active_clients_loaded()); |
1747 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1759 EXPECT_EQ(ResourceScheduler::THROTTLED, |
1748 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1760 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1749 kBackgroundRouteId)); | 1761 kBackgroundRouteId)); |
1750 EXPECT_EQ(ResourceScheduler::THROTTLED, | 1762 EXPECT_EQ(ResourceScheduler::THROTTLED, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 scheduler_.OnAudibilityChanged(kBackgroundChildId, kBackgroundRouteId, true); | 1878 scheduler_.OnAudibilityChanged(kBackgroundChildId, kBackgroundRouteId, true); |
1867 EXPECT_EQ(ResourceScheduler::UNTHROTTLED, | 1879 EXPECT_EQ(ResourceScheduler::UNTHROTTLED, |
1868 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1880 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1869 kBackgroundRouteId)); | 1881 kBackgroundRouteId)); |
1870 EXPECT_FALSE(mock_timer_->IsRunning()); | 1882 EXPECT_FALSE(mock_timer_->IsRunning()); |
1871 } | 1883 } |
1872 | 1884 |
1873 TEST_F(ResourceSchedulerTest, LastCoalescedClientDeletionStopsTimer) { | 1885 TEST_F(ResourceSchedulerTest, LastCoalescedClientDeletionStopsTimer) { |
1874 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1886 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1875 true /* should_coalesce */); | 1887 true /* should_coalesce */); |
1876 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1888 scheduler_.OnClientCreated( |
| 1889 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1877 EXPECT_FALSE(mock_timer_->IsRunning()); | 1890 EXPECT_FALSE(mock_timer_->IsRunning()); |
1878 scheduler_.OnLoadingStateChanged(kChildId, kRouteId, true); | 1891 scheduler_.OnLoadingStateChanged(kChildId, kRouteId, true); |
1879 EXPECT_FALSE(mock_timer_->IsRunning()); | 1892 EXPECT_FALSE(mock_timer_->IsRunning()); |
1880 scheduler_.OnLoadingStateChanged( | 1893 scheduler_.OnLoadingStateChanged( |
1881 kBackgroundChildId, kBackgroundRouteId, true); | 1894 kBackgroundChildId, kBackgroundRouteId, true); |
1882 EXPECT_EQ(ResourceScheduler::COALESCED, | 1895 EXPECT_EQ(ResourceScheduler::COALESCED, |
1883 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1896 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1884 kBackgroundRouteId)); | 1897 kBackgroundRouteId)); |
1885 scheduler_.OnLoadingStateChanged( | 1898 scheduler_.OnLoadingStateChanged( |
1886 kBackgroundChildId2, kBackgroundRouteId2, true); | 1899 kBackgroundChildId2, kBackgroundRouteId2, true); |
1887 EXPECT_EQ(ResourceScheduler::COALESCED, | 1900 EXPECT_EQ(ResourceScheduler::COALESCED, |
1888 scheduler_.GetClientStateForTesting(kBackgroundChildId2, | 1901 scheduler_.GetClientStateForTesting(kBackgroundChildId2, |
1889 kBackgroundRouteId2)); | 1902 kBackgroundRouteId2)); |
1890 EXPECT_TRUE(mock_timer_->IsRunning()); | 1903 EXPECT_TRUE(mock_timer_->IsRunning()); |
1891 | 1904 |
1892 scheduler_.OnClientDeleted(kBackgroundChildId, kBackgroundRouteId); | 1905 scheduler_.OnClientDeleted(kBackgroundChildId, kBackgroundRouteId); |
1893 EXPECT_TRUE(mock_timer_->IsRunning()); | 1906 EXPECT_TRUE(mock_timer_->IsRunning()); |
1894 | 1907 |
1895 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1908 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1896 EXPECT_FALSE(mock_timer_->IsRunning()); | 1909 EXPECT_FALSE(mock_timer_->IsRunning()); |
1897 | 1910 |
1898 // To avoid errors on test tear down. | 1911 // To avoid errors on test tear down. |
1899 scheduler_.OnClientCreated(kBackgroundChildId, kBackgroundRouteId, false); | 1912 scheduler_.OnClientCreated( |
| 1913 kBackgroundChildId, kBackgroundRouteId, false, false); |
1900 } | 1914 } |
1901 | 1915 |
1902 TEST_F(ResourceSchedulerTest, LastCoalescedClientStartsLoadingStopsTimer) { | 1916 TEST_F(ResourceSchedulerTest, LastCoalescedClientStartsLoadingStopsTimer) { |
1903 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1917 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1904 true /* should_coalesce */); | 1918 true /* should_coalesce */); |
1905 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1919 scheduler_.OnClientCreated( |
| 1920 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1906 EXPECT_FALSE(mock_timer_->IsRunning()); | 1921 EXPECT_FALSE(mock_timer_->IsRunning()); |
1907 scheduler_.OnLoadingStateChanged(kChildId, kRouteId, true); | 1922 scheduler_.OnLoadingStateChanged(kChildId, kRouteId, true); |
1908 EXPECT_FALSE(mock_timer_->IsRunning()); | 1923 EXPECT_FALSE(mock_timer_->IsRunning()); |
1909 scheduler_.OnLoadingStateChanged( | 1924 scheduler_.OnLoadingStateChanged( |
1910 kBackgroundChildId, kBackgroundRouteId, true); | 1925 kBackgroundChildId, kBackgroundRouteId, true); |
1911 EXPECT_EQ(ResourceScheduler::COALESCED, | 1926 EXPECT_EQ(ResourceScheduler::COALESCED, |
1912 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1927 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1913 kBackgroundRouteId)); | 1928 kBackgroundRouteId)); |
1914 scheduler_.OnLoadingStateChanged( | 1929 scheduler_.OnLoadingStateChanged( |
1915 kBackgroundChildId2, kBackgroundRouteId2, true); | 1930 kBackgroundChildId2, kBackgroundRouteId2, true); |
(...skipping 10 matching lines...) Expand all Loading... |
1926 kBackgroundChildId2, kBackgroundRouteId2, false); | 1941 kBackgroundChildId2, kBackgroundRouteId2, false); |
1927 EXPECT_FALSE(mock_timer_->IsRunning()); | 1942 EXPECT_FALSE(mock_timer_->IsRunning()); |
1928 | 1943 |
1929 // This is needed to avoid errors on test tear down. | 1944 // This is needed to avoid errors on test tear down. |
1930 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); | 1945 scheduler_.OnClientDeleted(kBackgroundChildId2, kBackgroundRouteId2); |
1931 } | 1946 } |
1932 | 1947 |
1933 TEST_F(ResourceSchedulerTest, LastCoalescedClientBecomesVisibleStopsTimer) { | 1948 TEST_F(ResourceSchedulerTest, LastCoalescedClientBecomesVisibleStopsTimer) { |
1934 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, | 1949 scheduler_.SetThrottleOptionsForTesting(true /* should_throttle */, |
1935 true /* should_coalesce */); | 1950 true /* should_coalesce */); |
1936 scheduler_.OnClientCreated(kBackgroundChildId2, kBackgroundRouteId2, false); | 1951 scheduler_.OnClientCreated( |
| 1952 kBackgroundChildId2, kBackgroundRouteId2, false, false); |
1937 EXPECT_FALSE(mock_timer_->IsRunning()); | 1953 EXPECT_FALSE(mock_timer_->IsRunning()); |
1938 scheduler_.OnLoadingStateChanged(kChildId, kRouteId, true); | 1954 scheduler_.OnLoadingStateChanged(kChildId, kRouteId, true); |
1939 EXPECT_FALSE(mock_timer_->IsRunning()); | 1955 EXPECT_FALSE(mock_timer_->IsRunning()); |
1940 scheduler_.OnLoadingStateChanged( | 1956 scheduler_.OnLoadingStateChanged( |
1941 kBackgroundChildId, kBackgroundRouteId, true); | 1957 kBackgroundChildId, kBackgroundRouteId, true); |
1942 EXPECT_EQ(ResourceScheduler::COALESCED, | 1958 EXPECT_EQ(ResourceScheduler::COALESCED, |
1943 scheduler_.GetClientStateForTesting(kBackgroundChildId, | 1959 scheduler_.GetClientStateForTesting(kBackgroundChildId, |
1944 kBackgroundRouteId)); | 1960 kBackgroundRouteId)); |
1945 scheduler_.OnLoadingStateChanged( | 1961 scheduler_.OnLoadingStateChanged( |
1946 kBackgroundChildId2, kBackgroundRouteId2, true); | 1962 kBackgroundChildId2, kBackgroundRouteId2, true); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2171 web_contents_2.reset(); | 2187 web_contents_2.reset(); |
2172 base::RunLoop().RunUntilIdle(); | 2188 base::RunLoop().RunUntilIdle(); |
2173 | 2189 |
2174 browser_context.reset(); | 2190 browser_context.reset(); |
2175 render_process_host_factory.reset(); | 2191 render_process_host_factory.reset(); |
2176 } | 2192 } |
2177 | 2193 |
2178 } // unnamed namespace | 2194 } // unnamed namespace |
2179 | 2195 |
2180 } // namespace content | 2196 } // namespace content |
OLD | NEW |