diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-01-26 15:39:10 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-03-12 13:27:21 +0000 |
commit | a984c64b0a17d62ca5cd866ad64bd0679a0cca96 (patch) | |
tree | 203e2470c5b651bf33f9d28f5b42854b3a1480a3 /src/webengine | |
parent | 2cf54e48922a7d379fb7e212966d05bc402e475d (diff) |
Clean up global profiles and ownership
This patch removes the unused global off-the-record browser-contexts
and changes all browser-contexts to be ref-counted by an API level
profile.
The API default profiles are now owned by a global QObject and are
deleted on exit.
Change-Id: Id7c9eafa24829118105f58b66663a6348216823d
Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'src/webengine')
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 26 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile_p.h | 2 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile_p_p.h | 5 |
3 files changed, 16 insertions, 17 deletions
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 718007c35..545352861 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -50,20 +50,17 @@ using QtWebEngineCore::BrowserContextAdapter; QT_BEGIN_NAMESPACE -QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(BrowserContextAdapter* browserContext, bool ownsContext) +QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(BrowserContextAdapter* browserContext) : m_settings(new QQuickWebEngineSettings()) - , m_browserContext(browserContext) + , m_browserContextRef(browserContext) { - if (ownsContext) - m_browserContextRef = browserContext; - - m_browserContext->setClient(this); + m_browserContextRef->addClient(this); m_settings->d_ptr->initDefaults(browserContext->isOffTheRecord()); } QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate() { - m_browserContext->setClient(0); + m_browserContextRef->removeClient(this); Q_FOREACH (QQuickWebEngineDownloadItem* download, m_ongoingDownloads) { if (download) @@ -75,7 +72,7 @@ QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate() void QQuickWebEngineProfilePrivate::cancelDownload(quint32 downloadId) { - m_browserContext->cancelDownload(downloadId); + browserContext()->cancelDownload(downloadId); } void QQuickWebEngineProfilePrivate::downloadDestroyed(quint32 downloadId) @@ -161,13 +158,14 @@ void QQuickWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info */ QQuickWebEngineProfile::QQuickWebEngineProfile() - : d_ptr(new QQuickWebEngineProfilePrivate(new BrowserContextAdapter(false), true)) + : d_ptr(new QQuickWebEngineProfilePrivate(new BrowserContextAdapter(false))) { d_ptr->q_ptr = this; } -QQuickWebEngineProfile::QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *privatePtr) - : d_ptr(privatePtr) +QQuickWebEngineProfile::QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *privatePtr, QObject *parent) + : QObject(parent) + , d_ptr(privatePtr) { d_ptr->q_ptr = this; } @@ -399,8 +397,10 @@ void QQuickWebEngineProfile::setHttpCacheMaximumSize(int maximumSize) QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile() { - static QQuickWebEngineProfile profile(new QQuickWebEngineProfilePrivate(BrowserContextAdapter::defaultContext(), false)); - return &profile; + static QQuickWebEngineProfile *profile = new QQuickWebEngineProfile( + new QQuickWebEngineProfilePrivate(BrowserContextAdapter::defaultContext()), + BrowserContextAdapter::globalQObjectRoot()); + return profile; } QQuickWebEngineSettings *QQuickWebEngineProfile::settings() const diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index ee91d7728..3978fc5e0 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -121,7 +121,7 @@ signals: private: Q_DECLARE_PRIVATE(QQuickWebEngineProfile) - QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *); + QQuickWebEngineProfile(QQuickWebEngineProfilePrivate *, QObject *parent = 0); QQuickWebEngineSettings *settings() const; friend class QQuickWebEngineSettings; diff --git a/src/webengine/api/qquickwebengineprofile_p_p.h b/src/webengine/api/qquickwebengineprofile_p_p.h index 0cf11acec..a702a8a1d 100644 --- a/src/webengine/api/qquickwebengineprofile_p_p.h +++ b/src/webengine/api/qquickwebengineprofile_p_p.h @@ -52,10 +52,10 @@ class QQuickWebEngineSettings; class QQuickWebEngineProfilePrivate : public QtWebEngineCore::BrowserContextAdapterClient { public: Q_DECLARE_PUBLIC(QQuickWebEngineProfile) - QQuickWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter* browserContext, bool ownsContext); + QQuickWebEngineProfilePrivate(QtWebEngineCore::BrowserContextAdapter* browserContext); ~QQuickWebEngineProfilePrivate(); - QtWebEngineCore::BrowserContextAdapter *browserContext() const { return m_browserContext; } + QtWebEngineCore::BrowserContextAdapter *browserContext() const { return m_browserContextRef.data(); } QQuickWebEngineSettings *settings() const { return m_settings.data(); } void cancelDownload(quint32 downloadId); @@ -68,7 +68,6 @@ private: friend class QQuickWebEngineViewPrivate; QQuickWebEngineProfile *q_ptr; QScopedPointer<QQuickWebEngineSettings> m_settings; - QtWebEngineCore::BrowserContextAdapter *m_browserContext; QExplicitlySharedDataPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextRef; QMap<quint32, QPointer<QQuickWebEngineDownloadItem> > m_ongoingDownloads; }; |