| 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/bind.h" |
| 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" |
| 8 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 9 #include "base/pickle.h" | 12 #include "base/pickle.h" |
| 10 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 12 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
| 13 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 14 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
| 15 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
| 16 #include "net/url_request/url_request_error_job.h" | 19 #include "net/url_request/url_request_error_job.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 208 |
| 206 void TearDownTest() { | 209 void TearDownTest() { |
| 207 DCHECK(MessageLoop::current() == io_thread_->message_loop()); | 210 DCHECK(MessageLoop::current() == io_thread_->message_loop()); |
| 208 net::URLRequest::Deprecated::RegisterProtocolFactory( | 211 net::URLRequest::Deprecated::RegisterProtocolFactory( |
| 209 "http", orig_http_factory_); | 212 "http", orig_http_factory_); |
| 210 orig_http_factory_ = NULL; | 213 orig_http_factory_ = NULL; |
| 211 request_.reset(); | 214 request_.reset(); |
| 212 url_request_delegate_.reset(); | 215 url_request_delegate_.reset(); |
| 213 DCHECK(!mock_factory_job_); | 216 DCHECK(!mock_factory_job_); |
| 214 | 217 |
| 215 while (!task_stack_.empty()) { | 218 while (!task_stack_.empty()) |
| 216 delete task_stack_.top().first; | |
| 217 task_stack_.pop(); | 219 task_stack_.pop(); |
| 218 } | 220 |
| 219 reader_.reset(); | 221 reader_.reset(); |
| 220 read_buffer_ = NULL; | 222 read_buffer_ = NULL; |
| 221 read_info_buffer_ = NULL; | 223 read_info_buffer_ = NULL; |
| 222 writer_.reset(); | 224 writer_.reset(); |
| 223 write_buffer_ = NULL; | 225 write_buffer_ = NULL; |
| 224 write_info_buffer_ = NULL; | 226 write_info_buffer_ = NULL; |
| 225 storage_delegate_.reset(); | 227 storage_delegate_.reset(); |
| 226 service_.reset(); | 228 service_.reset(); |
| 227 } | 229 } |
| 228 | 230 |
| 229 void TestFinished() { | 231 void TestFinished() { |
| 230 // We unwind the stack prior to finishing up to let stack | 232 // We unwind the stack prior to finishing up to let stack |
| 231 // based objects get deleted. | 233 // based objects get deleted. |
| 232 DCHECK(MessageLoop::current() == io_thread_->message_loop()); | 234 DCHECK(MessageLoop::current() == io_thread_->message_loop()); |
| 233 MessageLoop::current()->PostTask(FROM_HERE, | 235 MessageLoop::current()->PostTask(FROM_HERE, |
| 234 NewRunnableMethod( | 236 base::Bind(&AppCacheURLRequestJobTest::TestFinishedUnwound, |
| 235 this, &AppCacheURLRequestJobTest::TestFinishedUnwound)); | 237 base::Unretained(this))); |
| 236 } | 238 } |
| 237 | 239 |
| 238 void TestFinishedUnwound() { | 240 void TestFinishedUnwound() { |
| 239 TearDownTest(); | 241 TearDownTest(); |
| 240 test_finished_event_->Signal(); | 242 test_finished_event_->Signal(); |
| 241 } | 243 } |
| 242 | 244 |
| 243 void PushNextTask(Task* task) { | 245 void PushNextTask(const base::Closure& task) { |
| 244 task_stack_.push(std::pair<Task*, bool>(task, false)); | 246 task_stack_.push(std::pair<base::Closure, bool>(task, false)); |
| 245 } | 247 } |
| 246 | 248 |
| 247 void PushNextTaskAsImmediate(Task* task) { | 249 void PushNextTaskAsImmediate(const base::Closure& task) { |
| 248 task_stack_.push(std::pair<Task*, bool>(task, true)); | 250 task_stack_.push(std::pair<base::Closure, bool>(task, true)); |
| 249 } | 251 } |
| 250 | 252 |
| 251 void ScheduleNextTask() { | 253 void ScheduleNextTask() { |
| 252 DCHECK(MessageLoop::current() == io_thread_->message_loop()); | 254 DCHECK(MessageLoop::current() == io_thread_->message_loop()); |
| 253 if (task_stack_.empty()) { | 255 if (task_stack_.empty()) { |
| 254 TestFinished(); | 256 TestFinished(); |
| 255 return; | 257 return; |
| 256 } | 258 } |
| 257 scoped_ptr<Task> task(task_stack_.top().first); | 259 base::Closure task =task_stack_.top().first; |
| 258 bool immediate = task_stack_.top().second; | 260 bool immediate = task_stack_.top().second; |
| 259 task_stack_.pop(); | 261 task_stack_.pop(); |
| 260 if (immediate) | 262 if (immediate) |
| 261 task->Run(); | 263 task.Run(); |
| 262 else | 264 else |
| 263 MessageLoop::current()->PostTask(FROM_HERE, task.release()); | 265 MessageLoop::current()->PostTask(FROM_HERE, task); |
| 264 } | 266 } |
| 265 | 267 |
| 266 // Wrappers to call AppCacheResponseReader/Writer Read and Write methods | 268 // Wrappers to call AppCacheResponseReader/Writer Read and Write methods |
| 267 | 269 |
| 268 void WriteBasicResponse() { | 270 void WriteBasicResponse() { |
| 269 scoped_refptr<IOBuffer> body(new WrappedIOBuffer(kHttpBasicBody)); | 271 scoped_refptr<IOBuffer> body(new WrappedIOBuffer(kHttpBasicBody)); |
| 270 std::string raw_headers(kHttpBasicHeaders, arraysize(kHttpBasicHeaders)); | 272 std::string raw_headers(kHttpBasicHeaders, arraysize(kHttpBasicHeaders)); |
| 271 WriteResponse(MakeHttpResponseInfo(raw_headers), body, | 273 WriteResponse(MakeHttpResponseInfo(raw_headers), body, |
| 272 strlen(kHttpBasicBody)); | 274 strlen(kHttpBasicBody)); |
| 273 } | 275 } |
| 274 | 276 |
| 275 void WriteResponse(net::HttpResponseInfo* head, | 277 void WriteResponse(net::HttpResponseInfo* head, |
| 276 IOBuffer* body, int body_len) { | 278 IOBuffer* body, int body_len) { |
| 277 DCHECK(body); | 279 DCHECK(body); |
| 278 scoped_refptr<IOBuffer> body_ref(body); | 280 scoped_refptr<IOBuffer> body_ref(body); |
| 279 PushNextTask(NewRunnableMethod( | 281 PushNextTask(base::Bind(&AppCacheURLRequestJobTest::WriteResponseBody, |
| 280 this, &AppCacheURLRequestJobTest::WriteResponseBody, | 282 base::Unretained(this), body_ref, body_len)); |
| 281 body_ref, body_len)); | |
| 282 WriteResponseHead(head); | 283 WriteResponseHead(head); |
| 283 } | 284 } |
| 284 | 285 |
| 285 void WriteResponseHead(net::HttpResponseInfo* head) { | 286 void WriteResponseHead(net::HttpResponseInfo* head) { |
| 286 EXPECT_FALSE(writer_->IsWritePending()); | 287 EXPECT_FALSE(writer_->IsWritePending()); |
| 287 expected_write_result_ = GetHttpResponseInfoSize(head); | 288 expected_write_result_ = GetHttpResponseInfoSize(head); |
| 288 write_info_buffer_ = new HttpResponseInfoIOBuffer(head); | 289 write_info_buffer_ = new HttpResponseInfoIOBuffer(head); |
| 289 writer_->WriteInfo(write_info_buffer_, &write_info_callback_); | 290 writer_->WriteInfo(write_info_buffer_, &write_info_callback_); |
| 290 } | 291 } |
| 291 | 292 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 EXPECT_EQ(kEntry.types(), job->entry().types()); | 450 EXPECT_EQ(kEntry.types(), job->entry().types()); |
| 450 EXPECT_EQ(kEntry.response_id(), job->entry().response_id()); | 451 EXPECT_EQ(kEntry.response_id(), job->entry().response_id()); |
| 451 | 452 |
| 452 TestFinished(); | 453 TestFinished(); |
| 453 } | 454 } |
| 454 | 455 |
| 455 // DeliverNetworkResponse -------------------------------------------------- | 456 // DeliverNetworkResponse -------------------------------------------------- |
| 456 | 457 |
| 457 void DeliverNetworkResponse() { | 458 void DeliverNetworkResponse() { |
| 458 // This test has async steps. | 459 // This test has async steps. |
| 459 PushNextTask(NewRunnableMethod( | 460 PushNextTask( |
| 460 this, &AppCacheURLRequestJobTest::VerifyDeliverNetworkResponse)); | 461 base::Bind(&AppCacheURLRequestJobTest::VerifyDeliverNetworkResponse, |
| 462 base::Unretained(this))); |
| 461 | 463 |
| 462 AppCacheStorage* storage = service_->storage(); | 464 AppCacheStorage* storage = service_->storage(); |
| 463 request_.reset( | 465 request_.reset( |
| 464 new net::URLRequest(GURL("http://blah/"), url_request_delegate_.get())); | 466 new net::URLRequest(GURL("http://blah/"), url_request_delegate_.get())); |
| 465 | 467 |
| 466 // Setup to create an AppCacheURLRequestJob with orders to deliver | 468 // Setup to create an AppCacheURLRequestJob with orders to deliver |
| 467 // a network response. | 469 // a network response. |
| 468 mock_factory_job_ = new AppCacheURLRequestJob(request_.get(), storage); | 470 mock_factory_job_ = new AppCacheURLRequestJob(request_.get(), storage); |
| 469 mock_factory_job_->DeliverNetworkResponse(); | 471 mock_factory_job_->DeliverNetworkResponse(); |
| 470 EXPECT_TRUE(mock_factory_job_->is_delivering_network_response()); | 472 EXPECT_TRUE(mock_factory_job_->is_delivering_network_response()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 481 void VerifyDeliverNetworkResponse() { | 483 void VerifyDeliverNetworkResponse() { |
| 482 EXPECT_EQ(request_->status().error(), | 484 EXPECT_EQ(request_->status().error(), |
| 483 net::ERR_INTERNET_DISCONNECTED); | 485 net::ERR_INTERNET_DISCONNECTED); |
| 484 TestFinished(); | 486 TestFinished(); |
| 485 } | 487 } |
| 486 | 488 |
| 487 // DeliverErrorResponse -------------------------------------------------- | 489 // DeliverErrorResponse -------------------------------------------------- |
| 488 | 490 |
| 489 void DeliverErrorResponse() { | 491 void DeliverErrorResponse() { |
| 490 // This test has async steps. | 492 // This test has async steps. |
| 491 PushNextTask(NewRunnableMethod( | 493 PushNextTask( |
| 492 this, &AppCacheURLRequestJobTest::VerifyDeliverErrorResponse)); | 494 base::Bind(&AppCacheURLRequestJobTest::VerifyDeliverErrorResponse, |
| 495 base::Unretained(this))); |
| 493 | 496 |
| 494 AppCacheStorage* storage = service_->storage(); | 497 AppCacheStorage* storage = service_->storage(); |
| 495 request_.reset( | 498 request_.reset( |
| 496 new net::URLRequest(GURL("http://blah/"), url_request_delegate_.get())); | 499 new net::URLRequest(GURL("http://blah/"), url_request_delegate_.get())); |
| 497 | 500 |
| 498 // Setup to create an AppCacheURLRequestJob with orders to deliver | 501 // Setup to create an AppCacheURLRequestJob with orders to deliver |
| 499 // a network response. | 502 // a network response. |
| 500 mock_factory_job_ = new AppCacheURLRequestJob(request_.get(), storage); | 503 mock_factory_job_ = new AppCacheURLRequestJob(request_.get(), storage); |
| 501 mock_factory_job_->DeliverErrorResponse(); | 504 mock_factory_job_->DeliverErrorResponse(); |
| 502 EXPECT_TRUE(mock_factory_job_->is_delivering_error_response()); | 505 EXPECT_TRUE(mock_factory_job_->is_delivering_error_response()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 518 // DeliverSmallAppCachedResponse -------------------------------------- | 521 // DeliverSmallAppCachedResponse -------------------------------------- |
| 519 // "Small" being small enough to read completely in a single | 522 // "Small" being small enough to read completely in a single |
| 520 // request->Read call. | 523 // request->Read call. |
| 521 | 524 |
| 522 void DeliverSmallAppCachedResponse() { | 525 void DeliverSmallAppCachedResponse() { |
| 523 // This test has several async steps. | 526 // This test has several async steps. |
| 524 // 1. Write a small response to response storage. | 527 // 1. Write a small response to response storage. |
| 525 // 2. Use net::URLRequest to retrieve it. | 528 // 2. Use net::URLRequest to retrieve it. |
| 526 // 3. Verify we received what we expected to receive. | 529 // 3. Verify we received what we expected to receive. |
| 527 | 530 |
| 528 PushNextTask(NewRunnableMethod( | 531 PushNextTask(base::Bind( |
| 529 this, &AppCacheURLRequestJobTest::VerifyDeliverSmallAppCachedResponse)); | 532 &AppCacheURLRequestJobTest::VerifyDeliverSmallAppCachedResponse, |
| 530 PushNextTask(NewRunnableMethod( | 533 base::Unretained(this))); |
| 531 this, &AppCacheURLRequestJobTest::RequestAppCachedResource, false)); | 534 PushNextTask( |
| 535 base::Bind(&AppCacheURLRequestJobTest::RequestAppCachedResource, |
| 536 base::Unretained(this), false)); |
| 532 | 537 |
| 533 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); | 538 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); |
| 534 written_response_id_ = writer_->response_id(); | 539 written_response_id_ = writer_->response_id(); |
| 535 WriteBasicResponse(); | 540 WriteBasicResponse(); |
| 536 // Continues async | 541 // Continues async |
| 537 } | 542 } |
| 538 | 543 |
| 539 void RequestAppCachedResource(bool start_after_delivery_orders) { | 544 void RequestAppCachedResource(bool start_after_delivery_orders) { |
| 540 AppCacheStorage* storage = service_->storage(); | 545 AppCacheStorage* storage = service_->storage(); |
| 541 request_.reset( | 546 request_.reset( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 591 |
| 587 // DeliverLargeAppCachedResponse -------------------------------------- | 592 // DeliverLargeAppCachedResponse -------------------------------------- |
| 588 // "Large" enough to require multiple calls to request->Read to complete. | 593 // "Large" enough to require multiple calls to request->Read to complete. |
| 589 | 594 |
| 590 void DeliverLargeAppCachedResponse() { | 595 void DeliverLargeAppCachedResponse() { |
| 591 // This test has several async steps. | 596 // This test has several async steps. |
| 592 // 1. Write a large response to response storage. | 597 // 1. Write a large response to response storage. |
| 593 // 2. Use net::URLRequest to retrieve it. | 598 // 2. Use net::URLRequest to retrieve it. |
| 594 // 3. Verify we received what we expected to receive. | 599 // 3. Verify we received what we expected to receive. |
| 595 | 600 |
| 596 PushNextTask(NewRunnableMethod( | 601 PushNextTask(base::Bind( |
| 597 this, &AppCacheURLRequestJobTest::VerifyDeliverLargeAppCachedResponse)); | 602 &AppCacheURLRequestJobTest::VerifyDeliverLargeAppCachedResponse, |
| 598 PushNextTask(NewRunnableMethod( | 603 base::Unretained(this))); |
| 599 this, &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); | 604 PushNextTask(base::Bind( |
| 605 &AppCacheURLRequestJobTest::RequestAppCachedResource, |
| 606 base::Unretained(this), true)); |
| 600 | 607 |
| 601 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); | 608 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); |
| 602 written_response_id_ = writer_->response_id(); | 609 written_response_id_ = writer_->response_id(); |
| 603 WriteLargeResponse(); | 610 WriteLargeResponse(); |
| 604 // Continues async | 611 // Continues async |
| 605 } | 612 } |
| 606 | 613 |
| 607 void WriteLargeResponse() { | 614 void WriteLargeResponse() { |
| 608 // 3, 1k blocks | 615 // 3, 1k blocks |
| 609 static const char kHttpHeaders[] = | 616 static const char kHttpHeaders[] = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 628 TestFinished(); | 635 TestFinished(); |
| 629 } | 636 } |
| 630 | 637 |
| 631 // DeliverPartialResponse -------------------------------------- | 638 // DeliverPartialResponse -------------------------------------- |
| 632 | 639 |
| 633 void DeliverPartialResponse() { | 640 void DeliverPartialResponse() { |
| 634 // This test has several async steps. | 641 // This test has several async steps. |
| 635 // 1. Write a small response to response storage. | 642 // 1. Write a small response to response storage. |
| 636 // 2. Use net::URLRequest to retrieve it a subset using a range request | 643 // 2. Use net::URLRequest to retrieve it a subset using a range request |
| 637 // 3. Verify we received what we expected to receive. | 644 // 3. Verify we received what we expected to receive. |
| 638 PushNextTask(NewRunnableMethod( | 645 PushNextTask(base::Bind( |
| 639 this, &AppCacheURLRequestJobTest::VerifyDeliverPartialResponse)); | 646 &AppCacheURLRequestJobTest::VerifyDeliverPartialResponse, |
| 640 PushNextTask(NewRunnableMethod( | 647 base::Unretained(this))); |
| 641 this, &AppCacheURLRequestJobTest::MakeRangeRequest)); | 648 PushNextTask(base::Bind( |
| 649 &AppCacheURLRequestJobTest::MakeRangeRequest, base::Unretained(this))); |
| 642 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); | 650 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); |
| 643 written_response_id_ = writer_->response_id(); | 651 written_response_id_ = writer_->response_id(); |
| 644 WriteBasicResponse(); | 652 WriteBasicResponse(); |
| 645 // Continues async | 653 // Continues async |
| 646 } | 654 } |
| 647 | 655 |
| 648 void MakeRangeRequest() { | 656 void MakeRangeRequest() { |
| 649 AppCacheStorage* storage = service_->storage(); | 657 AppCacheStorage* storage = service_->storage(); |
| 650 request_.reset( | 658 request_.reset( |
| 651 new net::URLRequest(GURL("http://blah/"), url_request_delegate_.get())); | 659 new net::URLRequest(GURL("http://blah/"), url_request_delegate_.get())); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 } | 701 } |
| 694 | 702 |
| 695 // CancelRequest -------------------------------------- | 703 // CancelRequest -------------------------------------- |
| 696 | 704 |
| 697 void CancelRequest() { | 705 void CancelRequest() { |
| 698 // This test has several async steps. | 706 // This test has several async steps. |
| 699 // 1. Write a large response to response storage. | 707 // 1. Write a large response to response storage. |
| 700 // 2. Use net::URLRequest to retrieve it. | 708 // 2. Use net::URLRequest to retrieve it. |
| 701 // 3. Cancel the request after data starts coming in. | 709 // 3. Cancel the request after data starts coming in. |
| 702 | 710 |
| 703 PushNextTask(NewRunnableMethod( | 711 PushNextTask(base::Bind( |
| 704 this, &AppCacheURLRequestJobTest::VerifyCancel)); | 712 &AppCacheURLRequestJobTest::VerifyCancel, base::Unretained(this))); |
| 705 PushNextTask(NewRunnableMethod( | 713 PushNextTask(base::Bind( |
| 706 this, &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); | 714 &AppCacheURLRequestJobTest::RequestAppCachedResource, |
| 715 base::Unretained(this), true)); |
| 707 | 716 |
| 708 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); | 717 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); |
| 709 written_response_id_ = writer_->response_id(); | 718 written_response_id_ = writer_->response_id(); |
| 710 WriteLargeResponse(); | 719 WriteLargeResponse(); |
| 711 | 720 |
| 712 url_request_delegate_->kill_after_amount_received_ = kBlockSize; | 721 url_request_delegate_->kill_after_amount_received_ = kBlockSize; |
| 713 url_request_delegate_->kill_with_io_pending_ = false; | 722 url_request_delegate_->kill_with_io_pending_ = false; |
| 714 // Continues async | 723 // Continues async |
| 715 } | 724 } |
| 716 | 725 |
| 717 void VerifyCancel() { | 726 void VerifyCancel() { |
| 718 EXPECT_EQ(net::URLRequestStatus::CANCELED, | 727 EXPECT_EQ(net::URLRequestStatus::CANCELED, |
| 719 request_->status().status()); | 728 request_->status().status()); |
| 720 TestFinished(); | 729 TestFinished(); |
| 721 } | 730 } |
| 722 | 731 |
| 723 // CancelRequestWithIOPending -------------------------------------- | 732 // CancelRequestWithIOPending -------------------------------------- |
| 724 | 733 |
| 725 void CancelRequestWithIOPending() { | 734 void CancelRequestWithIOPending() { |
| 726 // This test has several async steps. | 735 // This test has several async steps. |
| 727 // 1. Write a large response to response storage. | 736 // 1. Write a large response to response storage. |
| 728 // 2. Use net::URLRequest to retrieve it. | 737 // 2. Use net::URLRequest to retrieve it. |
| 729 // 3. Cancel the request after data starts coming in. | 738 // 3. Cancel the request after data starts coming in. |
| 730 | 739 |
| 731 PushNextTask(NewRunnableMethod( | 740 PushNextTask(base::Bind( |
| 732 this, &AppCacheURLRequestJobTest::VerifyCancel)); | 741 &AppCacheURLRequestJobTest::VerifyCancel, base::Unretained(this))); |
| 733 PushNextTask(NewRunnableMethod( | 742 PushNextTask(base::Bind( |
| 734 this, &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); | 743 &AppCacheURLRequestJobTest::RequestAppCachedResource, |
| 744 base::Unretained(this), true)); |
| 735 | 745 |
| 736 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); | 746 writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); |
| 737 written_response_id_ = writer_->response_id(); | 747 written_response_id_ = writer_->response_id(); |
| 738 WriteLargeResponse(); | 748 WriteLargeResponse(); |
| 739 | 749 |
| 740 url_request_delegate_->kill_after_amount_received_ = kBlockSize; | 750 url_request_delegate_->kill_after_amount_received_ = kBlockSize; |
| 741 url_request_delegate_->kill_with_io_pending_ = true; | 751 url_request_delegate_->kill_with_io_pending_ = true; |
| 742 // Continues async | 752 // Continues async |
| 743 } | 753 } |
| 744 | 754 |
| 745 | 755 |
| 746 // Data members -------------------------------------------------------- | 756 // Data members -------------------------------------------------------- |
| 747 | 757 |
| 748 scoped_ptr<base::WaitableEvent> test_finished_event_; | 758 scoped_ptr<base::WaitableEvent> test_finished_event_; |
| 749 scoped_ptr<MockStorageDelegate> storage_delegate_; | 759 scoped_ptr<MockStorageDelegate> storage_delegate_; |
| 750 scoped_ptr<MockAppCacheService> service_; | 760 scoped_ptr<MockAppCacheService> service_; |
| 751 std::stack<std::pair<Task*, bool> > task_stack_; | 761 std::stack<std::pair<base::Closure, bool> > task_stack_; |
| 752 | 762 |
| 753 scoped_ptr<AppCacheResponseReader> reader_; | 763 scoped_ptr<AppCacheResponseReader> reader_; |
| 754 scoped_refptr<HttpResponseInfoIOBuffer> read_info_buffer_; | 764 scoped_refptr<HttpResponseInfoIOBuffer> read_info_buffer_; |
| 755 scoped_refptr<IOBuffer> read_buffer_; | 765 scoped_refptr<IOBuffer> read_buffer_; |
| 756 int expected_read_result_; | 766 int expected_read_result_; |
| 757 net::OldCompletionCallbackImpl<AppCacheURLRequestJobTest> read_callback_; | 767 net::OldCompletionCallbackImpl<AppCacheURLRequestJobTest> read_callback_; |
| 758 net::OldCompletionCallbackImpl<AppCacheURLRequestJobTest> read_info_callback_; | 768 net::OldCompletionCallbackImpl<AppCacheURLRequestJobTest> read_info_callback_; |
| 759 bool should_delete_reader_in_completion_callback_; | 769 bool should_delete_reader_in_completion_callback_; |
| 760 int reader_deletion_count_down_; | 770 int reader_deletion_count_down_; |
| 761 bool read_callback_was_called_; | 771 bool read_callback_was_called_; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 | 823 |
| 814 TEST_F(AppCacheURLRequestJobTest, CancelRequest) { | 824 TEST_F(AppCacheURLRequestJobTest, CancelRequest) { |
| 815 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequest); | 825 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequest); |
| 816 } | 826 } |
| 817 | 827 |
| 818 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) { | 828 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) { |
| 819 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending); | 829 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending); |
| 820 } | 830 } |
| 821 | 831 |
| 822 } // namespace appcache | 832 } // namespace appcache |
| 823 | |
| 824 // AppCacheURLRequestJobTest is expected to always live longer than the | |
| 825 // runnable methods. This lets us call NewRunnableMethod on its instances. | |
| 826 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheURLRequestJobTest); | |
| OLD | NEW |