| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 test_finished_event_.reset(new base::WaitableEvent( | 403 test_finished_event_.reset(new base::WaitableEvent( |
| 404 base::WaitableEvent::ResetPolicy::AUTOMATIC, | 404 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 405 base::WaitableEvent::InitialState::NOT_SIGNALED)); | 405 base::WaitableEvent::InitialState::NOT_SIGNALED)); |
| 406 io_thread->task_runner()->PostTask( | 406 io_thread->task_runner()->PostTask( |
| 407 FROM_HERE, base::Bind(&AppCacheStorageImplTest::MethodWrapper<Method>, | 407 FROM_HERE, base::Bind(&AppCacheStorageImplTest::MethodWrapper<Method>, |
| 408 base::Unretained(this), method)); | 408 base::Unretained(this), method)); |
| 409 test_finished_event_->Wait(); | 409 test_finished_event_->Wait(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 void SetUpTest() { | 412 void SetUpTest() { |
| 413 DCHECK(base::MessageLoop::current() == io_thread->message_loop()); | 413 DCHECK(io_thread->task_runner()->BelongsToCurrentThread()); |
| 414 service_.reset(new AppCacheServiceImpl(NULL)); | 414 service_.reset(new AppCacheServiceImpl(NULL)); |
| 415 service_->Initialize(base::FilePath(), db_thread->task_runner(), NULL); | 415 service_->Initialize(base::FilePath(), db_thread->task_runner(), NULL); |
| 416 mock_quota_manager_proxy_ = new MockQuotaManagerProxy(); | 416 mock_quota_manager_proxy_ = new MockQuotaManagerProxy(); |
| 417 service_->quota_manager_proxy_ = mock_quota_manager_proxy_; | 417 service_->quota_manager_proxy_ = mock_quota_manager_proxy_; |
| 418 delegate_.reset(new MockStorageDelegate(this)); | 418 delegate_.reset(new MockStorageDelegate(this)); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void TearDownTest() { | 421 void TearDownTest() { |
| 422 DCHECK(base::MessageLoop::current() == io_thread->message_loop()); | 422 DCHECK(io_thread->task_runner()->BelongsToCurrentThread()); |
| 423 storage()->CancelDelegateCallbacks(delegate()); | 423 storage()->CancelDelegateCallbacks(delegate()); |
| 424 group_ = NULL; | 424 group_ = NULL; |
| 425 cache_ = NULL; | 425 cache_ = NULL; |
| 426 cache2_ = NULL; | 426 cache2_ = NULL; |
| 427 mock_quota_manager_proxy_ = NULL; | 427 mock_quota_manager_proxy_ = NULL; |
| 428 delegate_.reset(); | 428 delegate_.reset(); |
| 429 service_.reset(); | 429 service_.reset(); |
| 430 FlushDbThreadTasks(); | 430 FlushDbThreadTasks(); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void TestFinished() { | 433 void TestFinished() { |
| 434 // We unwind the stack prior to finishing up to let stack | 434 // We unwind the stack prior to finishing up to let stack |
| 435 // based objects get deleted. | 435 // based objects get deleted. |
| 436 DCHECK(base::MessageLoop::current() == io_thread->message_loop()); | 436 DCHECK(io_thread->task_runner()->BelongsToCurrentThread()); |
| 437 base::ThreadTaskRunnerHandle::Get()->PostTask( | 437 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 438 FROM_HERE, base::Bind(&AppCacheStorageImplTest::TestFinishedUnwound, | 438 FROM_HERE, base::Bind(&AppCacheStorageImplTest::TestFinishedUnwound, |
| 439 base::Unretained(this))); | 439 base::Unretained(this))); |
| 440 } | 440 } |
| 441 | 441 |
| 442 void TestFinishedUnwound() { | 442 void TestFinishedUnwound() { |
| 443 TearDownTest(); | 443 TearDownTest(); |
| 444 test_finished_event_->Signal(); | 444 test_finished_event_->Signal(); |
| 445 } | 445 } |
| 446 | 446 |
| 447 void PushNextTask(const base::Closure& task) { | 447 void PushNextTask(const base::Closure& task) { |
| 448 task_stack_.push(task); | 448 task_stack_.push(task); |
| 449 } | 449 } |
| 450 | 450 |
| 451 void ScheduleNextTask() { | 451 void ScheduleNextTask() { |
| 452 DCHECK(base::MessageLoop::current() == io_thread->message_loop()); | 452 DCHECK(io_thread->task_runner()->BelongsToCurrentThread()); |
| 453 if (task_stack_.empty()) { | 453 if (task_stack_.empty()) { |
| 454 return; | 454 return; |
| 455 } | 455 } |
| 456 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task_stack_.top()); | 456 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task_stack_.top()); |
| 457 task_stack_.pop(); | 457 task_stack_.pop(); |
| 458 } | 458 } |
| 459 | 459 |
| 460 static void SignalEvent(base::WaitableEvent* event) { | 460 static void SignalEvent(base::WaitableEvent* event) { |
| 461 event->Signal(); | 461 event->Signal(); |
| 462 } | 462 } |
| (...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2029 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); | 2029 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); |
| 2030 } | 2030 } |
| 2031 | 2031 |
| 2032 TEST_F(AppCacheStorageImplTest, Reinitialize3) { | 2032 TEST_F(AppCacheStorageImplTest, Reinitialize3) { |
| 2033 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); | 2033 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); |
| 2034 } | 2034 } |
| 2035 | 2035 |
| 2036 // That's all folks! | 2036 // That's all folks! |
| 2037 | 2037 |
| 2038 } // namespace content | 2038 } // namespace content |
| OLD | NEW |