| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "net/url_request/url_request_test_job.h" | 7 #include "net/url_request/url_request_test_job.h" |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 void URLRequestTestJob::GetResponseInfo(net::HttpResponseInfo* info) { | 123 void URLRequestTestJob::GetResponseInfo(net::HttpResponseInfo* info) { |
| 124 const std::string kResponseHeaders = StringPrintf( | 124 const std::string kResponseHeaders = StringPrintf( |
| 125 "HTTP/1.1 200 OK%c" | 125 "HTTP/1.1 200 OK%c" |
| 126 "Content-type: text/html%c" | 126 "Content-type: text/html%c" |
| 127 "%c", 0, 0, 0); | 127 "%c", 0, 0, 0); |
| 128 info->headers = new net::HttpResponseHeaders(kResponseHeaders); | 128 info->headers = new net::HttpResponseHeaders(kResponseHeaders); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void URLRequestTestJob::Kill() { | 131 void URLRequestTestJob::Kill() { |
| 132 if (request_) { | 132 stage_ = DONE; |
| 133 // Note that this state will still cause a NotifyDone to get called | 133 URLRequestJob::Kill(); |
| 134 // in ProcessNextOperation, which is required for jobs. | |
| 135 stage_ = ALL_DATA; | |
| 136 pending_jobs.push_back(scoped_refptr<URLRequestTestJob>(this)); | |
| 137 } | |
| 138 } | 134 } |
| 139 | 135 |
| 140 bool URLRequestTestJob::ProcessNextOperation() { | 136 bool URLRequestTestJob::ProcessNextOperation() { |
| 141 switch (stage_) { | 137 switch (stage_) { |
| 142 case WAITING: | 138 case WAITING: |
| 143 stage_ = DATA_AVAILABLE; | 139 stage_ = DATA_AVAILABLE; |
| 144 // OK if ReadRawData wasn't called yet. | 140 // OK if ReadRawData wasn't called yet. |
| 145 if (async_buf_) { | 141 if (async_buf_) { |
| 146 int bytes_read; | 142 int bytes_read; |
| 147 if (!ReadRawData(async_buf_, async_buf_size_, &bytes_read)) | 143 if (!ReadRawData(async_buf_, async_buf_size_, &bytes_read)) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 172 | 168 |
| 173 scoped_refptr<URLRequestTestJob> next_job(pending_jobs[0]); | 169 scoped_refptr<URLRequestTestJob> next_job(pending_jobs[0]); |
| 174 pending_jobs.erase(pending_jobs.begin()); | 170 pending_jobs.erase(pending_jobs.begin()); |
| 175 | 171 |
| 176 if (next_job->ProcessNextOperation()) | 172 if (next_job->ProcessNextOperation()) |
| 177 pending_jobs.push_back(next_job); | 173 pending_jobs.push_back(next_job); |
| 178 | 174 |
| 179 return true; | 175 return true; |
| 180 } | 176 } |
| 181 | 177 |
| OLD | NEW |