diff options
author | Michal Klocek <michal.klocek@qt.io> | 2020-04-16 15:41:42 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2020-04-20 09:45:00 +0200 |
commit | 9e56f570e31a0ef18e544bb21dfddebfe43ec2d0 (patch) | |
tree | 5f3af76e8120aada7bc472ece9c7f25da149c9d4 | |
parent | a05bb73747620dd8f0294a57ff690a4f4202884e (diff) |
Cleanup interceptors in profile
Change-Id: Ibc6d63845601b8189ac38bacc77885327284c81f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r-- | src/core/profile_adapter.cpp | 28 | ||||
-rw-r--r-- | src/core/profile_adapter.h | 5 | ||||
-rw-r--r-- | src/core/profile_io_data_qt.cpp | 43 | ||||
-rw-r--r-- | src/core/profile_io_data_qt.h | 10 |
4 files changed, 0 insertions, 86 deletions
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index c27883b65..d2c4ab1d8 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -95,7 +95,6 @@ ProfileAdapter::ProfileAdapter(const QString &storageName): , m_persistentCookiesPolicy(AllowPersistentCookies) , m_visitedLinksPolicy(TrackVisitedLinksOnDisk) , m_httpCacheMaxSize(0) - , m_pageRequestInterceptors(0) { WebEngineContext::current()->addProfileAdapter(this); // creation of profile requires webengine context @@ -134,7 +133,6 @@ ProfileAdapter::~ProfileAdapter() #if QT_CONFIG(ssl) delete m_clientCertificateStore; #endif - Q_ASSERT(m_pageRequestInterceptors == 0); } void ProfileAdapter::setStorageName(const QString &storageName) @@ -194,19 +192,7 @@ QWebEngineUrlRequestInterceptor *ProfileAdapter::requestInterceptor() void ProfileAdapter::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) { - if (m_requestInterceptor == interceptor) - return; - - if (m_requestInterceptor) - disconnect(m_requestInterceptor, &QObject::destroyed, this, nullptr); m_requestInterceptor = interceptor; - if (m_requestInterceptor) - connect(m_requestInterceptor, &QObject::destroyed, this, [this] () { - m_profile->m_profileIOData->updateRequestInterceptor(); - Q_ASSERT(!m_profile->m_profileIOData->requestInterceptor()); - }); - - m_profile->m_profileIOData->updateRequestInterceptor(); } void ProfileAdapter::addClient(ProfileAdapterClient *adapterClient) @@ -219,20 +205,6 @@ void ProfileAdapter::removeClient(ProfileAdapterClient *adapterClient) m_clients.removeOne(adapterClient); } -void ProfileAdapter::addPageRequestInterceptor() -{ - ++m_pageRequestInterceptors; - m_profile->m_profileIOData->updateRequestInterceptor(); -} - -void ProfileAdapter::removePageRequestInterceptor() -{ - Q_ASSERT(m_pageRequestInterceptors > 0); - --m_pageRequestInterceptors; - m_profile->m_profileIOData->updateRequestInterceptor(); -} - - void ProfileAdapter::cancelDownload(quint32 downloadId) { downloadManagerDelegate()->cancelDownload(downloadId); diff --git a/src/core/profile_adapter.h b/src/core/profile_adapter.h index 60d04273b..1e5a3e21f 100644 --- a/src/core/profile_adapter.h +++ b/src/core/profile_adapter.h @@ -199,10 +199,6 @@ public: void setUseForGlobalCertificateVerification(bool enable = true); bool isUsedForGlobalCertificateVerification() const; - void addPageRequestInterceptor(); - void removePageRequestInterceptor(); - bool hasPageRequestInterceptor() const { return m_pageRequestInterceptors > 0; } - #if QT_CONFIG(ssl) QWebEngineClientCertificateStore *clientCertificateStore(); #endif @@ -247,7 +243,6 @@ private: QList<ProfileAdapterClient*> m_clients; QVector<WebContentsAdapterClient *> m_webContentsAdapterClients; int m_httpCacheMaxSize; - int m_pageRequestInterceptors; QrcUrlSchemeHandler m_qrcHandler; Q_DISABLE_COPY(ProfileAdapter) diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index fd073f208..64ad096a6 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -155,49 +155,6 @@ void ProfileIODataQt::resetNetworkContext() })); } -void ProfileIODataQt::updateRequestInterceptor() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - const std::lock_guard<QRecursiveMutex> lock(m_mutex); - m_requestInterceptor = m_profileAdapter->requestInterceptor(); - m_hasPageInterceptors = m_profileAdapter->hasPageRequestInterceptor(); - if (m_requestInterceptor) - m_isInterceptorDeprecated = m_requestInterceptor->property("deprecated").toBool(); - else - m_isInterceptorDeprecated = false; - // We in this case do not need to regenerate any Chromium classes. -} - -bool ProfileIODataQt::isInterceptorDeprecated() const -{ - return m_isInterceptorDeprecated; -} - -QWebEngineUrlRequestInterceptor *ProfileIODataQt::acquireInterceptor() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - m_mutex.lock(); - return m_requestInterceptor; -} - -QWebEngineUrlRequestInterceptor *ProfileIODataQt::requestInterceptor() -{ - return m_requestInterceptor; -} - -bool ProfileIODataQt::hasPageInterceptors() -{ - // used in NetworkDelegateQt::OnBeforeURLRequest - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - return m_hasPageInterceptors; -} - -void ProfileIODataQt::releaseInterceptor() -{ - Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - m_mutex.unlock(); -} - bool ProfileIODataQt::canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const { return m_cookieDelegate->canGetCookies(firstPartyUrl, url); diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h index 6d9dd1a45..26ae1bcb2 100644 --- a/src/core/profile_io_data_qt.h +++ b/src/core/profile_io_data_qt.h @@ -87,15 +87,8 @@ public: bool canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const; // Used in NetworkDelegateQt::OnBeforeURLRequest. - bool isInterceptorDeprecated() const; // Remove for Qt6 - QWebEngineUrlRequestInterceptor *acquireInterceptor(); // Remove for Qt6 - void releaseInterceptor(); - QWebEngineUrlRequestInterceptor *requestInterceptor(); - void setFullConfiguration(); // runs on ui thread void resetNetworkContext(); // runs on ui thread - void updateRequestInterceptor(); // runs on ui thread - bool hasPageInterceptors(); network::mojom::NetworkContextParamsPtr CreateNetworkContextParams(); @@ -125,7 +118,6 @@ private: QString m_httpUserAgent; ProfileAdapter::HttpCacheType m_httpCacheType; QString m_httpCachePath; - QWebEngineUrlRequestInterceptor* m_requestInterceptor = nullptr; #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QMutex m_mutex{QMutex::Recursive}; using QRecursiveMutex = QMutex; @@ -134,10 +126,8 @@ private: #endif int m_httpCacheMaxSize = 0; bool m_useForGlobalCertificateVerification = false; - bool m_hasPageInterceptors = false; base::WeakPtrFactory<ProfileIODataQt> m_weakPtrFactory; // this should be always the last member QString m_dataPath; - volatile bool m_isInterceptorDeprecated = false; // Remove for Qt6 DISALLOW_COPY_AND_ASSIGN(ProfileIODataQt); }; } // namespace QtWebEngineCore |