| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 NetworkDelegate* network_delegate, | 82 NetworkDelegate* network_delegate, |
| 83 const std::string& scheme) { | 83 const std::string& scheme) { |
| 84 return new URLRequestTestJob(request, network_delegate); | 84 return new URLRequestTestJob(request, network_delegate); |
| 85 } | 85 } |
| 86 | 86 |
| 87 URLRequestTestJob::URLRequestTestJob(URLRequest* request, | 87 URLRequestTestJob::URLRequestTestJob(URLRequest* request, |
| 88 NetworkDelegate* network_delegate) | 88 NetworkDelegate* network_delegate) |
| 89 : URLRequestJob(request, network_delegate), | 89 : URLRequestJob(request, network_delegate), |
| 90 auto_advance_(false), | 90 auto_advance_(false), |
| 91 stage_(WAITING), | 91 stage_(WAITING), |
| 92 priority_(request->priority()), |
| 92 offset_(0), | 93 offset_(0), |
| 93 async_buf_(NULL), | 94 async_buf_(NULL), |
| 94 async_buf_size_(0), | 95 async_buf_size_(0), |
| 95 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 96 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 96 } | 97 } |
| 97 | 98 |
| 98 URLRequestTestJob::URLRequestTestJob(URLRequest* request, | 99 URLRequestTestJob::URLRequestTestJob(URLRequest* request, |
| 99 NetworkDelegate* network_delegate, | 100 NetworkDelegate* network_delegate, |
| 100 bool auto_advance) | 101 bool auto_advance) |
| 101 : URLRequestJob(request, network_delegate), | 102 : URLRequestJob(request, network_delegate), |
| 102 auto_advance_(auto_advance), | 103 auto_advance_(auto_advance), |
| 103 stage_(WAITING), | 104 stage_(WAITING), |
| 105 priority_(request->priority()), |
| 104 offset_(0), | 106 offset_(0), |
| 105 async_buf_(NULL), | 107 async_buf_(NULL), |
| 106 async_buf_size_(0), | 108 async_buf_size_(0), |
| 107 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 109 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 108 } | 110 } |
| 109 | 111 |
| 110 URLRequestTestJob::URLRequestTestJob(URLRequest* request, | 112 URLRequestTestJob::URLRequestTestJob(URLRequest* request, |
| 111 NetworkDelegate* network_delegate, | 113 NetworkDelegate* network_delegate, |
| 112 const std::string& response_headers, | 114 const std::string& response_headers, |
| 113 const std::string& response_data, | 115 const std::string& response_data, |
| 114 bool auto_advance) | 116 bool auto_advance) |
| 115 : URLRequestJob(request, network_delegate), | 117 : URLRequestJob(request, network_delegate), |
| 116 auto_advance_(auto_advance), | 118 auto_advance_(auto_advance), |
| 117 stage_(WAITING), | 119 stage_(WAITING), |
| 120 priority_(request->priority()), |
| 118 response_headers_(new HttpResponseHeaders(response_headers)), | 121 response_headers_(new HttpResponseHeaders(response_headers)), |
| 119 response_data_(response_data), | 122 response_data_(response_data), |
| 120 offset_(0), | 123 offset_(0), |
| 121 async_buf_(NULL), | 124 async_buf_(NULL), |
| 122 async_buf_size_(0), | 125 async_buf_size_(0), |
| 123 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 126 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 124 } | 127 } |
| 125 | 128 |
| 126 URLRequestTestJob::~URLRequestTestJob() { | 129 URLRequestTestJob::~URLRequestTestJob() { |
| 127 g_pending_jobs.Get().erase( | 130 g_pending_jobs.Get().erase( |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 222 |
| 220 std::string value; | 223 std::string value; |
| 221 if (!response_headers_->IsRedirect(&value)) | 224 if (!response_headers_->IsRedirect(&value)) |
| 222 return false; | 225 return false; |
| 223 | 226 |
| 224 *location = request_->url().Resolve(value); | 227 *location = request_->url().Resolve(value); |
| 225 *http_status_code = response_headers_->response_code(); | 228 *http_status_code = response_headers_->response_code(); |
| 226 return true; | 229 return true; |
| 227 } | 230 } |
| 228 | 231 |
| 232 void URLRequestTestJob::SetPriority(RequestPriority priority) { |
| 233 priority_ = priority; |
| 234 } |
| 229 | 235 |
| 230 void URLRequestTestJob::Kill() { | 236 void URLRequestTestJob::Kill() { |
| 231 stage_ = DONE; | 237 stage_ = DONE; |
| 232 URLRequestJob::Kill(); | 238 URLRequestJob::Kill(); |
| 233 weak_factory_.InvalidateWeakPtrs(); | 239 weak_factory_.InvalidateWeakPtrs(); |
| 234 g_pending_jobs.Get().erase( | 240 g_pending_jobs.Get().erase( |
| 235 std::remove( | 241 std::remove( |
| 236 g_pending_jobs.Get().begin(), g_pending_jobs.Get().end(), this), | 242 g_pending_jobs.Get().begin(), g_pending_jobs.Get().end(), this), |
| 237 g_pending_jobs.Get().end()); | 243 g_pending_jobs.Get().end()); |
| 238 } | 244 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 300 |
| 295 URLRequestTestJob* next_job(g_pending_jobs.Get().front()); | 301 URLRequestTestJob* next_job(g_pending_jobs.Get().front()); |
| 296 g_pending_jobs.Get().pop_front(); | 302 g_pending_jobs.Get().pop_front(); |
| 297 | 303 |
| 298 DCHECK(!next_job->auto_advance()); // auto_advance jobs should be in this q | 304 DCHECK(!next_job->auto_advance()); // auto_advance jobs should be in this q |
| 299 next_job->ProcessNextOperation(); | 305 next_job->ProcessNextOperation(); |
| 300 return true; | 306 return true; |
| 301 } | 307 } |
| 302 | 308 |
| 303 } // namespace net | 309 } // namespace net |
| OLD | NEW |