| 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_update_job.h" | 5 #include "content/browser/appcache/appcache_update_job.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 tested_manifest_path_override_(NULL) { | 618 tested_manifest_path_override_(NULL) { |
| 619 io_thread_.reset(new IOThread("AppCacheUpdateJob IO test thread")); | 619 io_thread_.reset(new IOThread("AppCacheUpdateJob IO test thread")); |
| 620 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); | 620 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); |
| 621 io_thread_->StartWithOptions(options); | 621 io_thread_->StartWithOptions(options); |
| 622 } | 622 } |
| 623 | 623 |
| 624 // Use a separate IO thread to run a test. Thread will be destroyed | 624 // Use a separate IO thread to run a test. Thread will be destroyed |
| 625 // when it goes out of scope. | 625 // when it goes out of scope. |
| 626 template <class Method> | 626 template <class Method> |
| 627 void RunTestOnIOThread(Method method) { | 627 void RunTestOnIOThread(Method method) { |
| 628 event_.reset(new base::WaitableEvent(false, false)); | 628 event_.reset(new base::WaitableEvent( |
| 629 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 630 base::WaitableEvent::InitialState::NOT_SIGNALED)); |
| 629 io_thread_->task_runner()->PostTask( | 631 io_thread_->task_runner()->PostTask( |
| 630 FROM_HERE, base::Bind(method, base::Unretained(this))); | 632 FROM_HERE, base::Bind(method, base::Unretained(this))); |
| 631 | 633 |
| 632 // Wait until task is done before exiting the test. | 634 // Wait until task is done before exiting the test. |
| 633 event_->Wait(); | 635 event_->Wait(); |
| 634 } | 636 } |
| 635 | 637 |
| 636 void StartCacheAttemptTest() { | 638 void StartCacheAttemptTest() { |
| 637 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); | 639 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); |
| 638 | 640 |
| (...skipping 3084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3723 | 3725 |
| 3724 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { | 3726 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { |
| 3725 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); | 3727 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); |
| 3726 } | 3728 } |
| 3727 | 3729 |
| 3728 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { | 3730 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { |
| 3729 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); | 3731 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); |
| 3730 } | 3732 } |
| 3731 | 3733 |
| 3732 } // namespace content | 3734 } // namespace content |
| OLD | NEW |