Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(900)

Side by Side Diff: net/cookies/cookie_monster_unittest.cc

Issue 2071593002: Revert of Making cookies eviction quotas match spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/cookies/cookie_monster.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/cookies/cookie_monster.h" 5 #include "net/cookies/cookie_monster.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 // Cookie same priority, repeated for each priority. 558 // Cookie same priority, repeated for each priority.
559 TestPriorityCookieCase(cm.get(), "181LN", 150U, 0U, 0U, 150U, 0U); 559 TestPriorityCookieCase(cm.get(), "181LN", 150U, 0U, 0U, 150U, 0U);
560 TestPriorityCookieCase(cm.get(), "181MN", 0U, 150U, 0U, 150U, 0U); 560 TestPriorityCookieCase(cm.get(), "181MN", 0U, 150U, 0U, 150U, 0U);
561 TestPriorityCookieCase(cm.get(), "181HN", 0U, 0U, 150U, 150U, 0U); 561 TestPriorityCookieCase(cm.get(), "181HN", 0U, 0U, 150U, 150U, 0U);
562 562
563 // Pairwise scenarios. 563 // Pairwise scenarios.
564 // Round 1 => none; round2 => 31M; round 3 => none. 564 // Round 1 => none; round2 => 31M; round 3 => none.
565 TestPriorityCookieCase(cm.get(), "10HN 171MN", 0U, 140U, 10U, 150U, 0U); 565 TestPriorityCookieCase(cm.get(), "10HN 171MN", 0U, 140U, 10U, 150U, 0U);
566 // Round 1 => 10L; round2 => 21M; round 3 => none. 566 // Round 1 => 10L; round2 => 21M; round 3 => none.
567 TestPriorityCookieCase(cm.get(), "141MN 40LN", 30U, 120U, 0U, 150U, 0U); 567 TestPriorityCookieCase(cm.get(), "141MN 40LN", 30U, 120U, 0U, 150U, 0U);
568 // Round 1 => none; round2 => 30M; round 3 => 1H. 568 // Round 1 => none; round2 => none; round 3 => 31H.
569 TestPriorityCookieCase(cm.get(), "101HN 80MN", 0U, 50U, 100U, 150U, 0U); 569 TestPriorityCookieCase(cm.get(), "101HN 80MN", 0U, 80U, 70U, 150U, 0U);
570 570
571 // For {low, medium} priorities right on quota, different orders. 571 // For {low, medium} priorities right on quota, different orders.
572 // Round 1 => 1L; round 2 => none, round3 => 30H. 572 // Round 1 => 1L; round 2 => none, round3 => 30L.
573 TestPriorityCookieCase(cm.get(), "31LN 50MN 100HN", 30U, 50U, 70U, 150U, 573 TestPriorityCookieCase(cm.get(), "31LN 50MN 100HN", 0U, 50U, 100U, 150U,
574 0U); 574 0U);
575 // Round 1 => none; round 2 => 1M, round3 => 30H. 575 // Round 1 => none; round 2 => 1M, round3 => 30M.
576 TestPriorityCookieCase(cm.get(), "51MN 100HN 30LN", 30U, 50U, 70U, 150U, 576 TestPriorityCookieCase(cm.get(), "51MN 100HN 30LN", 30U, 20U, 100U, 150U,
577 0U); 577 0U);
578 // Round 1 => none; round 2 => none; round3 => 31H. 578 // Round 1 => none; round 2 => none; round3 => 31H.
579 TestPriorityCookieCase(cm.get(), "101HN 50MN 30LN", 30U, 50U, 70U, 150U, 579 TestPriorityCookieCase(cm.get(), "101HN 50MN 30LN", 30U, 50U, 70U, 150U,
580 0U); 580 0U);
581 581
582 // Round 1 => 10L; round 2 => 10M; round3 => 11H. 582 // Round 1 => 10L; round 2 => 10M; round3 => 11H.
583 TestPriorityCookieCase(cm.get(), "81HN 60MN 40LN", 30U, 50U, 70U, 150U, 0U); 583 TestPriorityCookieCase(cm.get(), "81HN 60MN 40LN", 30U, 50U, 70U, 150U, 0U);
584 584
585 // More complex scenarios. 585 // More complex scenarios.
586 // Round 1 => 10L; round 2 => 10M; round 3 => 11H. 586 // Round 1 => 10L; round 2 => 10M; round 3 => 11H.
587 TestPriorityCookieCase(cm.get(), "21HN 60MN 40LN 60HN", 30U, 50U, 70U, 150U, 587 TestPriorityCookieCase(cm.get(), "21HN 60MN 40LN 60HN", 30U, 50U, 70U, 150U,
588 0U); 588 0U);
589 // Round 1 => 10L; round 2 => 21M; round 3 => 0H. 589 // Round 1 => 10L; round 2 => 11M, 10L; round 3 => none.
590 TestPriorityCookieCase(cm.get(), "11HN 10MN 20LN 110MN 20LN 10HN", 30U, 99U, 590 TestPriorityCookieCase(cm.get(), "11HN 10MN 20LN 110MN 20LN 10HN", 20U,
591 21U, 150U, 0U); 591 109U, 21U, 150U, 0U);
592 // Round 1 => none; round 2 => none; round 3 => 31H. 592 // Round 1 => none; round 2 => none; round 3 => 11L, 10M, 10H.
593 TestPriorityCookieCase(cm.get(), "11LN 10MN 140HN 10MN 10LN", 21U, 20U, 593 TestPriorityCookieCase(cm.get(), "11LN 10MN 140HN 10MN 10LN", 10U, 10U,
594 109U, 150U, 0U); 594 130U, 150U, 0U);
595 // Round 1 => none; round 2 => 21M; round 3 => 10H. 595 // Round 1 => none; round 2 => 1M; round 3 => 10L, 10M, 10H.
596 TestPriorityCookieCase(cm.get(), "11MN 10HN 10LN 60MN 90HN", 10U, 50U, 90U, 596 TestPriorityCookieCase(cm.get(), "11MN 10HN 10LN 60MN 90HN", 0U, 60U, 90U,
597 150U, 0U); 597 150U, 0U);
598 // Round 1 => none; round 2 => 31M; round 3 => none. 598 // Round 1 => none; round 2 => 10L, 21M; round 3 => none.
599 TestPriorityCookieCase(cm.get(), "11MN 10HN 10LN 90MN 60HN", 10U, 70U, 70U, 599 TestPriorityCookieCase(cm.get(), "11MN 10HN 10LN 90MN 60HN", 0U, 80U, 70U,
600 150U, 0U); 600 150U, 0U);
601 601
602 // TODO(jww): According to
603 // https://tools.ietf.org/html/draft-west-cookie-priority#section-3, it
604 // seems that quotas are a mechanism for preventing another application on
605 // the same doman from DoS'ing an application by constantly evicting *all*
606 // lower priority cookies.
607 //
608 // Unfortunately, this has never strictly worked in our implementation. Take
609 // the following test as an example:
610 // TestPriorityCookieCase(cm.get(), "50LN 131HN", 30U, 0U, 120U, 150U, 0U);
611 //
612 // According to this theory, we would expect eviction to proceed as:
602 // Round 1 => 20L; round 2 => 0; round 3 => 11H 613 // Round 1 => 20L; round 2 => 0; round 3 => 11H
603 TestPriorityCookieCase(cm.get(), "50LN 131HN", 30U, 0U, 120U, 150U, 0U); 614 // thus resulting in 30L and 120H at the end.
615 //
616 // However, what happens in practice is that the cookies left are 19L and
617 // 131H. This is because the quotas are accumulated over the rounds and what
618 // priority they apply to is lost information. Since in the last round all
619 // that is known is a total quota, and the low-priority cookies are least
620 // recently accessed, they are evicted first to get down to 150 cookies.
621 //
622 // We should address this and uncomment the test below when it is fixed.
623 //
624 // See https://crbug.com/609550
625 //
626 // Round 1 => 20L; round 2 => 0; round 3 => 11H
627 // TestPriorityCookieCase(cm.get(), "50LN 131HN", 30U, 0U, 120U, 150U, 0U);
604 // Round 1 => 20L; round 2 => 0; round 3 => 11H 628 // Round 1 => 20L; round 2 => 0; round 3 => 11H
605 TestPriorityCookieCase(cm.get(), "131HN 50LN", 30U, 0U, 120U, 150U, 0U); 629 TestPriorityCookieCase(cm.get(), "131HN 50LN", 30U, 0U, 120U, 150U, 0U);
606 // Round 1 => 20L; round 2 => none; round 3 => 11H. 630 // Round 1 => 20L; round 2 => none; round 3 => 11H.
607 TestPriorityCookieCase(cm.get(), "50HN 50LN 81HN", 30U, 0U, 120U, 150U, 0U); 631 TestPriorityCookieCase(cm.get(), "50HN 50LN 81HN", 30U, 0U, 120U, 150U, 0U);
608 // Round 1 => 20L; round 2 => none; round 3 => 11H. 632 // Round 1 => 20L; round 2 => none; round 3 => 11H.
609 TestPriorityCookieCase(cm.get(), "81HN 50LN 50HN", 30U, 0U, 120U, 150U, 0U); 633 TestPriorityCookieCase(cm.get(), "81HN 50LN 50HN", 30U, 0U, 120U, 150U, 0U);
610 } 634 }
611 635
612 void TestPriorityAwareGarbageCollectHelperSecure() { 636 void TestPriorityAwareGarbageCollectHelperSecure() {
613 // Hard-coding limits in the test, but use DCHECK_EQ to enforce constraint. 637 // Hard-coding limits in the test, but use DCHECK_EQ to enforce constraint.
614 DCHECK_EQ(180U, CookieMonster::kDomainMaxCookies); 638 DCHECK_EQ(180U, CookieMonster::kDomainMaxCookies);
615 DCHECK_EQ(150U, CookieMonster::kDomainMaxCookies - 639 DCHECK_EQ(150U, CookieMonster::kDomainMaxCookies -
616 CookieMonster::kDomainPurgeCookies); 640 CookieMonster::kDomainPurgeCookies);
617 641
618 std::unique_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr)); 642 std::unique_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
619 643
620 // Each test case adds 181 cookies, so 31 cookies are evicted. 644 // Each test case adds 181 cookies, so 31 cookies are evicted.
621 // Cookie same priority, repeated for each priority. 645 // Cookie same priority, repeated for each priority.
622 // Round 1 => 31L; round2 => none; round 3 => none.
623 TestPriorityCookieCase(cm.get(), "181LS", 150U, 0U, 0U, 0U, 150U); 646 TestPriorityCookieCase(cm.get(), "181LS", 150U, 0U, 0U, 0U, 150U);
624 // Round 1 => none; round2 => 31M; round 3 => none.
625 TestPriorityCookieCase(cm.get(), "181MS", 0U, 150U, 0U, 0U, 150U); 647 TestPriorityCookieCase(cm.get(), "181MS", 0U, 150U, 0U, 0U, 150U);
626 // Round 1 => none; round2 => none; round 3 => 31H.
627 TestPriorityCookieCase(cm.get(), "181HS", 0U, 0U, 150U, 0U, 150U); 648 TestPriorityCookieCase(cm.get(), "181HS", 0U, 0U, 150U, 0U, 150U);
628 649
629 // Pairwise scenarios. 650 // Pairwise scenarios.
630 // Round 1 => none; round2 => 31M; round 3 => none. 651 // Round 1 => none; round2 => 31M; round 3 => none.
631 TestPriorityCookieCase(cm.get(), "10HS 171MS", 0U, 140U, 10U, 0U, 150U); 652 TestPriorityCookieCase(cm.get(), "10HS 171MS", 0U, 140U, 10U, 0U, 150U);
632 // Round 1 => 10L; round2 => 21M; round 3 => none. 653 // Round 1 => 10L; round2 => 21M; round 3 => none.
633 TestPriorityCookieCase(cm.get(), "141MS 40LS", 30U, 120U, 0U, 0U, 150U); 654 TestPriorityCookieCase(cm.get(), "141MS 40LS", 30U, 120U, 0U, 0U, 150U);
634 // Round 1 => none; round2 => 30M; round 3 => 1H. 655 // Round 1 => none; round2 => none; round 3 => 31H.
635 TestPriorityCookieCase(cm.get(), "101HS 80MS", 0U, 50U, 100U, 0U, 150U); 656 TestPriorityCookieCase(cm.get(), "101HS 80MS", 0U, 80U, 70U, 0U, 150U);
636 657
637 // For {low, medium} priorities right on quota, different orders. 658 // For {low, medium} priorities right on quota, different orders.
638 // Round 1 => 1L; round 2 => none, round3 => 30H. 659 // Round 1 => 1L; round 2 => none, round3 => 30L.
639 TestPriorityCookieCase(cm.get(), "31LS 50MS 100HS", 30U, 50U, 70U, 0U, 660 TestPriorityCookieCase(cm.get(), "31LS 50MS 100HS", 0U, 50U, 100U, 0U,
640 150U); 661 150U);
641 // Round 1 => none; round 2 => 1M, round3 => 30H. 662 // Round 1 => none; round 2 => 1M, round3 => 30M.
642 TestPriorityCookieCase(cm.get(), "51MS 100HS 30LS", 30U, 50U, 70U, 0U, 663 TestPriorityCookieCase(cm.get(), "51MS 100HS 30LS", 30U, 20U, 100U, 0U,
643 150U); 664 150U);
644 // Round 1 => none; round 2 => none; round3 => 31H. 665 // Round 1 => none; round 2 => none; round3 => 31H.
645 TestPriorityCookieCase(cm.get(), "101HS 50MS 30LS", 30U, 50U, 70U, 0U, 666 TestPriorityCookieCase(cm.get(), "101HS 50MS 30LS", 30U, 50U, 70U, 0U,
646 150U); 667 150U);
647 668
648 // Round 1 => 10L; round 2 => 10M; round3 => 11H. 669 // Round 1 => 10L; round 2 => 10M; round3 => 11H.
649 TestPriorityCookieCase(cm.get(), "81HS 60MS 40LS", 30U, 50U, 70U, 0U, 150U); 670 TestPriorityCookieCase(cm.get(), "81HS 60MS 40LS", 30U, 50U, 70U, 0U, 150U);
650 671
651 // More complex scenarios. 672 // More complex scenarios.
652 // Round 1 => 10L; round 2 => 10M; round 3 => 11H. 673 // Round 1 => 10L; round 2 => 10M; round 3 => 11H.
653 TestPriorityCookieCase(cm.get(), "21HS 60MS 40LS 60HS", 30U, 50U, 70U, 0U, 674 TestPriorityCookieCase(cm.get(), "21HS 60MS 40LS 60HS", 30U, 50U, 70U, 0U,
654 150U); 675 150U);
655 // Round 1 => 10L; round 2 => 21M; round 3 => none. 676 // Round 1 => 10L; round 2 => 11M, 10L; round 3 => none.
656 TestPriorityCookieCase(cm.get(), "11HS 10MS 20LS 110MS 20LS 10HS", 30U, 99U, 677 TestPriorityCookieCase(cm.get(), "11HS 10MS 20LS 110MS 20LS 10HS", 20U,
657 21U, 0U, 150U); 678 109U, 21U, 0U, 150U);
658 // Round 1 => none; round 2 => none; round 3 => 31H. 679 // Round 1 => none; round 2 => none; round 3 => 11L, 10M, 10H.
659 TestPriorityCookieCase(cm.get(), "11LS 10MS 140HS 10MS 10LS", 21U, 20U, 680 TestPriorityCookieCase(cm.get(), "11LS 10MS 140HS 10MS 10LS", 10U, 10U,
660 109U, 0U, 150U); 681 130U, 0U, 150U);
661 // Round 1 => none; round 2 => 21M; round 3 => 10H. 682 // Round 1 => none; round 2 => 1M; round 3 => 10L, 10M, 10H.
662 TestPriorityCookieCase(cm.get(), "11MS 10HS 10LS 60MS 90HS", 10U, 50U, 90U, 683 TestPriorityCookieCase(cm.get(), "11MS 10HS 10LS 60MS 90HS", 0U, 60U, 90U,
663 0U, 150U); 684 0U, 150U);
664 // Round 1 => none; round 2 => 31M; round 3 => none. 685 // Round 1 => none; round 2 => 10L, 21M; round 3 => none.
665 TestPriorityCookieCase(cm.get(), "11MS 10HS 10LS 90MS 60HS", 10U, 70U, 70U, 686 TestPriorityCookieCase(cm.get(), "11MS 10HS 10LS 90MS 60HS", 0U, 80U, 70U,
666 0U, 150U); 687 0U, 150U);
667 } 688 }
668 689
669 void TestPriorityAwareGarbageCollectHelperMixed() { 690 void TestPriorityAwareGarbageCollectHelperMixed() {
670 // Hard-coding limits in the test, but use DCHECK_EQ to enforce constraint. 691 // Hard-coding limits in the test, but use DCHECK_EQ to enforce constraint.
671 DCHECK_EQ(180U, CookieMonster::kDomainMaxCookies); 692 DCHECK_EQ(180U, CookieMonster::kDomainMaxCookies);
672 DCHECK_EQ(150U, CookieMonster::kDomainMaxCookies - 693 DCHECK_EQ(150U, CookieMonster::kDomainMaxCookies -
673 CookieMonster::kDomainPurgeCookies); 694 CookieMonster::kDomainPurgeCookies);
674 695
675 std::unique_ptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); 696 std::unique_ptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
676 697
677 // Each test case adds 180 secure cookies, and some non-secure cookie. The 698 // Each test case adds 180 secure cookies, and some non-secure cookie. The
678 // secure cookies take priority, so the non-secure cookie is removed, along 699 // secure cookies take priority, so the non-secure cookie is removed, along
679 // with 30 secure cookies. Repeated for each priority, and with the 700 // with 30 secure cookies. Repeated for each priority, and with the
680 // non-secure cookie as older and newer. 701 // non-secure cookie as older and newer.
681 // Round 1 => 1LN; round 2 => 30LS; round 3 => none.
682 // Round 4 => none; round 5 => none; round 6 => none.
683 TestPriorityCookieCase(cm.get(), "1LN 180LS", 150U, 0U, 0U, 0U, 150U); 702 TestPriorityCookieCase(cm.get(), "1LN 180LS", 150U, 0U, 0U, 0U, 150U);
684 // Round 1 => none; round 2 => none; round 3 => 1MN.
685 // Round 4 => none; round 5 => 30MS; round 6 => none.
686 TestPriorityCookieCase(cm.get(), "1MN 180MS", 0U, 150U, 0U, 0U, 150U); 703 TestPriorityCookieCase(cm.get(), "1MN 180MS", 0U, 150U, 0U, 0U, 150U);
687 // Round 1 => none; round 2 => none; round 3 => none.
688 // Round 4 => 1HN; round 5 => none; round 6 => 30HS.
689 TestPriorityCookieCase(cm.get(), "1HN 180HS", 0U, 0U, 150U, 0U, 150U); 704 TestPriorityCookieCase(cm.get(), "1HN 180HS", 0U, 0U, 150U, 0U, 150U);
690 // Round 1 => 1LN; round 2 => 30LS; round 3 => none.
691 // Round 4 => none; round 5 => none; round 6 => none.
692 TestPriorityCookieCase(cm.get(), "180LS 1LN", 150U, 0U, 0U, 0U, 150U); 705 TestPriorityCookieCase(cm.get(), "180LS 1LN", 150U, 0U, 0U, 0U, 150U);
693 // Round 1 => none; round 2 => none; round 3 => 1MN.
694 // Round 4 => none; round 5 => 30MS; round 6 => none.
695 TestPriorityCookieCase(cm.get(), "180MS 1MN", 0U, 150U, 0U, 0U, 150U); 706 TestPriorityCookieCase(cm.get(), "180MS 1MN", 0U, 150U, 0U, 0U, 150U);
696 // Round 1 => none; round 2 => none; round 3 => none.
697 // Round 4 => 1HN; round 5 => none; round 6 => 30HS.
698 TestPriorityCookieCase(cm.get(), "180HS 1HN", 0U, 0U, 150U, 0U, 150U); 707 TestPriorityCookieCase(cm.get(), "180HS 1HN", 0U, 0U, 150U, 0U, 150U);
699 708
700 // Low-priority secure cookies are removed before higher priority non-secure 709 // Low-priority secure cookies are removed before higher priority non-secure
701 // cookies. 710 // cookies.
702 // Round 1 => none; round 2 => 31LS; round 3 => none.
703 // Round 4 => none; round 5 => none; round 6 => none.
704 TestPriorityCookieCase(cm.get(), "180LS 1MN", 149U, 1U, 0U, 1U, 149U); 711 TestPriorityCookieCase(cm.get(), "180LS 1MN", 149U, 1U, 0U, 1U, 149U);
705 // Round 1 => none; round 2 => 31LS; round 3 => none.
706 // Round 4 => none; round 5 => none; round 6 => none.
707 TestPriorityCookieCase(cm.get(), "180LS 1HN", 149U, 0U, 1U, 1U, 149U); 712 TestPriorityCookieCase(cm.get(), "180LS 1HN", 149U, 0U, 1U, 1U, 149U);
708 // Round 1 => none; round 2 => 31LS; round 3 => none.
709 // Round 4 => none; round 5 => none; round 6 => none.
710 TestPriorityCookieCase(cm.get(), "1MN 180LS", 149U, 1U, 0U, 1U, 149U); 713 TestPriorityCookieCase(cm.get(), "1MN 180LS", 149U, 1U, 0U, 1U, 149U);
711 // Round 1 => none; round 2 => 31LS; round 3 => none.
712 // Round 4 => none; round 5 => none; round 6 => none.
713 TestPriorityCookieCase(cm.get(), "1HN 180LS", 149U, 0U, 1U, 1U, 149U); 714 TestPriorityCookieCase(cm.get(), "1HN 180LS", 149U, 0U, 1U, 1U, 149U);
714 715
715 // Higher-priority non-secure cookies are removed before any secure cookie 716 // Higher-priority non-secure cookies are removed before any secure cookie
716 // with greater than low-priority. Is it true? How about the quota? 717 // with greater than low-priority.
717 // Round 1 => none; round 2 => none; round 3 => none. 718 TestPriorityCookieCase(cm.get(), "180MS 1HN", 0U, 150U, 0U, 0U, 150U);
718 // Round 4 => none; round 5 => 31MS; round 6 => none. 719 TestPriorityCookieCase(cm.get(), "1HN 180MS", 0U, 150U, 0U, 0U, 150U);
719 TestPriorityCookieCase(cm.get(), "180MS 1HN", 0U, 149U, 1U, 1U, 149U);
720 // Round 1 => none; round 2 => none; round 3 => none.
721 // Round 4 => none; round 5 => 31MS; round 6 => none.
722 TestPriorityCookieCase(cm.get(), "1HN 180MS", 0U, 149U, 1U, 1U, 149U);
723 720
724 // Pairwise: 721 // Pairwise:
725 // Round 1 => 31LN; round 2 => none; round 3 => none.
726 // Round 4 => none; round 5 => none; round 6 => none.
727 TestPriorityCookieCase(cm.get(), "1LS 180LN", 150U, 0U, 0U, 149U, 1U); 722 TestPriorityCookieCase(cm.get(), "1LS 180LN", 150U, 0U, 0U, 149U, 1U);
728 // Round 1 => 31LN; round 2 => none; round 3 => none.
729 // Round 4 => none; round 5 => none; round 6 => none.
730 TestPriorityCookieCase(cm.get(), "100LS 81LN", 150U, 0U, 0U, 50U, 100U); 723 TestPriorityCookieCase(cm.get(), "100LS 81LN", 150U, 0U, 0U, 50U, 100U);
731 // Round 1 => 31LN; round 2 => none; round 3 => none.
732 // Round 4 => none; round 5 => none; round 6 => none.
733 TestPriorityCookieCase(cm.get(), "150LS 31LN", 150U, 0U, 0U, 0U, 150U); 724 TestPriorityCookieCase(cm.get(), "150LS 31LN", 150U, 0U, 0U, 0U, 150U);
734 // Round 1 => none; round 2 => none; round 3 => none. 725 TestPriorityCookieCase(cm.get(), "1LS 180HN", 0U, 0U, 150U, 150U, 0U);
735 // Round 4 => 31HN; round 5 => none; round 6 => none.
736 TestPriorityCookieCase(cm.get(), "1LS 180HN", 1U, 0U, 149U, 149U, 1U);
737 // Round 1 => none; round 2 => 31LS; round 3 => none.
738 // Round 4 => none; round 5 => none; round 6 => none.
739 TestPriorityCookieCase(cm.get(), "100LS 81HN", 69U, 0U, 81U, 81U, 69U); 726 TestPriorityCookieCase(cm.get(), "100LS 81HN", 69U, 0U, 81U, 81U, 69U);
740 // Round 1 => none; round 2 => 31LS; round 3 => none.
741 // Round 4 => none; round 5 => none; round 6 => none.
742 TestPriorityCookieCase(cm.get(), "150LS 31HN", 119U, 0U, 31U, 31U, 119U); 727 TestPriorityCookieCase(cm.get(), "150LS 31HN", 119U, 0U, 31U, 31U, 119U);
743 728
744 // Quota calculations inside non-secure/secure blocks remain in place: 729 // Quota calculations inside non-secure/secure blocks remain in place:
745 // Round 1 => none; round 2 => 20LS; round 3 => none. 730 // Round 1 => 20LS; round 2 => none; round 3 => 11HN.
746 // Round 4 => 11HN; round 5 => none; round 6 => none.
747 TestPriorityCookieCase(cm.get(), "50HN 50LS 81HS", 30U, 0U, 120U, 39U, 731 TestPriorityCookieCase(cm.get(), "50HN 50LS 81HS", 30U, 0U, 120U, 39U,
748 111U); 732 111U);
749 // Round 1 => none; round 2 => none; round 3 => 31MN. 733 // Round 1 => none; round 2 => 10LS, 21MN; round 3 => none.
750 // Round 4 => none; round 5 => none; round 6 => none. 734 TestPriorityCookieCase(cm.get(), "11MS 10HN 10LS 90MN 60HN", 0U, 80U, 70U,
751 TestPriorityCookieCase(cm.get(), "11MS 10HN 10LS 90MN 60HN", 10U, 70U, 70U, 735 139U, 11U);
752 129U, 21U);
753 // Round 1 => 31LN; round 2 => none; round 3 => none.
754 // Round 4 => none; round 5 => none; round 6 => none.
755 TestPriorityCookieCase(cm.get(), "40LS 40LN 101HS", 49U, 0U, 101U, 9U,
756 141U);
757 736
758 // Multiple GC rounds end up with consistent behavior: 737 // Multiple GC rounds end up with consistent behavior:
759 // GC is started as soon as there are 181 cookies in the store. 738 TestPriorityCookieCase(cm.get(), "100HS 100LN 100MN", 0, 76U, 100U, 76U,
760 // On each major round it tries to preserve the quota for each priority. 739 100U);
761 // It is not aware about more cookies going in.
762 // 1 GC notices there are 181 cookies - 100HS 81LN 0MN
763 // Round 1 => 31LN; round 2 => none; round 3 => none.
764 // Round 4 => none; round 5 => none; round 6 => none.
765 // 2 GC notices there are 181 cookies - 100HS 69LN 12MN
766 // Round 1 => 31LN; round 2 => none; round 3 => none.
767 // Round 4 => none; round 5 => none; round 6 => none.
768 // 3 GC notices there are 181 cookies - 100HS 38LN 43MN
769 // Round 1 => 8LN; round 2 => none; round 3 => none.
770 // Round 4 => none; round 5 => none; round 6 => 23HS.
771 // 4 GC notcies there are 181 cookies - 77HS 30LN 74MN
772 // Round 1 => none; round 2 => none; round 3 => 24MN.
773 // Round 4 => none; round 5 => none; round 6 => 7HS.
774 TestPriorityCookieCase(cm.get(), "100HS 100LN 100MN", 30U, 76U, 70U, 106U,
775 70U);
776 } 740 }
777 741
778 // Function for creating a CM with a number of cookies in it, 742 // Function for creating a CM with a number of cookies in it,
779 // no store (and hence no ability to affect access time). 743 // no store (and hence no ability to affect access time).
780 CookieMonster* CreateMonsterForGC(int num_cookies) { 744 CookieMonster* CreateMonsterForGC(int num_cookies) {
781 CookieMonster* cm(new CookieMonster(NULL, NULL)); 745 CookieMonster* cm(new CookieMonster(NULL, NULL));
782 for (int i = 0; i < num_cookies; i++) { 746 for (int i = 0; i < num_cookies; i++) {
783 SetCookie(cm, GURL(base::StringPrintf("http://h%05d.izzle", i)), "a=1"); 747 SetCookie(cm, GURL(base::StringPrintf("http://h%05d.izzle", i)), "a=1");
784 } 748 }
785 return cm; 749 return cm;
(...skipping 2698 matching lines...) Expand 10 before | Expand all | Expand 10 after
3484 monster()->AddCallbackForCookie( 3448 monster()->AddCallbackForCookie(
3485 test_url_, "abc", 3449 test_url_, "abc",
3486 base::Bind(&RecordCookieChanges, &cookies1, nullptr))); 3450 base::Bind(&RecordCookieChanges, &cookies1, nullptr)));
3487 SetCookie(monster(), test_url_, "abc=def"); 3451 SetCookie(monster(), test_url_, "abc=def");
3488 base::MessageLoop::current()->RunUntilIdle(); 3452 base::MessageLoop::current()->RunUntilIdle();
3489 EXPECT_EQ(1U, cookies0.size()); 3453 EXPECT_EQ(1U, cookies0.size());
3490 EXPECT_EQ(1U, cookies0.size()); 3454 EXPECT_EQ(1U, cookies0.size());
3491 } 3455 }
3492 3456
3493 } // namespace net 3457 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/cookie_monster.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698