summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-11-26 12:06:53 +0100
committerJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-12-10 09:59:56 +0000
commit82b5f6214e3eca569e85cab21d6a8417388f9822 (patch)
tree69e85de4bb97bddba8be8382d56576170c505555
parent9daa85a3f12c6ce0e6908598c6f54a7dac28ce79 (diff)
Make use of QObject's d-pointer in QWebEngineCookieStore
This safes us from managing d_ptr/q_ptr pairs and saves a bit of memory. Change-Id: Icdd692c5ddf0980de980bebb691ecf51b738acaa Reviewed-by: Michal Klocek <michal.klocek@theqtcompany.com> Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
-rw-r--r--src/core/api/qwebenginecookiestore.cpp6
-rw-r--r--src/core/api/qwebenginecookiestore.h1
-rw-r--r--src/core/api/qwebenginecookiestore_p.h9
-rw-r--r--src/core/cookie_monster_delegate_qt.cpp6
4 files changed, 10 insertions, 12 deletions
diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp
index 51753e87..89272057 100644
--- a/src/core/api/qwebenginecookiestore.cpp
+++ b/src/core/api/qwebenginecookiestore.cpp
@@ -46,13 +46,12 @@ QT_BEGIN_NAMESPACE
using namespace QtWebEngineCore;
-QWebEngineCookieStorePrivate::QWebEngineCookieStorePrivate(QWebEngineCookieStore* q)
+QWebEngineCookieStorePrivate::QWebEngineCookieStorePrivate()
: m_nextCallbackId(CallbackDirectory::ReservedCallbackIdsEnd)
, m_deleteSessionCookiesPending(false)
, m_deleteAllCookiesPending(false)
, m_getAllCookiesPending(false)
, delegate(0)
- , q_ptr(q)
{
}
@@ -246,8 +245,7 @@ bool QWebEngineCookieStorePrivate::canSetCookie(const QUrl &firstPartyUrl, const
*/
QWebEngineCookieStore::QWebEngineCookieStore(QObject *parent)
- : QObject(parent)
- , d_ptr(new QWebEngineCookieStorePrivate(this))
+ : QObject(*new QWebEngineCookieStorePrivate, parent)
{
}
diff --git a/src/core/api/qwebenginecookiestore.h b/src/core/api/qwebenginecookiestore.h
index 6cbe399f..73a4ac19 100644
--- a/src/core/api/qwebenginecookiestore.h
+++ b/src/core/api/qwebenginecookiestore.h
@@ -94,7 +94,6 @@ private:
friend class QtWebEngineCore::CookieMonsterDelegateQt;
Q_DISABLE_COPY(QWebEngineCookieStore)
Q_DECLARE_PRIVATE(QWebEngineCookieStore)
- QScopedPointer<QWebEngineCookieStorePrivate> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/core/api/qwebenginecookiestore_p.h b/src/core/api/qwebenginecookiestore_p.h
index d773c0d3..b8c8b614 100644
--- a/src/core/api/qwebenginecookiestore_p.h
+++ b/src/core/api/qwebenginecookiestore_p.h
@@ -56,6 +56,7 @@
#include <QVector>
#include <QNetworkCookie>
#include <QUrl>
+#include <QtCore/private/qobject_p.h>
namespace QtWebEngineCore {
class CookieMonsterDelegateQt;
@@ -63,7 +64,9 @@ class CookieMonsterDelegateQt;
QT_BEGIN_NAMESPACE
-class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStorePrivate {
+class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStorePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QWebEngineCookieStore)
struct CookieData {
quint64 callbackId;
QNetworkCookie cookie;
@@ -71,7 +74,6 @@ class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStorePrivate {
};
friend class QTypeInfo<CookieData>;
public:
- Q_DECLARE_PUBLIC(QWebEngineCookieStore)
QtWebEngineCore::CallbackDirectory callbackDirectory;
QWebEngineCallback<QWebEngineCookieStore::FilterRequest&> filterCallback;
QVector<CookieData> m_pendingUserCookies;
@@ -81,9 +83,8 @@ public:
bool m_getAllCookiesPending;
QtWebEngineCore::CookieMonsterDelegateQt *delegate;
- QWebEngineCookieStore *q_ptr;
- QWebEngineCookieStorePrivate(QWebEngineCookieStore *q);
+ QWebEngineCookieStorePrivate();
void processPendingUserCookies();
void setCookie(const QWebEngineCallback<bool> &callback, const QNetworkCookie &cookie, const QUrl &origin);
diff --git a/src/core/cookie_monster_delegate_qt.cpp b/src/core/cookie_monster_delegate_qt.cpp
index a81670a6..fa4e9e8b 100644
--- a/src/core/cookie_monster_delegate_qt.cpp
+++ b/src/core/cookie_monster_delegate_qt.cpp
@@ -152,7 +152,7 @@ void CookieMonsterDelegateQt::setClient(QWebEngineCookieStore *client)
if (!m_client)
return;
- m_client->d_ptr->delegate = this;
+ m_client->d_func()->delegate = this;
if (hasCookieMonster())
m_client->d_func()->processPendingUserCookies();
@@ -163,14 +163,14 @@ bool CookieMonsterDelegateQt::canSetCookie(const QUrl &firstPartyUrl, const QByt
if (!m_client)
return true;
- return m_client->d_ptr->canSetCookie(firstPartyUrl, cookieLine, url);
+ return m_client->d_func()->canSetCookie(firstPartyUrl, cookieLine, url);
}
void CookieMonsterDelegateQt::OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, ChangeCause cause)
{
if (!m_client)
return;
- m_client->d_ptr->onCookieChanged(toQt(cookie), removed);
+ m_client->d_func()->onCookieChanged(toQt(cookie), removed);
}
}