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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 // static getter for error response headers | 64 // static getter for error response headers |
65 std::string URLRequestTestJob::test_error_headers() { | 65 std::string URLRequestTestJob::test_error_headers() { |
66 const char headers[] = | 66 const char headers[] = |
67 "HTTP/1.1 500 BOO HOO\0" | 67 "HTTP/1.1 500 BOO HOO\0" |
68 "\0"; | 68 "\0"; |
69 return std::string(headers, arraysize(headers)); | 69 return std::string(headers, arraysize(headers)); |
70 } | 70 } |
71 | 71 |
72 // static | 72 // static |
73 URLRequestJob* URLRequestTestJob::Factory(URLRequest* request, | 73 URLRequestJob* URLRequestTestJob::Factory(net::URLRequest* request, |
74 const std::string& scheme) { | 74 const std::string& scheme) { |
75 return new URLRequestTestJob(request); | 75 return new URLRequestTestJob(request); |
76 } | 76 } |
77 | 77 |
78 URLRequestTestJob::URLRequestTestJob(URLRequest* request) | 78 URLRequestTestJob::URLRequestTestJob(net::URLRequest* request) |
79 : URLRequestJob(request), | 79 : URLRequestJob(request), |
80 auto_advance_(false), | 80 auto_advance_(false), |
81 stage_(WAITING), | 81 stage_(WAITING), |
82 offset_(0), | 82 offset_(0), |
83 async_buf_(NULL), | 83 async_buf_(NULL), |
84 async_buf_size_(0) { | 84 async_buf_size_(0) { |
85 } | 85 } |
86 | 86 |
87 URLRequestTestJob::URLRequestTestJob(URLRequest* request, bool auto_advance) | 87 URLRequestTestJob::URLRequestTestJob(net::URLRequest* request, |
| 88 bool auto_advance) |
88 : URLRequestJob(request), | 89 : URLRequestJob(request), |
89 auto_advance_(auto_advance), | 90 auto_advance_(auto_advance), |
90 stage_(WAITING), | 91 stage_(WAITING), |
91 offset_(0), | 92 offset_(0), |
92 async_buf_(NULL), | 93 async_buf_(NULL), |
93 async_buf_size_(0) { | 94 async_buf_size_(0) { |
94 } | 95 } |
95 | 96 |
96 URLRequestTestJob::URLRequestTestJob(URLRequest* request, | 97 URLRequestTestJob::URLRequestTestJob(net::URLRequest* request, |
97 const std::string& response_headers, | 98 const std::string& response_headers, |
98 const std::string& response_data, | 99 const std::string& response_data, |
99 bool auto_advance) | 100 bool auto_advance) |
100 : URLRequestJob(request), | 101 : URLRequestJob(request), |
101 auto_advance_(auto_advance), | 102 auto_advance_(auto_advance), |
102 stage_(WAITING), | 103 stage_(WAITING), |
103 response_headers_(new net::HttpResponseHeaders(response_headers)), | 104 response_headers_(new net::HttpResponseHeaders(response_headers)), |
104 response_data_(response_data), | 105 response_data_(response_data), |
105 offset_(0), | 106 offset_(0), |
106 async_buf_(NULL), | 107 async_buf_(NULL), |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 if (pending_jobs.empty()) | 252 if (pending_jobs.empty()) |
252 return false; | 253 return false; |
253 | 254 |
254 scoped_refptr<URLRequestTestJob> next_job(pending_jobs[0]); | 255 scoped_refptr<URLRequestTestJob> next_job(pending_jobs[0]); |
255 pending_jobs.erase(pending_jobs.begin()); | 256 pending_jobs.erase(pending_jobs.begin()); |
256 | 257 |
257 DCHECK(!next_job->auto_advance()); // auto_advance jobs should be in this q | 258 DCHECK(!next_job->auto_advance()); // auto_advance jobs should be in this q |
258 next_job->ProcessNextOperation(); | 259 next_job->ProcessNextOperation(); |
259 return true; | 260 return true; |
260 } | 261 } |
OLD | NEW |