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/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 high.reset(); | 424 high.reset(); |
425 EXPECT_TRUE(second_last_singlehost->started()); | 425 EXPECT_TRUE(second_last_singlehost->started()); |
426 EXPECT_FALSE(last_singlehost->started()); | 426 EXPECT_FALSE(last_singlehost->started()); |
427 lows_singlehost.erase(lows_singlehost.begin()); | 427 lows_singlehost.erase(lows_singlehost.begin()); |
428 EXPECT_TRUE(last_singlehost->started()); | 428 EXPECT_TRUE(last_singlehost->started()); |
429 | 429 |
430 // Queue more requests from different hosts until we reach the total limit. | 430 // Queue more requests from different hosts until we reach the total limit. |
431 int expected_slots_left = | 431 int expected_slots_left = |
432 kMaxNumDelayableRequestsPerClient - kMaxNumDelayableRequestsPerHost; | 432 kMaxNumDelayableRequestsPerClient - kMaxNumDelayableRequestsPerHost; |
433 EXPECT_GT(expected_slots_left, 0); | 433 EXPECT_GT(expected_slots_left, 0); |
434 ScopedVector<TestRequest> lows_differenthosts; | 434 ScopedVector<TestRequest> lows_different_host; |
435 for (int i = 0; i < expected_slots_left; ++i) { | 435 for (int i = 0; i < expected_slots_left; ++i) { |
436 string url = "http://host" + base::IntToString(i) + "/low"; | 436 string url = "http://host" + base::IntToString(i) + "/low"; |
437 lows_differenthosts.push_back(NewRequest(url.c_str(), net::LOWEST)); | 437 lows_different_host.push_back(NewRequest(url.c_str(), net::LOWEST)); |
438 EXPECT_TRUE(lows_differenthosts[i]->started()); | 438 EXPECT_TRUE(lows_different_host[i]->started()); |
439 } | 439 } |
440 | 440 |
441 scoped_ptr<TestRequest> last_differenthost(NewRequest("http://host_new/last", | 441 scoped_ptr<TestRequest> last_different_host(NewRequest("http://host_new/last", |
442 net::LOWEST)); | 442 net::LOWEST)); |
443 EXPECT_FALSE(last_differenthost->started()); | 443 EXPECT_FALSE(last_different_host->started()); |
444 } | 444 } |
445 | 445 |
446 TEST_F(ResourceSchedulerTest, RaisePriorityAndStart) { | 446 TEST_F(ResourceSchedulerTest, RaisePriorityAndStart) { |
447 // Dummies to enforce scheduling. | 447 // Dummies to enforce scheduling. |
448 scoped_ptr<TestRequest> high(NewRequest("http://host/high", net::HIGHEST)); | 448 scoped_ptr<TestRequest> high(NewRequest("http://host/high", net::HIGHEST)); |
449 scoped_ptr<TestRequest> low(NewRequest("http://host/req", net::LOWEST)); | 449 scoped_ptr<TestRequest> low(NewRequest("http://host/req", net::LOWEST)); |
450 | 450 |
451 scoped_ptr<TestRequest> request(NewRequest("http://host/req", net::LOWEST)); | 451 scoped_ptr<TestRequest> request(NewRequest("http://host/req", net::LOWEST)); |
452 EXPECT_FALSE(request->started()); | 452 EXPECT_FALSE(request->started()); |
453 | 453 |
(...skipping 1842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 } | 2296 } |
2297 scoped_ptr<TestRequest> lowest(NewRequestWithChildAndRoute( | 2297 scoped_ptr<TestRequest> lowest(NewRequestWithChildAndRoute( |
2298 "http://host/lowest", net::LOWEST, kChildId2, kRouteId2)); | 2298 "http://host/lowest", net::LOWEST, kChildId2, kRouteId2)); |
2299 EXPECT_FALSE(lowest->started()); | 2299 EXPECT_FALSE(lowest->started()); |
2300 scheduler_->OnClientDeleted(kChildId2, kRouteId2); | 2300 scheduler_->OnClientDeleted(kChildId2, kRouteId2); |
2301 high.reset(); | 2301 high.reset(); |
2302 delayable_requests.clear(); | 2302 delayable_requests.clear(); |
2303 EXPECT_TRUE(lowest->started()); | 2303 EXPECT_TRUE(lowest->started()); |
2304 } | 2304 } |
2305 | 2305 |
| 2306 TEST_F(ResourceSchedulerTest, DefaultLayoutBlockingPriority) { |
| 2307 const int kDeferLateScripts = 0; |
| 2308 const int kIncreaseFontPriority = 0; |
| 2309 const int kIncreaseAsyncScriptPriority = 0; |
| 2310 const int kEnablePriorityIncrease = 0; |
| 2311 const int kEnableLayoutBlockingThreshold = 0; |
| 2312 const int kLayoutBlockingThreshold = 0; |
| 2313 const int kMaxNumDelayableWhileLayoutBlocking = 1; |
| 2314 const int kMaxNumDelayableRequestsPerClient = 10; |
| 2315 ASSERT_TRUE(InitializeFieldTrials(base::StringPrintf( |
| 2316 "ResourcePriorities/LayoutBlocking_%d%d%d%d%d_%d_%d_%d/", |
| 2317 kDeferLateScripts, |
| 2318 kIncreaseFontPriority, |
| 2319 kIncreaseAsyncScriptPriority, |
| 2320 kEnablePriorityIncrease, |
| 2321 kEnableLayoutBlockingThreshold, |
| 2322 kLayoutBlockingThreshold, |
| 2323 kMaxNumDelayableWhileLayoutBlocking, |
| 2324 kMaxNumDelayableRequestsPerClient))); |
| 2325 InitializeScheduler(); |
| 2326 scoped_ptr<TestRequest> high( |
| 2327 NewRequest("http://hosthigh/high", net::HIGHEST)); |
| 2328 scoped_ptr<TestRequest> high2( |
| 2329 NewRequest("http://hosthigh/high", net::HIGHEST)); |
| 2330 scoped_ptr<TestRequest> medium( |
| 2331 NewRequest("http://hostmedium/medium", net::MEDIUM)); |
| 2332 scoped_ptr<TestRequest> medium2( |
| 2333 NewRequest("http://hostmedium/medium", net::MEDIUM)); |
| 2334 scoped_ptr<TestRequest> low(NewRequest("http://hostlow/low", net::LOW)); |
| 2335 scoped_ptr<TestRequest> low2(NewRequest("http://hostlow/low", net::LOW)); |
| 2336 scoped_ptr<TestRequest> lowest(NewRequest("http://hostlowest/lowest", net::LOW
EST)); |
| 2337 scoped_ptr<TestRequest> lowest2( |
| 2338 NewRequest("http://hostlowest/lowest", net::LOWEST)); |
| 2339 EXPECT_TRUE(high->started()); |
| 2340 EXPECT_TRUE(high2->started()); |
| 2341 EXPECT_TRUE(medium->started()); |
| 2342 EXPECT_TRUE(medium2->started()); |
| 2343 EXPECT_TRUE(low->started()); |
| 2344 EXPECT_TRUE(low2->started()); |
| 2345 EXPECT_TRUE(lowest->started()); |
| 2346 EXPECT_FALSE(lowest2->started()); |
| 2347 lowest.reset(); |
| 2348 EXPECT_TRUE(lowest2->started()); |
| 2349 } |
| 2350 |
| 2351 TEST_F(ResourceSchedulerTest, IncreaseLayoutBlockingPriority) { |
| 2352 // Changes the level of priorities that are allowed during layout-blocking |
| 2353 // from net::LOWEST to net::LOW. |
| 2354 const int kDeferLateScripts = 0; |
| 2355 const int kIncreaseFontPriority = 0; |
| 2356 const int kIncreaseAsyncScriptPriority = 0; |
| 2357 const int kEnablePriorityIncrease = 1; |
| 2358 const int kEnableLayoutBlockingThreshold = 0; |
| 2359 const int kLayoutBlockingThreshold = 0; |
| 2360 const int kMaxNumDelayableWhileLayoutBlocking = 1; |
| 2361 const int kMaxNumDelayableRequestsPerClient = 10; |
| 2362 ASSERT_TRUE(InitializeFieldTrials(base::StringPrintf( |
| 2363 "ResourcePriorities/LayoutBlocking_%d%d%d%d%d_%d_%d_%d/", |
| 2364 kDeferLateScripts, |
| 2365 kIncreaseFontPriority, |
| 2366 kIncreaseAsyncScriptPriority, |
| 2367 kEnablePriorityIncrease, |
| 2368 kEnableLayoutBlockingThreshold, |
| 2369 kLayoutBlockingThreshold, |
| 2370 kMaxNumDelayableWhileLayoutBlocking, |
| 2371 kMaxNumDelayableRequestsPerClient))); |
| 2372 InitializeScheduler(); |
| 2373 scoped_ptr<TestRequest> high( |
| 2374 NewRequest("http://hosthigh/high", net::HIGHEST)); |
| 2375 scoped_ptr<TestRequest> high2( |
| 2376 NewRequest("http://hosthigh/high", net::HIGHEST)); |
| 2377 scoped_ptr<TestRequest> medium( |
| 2378 NewRequest("http://hostmedium/medium", net::MEDIUM)); |
| 2379 scoped_ptr<TestRequest> medium2( |
| 2380 NewRequest("http://hostmedium/medium", net::MEDIUM)); |
| 2381 scoped_ptr<TestRequest> low(NewRequest("http://hostlow/low", net::LOW)); |
| 2382 scoped_ptr<TestRequest> low2(NewRequest("http://hostlow/low", net::LOW)); |
| 2383 scoped_ptr<TestRequest> lowest(NewRequest("http://hostlowest/lowest", net::LOW
EST)); |
| 2384 scoped_ptr<TestRequest> lowest2( |
| 2385 NewRequest("http://hostlowest/lowest", net::LOWEST)); |
| 2386 EXPECT_TRUE(high->started()); |
| 2387 EXPECT_TRUE(high2->started()); |
| 2388 EXPECT_TRUE(medium->started()); |
| 2389 EXPECT_TRUE(medium2->started()); |
| 2390 EXPECT_TRUE(low->started()); |
| 2391 EXPECT_FALSE(low2->started()); |
| 2392 EXPECT_FALSE(lowest->started()); |
| 2393 EXPECT_FALSE(lowest2->started()); |
| 2394 low.reset(); |
| 2395 EXPECT_TRUE(low2->started()); |
| 2396 EXPECT_FALSE(lowest->started()); |
| 2397 EXPECT_FALSE(lowest2->started()); |
| 2398 low2.reset(); |
| 2399 EXPECT_TRUE(lowest->started()); |
| 2400 EXPECT_FALSE(lowest2->started()); |
| 2401 lowest.reset(); |
| 2402 EXPECT_TRUE(lowest2->started()); |
| 2403 } |
| 2404 |
| 2405 TEST_F(ResourceSchedulerTest, UseLayoutBlockingThresholdOne) { |
| 2406 // Prevents any low priority requests from starting while more than |
| 2407 // N high priority requests are pending (before body). |
| 2408 const int kDeferLateScripts = 0; |
| 2409 const int kIncreaseFontPriority = 0; |
| 2410 const int kIncreaseAsyncScriptPriority = 0; |
| 2411 const int kEnablePriorityIncrease = 0; |
| 2412 const int kEnableLayoutBlockingThreshold = 1; |
| 2413 const int kLayoutBlockingThreshold = 1; |
| 2414 const int kMaxNumDelayableWhileLayoutBlocking = 1; |
| 2415 const int kMaxNumDelayableRequestsPerClient = 10; |
| 2416 ASSERT_TRUE(InitializeFieldTrials(base::StringPrintf( |
| 2417 "ResourcePriorities/LayoutBlocking_%d%d%d%d%d_%d_%d_%d/", |
| 2418 kDeferLateScripts, |
| 2419 kIncreaseFontPriority, |
| 2420 kIncreaseAsyncScriptPriority, |
| 2421 kEnablePriorityIncrease, |
| 2422 kEnableLayoutBlockingThreshold, |
| 2423 kLayoutBlockingThreshold, |
| 2424 kMaxNumDelayableWhileLayoutBlocking, |
| 2425 kMaxNumDelayableRequestsPerClient))); |
| 2426 InitializeScheduler(); |
| 2427 scoped_ptr<TestRequest> high(NewRequest("http://host/high", net::HIGHEST)); |
| 2428 scoped_ptr<TestRequest> high2(NewRequest("http://host/high", net::HIGHEST)); |
| 2429 scoped_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST)); |
| 2430 scoped_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); |
| 2431 EXPECT_TRUE(high->started()); |
| 2432 EXPECT_TRUE(high2->started()); |
| 2433 EXPECT_FALSE(low->started()); |
| 2434 EXPECT_FALSE(low2->started()); |
| 2435 high.reset(); |
| 2436 EXPECT_TRUE(low->started()); |
| 2437 EXPECT_FALSE(low2->started()); |
| 2438 high2.reset(); |
| 2439 EXPECT_FALSE(low2->started()); |
| 2440 scheduler()->OnWillInsertBody(kChildId, kRouteId); |
| 2441 EXPECT_TRUE(low2->started()); |
| 2442 } |
| 2443 |
| 2444 TEST_F(ResourceSchedulerTest, UseLayoutBlockingThresholdTwo) { |
| 2445 // Prevents any low priority requests from starting while more than |
| 2446 // N high priority requests are pending (before body). |
| 2447 const int kDeferLateScripts = 0; |
| 2448 const int kIncreaseFontPriority = 0; |
| 2449 const int kIncreaseAsyncScriptPriority = 0; |
| 2450 const int kEnablePriorityIncrease = 0; |
| 2451 const int kEnableLayoutBlockingThreshold = 1; |
| 2452 const int kLayoutBlockingThreshold = 2; |
| 2453 const int kMaxNumDelayableWhileLayoutBlocking = 1; |
| 2454 const int kMaxNumDelayableRequestsPerClient = 10; |
| 2455 ASSERT_TRUE(InitializeFieldTrials(base::StringPrintf( |
| 2456 "ResourcePriorities/LayoutBlocking_%d%d%d%d%d_%d_%d_%d/", |
| 2457 kDeferLateScripts, |
| 2458 kIncreaseFontPriority, |
| 2459 kIncreaseAsyncScriptPriority, |
| 2460 kEnablePriorityIncrease, |
| 2461 kEnableLayoutBlockingThreshold, |
| 2462 kLayoutBlockingThreshold, |
| 2463 kMaxNumDelayableWhileLayoutBlocking, |
| 2464 kMaxNumDelayableRequestsPerClient))); |
| 2465 InitializeScheduler(); |
| 2466 scoped_ptr<TestRequest> high(NewRequest("http://host/high", net::HIGHEST)); |
| 2467 scoped_ptr<TestRequest> high2(NewRequest("http://host/high", net::HIGHEST)); |
| 2468 scoped_ptr<TestRequest> high3(NewRequest("http://host/high", net::HIGHEST)); |
| 2469 scoped_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST)); |
| 2470 scoped_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); |
| 2471 EXPECT_TRUE(high->started()); |
| 2472 EXPECT_TRUE(high2->started()); |
| 2473 EXPECT_TRUE(high3->started()); |
| 2474 EXPECT_FALSE(low->started()); |
| 2475 EXPECT_FALSE(low2->started()); |
| 2476 high.reset(); |
| 2477 EXPECT_TRUE(low->started()); |
| 2478 EXPECT_FALSE(low2->started()); |
| 2479 high2.reset(); |
| 2480 high3.reset(); |
| 2481 EXPECT_FALSE(low2->started()); |
| 2482 scheduler()->OnWillInsertBody(kChildId, kRouteId); |
| 2483 EXPECT_TRUE(low2->started()); |
| 2484 } |
| 2485 |
| 2486 TEST_F(ResourceSchedulerTest, TwoDelayableLoadsUntilBodyInserted) { |
| 2487 // Allow for two low priority requests to be in flight at any point in time |
| 2488 // during the layout-blocking phase of loading. |
| 2489 const int kDeferLateScripts = 0; |
| 2490 const int kIncreaseFontPriority = 0; |
| 2491 const int kIncreaseAsyncScriptPriority = 0; |
| 2492 const int kEnablePriorityIncrease = 0; |
| 2493 const int kEnableLayoutBlockingThreshold = 0; |
| 2494 const int kLayoutBlockingThreshold = 0; |
| 2495 const int kMaxNumDelayableWhileLayoutBlocking = 2; |
| 2496 const int kMaxNumDelayableRequestsPerClient = 10; |
| 2497 ASSERT_TRUE(InitializeFieldTrials(base::StringPrintf( |
| 2498 "ResourcePriorities/LayoutBlocking_%d%d%d%d%d_%d_%d_%d/", |
| 2499 kDeferLateScripts, |
| 2500 kIncreaseFontPriority, |
| 2501 kIncreaseAsyncScriptPriority, |
| 2502 kEnablePriorityIncrease, |
| 2503 kEnableLayoutBlockingThreshold, |
| 2504 kLayoutBlockingThreshold, |
| 2505 kMaxNumDelayableWhileLayoutBlocking, |
| 2506 kMaxNumDelayableRequestsPerClient))); |
| 2507 InitializeScheduler(); |
| 2508 scoped_ptr<TestRequest> high(NewRequest("http://host/high", net::HIGHEST)); |
| 2509 scoped_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST)); |
| 2510 scoped_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); |
| 2511 scoped_ptr<TestRequest> low3(NewRequest("http://host/low", net::LOWEST)); |
| 2512 EXPECT_TRUE(high->started()); |
| 2513 EXPECT_TRUE(low->started()); |
| 2514 EXPECT_TRUE(low2->started()); |
| 2515 EXPECT_FALSE(low3->started()); |
| 2516 high.reset(); |
| 2517 scheduler()->OnWillInsertBody(kChildId, kRouteId); |
| 2518 EXPECT_TRUE(low3->started()); |
| 2519 } |
| 2520 |
| 2521 TEST_F(ResourceSchedulerTest, |
| 2522 UseLayoutBlockingThresholdOneAndTwoDelayableLoadsUntilBodyInserted) { |
| 2523 // Allow for two low priority requests to be in flight during the |
| 2524 // layout-blocking phase of loading but only when there is not more than one |
| 2525 // in-flight high priority request. |
| 2526 const int kDeferLateScripts = 0; |
| 2527 const int kIncreaseFontPriority = 0; |
| 2528 const int kIncreaseAsyncScriptPriority = 0; |
| 2529 const int kEnablePriorityIncrease = 0; |
| 2530 const int kEnableLayoutBlockingThreshold = 1; |
| 2531 const int kLayoutBlockingThreshold = 1; |
| 2532 const int kMaxNumDelayableWhileLayoutBlocking = 2; |
| 2533 const int kMaxNumDelayableRequestsPerClient = 10; |
| 2534 ASSERT_TRUE(InitializeFieldTrials(base::StringPrintf( |
| 2535 "ResourcePriorities/LayoutBlocking_%d%d%d%d%d_%d_%d_%d/", |
| 2536 kDeferLateScripts, |
| 2537 kIncreaseFontPriority, |
| 2538 kIncreaseAsyncScriptPriority, |
| 2539 kEnablePriorityIncrease, |
| 2540 kEnableLayoutBlockingThreshold, |
| 2541 kLayoutBlockingThreshold, |
| 2542 kMaxNumDelayableWhileLayoutBlocking, |
| 2543 kMaxNumDelayableRequestsPerClient))); |
| 2544 InitializeScheduler(); |
| 2545 scoped_ptr<TestRequest> high(NewRequest("http://host/high", net::HIGHEST)); |
| 2546 scoped_ptr<TestRequest> high2(NewRequest("http://host/high", net::HIGHEST)); |
| 2547 scoped_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST)); |
| 2548 scoped_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); |
| 2549 scoped_ptr<TestRequest> low3(NewRequest("http://host/low", net::LOWEST)); |
| 2550 EXPECT_TRUE(high->started()); |
| 2551 EXPECT_TRUE(high2->started()); |
| 2552 EXPECT_FALSE(low->started()); |
| 2553 EXPECT_FALSE(low2->started()); |
| 2554 EXPECT_FALSE(low3->started()); |
| 2555 high.reset(); |
| 2556 EXPECT_TRUE(low->started()); |
| 2557 EXPECT_TRUE(low2->started()); |
| 2558 EXPECT_FALSE(low3->started()); |
| 2559 high2.reset(); |
| 2560 scheduler()->OnWillInsertBody(kChildId, kRouteId); |
| 2561 EXPECT_TRUE(low3->started()); |
| 2562 } |
| 2563 |
| 2564 TEST_F(ResourceSchedulerTest, TwentyMaxNumDelayableRequestsPerClient) { |
| 2565 // Do not exceed 20 low-priority requests to be in flight across all hosts |
| 2566 // at any point in time. |
| 2567 const int kDeferLateScripts = 0; |
| 2568 const int kIncreaseFontPriority = 0; |
| 2569 const int kIncreaseAsyncScriptPriority = 0; |
| 2570 const int kEnablePriorityIncrease = 0; |
| 2571 const int kEnableLayoutBlockingThreshold = 0; |
| 2572 const int kLayoutBlockingThreshold = 0; |
| 2573 const int kMaxNumDelayableWhileLayoutBlocking = 1; |
| 2574 const int kMaxNumDelayableRequestsPerClient = 20; |
| 2575 ASSERT_TRUE(InitializeFieldTrials(base::StringPrintf( |
| 2576 "ResourcePriorities/LayoutBlocking_%d%d%d%d%d_%d_%d_%d/", |
| 2577 kDeferLateScripts, |
| 2578 kIncreaseFontPriority, |
| 2579 kIncreaseAsyncScriptPriority, |
| 2580 kEnablePriorityIncrease, |
| 2581 kEnableLayoutBlockingThreshold, |
| 2582 kLayoutBlockingThreshold, |
| 2583 kMaxNumDelayableWhileLayoutBlocking, |
| 2584 kMaxNumDelayableRequestsPerClient))); |
| 2585 InitializeScheduler(); |
| 2586 |
| 2587 // Only load low priority resources if there's a body. |
| 2588 scheduler()->OnWillInsertBody(kChildId, kRouteId); |
| 2589 |
| 2590 // Queue requests from different hosts until the total limit is reached. |
| 2591 ScopedVector<TestRequest> lows_different_host; |
| 2592 for (int i = 0; i < kMaxNumDelayableRequestsPerClient; ++i) { |
| 2593 string url = "http://host" + base::IntToString(i) + "/low"; |
| 2594 lows_different_host.push_back(NewRequest(url.c_str(), net::LOWEST)); |
| 2595 EXPECT_TRUE(lows_different_host[i]->started()); |
| 2596 } |
| 2597 |
| 2598 scoped_ptr<TestRequest> last_different_host(NewRequest("http://host_new/last", |
| 2599 net::LOWEST)); |
| 2600 EXPECT_FALSE(last_different_host->started()); |
| 2601 } |
| 2602 |
| 2603 TEST_F(ResourceSchedulerTest, |
| 2604 TwentyMaxNumDelayableRequestsPerClientWithEverythingEnabled) { |
| 2605 // Do not exceed 20 low-priority requests to be in flight across all hosts |
| 2606 // at any point in time and make sure it still works correctly when the other |
| 2607 // options are toggled. |
| 2608 const int kDeferLateScripts = 1; |
| 2609 const int kIncreaseFontPriority = 1; |
| 2610 const int kIncreaseAsyncScriptPriority = 1; |
| 2611 const int kEnablePriorityIncrease = 1; |
| 2612 const int kEnableLayoutBlockingThreshold = 1; |
| 2613 const int kLayoutBlockingThreshold = 1; |
| 2614 const int kMaxNumDelayableWhileLayoutBlocking = 1; |
| 2615 const int kMaxNumDelayableRequestsPerClient = 20; |
| 2616 ASSERT_TRUE(InitializeFieldTrials(base::StringPrintf( |
| 2617 "ResourcePriorities/LayoutBlocking_%d%d%d%d%d_%d_%d_%d/", |
| 2618 kDeferLateScripts, |
| 2619 kIncreaseFontPriority, |
| 2620 kIncreaseAsyncScriptPriority, |
| 2621 kEnablePriorityIncrease, |
| 2622 kEnableLayoutBlockingThreshold, |
| 2623 kLayoutBlockingThreshold, |
| 2624 kMaxNumDelayableWhileLayoutBlocking, |
| 2625 kMaxNumDelayableRequestsPerClient))); |
| 2626 InitializeScheduler(); |
| 2627 |
| 2628 // Only load low priority resources if there's a body. |
| 2629 scheduler()->OnWillInsertBody(kChildId, kRouteId); |
| 2630 |
| 2631 // Queue requests from different hosts until the total limit is reached. |
| 2632 ScopedVector<TestRequest> lows_different_host; |
| 2633 for (int i = 0; i < kMaxNumDelayableRequestsPerClient; ++i) { |
| 2634 string url = "http://host" + base::IntToString(i) + "/low"; |
| 2635 lows_different_host.push_back(NewRequest(url.c_str(), net::LOWEST)); |
| 2636 EXPECT_TRUE(lows_different_host[i]->started()); |
| 2637 } |
| 2638 |
| 2639 scoped_ptr<TestRequest> last_different_host(NewRequest("http://host_new/last", |
| 2640 net::LOWEST)); |
| 2641 EXPECT_FALSE(last_different_host->started()); |
| 2642 } |
| 2643 |
2306 } // unnamed namespace | 2644 } // unnamed namespace |
2307 | 2645 |
2308 } // namespace content | 2646 } // namespace content |
OLD | NEW |