summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2019-03-01 12:42:01 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-03-23 00:24:58 +0000
commitcedb457045c9972ba6da9c101c2ad65006b4db93 (patch)
tree4877744e17cc9b41163a82f487c76a1eb52929a7
parentce6a1a74d16deecf0c150aa1f5bae2cc6a95e7b1 (diff)
Fix disabling http cache after 73-based
BrowserDataRemoverImpl::Remove() indirectly calls TransportSecurityState::DeleteAllDynamicDataSince() which notifies by a callback about the finished deletion since: https://chromium-review.googlesource.com/c/chromium/src/+/1335939 During the deletion the ProfileIODataQt::requestStorageGeneration() should not be called because it deletes net::TransporSecurityPersister which background_runner is where the finished deletion callback is scheduled. Change-Id: I4782d701f706ed7c8e104a78ba84a27183166fa4 Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
-rw-r--r--src/core/profile_io_data_qt.cpp41
-rw-r--r--src/core/profile_io_data_qt.h20
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp4
3 files changed, 57 insertions, 8 deletions
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
index 467223164..5d317b7f0 100644
--- a/src/core/profile_io_data_qt.cpp
+++ b/src/core/profile_io_data_qt.cpp
@@ -172,6 +172,7 @@ ProfileIODataQt::ProfileIODataQt(ProfileQt *profile)
m_clientCertificateStoreData(new ClientCertificateStoreData),
#endif
m_mutex(QMutex::Recursive),
+ m_removerObserver(this),
m_weakPtrFactory(this)
{
if (content::BrowserThread::IsThreadInitialized(content::BrowserThread::UI))
@@ -670,7 +671,8 @@ void ProfileIODataQt::updateStorageSettings()
file::ForgetServiceInstanceGroupUserDirAssociation(groupId);
file::AssociateServiceInstanceGroupWithUserDir(groupId, toFilePath(m_profileAdapter->dataPath()));
}
- requestStorageGeneration();
+ if (!m_pendingStorageRequestGeneration)
+ requestStorageGeneration();
}
void ProfileIODataQt::updateCookieStore()
@@ -680,7 +682,8 @@ void ProfileIODataQt::updateCookieStore()
m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy();
m_cookiesPath = m_profileAdapter->cookiesPath();
m_channelIdPath = m_profileAdapter->channelIdPath();
- requestStorageGeneration();
+ if (!m_pendingStorageRequestGeneration)
+ requestStorageGeneration();
}
void ProfileIODataQt::updateUserAgent()
@@ -689,7 +692,8 @@ void ProfileIODataQt::updateUserAgent()
QMutexLocker lock(&m_mutex);
m_httpAcceptLanguage = m_profileAdapter->httpAcceptLanguage();
m_httpUserAgent = m_profileAdapter->httpUserAgent();
- requestStorageGeneration();
+ if (!m_pendingStorageRequestGeneration)
+ requestStorageGeneration();
}
void ProfileIODataQt::updateHttpCache()
@@ -701,14 +705,19 @@ void ProfileIODataQt::updateHttpCache()
m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize();
if (m_httpCacheType == ProfileAdapter::NoCache) {
+ m_pendingStorageRequestGeneration = true;
content::BrowsingDataRemover *remover =
content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile());
- remover->Remove(base::Time(), base::Time::Max(),
+ remover->AddObserver(&m_removerObserver);
+ remover->RemoveAndReply(base::Time(), base::Time::Max(),
content::BrowsingDataRemover::DATA_TYPE_CACHE,
content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB |
- content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB);
+ content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB,
+ &m_removerObserver);
+ return;
}
- requestStorageGeneration();
+ if (!m_pendingStorageRequestGeneration)
+ requestStorageGeneration();
}
void ProfileIODataQt::updateJobFactory()
@@ -800,4 +809,24 @@ ProfileIODataQt *ProfileIODataQt::FromResourceContext(content::ResourceContext *
return static_cast<ResourceContextQt *>(resource_context)->m_io_data;
}
+void ProfileIODataQt::removeBrowsingDataRemoverObserver()
+{
+ content::BrowsingDataRemover *remover =
+ content::BrowserContext::GetBrowsingDataRemover(m_profileAdapter->profile());
+ remover->RemoveObserver(&m_removerObserver);
+}
+
+BrowsingDataRemoverObserverQt::BrowsingDataRemoverObserverQt(ProfileIODataQt *profileIOData)
+ : m_profileIOData(profileIOData)
+{
+}
+
+void BrowsingDataRemoverObserverQt::OnBrowsingDataRemoverDone()
+{
+ Q_ASSERT(m_profileIOData->m_pendingStorageRequestGeneration);
+ m_profileIOData->requestStorageGeneration();
+ m_profileIOData->removeBrowsingDataRemoverObserver();
+ m_profileIOData->m_pendingStorageRequestGeneration = false;
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h
index 57ddb6fd3..3d9a5ef19 100644
--- a/src/core/profile_io_data_qt.h
+++ b/src/core/profile_io_data_qt.h
@@ -41,6 +41,7 @@
#define PROFILE_IO_DATA_QT_H
#include "profile_adapter.h"
+#include "content/public/browser/browsing_data_remover.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "extensions/buildflags/buildflags.h"
@@ -70,8 +71,21 @@ class ExtensionSystemQt;
namespace QtWebEngineCore {
class ClientCertificateStoreData;
+class ProfileIODataQt;
class ProfileQt;
+
+class BrowsingDataRemoverObserverQt : public content::BrowsingDataRemover::Observer {
+public:
+ BrowsingDataRemoverObserverQt(ProfileIODataQt *profileIOData);
+
+ void OnBrowsingDataRemoverDone() override;
+
+private:
+ ProfileIODataQt *m_profileIOData;
+};
+
+
// ProfileIOData contains data that lives on the IOthread
// we still use shared memebers and use mutex which breaks
// idea for this object, but this is wip.
@@ -130,6 +144,8 @@ public:
std::unique_ptr<net::ClientCertStore> CreateClientCertStore();
static ProfileIODataQt *FromResourceContext(content::ResourceContext *resource_context);
private:
+ void removeBrowsingDataRemoverObserver();
+
ProfileQt *m_profile;
std::unique_ptr<net::URLRequestContextStorage> m_storage;
std::unique_ptr<net::NetworkDelegate> m_networkDelegate;
@@ -170,9 +186,13 @@ private:
bool m_ignoreCertificateErrors = false;
bool m_useForGlobalCertificateVerification = false;
bool m_hasPageInterceptors = false;
+ BrowsingDataRemoverObserverQt m_removerObserver;
base::WeakPtrFactory<ProfileIODataQt> m_weakPtrFactory; // this should be always the last member
QString m_dataPath;
+ bool m_pendingStorageRequestGeneration = false;
DISALLOW_COPY_AND_ASSIGN(ProfileIODataQt);
+
+ friend class BrowsingDataRemoverObserverQt;
};
} // namespace QtWebEngineCore
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index b0db4e974..8bd68bb97 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -60,7 +60,7 @@ private Q_SLOTS:
void downloadItem();
void changePersistentPath();
void initiator();
- void qtbug_72299(); // this should be the last test
+ void qtbug_71895(); // this should be the last test
};
void tst_QWebEngineProfile::init()
@@ -631,7 +631,7 @@ void tst_QWebEngineProfile::initiator()
QCOMPARE(handler.initiator, QUrl());
}
-void tst_QWebEngineProfile::qtbug_72299()
+void tst_QWebEngineProfile::qtbug_71895()
{
QWebEngineView view;
view.setUrl(QUrl("https://www.qt.io"));