| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/message_loop/message_loop_proxy.h" | 6 #include "base/message_loop/message_loop_proxy.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/browser/gpu/shader_disk_cache.h" | 10 #include "content/browser/gpu/shader_disk_cache.h" |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 scoped_refptr<MockSpecialStoragePolicy> mock_policy = | 665 scoped_refptr<MockSpecialStoragePolicy> mock_policy = |
| 666 new MockSpecialStoragePolicy; | 666 new MockSpecialStoragePolicy; |
| 667 mock_policy->AddProtected(kOrigin1.GetOrigin()); | 667 mock_policy->AddProtected(kOrigin1.GetOrigin()); |
| 668 | 668 |
| 669 PopulateTestQuotaManagedData(GetMockManager()); | 669 PopulateTestQuotaManagedData(GetMockManager()); |
| 670 | 670 |
| 671 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 671 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 672 BrowserContext::GetDefaultStoragePartition(browser_context())); | 672 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 673 partition->OverrideQuotaManagerForTesting( | 673 partition->OverrideQuotaManagerForTesting( |
| 674 GetMockManager()); | 674 GetMockManager()); |
| 675 partition->OverrideSpecialStoragePolicyForTesting(mock_policy); | 675 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
| 676 | 676 |
| 677 base::RunLoop run_loop; | 677 base::RunLoop run_loop; |
| 678 base::MessageLoop::current()->PostTask( | 678 base::MessageLoop::current()->PostTask( |
| 679 FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, | 679 FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, |
| 680 partition, GURL(), | 680 partition, GURL(), |
| 681 base::Bind(&DoesOriginMatchForUnprotectedWeb), | 681 base::Bind(&DoesOriginMatchForUnprotectedWeb), |
| 682 base::Time(), &run_loop)); | 682 base::Time(), &run_loop)); |
| 683 run_loop.Run(); | 683 run_loop.Run(); |
| 684 | 684 |
| 685 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 685 EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 701 scoped_refptr<MockSpecialStoragePolicy> mock_policy = | 701 scoped_refptr<MockSpecialStoragePolicy> mock_policy = |
| 702 new MockSpecialStoragePolicy; | 702 new MockSpecialStoragePolicy; |
| 703 mock_policy->AddProtected(kOrigin1.GetOrigin()); | 703 mock_policy->AddProtected(kOrigin1.GetOrigin()); |
| 704 | 704 |
| 705 PopulateTestQuotaManagedData(GetMockManager()); | 705 PopulateTestQuotaManagedData(GetMockManager()); |
| 706 | 706 |
| 707 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 707 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 708 BrowserContext::GetDefaultStoragePartition(browser_context())); | 708 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 709 partition->OverrideQuotaManagerForTesting( | 709 partition->OverrideQuotaManagerForTesting( |
| 710 GetMockManager()); | 710 GetMockManager()); |
| 711 partition->OverrideSpecialStoragePolicyForTesting(mock_policy); | 711 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
| 712 | 712 |
| 713 // Try to remove kOrigin1. Expect failure. | 713 // Try to remove kOrigin1. Expect failure. |
| 714 base::RunLoop run_loop; | 714 base::RunLoop run_loop; |
| 715 base::MessageLoop::current()->PostTask( | 715 base::MessageLoop::current()->PostTask( |
| 716 FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, | 716 FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, |
| 717 partition, kOrigin1, | 717 partition, kOrigin1, |
| 718 base::Bind(&DoesOriginMatchForUnprotectedWeb), | 718 base::Bind(&DoesOriginMatchForUnprotectedWeb), |
| 719 base::Time(), &run_loop)); | 719 base::Time(), &run_loop)); |
| 720 run_loop.Run(); | 720 run_loop.Run(); |
| 721 | 721 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 740 mock_policy->AddProtected(kOrigin1.GetOrigin()); | 740 mock_policy->AddProtected(kOrigin1.GetOrigin()); |
| 741 | 741 |
| 742 PopulateTestQuotaManagedData(GetMockManager()); | 742 PopulateTestQuotaManagedData(GetMockManager()); |
| 743 | 743 |
| 744 // Try to remove kOrigin1. Expect success. | 744 // Try to remove kOrigin1. Expect success. |
| 745 base::RunLoop run_loop; | 745 base::RunLoop run_loop; |
| 746 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 746 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 747 BrowserContext::GetDefaultStoragePartition(browser_context())); | 747 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 748 partition->OverrideQuotaManagerForTesting( | 748 partition->OverrideQuotaManagerForTesting( |
| 749 GetMockManager()); | 749 GetMockManager()); |
| 750 partition->OverrideSpecialStoragePolicyForTesting(mock_policy); | 750 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
| 751 base::MessageLoop::current()->PostTask( | 751 base::MessageLoop::current()->PostTask( |
| 752 FROM_HERE, | 752 FROM_HERE, |
| 753 base::Bind(&ClearQuotaDataWithOriginMatcher, | 753 base::Bind(&ClearQuotaDataWithOriginMatcher, |
| 754 partition, GURL(), | 754 partition, GURL(), |
| 755 base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), | 755 base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), |
| 756 base::Time(), &run_loop)); | 756 base::Time(), &run_loop)); |
| 757 run_loop.Run(); | 757 run_loop.Run(); |
| 758 | 758 |
| 759 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, | 759 EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 760 kClientFile)); | 760 kClientFile)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 | 841 |
| 842 RemoveLocalStorageTester tester(browser_context()); | 842 RemoveLocalStorageTester tester(browser_context()); |
| 843 | 843 |
| 844 tester.AddDOMStorageTestData(); | 844 tester.AddDOMStorageTestData(); |
| 845 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); | 845 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 846 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); | 846 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 847 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); | 847 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 848 | 848 |
| 849 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 849 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 850 BrowserContext::GetDefaultStoragePartition(browser_context())); | 850 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 851 partition->OverrideSpecialStoragePolicyForTesting(mock_policy); | 851 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
| 852 | 852 |
| 853 base::RunLoop run_loop; | 853 base::RunLoop run_loop; |
| 854 base::MessageLoop::current()->PostTask( | 854 base::MessageLoop::current()->PostTask( |
| 855 FROM_HERE, | 855 FROM_HERE, |
| 856 base::Bind(&ClearStuff, | 856 base::Bind(&ClearStuff, |
| 857 StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, | 857 StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, |
| 858 partition, base::Time(), base::Time::Max(), | 858 partition, base::Time(), base::Time::Max(), |
| 859 base::Bind(&DoesOriginMatchForUnprotectedWeb), | 859 base::Bind(&DoesOriginMatchForUnprotectedWeb), |
| 860 &run_loop)); | 860 &run_loop)); |
| 861 run_loop.Run(); | 861 run_loop.Run(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 873 | 873 |
| 874 RemoveLocalStorageTester tester(browser_context()); | 874 RemoveLocalStorageTester tester(browser_context()); |
| 875 | 875 |
| 876 tester.AddDOMStorageTestData(); | 876 tester.AddDOMStorageTestData(); |
| 877 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); | 877 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 878 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); | 878 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 879 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); | 879 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 880 | 880 |
| 881 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 881 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 882 BrowserContext::GetDefaultStoragePartition(browser_context())); | 882 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 883 partition->OverrideSpecialStoragePolicyForTesting(mock_policy); | 883 partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
| 884 | 884 |
| 885 base::RunLoop run_loop; | 885 base::RunLoop run_loop; |
| 886 base::MessageLoop::current()->PostTask( | 886 base::MessageLoop::current()->PostTask( |
| 887 FROM_HERE, | 887 FROM_HERE, |
| 888 base::Bind(&ClearStuff, | 888 base::Bind(&ClearStuff, |
| 889 StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, | 889 StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, |
| 890 partition, base::Time(), base::Time::Max(), | 890 partition, base::Time(), base::Time::Max(), |
| 891 base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), | 891 base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), |
| 892 &run_loop)); | 892 &run_loop)); |
| 893 run_loop.Run(); | 893 run_loop.Run(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 921 &run_loop)); | 921 &run_loop)); |
| 922 run_loop.Run(); | 922 run_loop.Run(); |
| 923 | 923 |
| 924 // kOrigin1 and kOrigin2 do not have age more than a week. | 924 // kOrigin1 and kOrigin2 do not have age more than a week. |
| 925 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); | 925 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 926 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); | 926 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 927 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); | 927 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 928 } | 928 } |
| 929 | 929 |
| 930 } // namespace content | 930 } // namespace content |
| OLD | NEW |