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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 URLRequestTestJob::URLRequestTestJob(URLRequest* request) | 51 URLRequestTestJob::URLRequestTestJob(URLRequest* request) |
52 : URLRequestJob(request), | 52 : URLRequestJob(request), |
53 stage_(WAITING), | 53 stage_(WAITING), |
54 offset_(0), | 54 offset_(0), |
55 async_buf_(NULL), | 55 async_buf_(NULL), |
56 async_buf_size_(0) { | 56 async_buf_size_(0) { |
57 } | 57 } |
58 | 58 |
59 // Force the response to set a reasonable MIME type | 59 // Force the response to set a reasonable MIME type |
60 bool URLRequestTestJob::GetMimeType(std::string* mime_type) { | 60 bool URLRequestTestJob::GetMimeType(std::string* mime_type) const { |
61 DCHECK(mime_type); | 61 DCHECK(mime_type); |
62 *mime_type = "text/html"; | 62 *mime_type = "text/html"; |
63 return true; | 63 return true; |
64 } | 64 } |
65 | 65 |
66 void URLRequestTestJob::Start() { | 66 void URLRequestTestJob::Start() { |
67 // Start reading asynchronously so that all error reporting and data | 67 // Start reading asynchronously so that all error reporting and data |
68 // callbacks happen as they would for network requests. | 68 // callbacks happen as they would for network requests. |
69 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 69 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
70 this, &URLRequestTestJob::StartAsync)); | 70 this, &URLRequestTestJob::StartAsync)); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 scoped_refptr<URLRequestTestJob> next_job(pending_jobs[0]); | 170 scoped_refptr<URLRequestTestJob> next_job(pending_jobs[0]); |
171 pending_jobs.erase(pending_jobs.begin()); | 171 pending_jobs.erase(pending_jobs.begin()); |
172 | 172 |
173 if (next_job->ProcessNextOperation()) | 173 if (next_job->ProcessNextOperation()) |
174 pending_jobs.push_back(next_job); | 174 pending_jobs.push_back(next_job); |
175 | 175 |
176 return true; | 176 return true; |
177 } | 177 } |
178 | 178 |
OLD | NEW |