summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@theqtcompany.com>2016-01-14 10:42:21 +0100
committerJoerg Bornemann <joerg.bornemann@theqtcompany.com>2016-01-15 08:50:08 +0000
commit7c7ee9a94bd566bd94e1548fb4bb6b5ec774c0d1 (patch)
tree74fa041a98759af730b36aed21cb6e3d98b18439 /src
parenteced172d4ebf573888a14990895f4b6f2ea74a73 (diff)
Have a WeakPtrFactory per thread in URLRequestCustomJob
We must separate WeakPtrs per thread. Otherwise we run into a DCHECK in weak_ptr.cc: "WeakPtrs must be checked on the same sequenced thread.". Done-by: Allan Change-Id: I6ae971b01fb8f8ecda13e50798d6315dcf19d96e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/url_request_custom_job.cpp16
-rw-r--r--src/core/url_request_custom_job.h3
2 files changed, 11 insertions, 8 deletions
diff --git a/src/core/url_request_custom_job.cpp b/src/core/url_request_custom_job.cpp
index 0a81d04a1..1b6f1c767 100644
--- a/src/core/url_request_custom_job.cpp
+++ b/src/core/url_request_custom_job.cpp
@@ -60,7 +60,8 @@ URLRequestCustomJob::URLRequestCustomJob(URLRequest *request, NetworkDelegate *n
, m_schemeHandler(schemeHandler)
, m_error(0)
, m_started(false)
- , m_weakFactory(this)
+ , m_weakFactoryIO(this)
+ , m_weakFactoryUI(this)
{
}
@@ -78,7 +79,7 @@ URLRequestCustomJob::~URLRequestCustomJob()
void URLRequestCustomJob::Start()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, base::Bind(&URLRequestCustomJob::startAsync, m_weakFactory.GetWeakPtr()));
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, base::Bind(&URLRequestCustomJob::startAsync, m_weakFactoryIO.GetWeakPtr()));
}
void URLRequestCustomJob::Kill()
@@ -93,7 +94,8 @@ void URLRequestCustomJob::Kill()
if (m_device && m_device->isOpen())
m_device->close();
m_device = 0;
- m_weakFactory.InvalidateWeakPtrs();
+ m_weakFactoryIO.InvalidateWeakPtrs();
+ m_weakFactoryUI.InvalidateWeakPtrs();
URLRequestJob::Kill();
}
@@ -151,7 +153,7 @@ void URLRequestCustomJob::setReplyDevice(QIODevice *device)
m_device->open(QIODevice::ReadOnly);
if (m_device && m_device->isReadable())
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyStarted, m_weakFactory.GetWeakPtr()));
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyStarted, m_weakFactoryUI.GetWeakPtr()));
else
fail(ERR_INVALID_URL);
}
@@ -179,7 +181,7 @@ void URLRequestCustomJob::redirect(const GURL &url)
QMutexLocker lock(&m_mutex);
m_redirect = url;
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyStarted, m_weakFactory.GetWeakPtr()));
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyStarted, m_weakFactoryUI.GetWeakPtr()));
}
void URLRequestCustomJob::abort()
@@ -189,7 +191,7 @@ void URLRequestCustomJob::abort()
if (m_device && m_device->isOpen())
m_device->close();
m_device = 0;
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyCanceled, m_weakFactory.GetWeakPtr()));
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyCanceled, m_weakFactoryUI.GetWeakPtr()));
}
void URLRequestCustomJob::notifyCanceled()
@@ -214,7 +216,7 @@ void URLRequestCustomJob::fail(int error)
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
QMutexLocker lock(&m_mutex);
m_error = error;
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyFailure, m_weakFactory.GetWeakPtr()));
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyFailure, m_weakFactoryUI.GetWeakPtr()));
}
void URLRequestCustomJob::notifyFailure()
diff --git a/src/core/url_request_custom_job.h b/src/core/url_request_custom_job.h
index a994c467a..be5cae43c 100644
--- a/src/core/url_request_custom_job.h
+++ b/src/core/url_request_custom_job.h
@@ -87,7 +87,8 @@ private:
int m_error;
GURL m_redirect;
bool m_started;
- base::WeakPtrFactory<URLRequestCustomJob> m_weakFactory;
+ base::WeakPtrFactory<URLRequestCustomJob> m_weakFactoryIO;
+ base::WeakPtrFactory<URLRequestCustomJob> m_weakFactoryUI;
friend class URLRequestCustomJobDelegate;