summaryrefslogtreecommitdiffstats
path: root/src/core/profile_io_data_qt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/profile_io_data_qt.cpp')
-rw-r--r--src/core/profile_io_data_qt.cpp169
1 files changed, 74 insertions, 95 deletions
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
index e44354029..01a4e98aa 100644
--- a/src/core/profile_io_data_qt.cpp
+++ b/src/core/profile_io_data_qt.cpp
@@ -189,6 +189,9 @@ ProfileIODataQt::~ProfileIODataQt()
#endif
}
+ if (m_urlRequestContext && m_urlRequestContext->proxy_resolution_service())
+ m_urlRequestContext->proxy_resolution_service()->OnShutdown();
+
m_resourceContext.reset();
if (m_cookieDelegate)
m_cookieDelegate->setCookieMonster(0); // this will let CookieMonsterDelegateQt be deleted
@@ -240,10 +243,10 @@ void ProfileIODataQt::initializeOnIOThread()
// this binds factory to io thread
m_weakPtr = m_weakPtrFactory.GetWeakPtr();
QMutexLocker lock(&m_mutex);
- m_initialized = true;
generateAllStorage();
generateJobFactory();
setGlobalCertificateVerification();
+ m_initialized = true;
}
void ProfileIODataQt::initializeOnUIThread()
@@ -258,6 +261,7 @@ void ProfileIODataQt::initializeOnUIThread()
protocolHandlerRegistry->CreateJobInterceptorFactory();
m_cookieDelegate = new CookieMonsterDelegateQt();
m_cookieDelegate->setClient(m_profile->profileAdapter()->cookieStore());
+ createProxyConfig();
}
void ProfileIODataQt::cancelAllUrlRequests()
@@ -293,11 +297,12 @@ void ProfileIODataQt::generateStorage()
// We must stop all requests before deleting their backends.
if (m_storage) {
- m_cookieDelegate->setCookieMonster(0);
- m_storage->set_cookie_store(0);
+ m_urlRequestContext->proxy_resolution_service()->OnShutdown();
+ m_cookieDelegate->setCookieMonster(nullptr);
+ m_storage->set_cookie_store(nullptr);
cancelAllUrlRequests();
// we need to get rid of dangling pointer due to coming storage deletion
- m_urlRequestContext->set_http_transaction_factory(0);
+ m_urlRequestContext->set_http_transaction_factory(nullptr);
m_httpNetworkSession.reset();
m_transportSecurityPersister.reset();
}
@@ -317,29 +322,23 @@ void ProfileIODataQt::generateStorage()
m_storage->set_cert_verifier(std::move(cert_verifier));
std::unique_ptr<net::MultiLogCTVerifier> ct_verifier(new net::MultiLogCTVerifier());
-// FIXME:
-// ct_verifier->AddLogs(net::ct::CreateLogVerifiersForKnownLogs());
+ std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs;
+ for (const auto &ct_log : certificate_transparency::GetKnownLogs()) {
+ scoped_refptr<const net::CTLogVerifier> log_verifier =
+ net::CTLogVerifier::Create(std::string(ct_log.log_key, ct_log.log_key_length),
+ ct_log.log_name,
+ ct_log.log_dns_domain);
+ if (!log_verifier)
+ continue;
+ ct_logs.push_back(std::move(log_verifier));
+ }
+ ct_verifier->AddLogs(ct_logs);
m_storage->set_cert_transparency_verifier(std::move(ct_verifier));
m_storage->set_ct_policy_enforcer(base::WrapUnique(new net::DefaultCTPolicyEnforcer()));
-
- std::unique_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL));
-
- // The System Proxy Resolver has issues on Windows with unconfigured network cards,
- // which is why we want to use the v8 one
- if (!m_dhcpPacFileFetcherFactory)
- m_dhcpPacFileFetcherFactory.reset(new net::DhcpPacFileFetcherFactory);
-
- proxy_resolver::mojom::ProxyResolverFactoryPtr proxyResolver(std::move(m_proxyResolverFactoryInterface));
- m_storage->set_proxy_resolution_service(network::CreateProxyResolutionServiceUsingMojoFactory(
- std::move(proxyResolver),
- std::unique_ptr<net::ProxyConfigService>(proxyConfigService),
- net::PacFileFetcherImpl::CreateWithFileUrlSupport(m_urlRequestContext.get()),
- m_dhcpPacFileFetcherFactory->Create(m_urlRequestContext.get()),
- host_resolver.get(),
- nullptr /* NetLog */,
- m_networkDelegate.get()));
-
+ m_storage->set_host_resolver(net::HostResolver::CreateDefaultResolver(NULL));
m_storage->set_ssl_config_service(std::make_unique<net::SSLConfigServiceDefaults>());
+ m_storage->set_http_auth_handler_factory(net::HttpAuthHandlerFactory::CreateDefault(
+ m_urlRequestContext->host_resolver()));
m_storage->set_transport_security_state(std::make_unique<net::TransportSecurityState>());
if (!m_dataPath.isEmpty()) {
@@ -355,20 +354,23 @@ void ProfileIODataQt::generateStorage()
background_task_runner);
};
- if (!m_httpAuthPreferences)
- m_httpAuthPreferences.reset(new net::HttpAuthPreferences());
-
- m_storage->set_http_auth_handler_factory(net::HttpAuthHandlerFactory::CreateDefault(
- host_resolver.get(),
- m_httpAuthPreferences.get()
-#if (defined(OS_POSIX) && !defined(OS_ANDROID)) || defined(OS_FUCHSIA)
- , std::string() /* gssapi library name */
-#endif
- ));
m_storage->set_http_server_properties(std::unique_ptr<net::HttpServerProperties>(
new net::HttpServerPropertiesImpl));
- // Give |m_storage| ownership at the end in case it's |mapped_host_resolver|.
- m_storage->set_host_resolver(std::move(host_resolver));
+
+ // The System Proxy Resolver has issues on Windows with unconfigured network cards,
+ // which is why we want to use the v8 one
+ if (!m_dhcpPacFileFetcherFactory)
+ m_dhcpPacFileFetcherFactory.reset(new net::DhcpPacFileFetcherFactory);
+
+ proxy_resolver::mojom::ProxyResolverFactoryPtr proxyResolver(std::move(m_proxyResolverFactoryInterface));
+ m_storage->set_proxy_resolution_service(network::CreateProxyResolutionServiceUsingMojoFactory(
+ std::move(proxyResolver),
+ std::unique_ptr<net::ProxyConfigService>(proxyConfigService),
+ net::PacFileFetcherImpl::CreateWithFileUrlSupport(m_urlRequestContext.get()),
+ m_dhcpPacFileFetcherFactory->Create(m_urlRequestContext.get()),
+ m_urlRequestContext->host_resolver(),
+ nullptr /* NetLog */,
+ m_urlRequestContext->network_delegate()));
}
@@ -376,10 +378,8 @@ void ProfileIODataQt::generateCookieStore()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
Q_ASSERT(m_urlRequestContext);
- Q_ASSERT(m_storage);
QMutexLocker lock(&m_mutex);
- m_updateCookieStore = false;
scoped_refptr<net::SQLiteChannelIDStore> channel_id_db;
if (!m_channelIdPath.isEmpty() && m_persistentCookiesPolicy != ProfileAdapter::NoPersistentCookies) {
@@ -393,11 +393,6 @@ void ProfileIODataQt::generateCookieStore()
base::WrapUnique(new net::ChannelIDService(
new net::DefaultChannelIDStore(channel_id_db.get()))));
- // Unset it first to get a chance to destroy and flush the old cookie store before
- // opening a new on possibly the same file.
- m_cookieDelegate->setCookieMonster(0);
- m_storage->set_cookie_store(0);
-
std::unique_ptr<net::CookieStore> cookieStore;
switch (m_persistentCookiesPolicy) {
case ProfileAdapter::NoPersistentCookies:
@@ -437,11 +432,6 @@ void ProfileIODataQt::generateCookieStore()
const std::vector<std::string> cookieableSchemes(kCookieableSchemes,
kCookieableSchemes + arraysize(kCookieableSchemes));
cookieMonster->SetCookieableSchemes(cookieableSchemes);
-
- if (!m_updateAllStorage && m_updateHttpCache) {
- // HttpCache needs to be regenerated when we generate a new channel id service
- generateHttpCache();
- }
}
void ProfileIODataQt::generateUserAgent()
@@ -451,8 +441,6 @@ void ProfileIODataQt::generateUserAgent()
Q_ASSERT(m_storage);
QMutexLocker lock(&m_mutex);
- m_updateUserAgent = false;
-
m_storage->set_http_user_agent_settings(std::unique_ptr<net::HttpUserAgentSettings>(
new net::StaticHttpUserAgentSettings(m_httpAcceptLanguage.toStdString(),
m_httpUserAgent.toStdString())));
@@ -465,10 +453,6 @@ void ProfileIODataQt::generateHttpCache()
Q_ASSERT(m_storage);
QMutexLocker lock(&m_mutex);
- m_updateHttpCache = false;
-
- if (m_updateCookieStore)
- generateCookieStore();
net::HttpCache::DefaultBackend* main_backend = 0;
switch (m_httpCacheType) {
@@ -635,6 +619,38 @@ void ProfileIODataQt::setFullConfiguration()
m_dataPath = m_profileAdapter->dataPath();
}
+void ProfileIODataQt::requestStorageGeneration() {
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ QMutexLocker lock(&m_mutex);
+ if (m_initialized && !m_updateAllStorage) {
+ m_updateAllStorage = true;
+ createProxyConfig();
+ base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
+ base::BindOnce(&ProfileIODataQt::generateAllStorage, m_weakPtr));
+ }
+}
+
+// TODO(miklocek): mojofy ProxyConfigServiceQt
+void ProfileIODataQt::createProxyConfig()
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ QMutexLocker lock(&m_mutex);
+ // We must create the proxy config service on the UI loop on Linux because it
+ // must synchronously run on the glib message loop. This will be passed to
+ // the URLRequestContextStorage on the IO thread in GetURLRequestContext().
+ Q_ASSERT(m_proxyConfigService == 0);
+ net::ProxyConfigWithAnnotation initialConfig;
+ ProxyPrefs::ConfigState initialConfigState = PrefProxyConfigTrackerImpl::ReadPrefConfig(
+ m_profileAdapter->profile()->GetPrefs(), &initialConfig);
+ m_proxyConfigService =
+ new ProxyConfigServiceQt(
+ net::ProxyResolutionService::CreateSystemProxyConfigService(
+ base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::IO})),
+ initialConfig, initialConfigState);
+ //pass interface to io thread
+ m_proxyResolverFactoryInterface = ChromeMojoProxyResolverFactory::CreateWithStrongBinding().PassInterface();
+}
+
void ProfileIODataQt::updateStorageSettings()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -647,28 +663,7 @@ void ProfileIODataQt::updateStorageSettings()
file::ForgetServiceUserIdUserDirAssociation(userId);
file::AssociateServiceUserIdWithUserDir(userId, toFilePath(m_profileAdapter->dataPath()));
}
-
- if (!m_updateAllStorage) {
- m_updateAllStorage = true;
- // We must create the proxy config service on the UI loop on Linux because it
- // must synchronously run on the glib message loop. This will be passed to
- // the URLRequestContextStorage on the IO thread in GetURLRequestContext().
- Q_ASSERT(m_proxyConfigService == 0);
- net::ProxyConfigWithAnnotation initialConfig;
- ProxyPrefs::ConfigState initialConfigState = PrefProxyConfigTrackerImpl::ReadPrefConfig(
- m_profileAdapter->profile()->GetPrefs(), &initialConfig);
-
- m_proxyConfigService =
- new ProxyConfigServiceQt(
- net::ProxyResolutionService::CreateSystemProxyConfigService(
- base::CreateSingleThreadTaskRunnerWithTraits({content::BrowserThread::IO})),
- initialConfig, initialConfigState);
- //pass interface to io thread
- m_proxyResolverFactoryInterface = ChromeMojoProxyResolverFactory::CreateWithStrongBinding().PassInterface();
- if (m_initialized)
- base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&ProfileIODataQt::generateAllStorage, m_weakPtr));
- }
+ requestStorageGeneration();
}
void ProfileIODataQt::updateCookieStore()
@@ -678,13 +673,7 @@ void ProfileIODataQt::updateCookieStore()
m_persistentCookiesPolicy = m_profileAdapter->persistentCookiesPolicy();
m_cookiesPath = m_profileAdapter->cookiesPath();
m_channelIdPath = m_profileAdapter->channelIdPath();
-
- if (m_initialized && !m_updateAllStorage && !m_updateCookieStore) {
- m_updateCookieStore = true;
- m_updateHttpCache = true;
- base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&ProfileIODataQt::generateCookieStore, m_weakPtr));
- }
+ requestStorageGeneration();
}
void ProfileIODataQt::updateUserAgent()
@@ -693,12 +682,7 @@ void ProfileIODataQt::updateUserAgent()
QMutexLocker lock(&m_mutex);
m_httpAcceptLanguage = m_profileAdapter->httpAcceptLanguage();
m_httpUserAgent = m_profileAdapter->httpUserAgent();
-
- if (m_initialized && !m_updateAllStorage && !m_updateUserAgent) {
- m_updateUserAgent = true;
- base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&ProfileIODataQt::generateUserAgent, m_weakPtr));
- }
+ requestStorageGeneration();
}
void ProfileIODataQt::updateHttpCache()
@@ -717,12 +701,7 @@ void ProfileIODataQt::updateHttpCache()
content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB |
content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB);
}
-
- if (m_initialized && !m_updateAllStorage && !m_updateHttpCache) {
- m_updateHttpCache = true;
- base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&ProfileIODataQt::generateHttpCache, m_weakPtr));
- }
+ requestStorageGeneration();
}
void ProfileIODataQt::updateJobFactory()