OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/url_request/url_request_test_job.h" | 5 #include "net/url_request/url_request_test_job.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 // Must call AdvanceJob() prior to NotifyReadComplete() since that may | 240 // Must call AdvanceJob() prior to NotifyReadComplete() since that may |
241 // delete |this|. | 241 // delete |this|. |
242 AdvanceJob(); | 242 AdvanceJob(); |
243 stage_ = DATA_AVAILABLE; | 243 stage_ = DATA_AVAILABLE; |
244 // OK if ReadRawData wasn't called yet. | 244 // OK if ReadRawData wasn't called yet. |
245 if (async_buf_) { | 245 if (async_buf_) { |
246 int bytes_read; | 246 int bytes_read; |
247 if (!ReadRawData(async_buf_, async_buf_size_, &bytes_read)) | 247 if (!ReadRawData(async_buf_, async_buf_size_, &bytes_read)) |
248 NOTREACHED() << "This should not return false in DATA_AVAILABLE."; | 248 NOTREACHED() << "This should not return false in DATA_AVAILABLE."; |
249 SetStatus(URLRequestStatus()); // clear the io pending flag | 249 SetStatus(URLRequestStatus()); // clear the io pending flag |
250 if (FinalRoundIOPending()) { | |
251 // Make any nested read calls return IO_PENDING. | |
rvargas (doing something else)
2012/05/29 18:13:36
This actually requires nested read calls for it to
Randy Smith (Not in Mondays)
2012/05/30 00:22:32
I renamed the upcall and changed it's semantics to
| |
252 stage_ = WAITING; | |
253 } | |
250 NotifyReadComplete(bytes_read); | 254 NotifyReadComplete(bytes_read); |
255 stage_ = DATA_AVAILABLE; | |
251 } | 256 } |
252 break; | 257 break; |
253 case DATA_AVAILABLE: | 258 case DATA_AVAILABLE: |
254 AdvanceJob(); | 259 AdvanceJob(); |
255 stage_ = ALL_DATA; // done sending data | 260 stage_ = ALL_DATA; // done sending data |
256 break; | 261 break; |
257 case ALL_DATA: | 262 case ALL_DATA: |
258 stage_ = DONE; | 263 stage_ = DONE; |
259 return; | 264 return; |
260 case DONE: | 265 case DONE: |
261 return; | 266 return; |
262 default: | 267 default: |
263 NOTREACHED() << "Invalid stage"; | 268 NOTREACHED() << "Invalid stage"; |
264 return; | 269 return; |
265 } | 270 } |
266 } | 271 } |
267 | 272 |
273 bool URLRequestTestJob::FinalRoundIOPending() { | |
274 return false; | |
275 } | |
276 | |
268 void URLRequestTestJob::AdvanceJob() { | 277 void URLRequestTestJob::AdvanceJob() { |
269 if (auto_advance_) { | 278 if (auto_advance_) { |
270 MessageLoop::current()->PostTask( | 279 MessageLoop::current()->PostTask( |
271 FROM_HERE, base::Bind(&URLRequestTestJob::ProcessNextOperation, | 280 FROM_HERE, base::Bind(&URLRequestTestJob::ProcessNextOperation, |
272 weak_factory_.GetWeakPtr())); | 281 weak_factory_.GetWeakPtr())); |
273 return; | 282 return; |
274 } | 283 } |
275 g_pending_jobs.Get().push_back(this); | 284 g_pending_jobs.Get().push_back(this); |
276 } | 285 } |
277 | 286 |
278 // static | 287 // static |
279 bool URLRequestTestJob::ProcessOnePendingMessage() { | 288 bool URLRequestTestJob::ProcessOnePendingMessage() { |
280 if (g_pending_jobs.Get().empty()) | 289 if (g_pending_jobs.Get().empty()) |
281 return false; | 290 return false; |
282 | 291 |
283 URLRequestTestJob* next_job(g_pending_jobs.Get().front()); | 292 URLRequestTestJob* next_job(g_pending_jobs.Get().front()); |
284 g_pending_jobs.Get().pop_front(); | 293 g_pending_jobs.Get().pop_front(); |
285 | 294 |
286 DCHECK(!next_job->auto_advance()); // auto_advance jobs should be in this q | 295 DCHECK(!next_job->auto_advance()); // auto_advance jobs should be in this q |
287 next_job->ProcessNextOperation(); | 296 next_job->ProcessNextOperation(); |
288 return true; | 297 return true; |
289 } | 298 } |
290 | 299 |
291 } // namespace net | 300 } // namespace net |
OLD | NEW |