| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stack> | 5 #include <stack> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 void RunTestOnIOThread(Method method) { | 180 void RunTestOnIOThread(Method method) { |
| 181 test_finished_event_ .reset(new base::WaitableEvent(false, false)); | 181 test_finished_event_ .reset(new base::WaitableEvent(false, false)); |
| 182 io_thread_->message_loop()->PostTask( | 182 io_thread_->message_loop()->PostTask( |
| 183 FROM_HERE, new WrapperTask<Method>(this, method)); | 183 FROM_HERE, new WrapperTask<Method>(this, method)); |
| 184 test_finished_event_->Wait(); | 184 test_finished_event_->Wait(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void SetUpTest() { | 187 void SetUpTest() { |
| 188 DCHECK(MessageLoop::current() == io_thread_->message_loop()); | 188 DCHECK(MessageLoop::current() == io_thread_->message_loop()); |
| 189 DCHECK(task_stack_.empty()); | 189 DCHECK(task_stack_.empty()); |
| 190 orig_http_factory_ = net::URLRequest::RegisterProtocolFactory( | 190 orig_http_factory_ = net::URLRequest::Deprecated::RegisterProtocolFactory( |
| 191 "http", MockHttpJobFactory); | 191 "http", MockHttpJobFactory); |
| 192 url_request_delegate_.reset(new MockURLRequestDelegate(this)); | 192 url_request_delegate_.reset(new MockURLRequestDelegate(this)); |
| 193 storage_delegate_.reset(new MockStorageDelegate(this)); | 193 storage_delegate_.reset(new MockStorageDelegate(this)); |
| 194 service_.reset(new MockAppCacheService()); | 194 service_.reset(new MockAppCacheService()); |
| 195 expected_read_result_ = 0; | 195 expected_read_result_ = 0; |
| 196 expected_write_result_ = 0; | 196 expected_write_result_ = 0; |
| 197 written_response_id_ = 0; | 197 written_response_id_ = 0; |
| 198 should_delete_reader_in_completion_callback_ = false; | 198 should_delete_reader_in_completion_callback_ = false; |
| 199 should_delete_writer_in_completion_callback_ = false; | 199 should_delete_writer_in_completion_callback_ = false; |
| 200 reader_deletion_count_down_ = 0; | 200 reader_deletion_count_down_ = 0; |
| 201 writer_deletion_count_down_ = 0; | 201 writer_deletion_count_down_ = 0; |
| 202 read_callback_was_called_ = false; | 202 read_callback_was_called_ = false; |
| 203 write_callback_was_called_ = false; | 203 write_callback_was_called_ = false; |
| 204 } | 204 } |
| 205 | 205 |
| 206 void TearDownTest() { | 206 void TearDownTest() { |
| 207 DCHECK(MessageLoop::current() == io_thread_->message_loop()); | 207 DCHECK(MessageLoop::current() == io_thread_->message_loop()); |
| 208 net::URLRequest::RegisterProtocolFactory("http", orig_http_factory_); | 208 net::URLRequest::Deprecated::RegisterProtocolFactory( |
| 209 "http", orig_http_factory_); |
| 209 orig_http_factory_ = NULL; | 210 orig_http_factory_ = NULL; |
| 210 request_.reset(); | 211 request_.reset(); |
| 211 url_request_delegate_.reset(); | 212 url_request_delegate_.reset(); |
| 212 DCHECK(!mock_factory_job_); | 213 DCHECK(!mock_factory_job_); |
| 213 | 214 |
| 214 while (!task_stack_.empty()) { | 215 while (!task_stack_.empty()) { |
| 215 delete task_stack_.top().first; | 216 delete task_stack_.top().first; |
| 216 task_stack_.pop(); | 217 task_stack_.pop(); |
| 217 } | 218 } |
| 218 reader_.reset(); | 219 reader_.reset(); |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 | 814 |
| 814 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) { | 815 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) { |
| 815 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending); | 816 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending); |
| 816 } | 817 } |
| 817 | 818 |
| 818 } // namespace appcache | 819 } // namespace appcache |
| 819 | 820 |
| 820 // AppCacheURLRequestJobTest is expected to always live longer than the | 821 // AppCacheURLRequestJobTest is expected to always live longer than the |
| 821 // runnable methods. This lets us call NewRunnableMethod on its instances. | 822 // runnable methods. This lets us call NewRunnableMethod on its instances. |
| 822 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheURLRequestJobTest); | 823 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheURLRequestJobTest); |
| OLD | NEW |