| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 io_thread.reset(NULL); | 393 io_thread.reset(NULL); |
| 394 db_thread.reset(NULL); | 394 db_thread.reset(NULL); |
| 395 } | 395 } |
| 396 | 396 |
| 397 // Test harness -------------------------------------------------- | 397 // Test harness -------------------------------------------------- |
| 398 | 398 |
| 399 AppCacheStorageImplTest() { request_delegate_.set_quit_on_complete(false); } | 399 AppCacheStorageImplTest() { request_delegate_.set_quit_on_complete(false); } |
| 400 | 400 |
| 401 template <class Method> | 401 template <class Method> |
| 402 void RunTestOnIOThread(Method method) { | 402 void RunTestOnIOThread(Method method) { |
| 403 test_finished_event_ .reset(new base::WaitableEvent(false, false)); | 403 test_finished_event_.reset(new base::WaitableEvent( |
| 404 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 405 base::WaitableEvent::InitialState::NOT_SIGNALED)); |
| 404 io_thread->task_runner()->PostTask( | 406 io_thread->task_runner()->PostTask( |
| 405 FROM_HERE, base::Bind(&AppCacheStorageImplTest::MethodWrapper<Method>, | 407 FROM_HERE, base::Bind(&AppCacheStorageImplTest::MethodWrapper<Method>, |
| 406 base::Unretained(this), method)); | 408 base::Unretained(this), method)); |
| 407 test_finished_event_->Wait(); | 409 test_finished_event_->Wait(); |
| 408 } | 410 } |
| 409 | 411 |
| 410 void SetUpTest() { | 412 void SetUpTest() { |
| 411 DCHECK(base::MessageLoop::current() == io_thread->message_loop()); | 413 DCHECK(base::MessageLoop::current() == io_thread->message_loop()); |
| 412 service_.reset(new AppCacheServiceImpl(NULL)); | 414 service_.reset(new AppCacheServiceImpl(NULL)); |
| 413 service_->Initialize(base::FilePath(), db_thread->task_runner(), NULL); | 415 service_->Initialize(base::FilePath(), db_thread->task_runner(), NULL); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 task_stack_.pop(); | 457 task_stack_.pop(); |
| 456 } | 458 } |
| 457 | 459 |
| 458 static void SignalEvent(base::WaitableEvent* event) { | 460 static void SignalEvent(base::WaitableEvent* event) { |
| 459 event->Signal(); | 461 event->Signal(); |
| 460 } | 462 } |
| 461 | 463 |
| 462 void FlushDbThreadTasks() { | 464 void FlushDbThreadTasks() { |
| 463 // We pump a task thru the db thread to ensure any tasks previously | 465 // We pump a task thru the db thread to ensure any tasks previously |
| 464 // scheduled on that thread have been performed prior to return. | 466 // scheduled on that thread have been performed prior to return. |
| 465 base::WaitableEvent event(false, false); | 467 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 468 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 466 db_thread->task_runner()->PostTask( | 469 db_thread->task_runner()->PostTask( |
| 467 FROM_HERE, base::Bind(&AppCacheStorageImplTest::SignalEvent, &event)); | 470 FROM_HERE, base::Bind(&AppCacheStorageImplTest::SignalEvent, &event)); |
| 468 event.Wait(); | 471 event.Wait(); |
| 469 } | 472 } |
| 470 | 473 |
| 471 // LoadCache_Miss ---------------------------------------------------- | 474 // LoadCache_Miss ---------------------------------------------------- |
| 472 | 475 |
| 473 void LoadCache_Miss() { | 476 void LoadCache_Miss() { |
| 474 // Attempt to load a cache that doesn't exist. Should | 477 // Attempt to load a cache that doesn't exist. Should |
| 475 // complete asynchronously. | 478 // complete asynchronously. |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2026 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); | 2029 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); |
| 2027 } | 2030 } |
| 2028 | 2031 |
| 2029 TEST_F(AppCacheStorageImplTest, Reinitialize3) { | 2032 TEST_F(AppCacheStorageImplTest, Reinitialize3) { |
| 2030 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); | 2033 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); |
| 2031 } | 2034 } |
| 2032 | 2035 |
| 2033 // That's all folks! | 2036 // That's all folks! |
| 2034 | 2037 |
| 2035 } // namespace content | 2038 } // namespace content |
| OLD | NEW |