Make ReadRawData a public member, so there is no need to detect types.
This commit is contained in:
parent
2a462cc2b7
commit
d8cd3d78ff
3 changed files with 3 additions and 24 deletions
|
@ -38,17 +38,7 @@ bool AdapterRequestJob::ReadRawData(net::IOBuffer* buf,
|
||||||
int buf_size,
|
int buf_size,
|
||||||
int *bytes_read) {
|
int *bytes_read) {
|
||||||
DCHECK(real_job_);
|
DCHECK(real_job_);
|
||||||
// The ReadRawData is a protected method.
|
return real_job_->ReadRawData(buf, buf_size, bytes_read);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AdapterRequestJob::IsRedirectResponse(GURL* location,
|
bool AdapterRequestJob::IsRedirectResponse(GURL* location,
|
||||||
|
@ -79,7 +69,6 @@ base::WeakPtr<AdapterRequestJob> AdapterRequestJob::GetWeakPtr() {
|
||||||
void AdapterRequestJob::CreateErrorJobAndStart(int error_code) {
|
void AdapterRequestJob::CreateErrorJobAndStart(int error_code) {
|
||||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
||||||
|
|
||||||
type_ = REQUEST_ERROR_JOB;
|
|
||||||
real_job_ = new net::URLRequestErrorJob(
|
real_job_ = new net::URLRequestErrorJob(
|
||||||
request(), network_delegate(), error_code);
|
request(), network_delegate(), error_code);
|
||||||
real_job_->Start();
|
real_job_->Start();
|
||||||
|
@ -90,7 +79,6 @@ void AdapterRequestJob::CreateStringJobAndStart(const std::string& mime_type,
|
||||||
const std::string& data) {
|
const std::string& data) {
|
||||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
||||||
|
|
||||||
type_ = REQUEST_STRING_JOB;
|
|
||||||
real_job_ = new URLRequestStringJob(
|
real_job_ = new URLRequestStringJob(
|
||||||
request(), network_delegate(), mime_type, charset, data);
|
request(), network_delegate(), mime_type, charset, data);
|
||||||
real_job_->Start();
|
real_job_->Start();
|
||||||
|
@ -99,7 +87,6 @@ void AdapterRequestJob::CreateStringJobAndStart(const std::string& mime_type,
|
||||||
void AdapterRequestJob::CreateFileJobAndStart(const base::FilePath& path) {
|
void AdapterRequestJob::CreateFileJobAndStart(const base::FilePath& path) {
|
||||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
||||||
|
|
||||||
type_ = REQUEST_FILE_JOB;
|
|
||||||
real_job_ = new net::URLRequestFileJob(request(), network_delegate(), path);
|
real_job_ = new net::URLRequestFileJob(request(), network_delegate(), path);
|
||||||
real_job_->Start();
|
real_job_->Start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,17 +52,9 @@ class AdapterRequestJob : public net::URLRequestJob {
|
||||||
void CreateJobFromProtocolHandlerAndStart();
|
void CreateJobFromProtocolHandlerAndStart();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum JOB_TYPE {
|
// The delegated request job.
|
||||||
REQUEST_ERROR_JOB,
|
|
||||||
REQUEST_STRING_JOB,
|
|
||||||
REQUEST_FILE_JOB,
|
|
||||||
};
|
|
||||||
|
|
||||||
scoped_refptr<net::URLRequestJob> real_job_;
|
scoped_refptr<net::URLRequestJob> real_job_;
|
||||||
|
|
||||||
// Type of the delegated url request job.
|
|
||||||
JOB_TYPE type_;
|
|
||||||
|
|
||||||
// Default protocol handler.
|
// Default protocol handler.
|
||||||
ProtocolHandler* protocol_handler_;
|
ProtocolHandler* protocol_handler_;
|
||||||
|
|
||||||
|
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit c62f91a82e5426996d149dcb63259f967a7e78fb
|
Subproject commit 3cb2782cff77081df2788c68948163dea53530d5
|
Loading…
Add table
Reference in a new issue