| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/appcache/appcache_storage_impl.h" | 5 #include "content/browser/appcache/appcache_storage_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <stack> | 10 #include <stack> |
| (...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 // on the current thread. | 1735 // on the current thread. |
| 1736 FlushDbThreadTasks(); | 1736 FlushDbThreadTasks(); |
| 1737 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1737 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1738 FROM_HERE, base::Bind(&AppCacheStorageImplTest::Continue_Reinitialize, | 1738 FROM_HERE, base::Bind(&AppCacheStorageImplTest::Continue_Reinitialize, |
| 1739 base::Unretained(this), test_case)); | 1739 base::Unretained(this), test_case)); |
| 1740 } | 1740 } |
| 1741 | 1741 |
| 1742 void Continue_Reinitialize(ReinitTestCase test_case) { | 1742 void Continue_Reinitialize(ReinitTestCase test_case) { |
| 1743 const int kMockProcessId = 1; | 1743 const int kMockProcessId = 1; |
| 1744 backend_.reset(new AppCacheBackendImpl); | 1744 backend_.reset(new AppCacheBackendImpl); |
| 1745 backend_->Initialize(service_.get(), &frontend_, kMockProcessId); | 1745 backend_->Initialize(service_.get(), &frontend_, kMockProcessId, -1); |
| 1746 | 1746 |
| 1747 if (test_case == CORRUPT_SQL_ON_INSTALL) { | 1747 if (test_case == CORRUPT_SQL_ON_INSTALL) { |
| 1748 // Break the db file | 1748 // Break the db file |
| 1749 EXPECT_FALSE(database()->was_corruption_detected()); | 1749 EXPECT_FALSE(database()->was_corruption_detected()); |
| 1750 ASSERT_TRUE(sql::test::CorruptSizeInHeader( | 1750 ASSERT_TRUE(sql::test::CorruptSizeInHeader( |
| 1751 temp_directory_.GetPath().AppendASCII("Index"))); | 1751 temp_directory_.GetPath().AppendASCII("Index"))); |
| 1752 } | 1752 } |
| 1753 | 1753 |
| 1754 if (test_case == CORRUPT_CACHE_ON_INSTALL || | 1754 if (test_case == CORRUPT_CACHE_ON_INSTALL || |
| 1755 test_case == CORRUPT_SQL_ON_INSTALL) { | 1755 test_case == CORRUPT_SQL_ON_INSTALL) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1766 ASSERT_EQ(CORRUPT_CACHE_ON_LOAD_EXISTING, test_case); | 1766 ASSERT_EQ(CORRUPT_CACHE_ON_LOAD_EXISTING, test_case); |
| 1767 // Try to access the existing cache manifest. | 1767 // Try to access the existing cache manifest. |
| 1768 // The URLRequestJob will eventually fail when it gets to disk | 1768 // The URLRequestJob will eventually fail when it gets to disk |
| 1769 // cache initialization. | 1769 // cache initialization. |
| 1770 backend_->RegisterHost(2); | 1770 backend_->RegisterHost(2); |
| 1771 AppCacheHost* host2 = backend_->GetHost(2); | 1771 AppCacheHost* host2 = backend_->GetHost(2); |
| 1772 GURL manifest_url = MockHttpServer::GetMockUrl("manifest"); | 1772 GURL manifest_url = MockHttpServer::GetMockUrl("manifest"); |
| 1773 request_ = service()->request_context()->CreateRequest( | 1773 request_ = service()->request_context()->CreateRequest( |
| 1774 manifest_url, net::DEFAULT_PRIORITY, &request_delegate_); | 1774 manifest_url, net::DEFAULT_PRIORITY, &request_delegate_); |
| 1775 AppCacheInterceptor::SetExtraRequestInfo( | 1775 AppCacheInterceptor::SetExtraRequestInfo( |
| 1776 request_.get(), service_.get(), | 1776 request_.get(), service_.get(), backend_->process_id(), -1, |
| 1777 backend_->process_id(), host2->host_id(), | 1777 host2->host_id(), RESOURCE_TYPE_MAIN_FRAME, false); |
| 1778 RESOURCE_TYPE_MAIN_FRAME, | |
| 1779 false); | |
| 1780 request_->Start(); | 1778 request_->Start(); |
| 1781 } | 1779 } |
| 1782 | 1780 |
| 1783 PushNextTask(base::Bind( | 1781 PushNextTask(base::Bind( |
| 1784 &AppCacheStorageImplTest::Verify_Reinitialized, | 1782 &AppCacheStorageImplTest::Verify_Reinitialized, |
| 1785 base::Unretained(this), | 1783 base::Unretained(this), |
| 1786 test_case)); | 1784 test_case)); |
| 1787 } | 1785 } |
| 1788 | 1786 |
| 1789 void Verify_Reinitialized(ReinitTestCase test_case) { | 1787 void Verify_Reinitialized(ReinitTestCase test_case) { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2027 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); | 2025 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); |
| 2028 } | 2026 } |
| 2029 | 2027 |
| 2030 TEST_F(AppCacheStorageImplTest, Reinitialize3) { | 2028 TEST_F(AppCacheStorageImplTest, Reinitialize3) { |
| 2031 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); | 2029 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); |
| 2032 } | 2030 } |
| 2033 | 2031 |
| 2034 // That's all folks! | 2032 // That's all folks! |
| 2035 | 2033 |
| 2036 } // namespace content | 2034 } // namespace content |
| OLD | NEW |