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

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

Issue 1170623003: Revert "content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/location.h"
8 #include "base/single_thread_task_runner.h"
9 #include "base/stl_util.h" 7 #include "base/stl_util.h"
10 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
11 #include "base/thread_task_runner_handle.h"
12 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
13 #include "content/browser/appcache/appcache_group.h" 10 #include "content/browser/appcache/appcache_group.h"
14 #include "content/browser/appcache/appcache_host.h" 11 #include "content/browser/appcache/appcache_host.h"
15 #include "content/browser/appcache/appcache_response.h" 12 #include "content/browser/appcache/appcache_response.h"
16 #include "content/browser/appcache/appcache_update_job.h" 13 #include "content/browser/appcache/appcache_update_job.h"
17 #include "content/browser/appcache/mock_appcache_service.h" 14 #include "content/browser/appcache/mock_appcache_service.h"
18 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
19 #include "net/http/http_response_headers.h" 16 #include "net/http/http_response_headers.h"
20 #include "net/url_request/url_request_error_job.h" 17 #include "net/url_request/url_request_error_job.h"
21 #include "net/url_request/url_request_job_factory_impl.h" 18 #include "net/url_request/url_request_job_factory_impl.h"
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 io_thread_.reset(new IOThread("AppCacheUpdateJob IO test thread")); 596 io_thread_.reset(new IOThread("AppCacheUpdateJob IO test thread"));
600 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); 597 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
601 io_thread_->StartWithOptions(options); 598 io_thread_->StartWithOptions(options);
602 } 599 }
603 600
604 // Use a separate IO thread to run a test. Thread will be destroyed 601 // Use a separate IO thread to run a test. Thread will be destroyed
605 // when it goes out of scope. 602 // when it goes out of scope.
606 template <class Method> 603 template <class Method>
607 void RunTestOnIOThread(Method method) { 604 void RunTestOnIOThread(Method method) {
608 event_.reset(new base::WaitableEvent(false, false)); 605 event_.reset(new base::WaitableEvent(false, false));
609 io_thread_->task_runner()->PostTask( 606 io_thread_->message_loop()->PostTask(
610 FROM_HERE, base::Bind(method, base::Unretained(this))); 607 FROM_HERE, base::Bind(method, base::Unretained(this)));
611 608
612 // Wait until task is done before exiting the test. 609 // Wait until task is done before exiting the test.
613 event_->Wait(); 610 event_->Wait();
614 } 611 }
615 612
616 void StartCacheAttemptTest() { 613 void StartCacheAttemptTest() {
617 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent()); 614 ASSERT_TRUE(base::MessageLoopForIO::IsCurrent());
618 615
619 MakeService(); 616 MakeService();
(...skipping 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 2976
2980 void OnUpdateComplete(AppCacheGroup* group) override { 2977 void OnUpdateComplete(AppCacheGroup* group) override {
2981 ASSERT_EQ(group_.get(), group); 2978 ASSERT_EQ(group_.get(), group);
2982 protect_newest_cache_ = group->newest_complete_cache(); 2979 protect_newest_cache_ = group->newest_complete_cache();
2983 UpdateFinished(); 2980 UpdateFinished();
2984 } 2981 }
2985 2982
2986 void UpdateFinished() { 2983 void UpdateFinished() {
2987 // We unwind the stack prior to finishing up to let stack-based objects 2984 // We unwind the stack prior to finishing up to let stack-based objects
2988 // get deleted. 2985 // get deleted.
2989 base::ThreadTaskRunnerHandle::Get()->PostTask( 2986 base::MessageLoop::current()->PostTask(
2990 FROM_HERE, base::Bind(&AppCacheUpdateJobTest::UpdateFinishedUnwound, 2987 FROM_HERE,
2991 base::Unretained(this))); 2988 base::Bind(&AppCacheUpdateJobTest::UpdateFinishedUnwound,
2989 base::Unretained(this)));
2992 } 2990 }
2993 2991
2994 void UpdateFinishedUnwound() { 2992 void UpdateFinishedUnwound() {
2995 EXPECT_EQ(AppCacheGroup::IDLE, group_->update_status()); 2993 EXPECT_EQ(AppCacheGroup::IDLE, group_->update_status());
2996 EXPECT_TRUE(group_->update_job() == NULL); 2994 EXPECT_TRUE(group_->update_job() == NULL);
2997 if (do_checks_after_update_finished_) 2995 if (do_checks_after_update_finished_)
2998 VerifyExpectations(); 2996 VerifyExpectations();
2999 2997
3000 // Clean up everything that was created on the IO thread. 2998 // Clean up everything that was created on the IO thread.
3001 protect_newest_cache_ = NULL; 2999 protect_newest_cache_ = NULL;
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
3646 3644
3647 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { 3645 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) {
3648 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); 3646 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest);
3649 } 3647 }
3650 3648
3651 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { 3649 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) {
3652 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); 3650 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest);
3653 } 3651 }
3654 3652
3655 } // namespace content 3653 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_storage_impl_unittest.cc ('k') | content/browser/appcache/appcache_url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698