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> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
17 #include "base/files/scoped_temp_dir.h" | 17 #include "base/files/scoped_temp_dir.h" |
18 #include "base/location.h" | 18 #include "base/location.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
22 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
23 #include "base/synchronization/waitable_event.h" | 23 #include "base/synchronization/waitable_event.h" |
24 #include "base/test/scoped_task_environment.h" | |
24 #include "base/threading/thread.h" | 25 #include "base/threading/thread.h" |
25 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
26 #include "content/browser/appcache/appcache.h" | 27 #include "content/browser/appcache/appcache.h" |
27 #include "content/browser/appcache/appcache_backend_impl.h" | 28 #include "content/browser/appcache/appcache_backend_impl.h" |
28 #include "content/browser/appcache/appcache_database.h" | 29 #include "content/browser/appcache/appcache_database.h" |
29 #include "content/browser/appcache/appcache_entry.h" | 30 #include "content/browser/appcache/appcache_entry.h" |
30 #include "content/browser/appcache/appcache_group.h" | 31 #include "content/browser/appcache/appcache_group.h" |
31 #include "content/browser/appcache/appcache_host.h" | 32 #include "content/browser/appcache/appcache_host.h" |
32 #include "content/browser/appcache/appcache_interceptor.h" | 33 #include "content/browser/appcache/appcache_interceptor.h" |
33 #include "content/browser/appcache/appcache_request_handler.h" | 34 #include "content/browser/appcache/appcache_request_handler.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 void CleanUp() override { | 181 void CleanUp() override { |
181 request_context_.reset(); | 182 request_context_.reset(); |
182 job_factory_.reset(); | 183 job_factory_.reset(); |
183 } | 184 } |
184 | 185 |
185 private: | 186 private: |
186 std::unique_ptr<net::URLRequestJobFactory> job_factory_; | 187 std::unique_ptr<net::URLRequestJobFactory> job_factory_; |
187 std::unique_ptr<net::URLRequestContext> request_context_; | 188 std::unique_ptr<net::URLRequestContext> request_context_; |
188 }; | 189 }; |
189 | 190 |
191 std::unique_ptr<base::test::ScopedTaskEnvironment> scoped_task_environment; | |
190 std::unique_ptr<IOThread> io_thread; | 192 std::unique_ptr<IOThread> io_thread; |
191 std::unique_ptr<base::Thread> db_thread; | 193 std::unique_ptr<base::Thread> background_thread; |
192 | 194 |
193 } // namespace | 195 } // namespace |
194 | 196 |
195 class AppCacheStorageImplTest : public testing::Test { | 197 class AppCacheStorageImplTest : public testing::Test { |
196 public: | 198 public: |
197 class MockStorageDelegate : public AppCacheStorage::Delegate { | 199 class MockStorageDelegate : public AppCacheStorage::Delegate { |
198 public: | 200 public: |
199 explicit MockStorageDelegate(AppCacheStorageImplTest* test) | 201 explicit MockStorageDelegate(AppCacheStorageImplTest* test) |
200 : loaded_cache_id_(0), stored_group_success_(false), | 202 : loaded_cache_id_(0), stored_group_success_(false), |
201 would_exceed_quota_(false), obsoleted_success_(false), | 203 would_exceed_quota_(false), obsoleted_success_(false), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 GURL found_manifest_url_; | 273 GURL found_manifest_url_; |
272 AppCacheStorageImplTest* test_; | 274 AppCacheStorageImplTest* test_; |
273 }; | 275 }; |
274 | 276 |
275 class MockQuotaManager : public storage::QuotaManager { | 277 class MockQuotaManager : public storage::QuotaManager { |
276 public: | 278 public: |
277 MockQuotaManager() | 279 MockQuotaManager() |
278 : QuotaManager(true /* is_incognito */, | 280 : QuotaManager(true /* is_incognito */, |
279 base::FilePath(), | 281 base::FilePath(), |
280 io_thread->task_runner().get(), | 282 io_thread->task_runner().get(), |
281 db_thread->task_runner().get(), | 283 background_thread->task_runner().get(), |
282 nullptr, | 284 nullptr, |
283 storage::GetQuotaSettingsFunc()), | 285 storage::GetQuotaSettingsFunc()), |
284 async_(false) {} | 286 async_(false) {} |
285 | 287 |
286 void GetUsageAndQuota(const GURL& origin, | 288 void GetUsageAndQuota(const GURL& origin, |
287 storage::StorageType type, | 289 storage::StorageType type, |
288 const UsageAndQuotaCallback& callback) override { | 290 const UsageAndQuotaCallback& callback) override { |
289 EXPECT_EQ(storage::kStorageTypeTemporary, type); | 291 EXPECT_EQ(storage::kStorageTypeTemporary, type); |
290 if (async_) { | 292 if (async_) { |
291 base::ThreadTaskRunnerHandle::Get()->PostTask( | 293 base::ThreadTaskRunnerHandle::Get()->PostTask( |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 (this->*method)(); | 367 (this->*method)(); |
366 } | 368 } |
367 | 369 |
368 // Helper callback to run a test on our io_thread. The io_thread is spun up | 370 // Helper callback to run a test on our io_thread. The io_thread is spun up |
369 // once and reused for all tests. | 371 // once and reused for all tests. |
370 template <class Method> | 372 template <class Method> |
371 void MethodWrapper(Method method) { | 373 void MethodWrapper(Method method) { |
372 SetUpTest(); | 374 SetUpTest(); |
373 | 375 |
374 // Ensure InitTask execution prior to conducting a test. | 376 // Ensure InitTask execution prior to conducting a test. |
375 FlushDbThreadTasks(); | 377 FlushAllTasks(); |
376 | 378 |
377 // We also have to wait for InitTask completion call to be performed | 379 // We also have to wait for InitTask completion call to be performed |
378 // on the IO thread prior to running the test. Its guaranteed to be | 380 // on the IO thread prior to running the test. Its guaranteed to be |
379 // queued by this time. | 381 // queued by this time. |
380 base::ThreadTaskRunnerHandle::Get()->PostTask( | 382 base::ThreadTaskRunnerHandle::Get()->PostTask( |
gab
2017/06/20 21:29:54
This could perhaps use SequencedTaskRunnerHandle::
michaeln
2017/07/11 00:33:54
Done throughout the file
| |
381 FROM_HERE, base::Bind(&AppCacheStorageImplTest::RunMethod<Method>, | 383 FROM_HERE, base::Bind(&AppCacheStorageImplTest::RunMethod<Method>, |
382 base::Unretained(this), method)); | 384 base::Unretained(this), method)); |
383 } | 385 } |
384 | 386 |
385 static void SetUpTestCase() { | 387 static void SetUpTestCase() { |
388 scoped_task_environment.reset(new base::test::ScopedTaskEnvironment()); | |
389 | |
386 // We start both threads as TYPE_IO because we also use the db_thead | 390 // We start both threads as TYPE_IO because we also use the db_thead |
387 // for the disk_cache which needs to be of TYPE_IO. | 391 // for the disk_cache which needs to be of TYPE_IO. |
388 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); | 392 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); |
389 io_thread.reset(new IOThread("AppCacheTest.IOThread")); | 393 io_thread.reset(new IOThread("AppCacheTest.IOThread")); |
390 ASSERT_TRUE(io_thread->StartWithOptions(options)); | 394 ASSERT_TRUE(io_thread->StartWithOptions(options)); |
391 db_thread.reset(new base::Thread("AppCacheTest::DBThread")); | 395 background_thread.reset(new base::Thread("AppCacheTest::BackgroundThread")); |
392 ASSERT_TRUE(db_thread->StartWithOptions(options)); | 396 ASSERT_TRUE(background_thread->StartWithOptions(options)); |
393 } | 397 } |
394 | 398 |
395 static void TearDownTestCase() { | 399 static void TearDownTestCase() { |
396 io_thread.reset(NULL); | 400 io_thread.reset(); |
397 db_thread.reset(NULL); | 401 background_thread.reset(); |
402 scoped_task_environment.reset(); | |
398 } | 403 } |
399 | 404 |
400 // Test harness -------------------------------------------------- | 405 // Test harness -------------------------------------------------- |
401 | 406 |
402 AppCacheStorageImplTest() { request_delegate_.set_quit_on_complete(false); } | 407 AppCacheStorageImplTest() { request_delegate_.set_quit_on_complete(false); } |
403 | 408 |
404 template <class Method> | 409 template <class Method> |
405 void RunTestOnIOThread(Method method) { | 410 void RunTestOnIOThread(Method method) { |
406 test_finished_event_.reset(new base::WaitableEvent( | 411 test_finished_event_.reset(new base::WaitableEvent( |
407 base::WaitableEvent::ResetPolicy::AUTOMATIC, | 412 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
408 base::WaitableEvent::InitialState::NOT_SIGNALED)); | 413 base::WaitableEvent::InitialState::NOT_SIGNALED)); |
409 io_thread->task_runner()->PostTask( | 414 io_thread->task_runner()->PostTask( |
410 FROM_HERE, base::Bind(&AppCacheStorageImplTest::MethodWrapper<Method>, | 415 FROM_HERE, base::Bind(&AppCacheStorageImplTest::MethodWrapper<Method>, |
411 base::Unretained(this), method)); | 416 base::Unretained(this), method)); |
412 test_finished_event_->Wait(); | 417 test_finished_event_->Wait(); |
413 } | 418 } |
414 | 419 |
415 void SetUpTest() { | 420 void SetUpTest() { |
416 DCHECK(io_thread->task_runner()->BelongsToCurrentThread()); | 421 DCHECK(io_thread->task_runner()->BelongsToCurrentThread()); |
417 service_.reset(new AppCacheServiceImpl(NULL)); | 422 service_.reset(new AppCacheServiceImpl(nullptr)); |
418 service_->Initialize(base::FilePath(), db_thread->task_runner(), NULL); | 423 service_->Initialize(base::FilePath(), background_thread->task_runner()); |
419 mock_quota_manager_proxy_ = new MockQuotaManagerProxy(); | 424 mock_quota_manager_proxy_ = new MockQuotaManagerProxy(); |
420 service_->quota_manager_proxy_ = mock_quota_manager_proxy_; | 425 service_->quota_manager_proxy_ = mock_quota_manager_proxy_; |
421 delegate_.reset(new MockStorageDelegate(this)); | 426 delegate_.reset(new MockStorageDelegate(this)); |
422 } | 427 } |
423 | 428 |
424 void TearDownTest() { | 429 void TearDownTest() { |
425 DCHECK(io_thread->task_runner()->BelongsToCurrentThread()); | 430 DCHECK(io_thread->task_runner()->BelongsToCurrentThread()); |
431 scoped_refptr<base::SequencedTaskRunner> db_runner = | |
432 storage()->db_task_runner_; | |
426 storage()->CancelDelegateCallbacks(delegate()); | 433 storage()->CancelDelegateCallbacks(delegate()); |
427 group_ = NULL; | 434 group_ = NULL; |
428 cache_ = NULL; | 435 cache_ = NULL; |
429 cache2_ = NULL; | 436 cache2_ = NULL; |
430 mock_quota_manager_proxy_ = NULL; | 437 mock_quota_manager_proxy_ = NULL; |
431 delegate_.reset(); | 438 delegate_.reset(); |
432 service_.reset(); | 439 service_.reset(); |
433 FlushDbThreadTasks(); | 440 FlushTasks(db_runner.get()); |
441 FlushTasks(background_thread->task_runner().get()); | |
442 FlushTasks(db_runner.get()); | |
434 } | 443 } |
435 | 444 |
436 void TestFinished() { | 445 void TestFinished() { |
437 // We unwind the stack prior to finishing up to let stack | 446 // We unwind the stack prior to finishing up to let stack |
438 // based objects get deleted. | 447 // based objects get deleted. |
439 DCHECK(io_thread->task_runner()->BelongsToCurrentThread()); | 448 DCHECK(io_thread->task_runner()->BelongsToCurrentThread()); |
440 base::ThreadTaskRunnerHandle::Get()->PostTask( | 449 base::ThreadTaskRunnerHandle::Get()->PostTask( |
441 FROM_HERE, base::Bind(&AppCacheStorageImplTest::TestFinishedUnwound, | 450 FROM_HERE, base::Bind(&AppCacheStorageImplTest::TestFinishedUnwound, |
442 base::Unretained(this))); | 451 base::Unretained(this))); |
443 } | 452 } |
(...skipping 13 matching lines...) Expand all Loading... | |
457 return; | 466 return; |
458 } | 467 } |
459 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task_stack_.top()); | 468 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task_stack_.top()); |
460 task_stack_.pop(); | 469 task_stack_.pop(); |
461 } | 470 } |
462 | 471 |
463 static void SignalEvent(base::WaitableEvent* event) { | 472 static void SignalEvent(base::WaitableEvent* event) { |
464 event->Signal(); | 473 event->Signal(); |
465 } | 474 } |
466 | 475 |
467 void FlushDbThreadTasks() { | 476 void FlushAllTasks() { |
477 FlushTasks(storage()->db_task_runner_.get()); | |
478 FlushTasks(background_thread->task_runner().get()); | |
479 FlushTasks(storage()->db_task_runner_.get()); | |
480 } | |
481 | |
482 void FlushTasks(base::SequencedTaskRunner* runner) { | |
468 // We pump a task thru the db thread to ensure any tasks previously | 483 // We pump a task thru the db thread to ensure any tasks previously |
469 // scheduled on that thread have been performed prior to return. | 484 // scheduled on that thread have been performed prior to return. |
470 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 485 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
471 base::WaitableEvent::InitialState::NOT_SIGNALED); | 486 base::WaitableEvent::InitialState::NOT_SIGNALED); |
472 db_thread->task_runner()->PostTask( | 487 runner->PostTask(FROM_HERE, |
473 FROM_HERE, base::Bind(&AppCacheStorageImplTest::SignalEvent, &event)); | 488 base::Bind(&AppCacheStorageImplTest::SignalEvent, &event)); |
474 event.Wait(); | 489 event.Wait(); |
475 } | 490 } |
476 | 491 |
477 // LoadCache_Miss ---------------------------------------------------- | 492 // LoadCache_Miss ---------------------------------------------------- |
478 | 493 |
479 void LoadCache_Miss() { | 494 void LoadCache_Miss() { |
480 // Attempt to load a cache that doesn't exist. Should | 495 // Attempt to load a cache that doesn't exist. Should |
481 // complete asynchronously. | 496 // complete asynchronously. |
482 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadCache_Miss, | 497 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadCache_Miss, |
483 base::Unretained(this))); | 498 base::Unretained(this))); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
892 | 907 |
893 // Conduct the test. | 908 // Conduct the test. |
894 storage()->MarkEntryAsForeign(kEntryUrl, 1); | 909 storage()->MarkEntryAsForeign(kEntryUrl, 1); |
895 | 910 |
896 // The entry in the working set should have been updated syncly. | 911 // The entry in the working set should have been updated syncly. |
897 EXPECT_TRUE(cache_->GetEntry(kEntryUrl)->IsForeign()); | 912 EXPECT_TRUE(cache_->GetEntry(kEntryUrl)->IsForeign()); |
898 EXPECT_TRUE(cache_->GetEntry(kEntryUrl)->IsExplicit()); | 913 EXPECT_TRUE(cache_->GetEntry(kEntryUrl)->IsExplicit()); |
899 | 914 |
900 // And the entry in storage should also be updated, but that | 915 // And the entry in storage should also be updated, but that |
901 // happens asynchronously on the db thread. | 916 // happens asynchronously on the db thread. |
902 FlushDbThreadTasks(); | 917 FlushAllTasks(); |
903 AppCacheDatabase::EntryRecord entry_record2; | 918 AppCacheDatabase::EntryRecord entry_record2; |
904 EXPECT_TRUE(database()->FindEntry(1, kEntryUrl, &entry_record2)); | 919 EXPECT_TRUE(database()->FindEntry(1, kEntryUrl, &entry_record2)); |
905 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, | 920 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, |
906 entry_record2.flags); | 921 entry_record2.flags); |
907 TestFinished(); | 922 TestFinished(); |
908 } | 923 } |
909 | 924 |
910 // MarkEntryAsForeignWithLoadInProgress ------------------------------- | 925 // MarkEntryAsForeignWithLoadInProgress ------------------------------- |
911 | 926 |
912 void MarkEntryAsForeignWithLoadInProgress() { | 927 void MarkEntryAsForeignWithLoadInProgress() { |
(...skipping 24 matching lines...) Expand all Loading... | |
937 | 952 |
938 void Verify_MarkEntryAsForeignWithLoadInProgress() { | 953 void Verify_MarkEntryAsForeignWithLoadInProgress() { |
939 EXPECT_EQ(1, delegate()->loaded_cache_id_); | 954 EXPECT_EQ(1, delegate()->loaded_cache_id_); |
940 EXPECT_TRUE(delegate()->loaded_cache_.get()); | 955 EXPECT_TRUE(delegate()->loaded_cache_.get()); |
941 | 956 |
942 // The entry in the working set should have been updated upon load. | 957 // The entry in the working set should have been updated upon load. |
943 EXPECT_TRUE(delegate()->loaded_cache_->GetEntry(kEntryUrl)->IsForeign()); | 958 EXPECT_TRUE(delegate()->loaded_cache_->GetEntry(kEntryUrl)->IsForeign()); |
944 EXPECT_TRUE(delegate()->loaded_cache_->GetEntry(kEntryUrl)->IsExplicit()); | 959 EXPECT_TRUE(delegate()->loaded_cache_->GetEntry(kEntryUrl)->IsExplicit()); |
945 | 960 |
946 // And the entry in storage should also be updated. | 961 // And the entry in storage should also be updated. |
947 FlushDbThreadTasks(); | 962 FlushAllTasks(); |
948 AppCacheDatabase::EntryRecord entry_record; | 963 AppCacheDatabase::EntryRecord entry_record; |
949 EXPECT_TRUE(database()->FindEntry(1, kEntryUrl, &entry_record)); | 964 EXPECT_TRUE(database()->FindEntry(1, kEntryUrl, &entry_record)); |
950 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, | 965 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, |
951 entry_record.flags); | 966 entry_record.flags); |
952 TestFinished(); | 967 TestFinished(); |
953 } | 968 } |
954 | 969 |
955 // FindNoMainResponse ------------------------------- | 970 // FindNoMainResponse ------------------------------- |
956 | 971 |
957 void FindNoMainResponse() { | 972 void FindNoMainResponse() { |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1717 entry_record.url = manifest_url; | 1732 entry_record.url = manifest_url; |
1718 entry_record.flags = AppCacheEntry::MANIFEST; | 1733 entry_record.flags = AppCacheEntry::MANIFEST; |
1719 entry_record.response_id = 1; | 1734 entry_record.response_id = 1; |
1720 entry_record.response_size = kDefaultEntrySize; | 1735 entry_record.response_size = kDefaultEntrySize; |
1721 EXPECT_TRUE(db.InsertEntry(&entry_record)); | 1736 EXPECT_TRUE(db.InsertEntry(&entry_record)); |
1722 } | 1737 } |
1723 | 1738 |
1724 // Recreate the service to point at the db and corruption on disk. | 1739 // Recreate the service to point at the db and corruption on disk. |
1725 service_.reset(new AppCacheServiceImpl(NULL)); | 1740 service_.reset(new AppCacheServiceImpl(NULL)); |
1726 service_->set_request_context(io_thread->request_context()); | 1741 service_->set_request_context(io_thread->request_context()); |
1727 service_->Initialize(temp_directory_.GetPath(), db_thread->task_runner(), | 1742 service_->Initialize(temp_directory_.GetPath(), |
1728 db_thread->task_runner()); | 1743 background_thread->task_runner()); |
1729 mock_quota_manager_proxy_ = new MockQuotaManagerProxy(); | 1744 mock_quota_manager_proxy_ = new MockQuotaManagerProxy(); |
1730 service_->quota_manager_proxy_ = mock_quota_manager_proxy_; | 1745 service_->quota_manager_proxy_ = mock_quota_manager_proxy_; |
1731 delegate_.reset(new MockStorageDelegate(this)); | 1746 delegate_.reset(new MockStorageDelegate(this)); |
1732 | 1747 |
1733 // Additional setup to observe reinitailize happens. | 1748 // Additional setup to observe reinitailize happens. |
1734 observer_.reset(new MockServiceObserver(this)); | 1749 observer_.reset(new MockServiceObserver(this)); |
1735 service_->AddObserver(observer_.get()); | 1750 service_->AddObserver(observer_.get()); |
1736 | 1751 |
1737 // We continue after the init task is complete including the callback | 1752 // We continue after the init task is complete including the callback |
1738 // on the current thread. | 1753 // on the current thread. |
1739 FlushDbThreadTasks(); | 1754 FlushAllTasks(); |
1740 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1755 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1741 FROM_HERE, base::Bind(&AppCacheStorageImplTest::Continue_Reinitialize, | 1756 FROM_HERE, base::Bind(&AppCacheStorageImplTest::Continue_Reinitialize, |
1742 base::Unretained(this), test_case)); | 1757 base::Unretained(this), test_case)); |
1743 } | 1758 } |
1744 | 1759 |
1745 void Continue_Reinitialize(ReinitTestCase test_case) { | 1760 void Continue_Reinitialize(ReinitTestCase test_case) { |
1746 const int kMockProcessId = 1; | 1761 const int kMockProcessId = 1; |
1747 backend_.reset(new AppCacheBackendImpl); | 1762 backend_.reset(new AppCacheBackendImpl); |
1748 backend_->Initialize(service_.get(), &frontend_, kMockProcessId); | 1763 backend_->Initialize(service_.get(), &frontend_, kMockProcessId); |
1749 | 1764 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1807 if (test_case == CORRUPT_CACHE_ON_INSTALL || | 1822 if (test_case == CORRUPT_CACHE_ON_INSTALL || |
1808 test_case == CORRUPT_SQL_ON_INSTALL) { | 1823 test_case == CORRUPT_SQL_ON_INSTALL) { |
1809 EXPECT_TRUE(frontend_.error_event_was_raised_); | 1824 EXPECT_TRUE(frontend_.error_event_was_raised_); |
1810 AppCacheHost* host1 = backend_->GetHost(1); | 1825 AppCacheHost* host1 = backend_->GetHost(1); |
1811 EXPECT_FALSE(host1->associated_cache()); | 1826 EXPECT_FALSE(host1->associated_cache()); |
1812 EXPECT_FALSE(host1->group_being_updated_.get()); | 1827 EXPECT_FALSE(host1->group_being_updated_.get()); |
1813 EXPECT_TRUE(host1->disabled_storage_reference_.get()); | 1828 EXPECT_TRUE(host1->disabled_storage_reference_.get()); |
1814 } else { | 1829 } else { |
1815 ASSERT_EQ(CORRUPT_CACHE_ON_LOAD_EXISTING, test_case); | 1830 ASSERT_EQ(CORRUPT_CACHE_ON_LOAD_EXISTING, test_case); |
1816 AppCacheHost* host2 = backend_->GetHost(2); | 1831 AppCacheHost* host2 = backend_->GetHost(2); |
1817 EXPECT_EQ(1, host2->main_resource_cache_->cache_id()); | |
1818 EXPECT_TRUE(host2->disabled_storage_reference_.get()); | 1832 EXPECT_TRUE(host2->disabled_storage_reference_.get()); |
1819 } | 1833 } |
1820 | 1834 |
1821 // Cleanup and claim victory. | 1835 // Cleanup and claim victory. |
1822 service_->RemoveObserver(observer_.get()); | 1836 service_->RemoveObserver(observer_.get()); |
1823 request_.reset(); | 1837 request_.reset(); |
1824 backend_.reset(); | 1838 backend_.reset(); |
1825 observer_.reset(); | 1839 observer_.reset(); |
1826 TestFinished(); | 1840 TestFinished(); |
1827 } | 1841 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2029 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); | 2043 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); |
2030 } | 2044 } |
2031 | 2045 |
2032 TEST_F(AppCacheStorageImplTest, Reinitialize3) { | 2046 TEST_F(AppCacheStorageImplTest, Reinitialize3) { |
2033 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); | 2047 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); |
2034 } | 2048 } |
2035 | 2049 |
2036 // That's all folks! | 2050 // That's all folks! |
2037 | 2051 |
2038 } // namespace content | 2052 } // namespace content |
OLD | NEW |