summaryrefslogtreecommitdiffstats
path: root/src/core/resource_context_qt.cpp
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2018-04-20 13:44:15 +0200
committerMichal Klocek <michal.klocek@qt.io>2018-05-25 08:30:20 +0000
commitaf313cb881610fedb04c9d486597462e6b3c8e12 (patch)
treed0573f374b926c8e7df8f87bcda8eb5754ee68cf /src/core/resource_context_qt.cpp
parent6c319ced199772c89a6c2cee46e551bb36c50360 (diff)
Refactor out ProfileIODataQt
Currently we can crash due to use-after-free of browser context, it happens due to fact that resource context has pointer to browser context which is destroyed on ui thread, while resource context is destroyed on io thread. We used url request getter to maintain objects destruction on io thread. Refactor the code and create profile io data, which will live on io thread, move all the objects currently maintained by url request getter qt to newly created class. Fix destruction order and remove references to browser context from resource context. Compared to url request getter, profile io data is not ref counted class and uses weak pointer factory to handle all "generate" requests. Task-number: QTBUG-67865 Change-Id: Iee4fec854eda1c1600d26e991657d4877cbc966f Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Diffstat (limited to 'src/core/resource_context_qt.cpp')
-rw-r--r--src/core/resource_context_qt.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/core/resource_context_qt.cpp b/src/core/resource_context_qt.cpp
index a906d74c0..8b909812f 100644
--- a/src/core/resource_context_qt.cpp
+++ b/src/core/resource_context_qt.cpp
@@ -39,24 +39,36 @@
#include "resource_context_qt.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
+#include "net/dns/host_resolver.h"
+#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
+#include "profile_io_data_qt.h"
-#include "profile_qt.h"
+#include <qglobal.h>
namespace QtWebEngineCore {
+ResourceContextQt::ResourceContextQt(ProfileIODataQt *io_data)
+ : m_io_data(io_data)
+{
+
+}
+
net::HostResolver *ResourceContextQt::GetHostResolver()
{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
return GetRequestContext()->host_resolver();
}
net::URLRequestContext* ResourceContextQt::GetRequestContext()
{
- Q_ASSERT(context);
+ Q_ASSERT(m_io_data);
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
// FIXME: This is the only remaining use of GetRequestContext(),
// but we are on the wrong thread for calling BrowserContext::GetDefaultStoragePartition
- return context->GetRequestContext()->GetURLRequestContext();
+ return m_io_data->urlRequestContext();
}
} // namespace QtWebEngineCore