Commit c8e3546c authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Make sure custom proxy config is always a valid pointer

This was part of the reason one of the Android tests is failing.

Bug: 721403
Change-Id: I58493a24c32aaac2e568ade3541dea36ff87b88c
Reviewed-on: https://chromium-review.googlesource.com/c/1352325Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611496}
parent b68bc5ef
...@@ -102,7 +102,12 @@ NetworkServiceProxyDelegate::NetworkServiceProxyDelegate( ...@@ -102,7 +102,12 @@ NetworkServiceProxyDelegate::NetworkServiceProxyDelegate(
mojom::CustomProxyConfigClientRequest config_client_request) mojom::CustomProxyConfigClientRequest config_client_request)
: proxy_config_(std::move(initial_config)), : proxy_config_(std::move(initial_config)),
binding_(this, std::move(config_client_request)), binding_(this, std::move(config_client_request)),
should_use_alternate_proxy_list_cache_(kMaxCacheSize) {} should_use_alternate_proxy_list_cache_(kMaxCacheSize) {
// Make sure there is always a valid proxy config so we don't need to null
// check it.
if (!proxy_config_)
proxy_config_ = mojom::CustomProxyConfig::New();
}
void NetworkServiceProxyDelegate::OnBeforeStartTransaction( void NetworkServiceProxyDelegate::OnBeforeStartTransaction(
net::URLRequest* request, net::URLRequest* request,
......
...@@ -50,6 +50,16 @@ class NetworkServiceProxyDelegateTest : public testing::Test { ...@@ -50,6 +50,16 @@ class NetworkServiceProxyDelegateTest : public testing::Test {
base::test::ScopedTaskEnvironment scoped_task_environment_; base::test::ScopedTaskEnvironment scoped_task_environment_;
}; };
TEST_F(NetworkServiceProxyDelegateTest, NullConfigDoesNotCrash) {
mojom::CustomProxyConfigClientPtr client;
auto delegate = std::make_unique<NetworkServiceProxyDelegate>(
nullptr, mojo::MakeRequest(&client));
net::HttpRequestHeaders headers;
auto request = CreateRequest(GURL(kHttpUrl));
delegate->OnBeforeStartTransaction(request.get(), &headers);
}
TEST_F(NetworkServiceProxyDelegateTest, AddsHeadersBeforeCache) { TEST_F(NetworkServiceProxyDelegateTest, AddsHeadersBeforeCache) {
auto config = mojom::CustomProxyConfig::New(); auto config = mojom::CustomProxyConfig::New();
config->rules.ParseFromString("http=proxy"); config->rules.ParseFromString("http=proxy");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment