Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Side by Side Diff: net/url_request/url_request_test_job.cc

Issue 5607004: net: Remove typedef net::URLRequestJob URLRequestJob; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 2 Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_simple_job.cc ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(net::URLRequest* request, 73 net::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(net::URLRequest* request) 78 URLRequestTestJob::URLRequestTestJob(net::URLRequest* request)
79 : URLRequestJob(request), 79 : net::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(net::URLRequest* request, 87 URLRequestTestJob::URLRequestTestJob(net::URLRequest* request,
88 bool auto_advance) 88 bool auto_advance)
89 : URLRequestJob(request), 89 : net::URLRequestJob(request),
90 auto_advance_(auto_advance), 90 auto_advance_(auto_advance),
91 stage_(WAITING), 91 stage_(WAITING),
92 offset_(0), 92 offset_(0),
93 async_buf_(NULL), 93 async_buf_(NULL),
94 async_buf_size_(0) { 94 async_buf_size_(0) {
95 } 95 }
96 96
97 URLRequestTestJob::URLRequestTestJob(net::URLRequest* request, 97 URLRequestTestJob::URLRequestTestJob(net::URLRequest* request,
98 const std::string& response_headers, 98 const std::string& response_headers,
99 const std::string& response_data, 99 const std::string& response_data,
100 bool auto_advance) 100 bool auto_advance)
101 : URLRequestJob(request), 101 : net::URLRequestJob(request),
102 auto_advance_(auto_advance), 102 auto_advance_(auto_advance),
103 stage_(WAITING), 103 stage_(WAITING),
104 response_headers_(new net::HttpResponseHeaders(response_headers)), 104 response_headers_(new net::HttpResponseHeaders(response_headers)),
105 response_data_(response_data), 105 response_data_(response_data),
106 offset_(0), 106 offset_(0),
107 async_buf_(NULL), 107 async_buf_(NULL),
108 async_buf_size_(0) { 108 async_buf_size_(0) {
109 } 109 }
110 110
111 URLRequestTestJob::~URLRequestTestJob() { 111 URLRequestTestJob::~URLRequestTestJob() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return false; 200 return false;
201 201
202 *location = request_->url().Resolve(value); 202 *location = request_->url().Resolve(value);
203 *http_status_code = response_headers_->response_code(); 203 *http_status_code = response_headers_->response_code();
204 return true; 204 return true;
205 } 205 }
206 206
207 207
208 void URLRequestTestJob::Kill() { 208 void URLRequestTestJob::Kill() {
209 stage_ = DONE; 209 stage_ = DONE;
210 URLRequestJob::Kill(); 210 net::URLRequestJob::Kill();
211 } 211 }
212 212
213 void URLRequestTestJob::ProcessNextOperation() { 213 void URLRequestTestJob::ProcessNextOperation() {
214 switch (stage_) { 214 switch (stage_) {
215 case WAITING: 215 case WAITING:
216 stage_ = DATA_AVAILABLE; 216 stage_ = DATA_AVAILABLE;
217 // OK if ReadRawData wasn't called yet. 217 // OK if ReadRawData wasn't called yet.
218 if (async_buf_) { 218 if (async_buf_) {
219 int bytes_read; 219 int bytes_read;
220 if (!ReadRawData(async_buf_, async_buf_size_, &bytes_read)) 220 if (!ReadRawData(async_buf_, async_buf_size_, &bytes_read))
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (pending_jobs.empty()) 252 if (pending_jobs.empty())
253 return false; 253 return false;
254 254
255 scoped_refptr<URLRequestTestJob> next_job(pending_jobs[0]); 255 scoped_refptr<URLRequestTestJob> next_job(pending_jobs[0]);
256 pending_jobs.erase(pending_jobs.begin()); 256 pending_jobs.erase(pending_jobs.begin());
257 257
258 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
259 next_job->ProcessNextOperation(); 259 next_job->ProcessNextOperation();
260 return true; 260 return true;
261 } 261 }
OLDNEW
« no previous file with comments | « net/url_request/url_request_simple_job.cc ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698