int buf_size,
int *bytes_read) {
DCHECK(real_job_);
- // The ReadRawData is a protected method.
- switch (type_) {
- case REQUEST_STRING_JOB:
- return static_cast<URLRequestStringJob*>(real_job_.get())->
- ReadRawData(buf, buf_size, bytes_read);
- case REQUEST_FILE_JOB:
- return static_cast<net::URLRequestFileJob*>(real_job_.get())->
- ReadRawData(buf, buf_size, bytes_read);
- default:
- return net::URLRequestJob::ReadRawData(buf, buf_size, bytes_read);
- }
+ return real_job_->ReadRawData(buf, buf_size, bytes_read);
}
bool AdapterRequestJob::IsRedirectResponse(GURL* location,
void AdapterRequestJob::CreateErrorJobAndStart(int error_code) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- type_ = REQUEST_ERROR_JOB;
real_job_ = new net::URLRequestErrorJob(
request(), network_delegate(), error_code);
real_job_->Start();
const std::string& data) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- type_ = REQUEST_STRING_JOB;
real_job_ = new URLRequestStringJob(
request(), network_delegate(), mime_type, charset, data);
real_job_->Start();
void AdapterRequestJob::CreateFileJobAndStart(const base::FilePath& path) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- type_ = REQUEST_FILE_JOB;
real_job_ = new net::URLRequestFileJob(request(), network_delegate(), path);
real_job_->Start();
}
void CreateJobFromProtocolHandlerAndStart();
private:
- enum JOB_TYPE {
- REQUEST_ERROR_JOB,
- REQUEST_STRING_JOB,
- REQUEST_FILE_JOB,
- };
-
+ // The delegated request job.
scoped_refptr<net::URLRequestJob> real_job_;
- // Type of the delegated url request job.
- JOB_TYPE type_;
-
// Default protocol handler.
ProtocolHandler* protocol_handler_;