From cfddf26f78e521809a17d4fab5bb7cfe18d3f08e Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 11 Jan 2018 11:24:48 +0100 Subject: Change BrowserContextAdapter to be QPointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BrowserContextAdapter is living and accessed only in UI thread, remove QSharedPointer usage and change QWebengineProfile to use QPointer. Prevent BrowserContextAdapter outliving WebEngineContext by setting globalObject as a parent to track WebEngineContext destruction. This commits tries to simplify the life cycle handling of browser context, it removes profile shutdown methods and QWebEngineBrowserContext, which was used to track profile destruction. Task-number: QTBUG-62147 Change-Id: I79f2c38a123cd053e3a59f4900afbdc759a396fe Reviewed-by: Qt CI Bot Reviewed-by: Jüri Valdmann Reviewed-by: Michael Brüning --- src/core/api/core_api.pro | 2 - src/core/api/qwebenginebrowsercontext.cpp | 73 ---------------------- src/core/api/qwebenginebrowsercontext_p.h | 83 -------------------------- src/core/browser_context_adapter.cpp | 15 ++--- src/core/browser_context_adapter.h | 6 +- src/core/browser_context_qt.cpp | 7 ++- src/core/net/custom_protocol_handler.cpp | 2 +- src/core/net/custom_protocol_handler.h | 6 +- src/core/net/url_request_context_getter_qt.cpp | 62 +++++++++---------- src/core/net/url_request_context_getter_qt.h | 13 ++-- src/core/net/url_request_custom_job.cpp | 2 +- src/core/net/url_request_custom_job.h | 4 +- src/core/net/url_request_custom_job_proxy.cpp | 11 ++-- src/core/net/url_request_custom_job_proxy.h | 6 +- src/core/web_contents_adapter.cpp | 8 +-- src/core/web_contents_adapter_client.h | 2 +- src/core/web_contents_delegate_qt.cpp | 2 +- src/core/web_engine_context.cpp | 17 +++--- src/core/web_engine_context.h | 7 ++- src/webengine/api/qquickwebengineprofile.cpp | 28 +++++---- src/webengine/api/qquickwebengineprofile_p.h | 7 +-- src/webengine/api/qquickwebengineview.cpp | 6 +- src/webengine/api/qquickwebengineview_p_p.h | 5 +- src/webenginewidgets/api/qwebenginepage.cpp | 2 +- src/webenginewidgets/api/qwebenginepage_p.h | 2 +- src/webenginewidgets/api/qwebengineprofile.cpp | 50 +++++++++++----- src/webenginewidgets/api/qwebengineprofile_p.h | 8 ++- 27 files changed, 154 insertions(+), 282 deletions(-) delete mode 100644 src/core/api/qwebenginebrowsercontext.cpp delete mode 100644 src/core/api/qwebenginebrowsercontext_p.h diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro index 632034a9d..727d82b8a 100644 --- a/src/core/api/core_api.pro +++ b/src/core/api/core_api.pro @@ -33,7 +33,6 @@ HEADERS = \ qwebenginecallback_p.h \ qtwebenginecoreglobal.h \ qtwebenginecoreglobal_p.h \ - qwebenginebrowsercontext_p.h \ qwebenginecookiestore.h \ qwebenginecookiestore_p.h \ qwebenginehttprequest.h \ @@ -47,7 +46,6 @@ HEADERS = \ SOURCES = \ qtwebenginecoreglobal.cpp \ - qwebenginebrowsercontext.cpp \ qwebenginecookiestore.cpp \ qwebenginehttprequest.cpp \ qwebenginequotarequest.cpp \ diff --git a/src/core/api/qwebenginebrowsercontext.cpp b/src/core/api/qwebenginebrowsercontext.cpp deleted file mode 100644 index c3ab16460..000000000 --- a/src/core/api/qwebenginebrowsercontext.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwebenginebrowsercontext_p.h" - -#include "browser_context_adapter.h" -#include - -QT_BEGIN_NAMESPACE - -QWebEngineBrowserContext::QWebEngineBrowserContext(QSharedPointer browserContext, - QtWebEngineCore::BrowserContextAdapterClient *profile) - : QObject(QtWebEngineCore::BrowserContextAdapter::globalQObjectRoot()) - , browserContextRef(browserContext) - , m_profile(profile) -{ - browserContextRef->addClient(m_profile); -} - -QWebEngineBrowserContext::~QWebEngineBrowserContext() -{ - if (m_profile) - shutdown(); -} - -void QWebEngineBrowserContext::shutdown() -{ - Q_ASSERT(m_profile); - // In the case the user sets this profile as the parent of the interceptor - // it can be deleted before the browser-context still referencing it is. - browserContextRef->setRequestInterceptor(nullptr); - browserContextRef->removeClient(m_profile); - m_profile = 0; - deleteLater(); -} - -QT_END_NAMESPACE diff --git a/src/core/api/qwebenginebrowsercontext_p.h b/src/core/api/qwebenginebrowsercontext_p.h deleted file mode 100644 index 713ab730e..000000000 --- a/src/core/api/qwebenginebrowsercontext_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWEBENGINEBROWSERCONTEXT_P_H -#define QWEBENGINEBROWSERCONTEXT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// -#include "qtwebenginecoreglobal_p.h" - -#include -#include - -namespace QtWebEngineCore { -class BrowserContextAdapter; -class BrowserContextAdapterClient; -} - -QT_BEGIN_NAMESPACE - -// This is a wrapper class for BrowserContextAdapter. BrowserContextAdapter must be destructed before WebEngineContext -// is destructed. Therefore access it via the QWebEngineBrowserContext which parent is the WebEngineContext::globalQObject. -// This guarantees the destruction together with the WebEngineContext. -class QWEBENGINE_PRIVATE_EXPORT QWebEngineBrowserContext : public QObject { -public: - QWebEngineBrowserContext(QSharedPointer browserContext, QtWebEngineCore::BrowserContextAdapterClient *profile); - ~QWebEngineBrowserContext(); - - void shutdown(); - - QSharedPointer browserContextRef; - -private: - QtWebEngineCore::BrowserContextAdapterClient *m_profile; -}; - -QT_END_NAMESPACE - -#endif // QWEBENGINEBROWSERCONTEXT_P_H diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index b0f244393..75f936f21 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -77,7 +77,8 @@ inline QString buildLocationFromStandardPath(const QString &standardPath, const namespace QtWebEngineCore { BrowserContextAdapter::BrowserContextAdapter(bool offTheRecord) - : m_offTheRecord(offTheRecord) + : QObject(BrowserContextAdapter::globalQObjectRoot()) + , m_offTheRecord(offTheRecord) , m_browserContext(new BrowserContextQt(this)) , m_httpCacheType(DiskHttpCache) , m_persistentCookiesPolicy(AllowPersistentCookies) @@ -96,7 +97,8 @@ BrowserContextAdapter::BrowserContextAdapter(bool offTheRecord) } BrowserContextAdapter::BrowserContextAdapter(const QString &storageName) - : m_name(storageName) + : QObject(BrowserContextAdapter::globalQObjectRoot()) + , m_name(storageName) , m_offTheRecord(false) , m_browserContext(new BrowserContextQt(this)) , m_httpCacheType(DiskHttpCache) @@ -117,12 +119,7 @@ BrowserContextAdapter::BrowserContextAdapter(const QString &storageName) BrowserContextAdapter::~BrowserContextAdapter() { - Q_ASSERT(!m_downloadManagerDelegate); m_browserContext->ShutdownStoragePartitions(); -} - -void BrowserContextAdapter::shutdown() -{ if (m_downloadManagerDelegate) { m_browserContext->GetDownloadManager(m_browserContext.data())->Shutdown(); m_downloadManagerDelegate.reset(); @@ -202,8 +199,6 @@ void BrowserContextAdapter::addClient(BrowserContextAdapterClient *adapterClient void BrowserContextAdapter::removeClient(BrowserContextAdapterClient *adapterClient) { m_clients.removeOne(adapterClient); - if (m_clients.isEmpty() && this != WebEngineContext::current()->m_defaultBrowserContext.data()) - shutdown(); } void BrowserContextAdapter::cancelDownload(quint32 downloadId) @@ -221,7 +216,7 @@ void BrowserContextAdapter::resumeDownload(quint32 downloadId) downloadManagerDelegate()->resumeDownload(downloadId); } -QSharedPointer BrowserContextAdapter::defaultContext() +BrowserContextAdapter *BrowserContextAdapter::defaultContext() { return WebEngineContext::current()->defaultBrowserContext(); } diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h index b647bc30c..e13c62a38 100644 --- a/src/core/browser_context_adapter.h +++ b/src/core/browser_context_adapter.h @@ -63,18 +63,16 @@ class DownloadManagerDelegateQt; class UserResourceControllerHost; class VisitedLinksManagerQt; -class QWEBENGINE_EXPORT BrowserContextAdapter : public QEnableSharedFromThis +class QWEBENGINE_EXPORT BrowserContextAdapter : public QObject { public: explicit BrowserContextAdapter(bool offTheRecord = false); explicit BrowserContextAdapter(const QString &storagePrefix); virtual ~BrowserContextAdapter(); - static QSharedPointer defaultContext(); + static BrowserContextAdapter* defaultContext(); static QObject* globalQObjectRoot(); - void shutdown(); - VisitedLinksManagerQt *visitedLinksManager(); DownloadManagerDelegateQt *downloadManagerDelegate(); diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp index 96bfde443..32dbe0666 100644 --- a/src/core/browser_context_qt.cpp +++ b/src/core/browser_context_qt.cpp @@ -195,9 +195,12 @@ content::PermissionManager *BrowserContextQt::GetPermissionManager() return permissionManager.get(); } -net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext(content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) +net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext( + content::ProtocolHandlerMap *protocol_handlers, + content::URLRequestInterceptorScopedVector request_interceptors) { - url_request_getter_ = new URLRequestContextGetterQt(m_adapter->sharedFromThis(), protocol_handlers, std::move(request_interceptors)); + url_request_getter_ = new URLRequestContextGetterQt(m_adapter, protocol_handlers, + std::move(request_interceptors)); return url_request_getter_.get(); } diff --git a/src/core/net/custom_protocol_handler.cpp b/src/core/net/custom_protocol_handler.cpp index 402df04ba..3620bc10c 100644 --- a/src/core/net/custom_protocol_handler.cpp +++ b/src/core/net/custom_protocol_handler.cpp @@ -46,7 +46,7 @@ namespace QtWebEngineCore { -CustomProtocolHandler::CustomProtocolHandler(QWeakPointer adapter) +CustomProtocolHandler::CustomProtocolHandler(QPointer adapter) : m_adapter(adapter) { } diff --git a/src/core/net/custom_protocol_handler.h b/src/core/net/custom_protocol_handler.h index 5d3838834..1568c269e 100644 --- a/src/core/net/custom_protocol_handler.h +++ b/src/core/net/custom_protocol_handler.h @@ -45,7 +45,7 @@ #include #include -#include +#include QT_FORWARD_DECLARE_CLASS(QIODevice) @@ -63,13 +63,13 @@ class BrowserContextAdapter; class QWEBENGINE_EXPORT CustomProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { public: - CustomProtocolHandler(QWeakPointer adapter); + CustomProtocolHandler(QPointer adapter); net::URLRequestJob *MaybeCreateJob(net::URLRequest *request, net::NetworkDelegate *networkDelegate) const override; private: DISALLOW_COPY_AND_ASSIGN(CustomProtocolHandler); - QWeakPointer m_adapter; + QPointer m_adapter; }; } // namespace diff --git a/src/core/net/url_request_context_getter_qt.cpp b/src/core/net/url_request_context_getter_qt.cpp index 904130611..89c048d18 100644 --- a/src/core/net/url_request_context_getter_qt.cpp +++ b/src/core/net/url_request_context_getter_qt.cpp @@ -90,7 +90,9 @@ namespace QtWebEngineCore { using content::BrowserThread; -URLRequestContextGetterQt::URLRequestContextGetterQt(QSharedPointer browserContext, content::ProtocolHandlerMap *protocolHandlers, content::URLRequestInterceptorScopedVector request_interceptors) +URLRequestContextGetterQt::URLRequestContextGetterQt(BrowserContextAdapter *browserContext, + content::ProtocolHandlerMap *protocolHandlers, + content::URLRequestInterceptorScopedVector request_interceptors) : m_ignoreCertificateErrors(false) , m_mutex(QMutex::Recursive) , m_contextInitialized(false) @@ -99,7 +101,7 @@ URLRequestContextGetterQt::URLRequestContextGetterQt(QSharedPointersetClient(browserContext->cookieStore()); - setFullConfiguration(browserContext); updateStorageSettings(); } @@ -127,21 +128,19 @@ URLRequestContextGetterQt::~URLRequestContextGetterQt() } -void URLRequestContextGetterQt::setFullConfiguration(QSharedPointer browserContext) +void URLRequestContextGetterQt::setFullConfiguration() { - if (!browserContext) - return; - - m_requestInterceptor = browserContext->requestInterceptor(); - m_persistentCookiesPolicy = browserContext->persistentCookiesPolicy(); - m_cookiesPath = browserContext->cookiesPath(); - m_channelIdPath = browserContext->channelIdPath(); - m_httpAcceptLanguage = browserContext->httpAcceptLanguage(); - m_httpUserAgent = browserContext->httpUserAgent(); - m_httpCacheType = browserContext->httpCacheType(); - m_httpCachePath = browserContext->httpCachePath(); - m_httpCacheMaxSize = browserContext->httpCacheMaxSize(); - m_customUrlSchemes = browserContext->customUrlSchemes(); + Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + m_requestInterceptor = m_browserContextAdapter->requestInterceptor(); + m_persistentCookiesPolicy = m_browserContextAdapter->persistentCookiesPolicy(); + m_cookiesPath = m_browserContextAdapter->cookiesPath(); + m_channelIdPath = m_browserContextAdapter->channelIdPath(); + m_httpAcceptLanguage = m_browserContextAdapter->httpAcceptLanguage(); + m_httpUserAgent = m_browserContextAdapter->httpUserAgent(); + m_httpCacheType = m_browserContextAdapter->httpCacheType(); + m_httpCachePath = m_browserContextAdapter->httpCachePath(); + m_httpCacheMaxSize = m_browserContextAdapter->httpCacheMaxSize(); + m_customUrlSchemes = m_browserContextAdapter->customUrlSchemes(); } net::URLRequestContext *URLRequestContextGetterQt::GetURLRequestContext() @@ -168,7 +167,7 @@ void URLRequestContextGetterQt::updateStorageSettings() Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); QMutexLocker lock(&m_mutex); - setFullConfiguration(m_browserContext.toStrongRef()); + setFullConfiguration(); if (!m_updateAllStorage) { m_updateAllStorage = true; @@ -287,9 +286,9 @@ void URLRequestContextGetterQt::updateCookieStore() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); QMutexLocker lock(&m_mutex); - m_persistentCookiesPolicy = m_browserContext.data()->persistentCookiesPolicy(); - m_cookiesPath = m_browserContext.data()->cookiesPath(); - m_channelIdPath = m_browserContext.data()->channelIdPath(); + m_persistentCookiesPolicy = m_browserContextAdapter->persistentCookiesPolicy(); + m_cookiesPath = m_browserContextAdapter->cookiesPath(); + m_channelIdPath = m_browserContextAdapter->channelIdPath(); if (m_contextInitialized && !m_updateAllStorage && !m_updateCookieStore) { m_updateCookieStore = true; @@ -373,8 +372,8 @@ void URLRequestContextGetterQt::updateUserAgent() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); QMutexLocker lock(&m_mutex); - m_httpAcceptLanguage = m_browserContext.data()->httpAcceptLanguage(); - m_httpUserAgent = m_browserContext.data()->httpUserAgent(); + m_httpAcceptLanguage = m_browserContextAdapter->httpAcceptLanguage(); + m_httpUserAgent = m_browserContextAdapter->httpUserAgent(); if (m_contextInitialized && !m_updateAllStorage && !m_updateUserAgent) { m_updateUserAgent = true; @@ -400,12 +399,12 @@ void URLRequestContextGetterQt::updateHttpCache() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); QMutexLocker lock(&m_mutex); - m_httpCacheType = m_browserContext.data()->httpCacheType(); - m_httpCachePath = m_browserContext.data()->httpCachePath(); - m_httpCacheMaxSize = m_browserContext.data()->httpCacheMaxSize(); + m_httpCacheType = m_browserContextAdapter->httpCacheType(); + m_httpCachePath = m_browserContextAdapter->httpCachePath(); + m_httpCacheMaxSize = m_browserContextAdapter->httpCacheMaxSize(); if (m_httpCacheType == BrowserContextAdapter::NoCache) { - content::BrowsingDataRemover *remover = content::BrowserContext::GetBrowsingDataRemover(m_browserContext.data()->browserContext()); + content::BrowsingDataRemover *remover = content::BrowserContext::GetBrowsingDataRemover(m_browserContextAdapter->browserContext()); remover->Remove(base::Time(), base::Time::Max(), content::BrowsingDataRemover::DATA_TYPE_CACHE, content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB); @@ -422,7 +421,8 @@ void URLRequestContextGetterQt::updateJobFactory() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); QMutexLocker lock(&m_mutex); - m_customUrlSchemes = m_browserContext.data()->customUrlSchemes(); + + m_customUrlSchemes = m_browserContextAdapter->customUrlSchemes(); if (m_contextInitialized && !m_updateJobFactory) { m_updateJobFactory = true; @@ -435,7 +435,7 @@ void URLRequestContextGetterQt::updateRequestInterceptor() { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); QMutexLocker lock(&m_mutex); - m_requestInterceptor = m_browserContext.data()->requestInterceptor(); + m_requestInterceptor = m_browserContextAdapter->requestInterceptor(); // We in this case do not need to regenerate any Chromium classes. } @@ -584,7 +584,7 @@ void URLRequestContextGetterQt::generateJobFactory() m_installedCustomSchemes = m_customUrlSchemes; Q_FOREACH (const QByteArray &scheme, m_installedCustomSchemes) { - jobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr(new CustomProtocolHandler(m_browserContext))); + jobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr(new CustomProtocolHandler(m_browserContextAdapter))); } m_baseJobFactory = jobFactory.get(); @@ -627,7 +627,7 @@ void URLRequestContextGetterQt::regenerateJobFactory() m_installedCustomSchemes = m_customUrlSchemes; Q_FOREACH (const QByteArray &scheme, m_installedCustomSchemes) { - m_baseJobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr(new CustomProtocolHandler(m_browserContext))); + m_baseJobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr(new CustomProtocolHandler(m_browserContextAdapter))); } } diff --git a/src/core/net/url_request_context_getter_qt.h b/src/core/net/url_request_context_getter_qt.h index 0eb4a2fe4..fbc445e4f 100644 --- a/src/core/net/url_request_context_getter_qt.h +++ b/src/core/net/url_request_context_getter_qt.h @@ -70,7 +70,9 @@ namespace QtWebEngineCore { // FIXME: This class should be split into a URLRequestContextGetter and a ProfileIOData, similar to what chrome does. class URLRequestContextGetterQt : public net::URLRequestContextGetter { public: - URLRequestContextGetterQt(QSharedPointer browserContext, content::ProtocolHandlerMap *protocolHandlers, content::URLRequestInterceptorScopedVector request_interceptors); + URLRequestContextGetterQt(BrowserContextAdapter *browserContext, + content::ProtocolHandlerMap *protocolHandlers, + content::URLRequestInterceptorScopedVector request_interceptors); net::URLRequestContext *GetURLRequestContext() override; scoped_refptr GetNetworkTaskRunner() const override; @@ -82,6 +84,7 @@ public: void updateHttpCache(); void updateJobFactory(); void updateRequestInterceptor(); + void setFullConfiguration(); private: virtual ~URLRequestContextGetterQt(); @@ -98,10 +101,7 @@ private: net::HttpNetworkSession::Params generateNetworkSessionParams(); net::HttpNetworkSession::Context generateNetworkSessionContext(); - void setFullConfiguration(QSharedPointer browserContext); - bool m_ignoreCertificateErrors; - QMutex m_mutex; bool m_contextInitialized; bool m_updateAllStorage; @@ -110,9 +110,10 @@ private: bool m_updateJobFactory; bool m_updateUserAgent; - QWeakPointer m_browserContext; + // m_browserContext is never dereferenced in IO thread and it is passed by + // qpointer in generateJobFactory + QPointer m_browserContextAdapter; content::ProtocolHandlerMap m_protocolHandlers; - QAtomicPointer m_proxyConfigService; std::unique_ptr m_urlRequestContext; std::unique_ptr m_networkDelegate; diff --git a/src/core/net/url_request_custom_job.cpp b/src/core/net/url_request_custom_job.cpp index cf96cd6d9..d9337687b 100644 --- a/src/core/net/url_request_custom_job.cpp +++ b/src/core/net/url_request_custom_job.cpp @@ -51,7 +51,7 @@ namespace QtWebEngineCore { URLRequestCustomJob::URLRequestCustomJob(URLRequest *request, NetworkDelegate *networkDelegate, const std::string &scheme, - QWeakPointer adapter) + QPointer adapter) : URLRequestJob(request, networkDelegate) , m_proxy(new URLRequestCustomJobProxy(this, scheme, adapter)) , m_device(nullptr) diff --git a/src/core/net/url_request_custom_job.h b/src/core/net/url_request_custom_job.h index 021cf3204..71c8d2613 100644 --- a/src/core/net/url_request_custom_job.h +++ b/src/core/net/url_request_custom_job.h @@ -42,7 +42,7 @@ #include "net/url_request/url_request_job.h" #include "url/gurl.h" -#include +#include QT_FORWARD_DECLARE_CLASS(QIODevice) @@ -58,7 +58,7 @@ public: URLRequestCustomJob(net::URLRequest *request, net::NetworkDelegate *networkDelegate, const std::string &scheme, - QWeakPointer adapter); + QPointer adapter); void Start() override; void Kill() override; int ReadRawData(net::IOBuffer *buf, int buf_size) override; diff --git a/src/core/net/url_request_custom_job_proxy.cpp b/src/core/net/url_request_custom_job_proxy.cpp index 6c9824bb9..411e1c868 100644 --- a/src/core/net/url_request_custom_job_proxy.cpp +++ b/src/core/net/url_request_custom_job_proxy.cpp @@ -51,7 +51,7 @@ namespace QtWebEngineCore { URLRequestCustomJobProxy::URLRequestCustomJobProxy(URLRequestCustomJob *job, const std::string &scheme, - QWeakPointer adapter) + QPointer adapter) : m_job(job) , m_started(false) , m_scheme(scheme) @@ -160,10 +160,11 @@ void URLRequestCustomJobProxy::initialize(GURL url, std::string method, base::Op if (initiator.has_value()) initiatorOrigin = toQt(initiator.value().GetURL()); - QWebEngineUrlSchemeHandler *schemeHandler = 0; - QSharedPointer browserContext = m_adapter.toStrongRef(); - if (browserContext) - schemeHandler = browserContext->customUrlSchemeHandlers()[toQByteArray(m_scheme)]; + QWebEngineUrlSchemeHandler *schemeHandler = nullptr; + + if (m_adapter) + schemeHandler = m_adapter->customUrlSchemeHandlers()[toQByteArray(m_scheme)]; + if (schemeHandler) { m_delegate = new URLRequestCustomJobDelegate(this, toQt(url), QByteArray::fromStdString(method), diff --git a/src/core/net/url_request_custom_job_proxy.h b/src/core/net/url_request_custom_job_proxy.h index 603ad5840..34d526348 100644 --- a/src/core/net/url_request_custom_job_proxy.h +++ b/src/core/net/url_request_custom_job_proxy.h @@ -44,7 +44,7 @@ #include "base/optional.h" #include "url/gurl.h" #include "url/origin.h" -#include +#include QT_FORWARD_DECLARE_CLASS(QIODevice) @@ -62,7 +62,7 @@ class URLRequestCustomJobProxy public: URLRequestCustomJobProxy(URLRequestCustomJob *job, const std::string &scheme, - QWeakPointer adapter); + QPointer adapter); ~URLRequestCustomJobProxy(); // Called from URLRequestCustomJobDelegate via post: @@ -82,7 +82,7 @@ public: // UI thread owned: std::string m_scheme; URLRequestCustomJobDelegate *m_delegate; - QWeakPointer m_adapter; + QPointer m_adapter; }; } // namespace QtWebEngineCore diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 6c4810c33..c7d36cb67 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -407,9 +407,7 @@ void WebContentsAdapter::setClient(WebContentsAdapterClient *adapterClient) { Q_ASSERT(!isInitialized()); m_adapterClient = adapterClient; - // We keep a reference to browserContextAdapter to keep it alive as long as we use it. - // This is needed in case the QML WebEngineProfile is garbage collected before the WebEnginePage. - m_browserContextAdapter = adapterClient->browserContextAdapter().data(); + m_browserContextAdapter = adapterClient->browserContextAdapter(); Q_ASSERT(m_browserContextAdapter); // This might replace any adapter that has been initialized with this WebEngineSettings. @@ -893,7 +891,9 @@ BrowserContextQt* WebContentsAdapter::browserContext() BrowserContextAdapter* WebContentsAdapter::browserContextAdapter() { - return m_browserContextAdapter ? m_browserContextAdapter : m_webContents ? static_cast(m_webContents->GetBrowserContext())->adapter() : 0; + return m_browserContextAdapter ? + m_browserContextAdapter : m_webContents ? + static_cast(m_webContents->GetBrowserContext())->adapter() : nullptr; } #ifndef QT_NO_ACCESSIBILITY diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index 4c5133772..2d057160d 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -453,7 +453,7 @@ public: virtual const QObject *holdingQObject() const = 0; virtual void setToolTip(const QString& toolTipText) = 0; - virtual QSharedPointer browserContextAdapter() = 0; + virtual BrowserContextAdapter *browserContextAdapter() = 0; virtual WebContentsAdapter* webContentsAdapter() = 0; }; diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 2de8fd64a..b98c822b0 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -287,7 +287,7 @@ void WebContentsDelegateQt::DidFinishNavigation(content::NavigationHandle *navig return; if (navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) { - BrowserContextAdapter *browserContextAdapter = m_viewClient->browserContextAdapter().data(); + BrowserContextAdapter *browserContextAdapter = m_viewClient->browserContextAdapter(); // VisistedLinksMaster asserts !IsOffTheRecord(). if (navigation_handle->ShouldUpdateHistory() && browserContextAdapter->trackVisitedLinks()) { for (const GURL &url : navigation_handle->GetRedirectChain()) diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 35402cdb0..922846fff 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -199,7 +199,8 @@ bool usingSoftwareDynamicGL() void WebEngineContext::destroyBrowserContext() { - m_defaultBrowserContext.reset(); + if (m_defaultBrowserContext) + qWarning() << "PostMainMessageLoopRun is done, but global profile still exists !"; } void WebEngineContext::destroy() @@ -211,11 +212,12 @@ void WebEngineContext::destroy() // Flush the UI message loop before quitting. while (delegate->DoWork()) { } - if (m_defaultBrowserContext) - m_defaultBrowserContext->shutdown(); // Delete the global object and thus custom profiles + m_defaultBrowserContext.reset(); delete m_globalQObject; m_globalQObject = nullptr; + + // Handle any events posted by browser-context shutdown. while (delegate->DoWork()) { } @@ -223,7 +225,7 @@ void WebEngineContext::destroy() m_devtoolsServer.reset(); m_runLoop->AfterRun(); - // Force to destroy RenderProcessHostImpl by destroying BrowserMainRunner. + // Fixme: Force to destroy RenderProcessHostImpl by destroying BrowserMainRunner. // RenderProcessHostImpl should be destroyed before WebEngineContext since // default BrowserContext might be used by the RenderprocessHostImpl's destructor. m_browserRunner.reset(); @@ -254,11 +256,12 @@ WebEngineContext *WebEngineContext::current() return sContext.get(); } -QSharedPointer WebEngineContext::defaultBrowserContext() +BrowserContextAdapter *WebEngineContext::defaultBrowserContext() { + Q_ASSERT(!s_destroyed); if (!m_defaultBrowserContext) - m_defaultBrowserContext = QSharedPointer::create(QStringLiteral("Default")); - return m_defaultBrowserContext; + m_defaultBrowserContext.reset(new BrowserContextAdapter(QStringLiteral("Default"))); + return m_defaultBrowserContext.data(); } QObject *WebEngineContext::globalQObject() diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h index c1640bdf2..63dbe9f23 100644 --- a/src/core/web_engine_context.h +++ b/src/core/web_engine_context.h @@ -48,7 +48,7 @@ #include "base/values.h" #include "printing/features/features.h" -#include +#include namespace base { class RunLoop; @@ -80,7 +80,8 @@ class WebEngineContext : public base::RefCounted { public: static WebEngineContext *current(); - QSharedPointer defaultBrowserContext(); + BrowserContextAdapter *defaultBrowserContext(); + QObject *globalQObject(); #if BUILDFLAG(ENABLE_BASIC_PRINTING) printing::PrintJobManager* getPrintJobManager(); @@ -99,7 +100,7 @@ private: std::unique_ptr m_contentRunner; std::unique_ptr m_browserRunner; QObject* m_globalQObject; - QSharedPointer m_defaultBrowserContext; + QScopedPointer m_defaultBrowserContext; std::unique_ptr m_devtoolsServer; #if BUILDFLAG(ENABLE_BASIC_PRINTING) std::unique_ptr m_printJobManager; diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 1dead56ac..68cc701e0 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -142,10 +142,11 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC The \a download argument holds the state of the finished download instance. */ -QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(QSharedPointer browserContext) +QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(BrowserContextAdapter *browserContext) : m_settings(new QQuickWebEngineSettings()) - , m_browserContext(new QWebEngineBrowserContext(browserContext, this)) + , m_browserContextAdapter(browserContext) { + m_browserContextAdapter->addClient(this); m_settings->d_ptr->initDefaults(); // Fullscreen API was implemented before the supported setting, so we must // make it default true to avoid change in default API behavior. @@ -154,10 +155,18 @@ QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(QSharedPointerdestroy(); } + if (m_browserContextAdapter) { + // In the case the user sets this profile as the parent of the interceptor + // it can be deleted before the browser-context still referencing it is. + m_browserContextAdapter->setRequestInterceptor(nullptr); + m_browserContextAdapter->removeClient(this); + } + Q_FOREACH (QQuickWebEngineDownloadItem *download, m_ongoingDownloads) { if (download) download->cancel(); @@ -165,8 +174,8 @@ QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate() m_ongoingDownloads.clear(); - if (m_browserContext) - m_browserContext->shutdown(); + if (q_ptr != QQuickWebEngineProfile::defaultProfile()) + delete m_browserContextAdapter; } void QQuickWebEngineProfilePrivate::addWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter) @@ -179,15 +188,10 @@ void QQuickWebEngineProfilePrivate::removeWebContentsAdapterClient(QQuickWebEngi m_webContentsAdapterClients.removeAll(adapter); } -QSharedPointer QQuickWebEngineProfilePrivate::browserContext() const -{ - return m_browserContext ? m_browserContext->browserContextRef : nullptr; -} - void QQuickWebEngineProfilePrivate::cancelDownload(quint32 downloadId) { - if (m_browserContext) - m_browserContext->browserContextRef->cancelDownload(downloadId); + if (m_browserContextAdapter) + m_browserContextAdapter->cancelDownload(downloadId); } void QQuickWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) @@ -322,7 +326,7 @@ void QQuickWebEngineProfilePrivate::userScripts_clear(QQmlListProperty::create(false))) + d_ptr(new QQuickWebEngineProfilePrivate(new QtWebEngineCore::BrowserContextAdapter(true))) { // Sets up the global WebEngineContext QQuickWebEngineProfile::defaultProfile(); diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index 489a3efdf..4bb5e6b39 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -53,7 +53,6 @@ #include "browser_context_adapter_client.h" #include "browser_context_adapter.h" -#include "qwebenginebrowsercontext_p.h" #include "qquickwebengineprofile_p.h" #include @@ -70,12 +69,12 @@ class QQuickWebEngineViewPrivate; class QQuickWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { public: Q_DECLARE_PUBLIC(QQuickWebEngineProfile) - QQuickWebEngineProfilePrivate(QSharedPointer browserContext); + QQuickWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter *browserContext); ~QQuickWebEngineProfilePrivate(); void addWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter); void removeWebContentsAdapterClient(QQuickWebEngineViewPrivate *adapter); - QSharedPointer browserContext() const; + QtWebEngineCore::BrowserContextAdapter* browserContext() const { return m_browserContextAdapter; } QQuickWebEngineSettings *settings() const { return m_settings.data(); } void cancelDownload(quint32 downloadId); @@ -94,7 +93,7 @@ private: friend class QQuickWebEngineViewPrivate; QQuickWebEngineProfile *q_ptr; QScopedPointer m_settings; - QPointer m_browserContext; + QPointer m_browserContextAdapter; QMap > m_ongoingDownloads; QList m_userScripts; QVector m_webContentsAdapterClients; diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 3d873c49f..97a0adef3 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -103,9 +103,9 @@ static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *obje #endif // QT_NO_ACCESSIBILITY QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate() - : adapter(QSharedPointer::create()) + : m_profile(QQuickWebEngineProfile::defaultProfile()) + , adapter(QSharedPointer::create()) , m_history(new QQuickWebEngineHistory(this)) - , m_profile(QQuickWebEngineProfile::defaultProfile()) , m_settings(new QQuickWebEngineSettings(m_profile->settings())) #ifdef ENABLE_QML_TESTSUPPORT_API , m_testSupport(0) @@ -621,7 +621,7 @@ QObject *QQuickWebEngineViewPrivate::accessibilityParentObject() return q; } -QSharedPointer QQuickWebEngineViewPrivate::browserContextAdapter() +BrowserContextAdapter *QQuickWebEngineViewPrivate::browserContextAdapter() { return m_profile->d_ptr->browserContext(); } diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 6051ab3be..8c8c57cf6 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -74,6 +74,7 @@ class QQmlContext; class QQuickWebEngineContextMenuRequest; class QQuickWebEngineSettings; class QQuickWebEngineFaviconProvider; +class QQuickWebEngineProfilePrivate; QQuickWebEngineView::WebAction editorActionForKeyEvent(QKeyEvent* event); @@ -149,7 +150,7 @@ public: void setToolTip(const QString &toolTipText) override; const QObject *holdingQObject() const override; - QSharedPointer browserContextAdapter() override; + QtWebEngineCore::BrowserContextAdapter *browserContextAdapter() override; QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override; void adoptWebContents(QtWebEngineCore::WebContentsAdapter *webContents); @@ -163,9 +164,9 @@ public: static QQuickWebEngineScript *userScripts_at(QQmlListProperty *p, int idx); static void userScripts_clear(QQmlListProperty *p); + QQuickWebEngineProfile *m_profile; QSharedPointer adapter; QScopedPointer m_history; - QQuickWebEngineProfile *m_profile; QScopedPointer m_settings; #ifdef ENABLE_QML_TESTSUPPORT_API QQuickWebEngineTestSupport *m_testSupport; diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 8911c63c8..eeca450c9 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -698,7 +698,7 @@ void QWebEnginePagePrivate::setFullScreenMode(bool fullscreen) } } -QSharedPointer QWebEnginePagePrivate::browserContextAdapter() +BrowserContextAdapter* QWebEnginePagePrivate::browserContextAdapter() { return profile->d_ptr->browserContext(); } diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index dc7d02b73..39fbf1506 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -146,7 +146,7 @@ public: void setToolTip(const QString &toolTipText) override; const QObject *holdingQObject() const override; - QSharedPointer browserContextAdapter() override; + QtWebEngineCore::BrowserContextAdapter *browserContextAdapter() override; QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override; void updateAction(QWebEnginePage::WebAction) const; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 746fe55e8..96cc2bb94 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -46,13 +46,12 @@ #include "qwebengineprofile_p.h" #include "qwebenginesettings.h" #include "qwebenginescriptcollection_p.h" - -#include "qwebenginebrowsercontext_p.h" #include "qtwebenginecoreglobal.h" #include "browser_context_adapter.h" #include "visited_links_manager_qt.h" #include "web_engine_settings.h" + QT_BEGIN_NAMESPACE ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::UnknownSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::UnknownSavePageFormat) @@ -148,18 +147,38 @@ using QtWebEngineCore::BrowserContextAdapter; \sa QWebEngineDownloadItem, QWebEnginePage::download() */ -QWebEngineProfilePrivate::QWebEngineProfilePrivate(QSharedPointer browserContext) - : m_settings(new QWebEngineSettings()) - , m_scriptCollection(new QWebEngineScriptCollection(new QWebEngineScriptCollectionPrivate(browserContext->userResourceController()))) - , m_browserContext(new QWebEngineBrowserContext(browserContext, this)) +// Fixme: fix storage name setters and unify constructors here and in BrowserContextAdapter +QWebEngineProfilePrivate::QWebEngineProfilePrivate(const QString &storageName) + : m_settings(new QWebEngineSettings()) + , m_browserContextAdapter(storageName.isEmpty()? + new QtWebEngineCore::BrowserContextAdapter(true): + new QtWebEngineCore::BrowserContextAdapter(storageName)) + , m_scriptCollection(new QWebEngineScriptCollection( + new QWebEngineScriptCollectionPrivate(m_browserContextAdapter->userResourceController()))) +{ + m_browserContextAdapter->addClient(this); + m_settings->d_ptr->initDefaults(); +} + +// Fixme: fix storage name setters and unify constructors here and in BrowserContextAdapter +QWebEngineProfilePrivate::QWebEngineProfilePrivate(BrowserContextAdapter* browserContextAdapter) + : m_settings(new QWebEngineSettings()) + , m_browserContextAdapter(browserContextAdapter) + , m_scriptCollection(new QWebEngineScriptCollection( + new QWebEngineScriptCollectionPrivate(m_browserContextAdapter->userResourceController()))) { + m_browserContextAdapter->addClient(this); m_settings->d_ptr->initDefaults(); } QWebEngineProfilePrivate::~QWebEngineProfilePrivate() { - delete m_settings; - m_settings = 0; + if (m_browserContextAdapter) { + // In the case the user sets this profile as the parent of the interceptor + // it can be deleted before the browser-context still referencing it is. + m_browserContextAdapter->setRequestInterceptor(nullptr); + m_browserContextAdapter->removeClient(this); + } Q_FOREACH (QWebEngineDownloadItem* download, m_ongoingDownloads) { if (download) @@ -167,13 +186,16 @@ QWebEngineProfilePrivate::~QWebEngineProfilePrivate() } m_ongoingDownloads.clear(); - if (m_browserContext) - m_browserContext->shutdown(); + + if (q_ptr != QWebEngineProfile::defaultProfile()) + delete m_browserContextAdapter; + + delete m_settings; } -QSharedPointer QWebEngineProfilePrivate::browserContext() const +BrowserContextAdapter* QWebEngineProfilePrivate::browserContext() const { - return m_browserContext ? m_browserContext->browserContextRef : nullptr; + return m_browserContextAdapter; } void QWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) @@ -245,7 +267,7 @@ void QWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info) */ QWebEngineProfile::QWebEngineProfile(QObject *parent) : QObject(parent) - , d_ptr(new QWebEngineProfilePrivate(QSharedPointer::create(true))) + , d_ptr(new QWebEngineProfilePrivate()) { d_ptr->q_ptr = this; } @@ -262,7 +284,7 @@ QWebEngineProfile::QWebEngineProfile(QObject *parent) */ QWebEngineProfile::QWebEngineProfile(const QString &storageName, QObject *parent) : QObject(parent) - , d_ptr(new QWebEngineProfilePrivate(QSharedPointer::create(storageName))) + , d_ptr(new QWebEngineProfilePrivate(storageName)) { d_ptr->q_ptr = this; } diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h index 72fa904e4..d3bfe0b91 100644 --- a/src/webenginewidgets/api/qwebengineprofile_p.h +++ b/src/webenginewidgets/api/qwebengineprofile_p.h @@ -73,10 +73,12 @@ class QWebEngineSettings; class QWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { public: Q_DECLARE_PUBLIC(QWebEngineProfile) - QWebEngineProfilePrivate(QSharedPointer browserContext); + QWebEngineProfilePrivate(const QString &storageName = QString()); + // This is used only by global profile + QWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter *browserContextAdapter); ~QWebEngineProfilePrivate(); - QSharedPointer browserContext() const; + QtWebEngineCore::BrowserContextAdapter* browserContext() const; QWebEngineSettings *settings() const { return m_settings; } void downloadDestroyed(quint32 downloadId); @@ -87,8 +89,8 @@ public: private: QWebEngineProfile *q_ptr; QWebEngineSettings *m_settings; + QPointer m_browserContextAdapter; QScopedPointer m_scriptCollection; - QPointer m_browserContext; QMap > m_ongoingDownloads; }; -- cgit v1.2.3