This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
fix: Always create cookie store with network context (3-1-x) #725
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
diff --git a/services/network/network_context.cc b/services/network/network_context.cc | ||
index b681ac5f60ca66f7d5e3e0ad50eb2d6e784e096a..ebe10f496965b71798bb5119b7cd4dee006012a5 100644 | ||
--- a/services/network/network_context.cc | ||
+++ b/services/network/network_context.cc | ||
@@ -38,6 +38,7 @@ | ||
#include "net/ssl/default_channel_id_store.h" | ||
#include "net/url_request/url_request_context.h" | ||
#include "net/url_request/url_request_context_builder.h" | ||
+#include "services/network/cookie_manager.h" | ||
#include "services/network/http_server_properties_pref_delegate.h" | ||
#include "services/network/ignore_errors_cert_verifier.h" | ||
#include "services/network/network_service.h" | ||
@@ -256,12 +257,30 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext( | ||
builder.set_accept_language("en-us,en"); | ||
builder.set_user_agent(network_context_params->user_agent); | ||
|
||
- // The cookie configuration is in this method, which is only used by the | ||
- // network process, and not ApplyContextParamsToBuilder which is used by the | ||
- // browser as well. This is because this code path doesn't handle encryption | ||
- // and other configuration done in QuotaPolicyCookieStore yet (and we still | ||
- // have to figure out which of the latter needs to move to the network | ||
- // process). TODO: http://crbug.com/789644 | ||
+ if (g_cert_verifier_for_testing) { | ||
+ builder.SetCertVerifier(std::make_unique<WrappedTestingCertVerifier>()); | ||
+ } else { | ||
+ std::unique_ptr<net::CertVerifier> cert_verifier = | ||
+ net::CertVerifier::CreateDefault(); | ||
+ builder.SetCertVerifier(IgnoreErrorsCertVerifier::MaybeWrapCertVerifier( | ||
+ *command_line, nullptr, std::move(cert_verifier))); | ||
+ } | ||
+ | ||
+ // |network_service_| may be nullptr in tests. | ||
+ return ApplyContextParamsToBuilder( | ||
+ &builder, network_context_params, | ||
+ network_service_ ? network_service_->quic_disabled() : false, | ||
+ network_service_ ? network_service_->net_log() : nullptr); | ||
+} | ||
+ | ||
+URLRequestContextOwner NetworkContext::ApplyContextParamsToBuilder( | ||
+ URLRequestContextBuilderMojo* builder, | ||
+ mojom::NetworkContextParams* network_context_params, | ||
+ bool quic_disabled, | ||
+ net::NetLog* net_log) { | ||
+ if (net_log) | ||
+ builder->set_net_log(net_log); | ||
+ | ||
if (network_context_params->cookie_path) { | ||
DCHECK(network_context_params->channel_id_path); | ||
net::CookieCryptoDelegate* crypto_delegate = nullptr; | ||
@@ -295,37 +314,13 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext( | ||
cookie_store->SetPersistSessionCookies(true); | ||
|
||
cookie_store->SetChannelIDServiceID(channel_id_service->GetUniqueID()); | ||
- builder.SetCookieAndChannelIdStores(std::move(cookie_store), | ||
- std::move(channel_id_service)); | ||
+ builder->SetCookieAndChannelIdStores(std::move(cookie_store), | ||
+ std::move(channel_id_service)); | ||
} else { | ||
DCHECK(!network_context_params->restore_old_session_cookies); | ||
DCHECK(!network_context_params->persist_session_cookies); | ||
} | ||
|
||
- if (g_cert_verifier_for_testing) { | ||
- builder.SetCertVerifier(std::make_unique<WrappedTestingCertVerifier>()); | ||
- } else { | ||
- std::unique_ptr<net::CertVerifier> cert_verifier = | ||
- net::CertVerifier::CreateDefault(); | ||
- builder.SetCertVerifier(IgnoreErrorsCertVerifier::MaybeWrapCertVerifier( | ||
- *command_line, nullptr, std::move(cert_verifier))); | ||
- } | ||
- | ||
- // |network_service_| may be nullptr in tests. | ||
- return ApplyContextParamsToBuilder( | ||
- &builder, network_context_params, | ||
- network_service_ ? network_service_->quic_disabled() : false, | ||
- network_service_ ? network_service_->net_log() : nullptr); | ||
-} | ||
- | ||
-URLRequestContextOwner NetworkContext::ApplyContextParamsToBuilder( | ||
- URLRequestContextBuilderMojo* builder, | ||
- mojom::NetworkContextParams* network_context_params, | ||
- bool quic_disabled, | ||
- net::NetLog* net_log) { | ||
- if (net_log) | ||
- builder->set_net_log(net_log); | ||
- | ||
builder->set_enable_brotli(network_context_params->enable_brotli); | ||
if (network_context_params->context_name) | ||
builder->set_name(*network_context_params->context_name); | ||
diff --git a/services/network/network_context.h b/services/network/network_context.h | ||
index b39c97b329684bf90e9ef0eaccbb4577b12db758..ef70d8585f41829d69425f8f35157d82fbff1f7f 100644 | ||
--- a/services/network/network_context.h | ||
+++ b/services/network/network_context.h | ||
@@ -16,7 +16,6 @@ | ||
#include "base/time/time.h" | ||
#include "mojo/public/cpp/bindings/binding.h" | ||
#include "mojo/public/cpp/bindings/strong_binding_set.h" | ||
-#include "services/network/cookie_manager.h" | ||
#include "services/network/public/mojom/network_service.mojom.h" | ||
#include "services/network/public/mojom/udp_socket.mojom.h" | ||
#include "services/network/public/mojom/url_loader_factory.mojom.h" | ||
@@ -28,6 +27,7 @@ class URLRequestContext; | ||
} // namespace net | ||
|
||
namespace network { | ||
+class CookieManager; | ||
class NetworkService; | ||
class ResourceScheduler; | ||
class ResourceSchedulerClient; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the trouble now 😆