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

Side by Side Diff: content/browser/appcache/appcache_storage_impl_unittest.cc

Issue 2940023002: TaskScheduler: migrate appcache database over to use it. (Closed)
Patch Set: comments + rebase Created 3 years, 5 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
OLDNEW
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"
25 #include "base/threading/sequenced_task_runner_handle.h"
24 #include "base/threading/thread.h" 26 #include "base/threading/thread.h"
25 #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"
34 #include "content/browser/appcache/appcache_service_impl.h" 35 #include "content/browser/appcache/appcache_service_impl.h"
35 #include "net/base/net_errors.h" 36 #include "net/base/net_errors.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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::SequencedTaskRunnerHandle::Get()->PostTask(
292 FROM_HERE, base::Bind(&MockQuotaManager::CallCallback, 294 FROM_HERE, base::Bind(&MockQuotaManager::CallCallback,
293 base::Unretained(this), callback)); 295 base::Unretained(this), callback));
294 return; 296 return;
295 } 297 }
296 CallCallback(callback); 298 CallCallback(callback);
297 } 299 }
298 300
299 void CallCallback(const UsageAndQuotaCallback& callback) { 301 void CallCallback(const UsageAndQuotaCallback& callback) {
300 callback.Run(storage::kQuotaStatusOk, 0, kMockQuota); 302 callback.Run(storage::kQuotaStatusOk, 0, kMockQuota);
301 } 303 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::SequencedTaskRunnerHandle::Get()->PostTask(
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::SequencedTaskRunnerHandle::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 }
444 453
445 void TestFinishedUnwound() { 454 void TestFinishedUnwound() {
446 TearDownTest(); 455 TearDownTest();
447 test_finished_event_->Signal(); 456 test_finished_event_->Signal();
448 } 457 }
449 458
450 void PushNextTask(const base::Closure& task) { 459 void PushNextTask(const base::Closure& task) {
451 task_stack_.push(task); 460 task_stack_.push(task);
452 } 461 }
453 462
454 void ScheduleNextTask() { 463 void ScheduleNextTask() {
455 DCHECK(io_thread->task_runner()->BelongsToCurrentThread()); 464 DCHECK(io_thread->task_runner()->BelongsToCurrentThread());
456 if (task_stack_.empty()) { 465 if (task_stack_.empty()) {
457 return; 466 return;
458 } 467 }
459 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task_stack_.top()); 468 base::SequencedTaskRunnerHandle::Get()->PostTask(FROM_HERE,
469 task_stack_.top());
460 task_stack_.pop(); 470 task_stack_.pop();
461 } 471 }
462 472
463 static void SignalEvent(base::WaitableEvent* event) { 473 static void SignalEvent(base::WaitableEvent* event) {
464 event->Signal(); 474 event->Signal();
465 } 475 }
466 476
467 void FlushDbThreadTasks() { 477 void FlushAllTasks() {
478 FlushTasks(storage()->db_task_runner_.get());
479 FlushTasks(background_thread->task_runner().get());
480 FlushTasks(storage()->db_task_runner_.get());
481 }
482
483 void FlushTasks(base::SequencedTaskRunner* runner) {
468 // We pump a task thru the db thread to ensure any tasks previously 484 // We pump a task thru the db thread to ensure any tasks previously
469 // scheduled on that thread have been performed prior to return. 485 // scheduled on that thread have been performed prior to return.
470 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, 486 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
471 base::WaitableEvent::InitialState::NOT_SIGNALED); 487 base::WaitableEvent::InitialState::NOT_SIGNALED);
472 db_thread->task_runner()->PostTask( 488 runner->PostTask(FROM_HERE,
473 FROM_HERE, base::Bind(&AppCacheStorageImplTest::SignalEvent, &event)); 489 base::Bind(&AppCacheStorageImplTest::SignalEvent, &event));
474 event.Wait(); 490 event.Wait();
475 } 491 }
476 492
477 // LoadCache_Miss ---------------------------------------------------- 493 // LoadCache_Miss ----------------------------------------------------
478 494
479 void LoadCache_Miss() { 495 void LoadCache_Miss() {
480 // Attempt to load a cache that doesn't exist. Should 496 // Attempt to load a cache that doesn't exist. Should
481 // complete asynchronously. 497 // complete asynchronously.
482 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadCache_Miss, 498 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadCache_Miss,
483 base::Unretained(this))); 499 base::Unretained(this)));
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 908
893 // Conduct the test. 909 // Conduct the test.
894 storage()->MarkEntryAsForeign(kEntryUrl, 1); 910 storage()->MarkEntryAsForeign(kEntryUrl, 1);
895 911
896 // The entry in the working set should have been updated syncly. 912 // The entry in the working set should have been updated syncly.
897 EXPECT_TRUE(cache_->GetEntry(kEntryUrl)->IsForeign()); 913 EXPECT_TRUE(cache_->GetEntry(kEntryUrl)->IsForeign());
898 EXPECT_TRUE(cache_->GetEntry(kEntryUrl)->IsExplicit()); 914 EXPECT_TRUE(cache_->GetEntry(kEntryUrl)->IsExplicit());
899 915
900 // And the entry in storage should also be updated, but that 916 // And the entry in storage should also be updated, but that
901 // happens asynchronously on the db thread. 917 // happens asynchronously on the db thread.
902 FlushDbThreadTasks(); 918 FlushAllTasks();
903 AppCacheDatabase::EntryRecord entry_record2; 919 AppCacheDatabase::EntryRecord entry_record2;
904 EXPECT_TRUE(database()->FindEntry(1, kEntryUrl, &entry_record2)); 920 EXPECT_TRUE(database()->FindEntry(1, kEntryUrl, &entry_record2));
905 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, 921 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN,
906 entry_record2.flags); 922 entry_record2.flags);
907 TestFinished(); 923 TestFinished();
908 } 924 }
909 925
910 // MarkEntryAsForeignWithLoadInProgress ------------------------------- 926 // MarkEntryAsForeignWithLoadInProgress -------------------------------
911 927
912 void MarkEntryAsForeignWithLoadInProgress() { 928 void MarkEntryAsForeignWithLoadInProgress() {
(...skipping 24 matching lines...) Expand all
937 953
938 void Verify_MarkEntryAsForeignWithLoadInProgress() { 954 void Verify_MarkEntryAsForeignWithLoadInProgress() {
939 EXPECT_EQ(1, delegate()->loaded_cache_id_); 955 EXPECT_EQ(1, delegate()->loaded_cache_id_);
940 EXPECT_TRUE(delegate()->loaded_cache_.get()); 956 EXPECT_TRUE(delegate()->loaded_cache_.get());
941 957
942 // The entry in the working set should have been updated upon load. 958 // The entry in the working set should have been updated upon load.
943 EXPECT_TRUE(delegate()->loaded_cache_->GetEntry(kEntryUrl)->IsForeign()); 959 EXPECT_TRUE(delegate()->loaded_cache_->GetEntry(kEntryUrl)->IsForeign());
944 EXPECT_TRUE(delegate()->loaded_cache_->GetEntry(kEntryUrl)->IsExplicit()); 960 EXPECT_TRUE(delegate()->loaded_cache_->GetEntry(kEntryUrl)->IsExplicit());
945 961
946 // And the entry in storage should also be updated. 962 // And the entry in storage should also be updated.
947 FlushDbThreadTasks(); 963 FlushAllTasks();
948 AppCacheDatabase::EntryRecord entry_record; 964 AppCacheDatabase::EntryRecord entry_record;
949 EXPECT_TRUE(database()->FindEntry(1, kEntryUrl, &entry_record)); 965 EXPECT_TRUE(database()->FindEntry(1, kEntryUrl, &entry_record));
950 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, 966 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN,
951 entry_record.flags); 967 entry_record.flags);
952 TestFinished(); 968 TestFinished();
953 } 969 }
954 970
955 // FindNoMainResponse ------------------------------- 971 // FindNoMainResponse -------------------------------
956 972
957 void FindNoMainResponse() { 973 void FindNoMainResponse() {
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 entry_record.url = manifest_url; 1733 entry_record.url = manifest_url;
1718 entry_record.flags = AppCacheEntry::MANIFEST; 1734 entry_record.flags = AppCacheEntry::MANIFEST;
1719 entry_record.response_id = 1; 1735 entry_record.response_id = 1;
1720 entry_record.response_size = kDefaultEntrySize; 1736 entry_record.response_size = kDefaultEntrySize;
1721 EXPECT_TRUE(db.InsertEntry(&entry_record)); 1737 EXPECT_TRUE(db.InsertEntry(&entry_record));
1722 } 1738 }
1723 1739
1724 // Recreate the service to point at the db and corruption on disk. 1740 // Recreate the service to point at the db and corruption on disk.
1725 service_.reset(new AppCacheServiceImpl(NULL)); 1741 service_.reset(new AppCacheServiceImpl(NULL));
1726 service_->set_request_context(io_thread->request_context()); 1742 service_->set_request_context(io_thread->request_context());
1727 service_->Initialize(temp_directory_.GetPath(), db_thread->task_runner(), 1743 service_->Initialize(temp_directory_.GetPath(),
1728 db_thread->task_runner()); 1744 background_thread->task_runner());
1729 mock_quota_manager_proxy_ = new MockQuotaManagerProxy(); 1745 mock_quota_manager_proxy_ = new MockQuotaManagerProxy();
1730 service_->quota_manager_proxy_ = mock_quota_manager_proxy_; 1746 service_->quota_manager_proxy_ = mock_quota_manager_proxy_;
1731 delegate_.reset(new MockStorageDelegate(this)); 1747 delegate_.reset(new MockStorageDelegate(this));
1732 1748
1733 // Additional setup to observe reinitailize happens. 1749 // Additional setup to observe reinitailize happens.
1734 observer_.reset(new MockServiceObserver(this)); 1750 observer_.reset(new MockServiceObserver(this));
1735 service_->AddObserver(observer_.get()); 1751 service_->AddObserver(observer_.get());
1736 1752
1737 // We continue after the init task is complete including the callback 1753 // We continue after the init task is complete including the callback
1738 // on the current thread. 1754 // on the current thread.
1739 FlushDbThreadTasks(); 1755 FlushAllTasks();
1740 base::ThreadTaskRunnerHandle::Get()->PostTask( 1756 base::SequencedTaskRunnerHandle::Get()->PostTask(
1741 FROM_HERE, base::Bind(&AppCacheStorageImplTest::Continue_Reinitialize, 1757 FROM_HERE, base::Bind(&AppCacheStorageImplTest::Continue_Reinitialize,
1742 base::Unretained(this), test_case)); 1758 base::Unretained(this), test_case));
1743 } 1759 }
1744 1760
1745 void Continue_Reinitialize(ReinitTestCase test_case) { 1761 void Continue_Reinitialize(ReinitTestCase test_case) {
1746 const int kMockProcessId = 1; 1762 const int kMockProcessId = 1;
1747 backend_.reset(new AppCacheBackendImpl); 1763 backend_.reset(new AppCacheBackendImpl);
1748 backend_->Initialize(service_.get(), &frontend_, kMockProcessId); 1764 backend_->Initialize(service_.get(), &frontend_, kMockProcessId);
1749 1765
1750 if (test_case == CORRUPT_SQL_ON_INSTALL) { 1766 if (test_case == CORRUPT_SQL_ON_INSTALL) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 if (test_case == CORRUPT_CACHE_ON_INSTALL || 1823 if (test_case == CORRUPT_CACHE_ON_INSTALL ||
1808 test_case == CORRUPT_SQL_ON_INSTALL) { 1824 test_case == CORRUPT_SQL_ON_INSTALL) {
1809 EXPECT_TRUE(frontend_.error_event_was_raised_); 1825 EXPECT_TRUE(frontend_.error_event_was_raised_);
1810 AppCacheHost* host1 = backend_->GetHost(1); 1826 AppCacheHost* host1 = backend_->GetHost(1);
1811 EXPECT_FALSE(host1->associated_cache()); 1827 EXPECT_FALSE(host1->associated_cache());
1812 EXPECT_FALSE(host1->group_being_updated_.get()); 1828 EXPECT_FALSE(host1->group_being_updated_.get());
1813 EXPECT_TRUE(host1->disabled_storage_reference_.get()); 1829 EXPECT_TRUE(host1->disabled_storage_reference_.get());
1814 } else { 1830 } else {
1815 ASSERT_EQ(CORRUPT_CACHE_ON_LOAD_EXISTING, test_case); 1831 ASSERT_EQ(CORRUPT_CACHE_ON_LOAD_EXISTING, test_case);
1816 AppCacheHost* host2 = backend_->GetHost(2); 1832 AppCacheHost* host2 = backend_->GetHost(2);
1817 EXPECT_EQ(1, host2->main_resource_cache_->cache_id());
1818 EXPECT_TRUE(host2->disabled_storage_reference_.get()); 1833 EXPECT_TRUE(host2->disabled_storage_reference_.get());
1819 } 1834 }
1820 1835
1821 // Cleanup and claim victory. 1836 // Cleanup and claim victory.
1822 service_->RemoveObserver(observer_.get()); 1837 service_->RemoveObserver(observer_.get());
1823 request_.reset(); 1838 request_.reset();
1824 backend_.reset(); 1839 backend_.reset();
1825 observer_.reset(); 1840 observer_.reset();
1826 TestFinished(); 1841 TestFinished();
1827 } 1842 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); 2044 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2);
2030 } 2045 }
2031 2046
2032 TEST_F(AppCacheStorageImplTest, Reinitialize3) { 2047 TEST_F(AppCacheStorageImplTest, Reinitialize3) {
2033 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); 2048 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3);
2034 } 2049 }
2035 2050
2036 // That's all folks! 2051 // That's all folks!
2037 2052
2038 } // namespace content 2053 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_storage_impl.cc ('k') | content/browser/appcache/appcache_storage_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698