The request should go through UI thread.

This commit is contained in:
Cheng Zhao 2013-08-24 19:46:38 +08:00
parent f63661256f
commit b7c9f8ba1c

View file

@ -41,9 +41,10 @@ class AdapterRequestJob : public net::URLRequestJob {
protected:
virtual void Start() OVERRIDE {
DCHECK(!real_job_);
real_job_ = new net::URLRequestErrorJob(
request(), network_delegate(), net::ERR_NOT_IMPLEMENTED);
real_job_->Start();
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
base::Bind(&AdapterRequestJob::GetJobTypeInUI, base::Unretained(this)));
}
virtual void Kill() OVERRIDE {
@ -94,9 +95,19 @@ class AdapterRequestJob : public net::URLRequestJob {
};
void GetJobTypeInUI() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
base::Bind(&AdapterRequestJob::CreateJobAndStart,
base::Unretained(this)));
}
void CreateJobAndStart() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
real_job_ = new net::URLRequestErrorJob(
request(), network_delegate(), net::ERR_NOT_IMPLEMENTED);
real_job_->Start();
}
scoped_refptr<net::URLRequestJob> real_job_;