diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-24 11:40:17 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-24 12:42:11 +0000 |
commit | 5d87695f37678f96492b258bbab36486c59866b4 (patch) | |
tree | be9783bbaf04fb930c4d74ca9c00b5e7954c8bc6 /chromium/net/proxy_resolution | |
parent | 6c11fb357ec39bf087b8b632e2b1e375aef1b38b (diff) | |
download | qtwebengine-chromium-5d87695f37678f96492b258bbab36486c59866b4.tar.gz |
BASELINE: Update Chromium to 75.0.3770.56
Change-Id: I86d2007fd27a45d5797eee06f4c9369b8b50ac4f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/net/proxy_resolution')
22 files changed, 517 insertions, 592 deletions
diff --git a/chromium/net/proxy_resolution/dhcp_pac_file_adapter_fetcher_win.cc b/chromium/net/proxy_resolution/dhcp_pac_file_adapter_fetcher_win.cc index c8b30245c7b..deb868792ee 100644 --- a/chromium/net/proxy_resolution/dhcp_pac_file_adapter_fetcher_win.cc +++ b/chromium/net/proxy_resolution/dhcp_pac_file_adapter_fetcher_win.cc @@ -214,7 +214,7 @@ std::string DhcpPacFileAdapterFetcher::GetPacURLFromDhcp( std::wstring adapter_name_wide = base::SysMultiByteToWide(adapter_name, CP_ACP); - DHCPCAPI_PARAMS_ARRAY send_params = { 0, NULL }; + DHCPCAPI_PARAMS_ARRAY send_params = {0, nullptr}; DHCPCAPI_PARAMS wpad_params = { 0 }; wpad_params.OptionId = 252; @@ -246,13 +246,10 @@ std::string DhcpPacFileAdapterFetcher::GetPacURLFromDhcp( // chances on non-standard, poorly documented usage. base::ScopedBlockingCall scoped_blocking_call( FROM_HERE, base::BlockingType::MAY_BLOCK); - res = ::DhcpRequestParams(DHCPCAPI_REQUEST_SYNCHRONOUS, - NULL, - const_cast<LPWSTR>(adapter_name_wide.c_str()), - NULL, - send_params, request_params, - result_buffer.get(), &result_buffer_size, - NULL); + res = ::DhcpRequestParams( + DHCPCAPI_REQUEST_SYNCHRONOUS, nullptr, + const_cast<LPWSTR>(adapter_name_wide.c_str()), nullptr, send_params, + request_params, result_buffer.get(), &result_buffer_size, nullptr); ++retry_count; } while (res == ERROR_MORE_DATA && retry_count <= 3); diff --git a/chromium/net/proxy_resolution/dhcp_pac_file_adapter_fetcher_win_unittest.cc b/chromium/net/proxy_resolution/dhcp_pac_file_adapter_fetcher_win_unittest.cc index cdc39aa2be2..d5be7632810 100644 --- a/chromium/net/proxy_resolution/dhcp_pac_file_adapter_fetcher_win_unittest.cc +++ b/chromium/net/proxy_resolution/dhcp_pac_file_adapter_fetcher_win_unittest.cc @@ -54,7 +54,7 @@ class MockDhcpPacFileAdapterFetcher : public DhcpPacFileAdapterFetcher { void Cancel() override { DhcpPacFileAdapterFetcher::Cancel(); - fetcher_ = NULL; + fetcher_ = nullptr; } std::unique_ptr<PacFileFetcher> ImplCreateScriptFetcher() override { @@ -116,7 +116,7 @@ class MockDhcpPacFileAdapterFetcher : public DhcpPacFileAdapterFetcher { // the simple approach currently used in ImplCreateScriptFetcher above). DCHECK(fetcher_ && fetcher_->has_pending_request()); fetcher_->NotifyFetchCompletion(fetcher_result_, pac_script_); - fetcher_ = NULL; + fetcher_ = nullptr; } bool IsWaitingForFetcher() const { diff --git a/chromium/net/proxy_resolution/dhcp_pac_file_fetcher_win.cc b/chromium/net/proxy_resolution/dhcp_pac_file_fetcher_win.cc index 5541498b363..348de981478 100644 --- a/chromium/net/proxy_resolution/dhcp_pac_file_fetcher_win.cc +++ b/chromium/net/proxy_resolution/dhcp_pac_file_fetcher_win.cc @@ -275,7 +275,7 @@ DhcpPacFileFetcherWin::DhcpPacFileFetcherWin( URLRequestContext* url_request_context) : state_(STATE_START), num_pending_fetchers_(0), - destination_string_(NULL), + destination_string_(nullptr), url_request_context_(url_request_context), task_runner_(base::MakeRefCounted<TaskRunnerWithCap>()) { DCHECK(url_request_context_); @@ -376,7 +376,7 @@ void DhcpPacFileFetcherWin::OnGetCandidateAdapterNamesDone( // and a previous query was cancelled before it completed. if (query.get() != last_query_.get()) return; - last_query_ = NULL; + last_query_ = nullptr; DhcpAdapterNamesLoggingInfo* logging_info = query->logging_info(); logging_info->origin_thread_end_time = base::TimeTicks::Now(); @@ -565,14 +565,11 @@ bool DhcpPacFileFetcherWin::GetCandidateAdapterNames( // Return only unicast addresses, and skip information we do not need. base::ScopedBlockingCall scoped_blocking_call( FROM_HERE, base::BlockingType::MAY_BLOCK); - error = GetAdaptersAddresses(AF_UNSPEC, - GAA_FLAG_SKIP_ANYCAST | - GAA_FLAG_SKIP_MULTICAST | - GAA_FLAG_SKIP_DNS_SERVER | - GAA_FLAG_SKIP_FRIENDLY_NAME, - NULL, - adapters.get(), - &adapters_size); + error = GetAdaptersAddresses( + AF_UNSPEC, + GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | + GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME, + nullptr, adapters.get(), &adapters_size); ++num_tries; } while (error == ERROR_BUFFER_OVERFLOW && num_tries <= 3); @@ -589,7 +586,7 @@ bool DhcpPacFileFetcherWin::GetCandidateAdapterNames( return false; } - IP_ADAPTER_ADDRESSES* adapter = NULL; + IP_ADAPTER_ADDRESSES* adapter = nullptr; for (adapter = adapters.get(); adapter; adapter = adapter->Next) { if (IsDhcpCapableAdapter(adapter)) { DCHECK(adapter->AdapterName); diff --git a/chromium/net/proxy_resolution/mock_pac_file_fetcher.cc b/chromium/net/proxy_resolution/mock_pac_file_fetcher.cc index 9e6ce594f32..07190a6cf5c 100644 --- a/chromium/net/proxy_resolution/mock_pac_file_fetcher.cc +++ b/chromium/net/proxy_resolution/mock_pac_file_fetcher.cc @@ -14,8 +14,7 @@ namespace net { MockPacFileFetcher::MockPacFileFetcher() - : pending_request_text_(NULL), - is_shutdown_(false) {} + : pending_request_text_(nullptr), is_shutdown_(false) {} MockPacFileFetcher::~MockPacFileFetcher() = default; @@ -60,7 +59,7 @@ void MockPacFileFetcher::OnShutdown() { } URLRequestContext* MockPacFileFetcher::GetRequestContext() const { - return NULL; + return nullptr; } const GURL& MockPacFileFetcher::pending_request_url() const { diff --git a/chromium/net/proxy_resolution/multi_threaded_proxy_resolver.cc b/chromium/net/proxy_resolution/multi_threaded_proxy_resolver.cc index b48196c0dab..479c9c53f5f 100644 --- a/chromium/net/proxy_resolution/multi_threaded_proxy_resolver.cc +++ b/chromium/net/proxy_resolution/multi_threaded_proxy_resolver.cc @@ -158,7 +158,7 @@ class MultiThreadedProxyResolver : public ProxyResolver, class Job : public base::RefCountedThreadSafe<Job> { public: - Job() : executor_(NULL), was_cancelled_(false) {} + Job() : executor_(nullptr), was_cancelled_(false) {} void set_executor(Executor* executor) { executor_ = executor; @@ -303,8 +303,8 @@ class MultiThreadedProxyResolver::GetProxyForURLJob : public Job { void Run(scoped_refptr<base::SingleThreadTaskRunner> origin_runner) override { ProxyResolver* resolver = executor()->resolver(); DCHECK(resolver); - int rv = resolver->GetProxyForURL(url_, &results_buf_, - CompletionOnceCallback(), NULL, net_log_); + int rv = resolver->GetProxyForURL( + url_, &results_buf_, CompletionOnceCallback(), nullptr, net_log_); DCHECK_NE(rv, ERR_IO_PENDING); origin_runner->PostTask( @@ -368,7 +368,7 @@ void Executor::StartJob(Job* job) { void Executor::OnJobCompleted(Job* job) { DCHECK_EQ(job, outstanding_job_.get()); - outstanding_job_ = NULL; + outstanding_job_ = nullptr; coordinator_->OnExecutorReady(this); } @@ -376,7 +376,7 @@ void Executor::Destroy() { DCHECK(coordinator_); { - // TODO(http://crbug.com/69710): Use TaskScheduler instead of creating a + // TODO(http://crbug.com/69710): Use ThreadPool instead of creating a // base::Thread. MultiThreadedProxyResolverScopedAllowJoinOnIO allow_thread_join; @@ -388,7 +388,7 @@ void Executor::Destroy() { if (outstanding_job_.get()) { outstanding_job_->Cancel(); // Orphan the job (since this executor may be deleted soon). - outstanding_job_->set_executor(NULL); + outstanding_job_->set_executor(nullptr); } // It is now safe to free the ProxyResolver, since all the tasks that @@ -396,8 +396,8 @@ void Executor::Destroy() { resolver_.reset(); // Null some stuff as a precaution. - coordinator_ = NULL; - outstanding_job_ = NULL; + coordinator_ = nullptr; + outstanding_job_ = nullptr; } Executor::~Executor() { @@ -479,7 +479,7 @@ Executor* MultiThreadedProxyResolver::FindIdleExecutor() { if (!executor->outstanding_job()) return executor; } - return NULL; + return nullptr; } void MultiThreadedProxyResolver::AddNewExecutor() { diff --git a/chromium/net/proxy_resolution/multi_threaded_proxy_resolver_unittest.cc b/chromium/net/proxy_resolution/multi_threaded_proxy_resolver_unittest.cc index dacb16ea7ed..6c93f5d6c9a 100644 --- a/chromium/net/proxy_resolution/multi_threaded_proxy_resolver_unittest.cc +++ b/chromium/net/proxy_resolution/multi_threaded_proxy_resolver_unittest.cc @@ -61,7 +61,7 @@ class MockProxyResolver : public ProxyResolver { EXPECT_TRUE(worker_thread_checker_.CalledOnValidThread()); EXPECT_TRUE(callback.is_null()); - EXPECT_TRUE(request == NULL); + EXPECT_TRUE(request == nullptr); // Write something into |net_log| (doesn't really have any meaning.) net_log.BeginEvent(NetLogEventType::PAC_JAVASCRIPT_ALERT); @@ -261,7 +261,7 @@ TEST_F(MultiThreadedProxyResolverTest, SingleThread_Basic) { BoundTestNetLog log0; ProxyInfo results0; rv = resolver().GetProxyForURL(GURL("http://request0"), &results0, - callback0.callback(), NULL, log0.bound()); + callback0.callback(), nullptr, log0.bound()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); // Wait for request 0 to finish. @@ -283,23 +283,23 @@ TEST_F(MultiThreadedProxyResolverTest, SingleThread_Basic) { TestCompletionCallback callback1; ProxyInfo results1; - rv = - resolver().GetProxyForURL(GURL("http://request1"), &results1, - callback1.callback(), NULL, NetLogWithSource()); + rv = resolver().GetProxyForURL(GURL("http://request1"), &results1, + callback1.callback(), nullptr, + NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); TestCompletionCallback callback2; ProxyInfo results2; - rv = - resolver().GetProxyForURL(GURL("http://request2"), &results2, - callback2.callback(), NULL, NetLogWithSource()); + rv = resolver().GetProxyForURL(GURL("http://request2"), &results2, + callback2.callback(), nullptr, + NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); TestCompletionCallback callback3; ProxyInfo results3; - rv = - resolver().GetProxyForURL(GURL("http://request3"), &results3, - callback3.callback(), NULL, NetLogWithSource()); + rv = resolver().GetProxyForURL(GURL("http://request3"), &results3, + callback3.callback(), nullptr, + NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); // Wait for the requests to finish (they must finish in the order they were @@ -345,7 +345,7 @@ TEST_F(MultiThreadedProxyResolverTest, ProxyInfo results1; BoundTestNetLog log1; rv = resolver().GetProxyForURL(GURL("http://request1"), &results1, - callback1.callback(), NULL, log1.bound()); + callback1.callback(), nullptr, log1.bound()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); std::unique_ptr<ProxyResolver::Request> request2; @@ -426,9 +426,9 @@ TEST_F(MultiThreadedProxyResolverTest, SingleThread_CancelRequest) { TestCompletionCallback callback1; ProxyInfo results1; - rv = - resolver().GetProxyForURL(GURL("http://request1"), &results1, - callback1.callback(), NULL, NetLogWithSource()); + rv = resolver().GetProxyForURL(GURL("http://request1"), &results1, + callback1.callback(), nullptr, + NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); std::unique_ptr<ProxyResolver::Request> request2; @@ -441,9 +441,9 @@ TEST_F(MultiThreadedProxyResolverTest, SingleThread_CancelRequest) { TestCompletionCallback callback3; ProxyInfo results3; - rv = - resolver().GetProxyForURL(GURL("http://request3"), &results3, - callback3.callback(), NULL, NetLogWithSource()); + rv = resolver().GetProxyForURL(GURL("http://request3"), &results3, + callback3.callback(), nullptr, + NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); // Cancel request0 (inprogress) and request2 (pending). @@ -487,23 +487,23 @@ TEST_F(MultiThreadedProxyResolverTest, SingleThread_CancelRequestByDeleting) { TestCompletionCallback callback0; ProxyInfo results0; - rv = - resolver().GetProxyForURL(GURL("http://request0"), &results0, - callback0.callback(), NULL, NetLogWithSource()); + rv = resolver().GetProxyForURL(GURL("http://request0"), &results0, + callback0.callback(), nullptr, + NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); TestCompletionCallback callback1; ProxyInfo results1; - rv = - resolver().GetProxyForURL(GURL("http://request1"), &results1, - callback1.callback(), NULL, NetLogWithSource()); + rv = resolver().GetProxyForURL(GURL("http://request1"), &results1, + callback1.callback(), nullptr, + NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); TestCompletionCallback callback2; ProxyInfo results2; - rv = - resolver().GetProxyForURL(GURL("http://request2"), &results2, - callback2.callback(), NULL, NetLogWithSource()); + rv = resolver().GetProxyForURL(GURL("http://request2"), &results2, + callback2.callback(), nullptr, + NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); // Wait until request 0 reaches the worker thread. diff --git a/chromium/net/proxy_resolution/network_delegate_error_observer.cc b/chromium/net/proxy_resolution/network_delegate_error_observer.cc index a898cb6cea8..99985400007 100644 --- a/chromium/net/proxy_resolution/network_delegate_error_observer.cc +++ b/chromium/net/proxy_resolution/network_delegate_error_observer.cc @@ -60,7 +60,7 @@ void NetworkDelegateErrorObserver::Core::NotifyPACScriptError( void NetworkDelegateErrorObserver::Core::Shutdown() { CHECK(origin_runner_->BelongsToCurrentThread()); - network_delegate_ = NULL; + network_delegate_ = nullptr; } // NetworkDelegateErrorObserver ----------------------------------------------- diff --git a/chromium/net/proxy_resolution/network_delegate_error_observer_unittest.cc b/chromium/net/proxy_resolution/network_delegate_error_observer_unittest.cc index 0a13cab0209..1bd3e42b448 100644 --- a/chromium/net/proxy_resolution/network_delegate_error_observer_unittest.cc +++ b/chromium/net/proxy_resolution/network_delegate_error_observer_unittest.cc @@ -108,7 +108,7 @@ TEST(NetworkDelegateErrorObserverTest, NoDelegate) { base::Thread thread("test_thread"); thread.Start(); NetworkDelegateErrorObserver observer( - NULL, base::ThreadTaskRunnerHandle::Get().get()); + nullptr, base::ThreadTaskRunnerHandle::Get().get()); thread.task_runner()->PostTask( FROM_HERE, base::BindOnce(&NetworkDelegateErrorObserver::OnPACScriptError, diff --git a/chromium/net/proxy_resolution/pac_file_decider_unittest.cc b/chromium/net/proxy_resolution/pac_file_decider_unittest.cc index c257c2ebd18..cd3d212cde9 100644 --- a/chromium/net/proxy_resolution/pac_file_decider_unittest.cc +++ b/chromium/net/proxy_resolution/pac_file_decider_unittest.cc @@ -108,7 +108,7 @@ class Rules { class RuleBasedPacFileFetcher : public PacFileFetcher { public: explicit RuleBasedPacFileFetcher(const Rules* rules) - : rules_(rules), request_context_(NULL) {} + : rules_(rules), request_context_(nullptr) {} virtual void SetRequestContext(URLRequestContext* context) { request_context_ = context; @@ -285,7 +285,7 @@ TEST(PacFileDeciderTest, CustomPacFails2) { rules.AddFailParsingRule("http://custom/proxy.pac"); TestCompletionCallback callback; - PacFileDecider decider(&fetcher, &dhcp_fetcher, NULL); + PacFileDecider decider(&fetcher, &dhcp_fetcher, nullptr); EXPECT_THAT(decider.Start(ProxyConfigWithAnnotation( config, TRAFFIC_ANNOTATION_FOR_TESTS), base::TimeDelta(), true, callback.callback()), @@ -302,7 +302,7 @@ TEST(PacFileDeciderTest, HasNullPacFileFetcher) { config.set_pac_url(GURL("http://custom/proxy.pac")); TestCompletionCallback callback; - PacFileDecider decider(NULL, &dhcp_fetcher, NULL); + PacFileDecider decider(nullptr, &dhcp_fetcher, nullptr); EXPECT_THAT(decider.Start(ProxyConfigWithAnnotation( config, TRAFFIC_ANNOTATION_FOR_TESTS), base::TimeDelta(), true, callback.callback()), @@ -322,7 +322,7 @@ TEST(PacFileDeciderTest, AutodetectSuccess) { Rules::Rule rule = rules.AddSuccessRule("http://wpad/wpad.dat"); TestCompletionCallback callback; - PacFileDecider decider(&fetcher, &dhcp_fetcher, NULL); + PacFileDecider decider(&fetcher, &dhcp_fetcher, nullptr); EXPECT_THAT(decider.Start(ProxyConfigWithAnnotation( config, TRAFFIC_ANNOTATION_FOR_TESTS), base::TimeDelta(), true, callback.callback()), @@ -344,7 +344,7 @@ class PacFileDeciderQuickCheckTest : public TestWithScopedTaskEnvironment { request_context_.set_host_resolver(&resolver_); fetcher_.SetRequestContext(&request_context_); config_.set_auto_detect(true); - decider_.reset(new PacFileDecider(&fetcher_, &dhcp_fetcher_, NULL)); + decider_.reset(new PacFileDecider(&fetcher_, &dhcp_fetcher_, nullptr)); } int StartDecider() { @@ -428,7 +428,7 @@ TEST_F(PacFileDeciderQuickCheckTest, QuickCheckInhibitsDhcp) { base::string16 pac_contents = base::UTF8ToUTF16(kPac); GURL url("http://foobar/baz"); dhcp_fetcher.SetPacURL(url); - decider_.reset(new PacFileDecider(&fetcher_, &dhcp_fetcher, NULL)); + decider_.reset(new PacFileDecider(&fetcher_, &dhcp_fetcher, nullptr)); EXPECT_THAT(StartDecider(), IsError(ERR_IO_PENDING)); dhcp_fetcher.CompleteRequests(OK, pac_contents); EXPECT_TRUE(decider_->effective_config().value().has_pac_url()); @@ -445,7 +445,7 @@ TEST_F(PacFileDeciderQuickCheckTest, QuickCheckDisabled) { resolver_.rules_map()[HostResolverSource::SYSTEM]->AddSimulatedFailure( "wpad"); MockPacFileFetcher fetcher; - decider_.reset(new PacFileDecider(&fetcher, &dhcp_fetcher_, NULL)); + decider_.reset(new PacFileDecider(&fetcher, &dhcp_fetcher_, nullptr)); EXPECT_THAT(StartDecider(), IsError(ERR_IO_PENDING)); EXPECT_TRUE(fetcher.has_pending_request()); fetcher.NotifyFetchCompletion(OK, kPac); @@ -482,7 +482,7 @@ TEST_F(PacFileDeciderQuickCheckTest, ShutdownDuringResolve) { TEST_F(PacFileDeciderQuickCheckTest, CancelPartway) { resolver_.set_ondemand_mode(true); EXPECT_THAT(StartDecider(), IsError(ERR_IO_PENDING)); - decider_.reset(NULL); + decider_.reset(nullptr); } // Fails at WPAD (downloading), but succeeds in choosing the custom PAC. @@ -499,7 +499,7 @@ TEST(PacFileDeciderTest, AutodetectFailCustomSuccess1) { Rules::Rule rule = rules.AddSuccessRule("http://custom/proxy.pac"); TestCompletionCallback callback; - PacFileDecider decider(&fetcher, &dhcp_fetcher, NULL); + PacFileDecider decider(&fetcher, &dhcp_fetcher, nullptr); EXPECT_THAT(decider.Start(ProxyConfigWithAnnotation( config, TRAFFIC_ANNOTATION_FOR_TESTS), base::TimeDelta(), true, callback.callback()), @@ -593,7 +593,7 @@ TEST(PacFileDeciderTest, AutodetectFailCustomFails1) { rules.AddFailDownloadRule("http://custom/proxy.pac"); TestCompletionCallback callback; - PacFileDecider decider(&fetcher, &dhcp_fetcher, NULL); + PacFileDecider decider(&fetcher, &dhcp_fetcher, nullptr); EXPECT_THAT(decider.Start(ProxyConfigWithAnnotation( config, TRAFFIC_ANNOTATION_FOR_TESTS), base::TimeDelta(), true, callback.callback()), @@ -615,7 +615,7 @@ TEST(PacFileDeciderTest, AutodetectFailCustomFails2) { rules.AddFailParsingRule("http://custom/proxy.pac"); TestCompletionCallback callback; - PacFileDecider decider(&fetcher, &dhcp_fetcher, NULL); + PacFileDecider decider(&fetcher, &dhcp_fetcher, nullptr); EXPECT_THAT(decider.Start(ProxyConfigWithAnnotation( config, TRAFFIC_ANNOTATION_FOR_TESTS), base::TimeDelta(), true, callback.callback()), @@ -753,7 +753,7 @@ TEST(PacFileDeciderTest, AutodetectDhcpSuccess) { rules.AddFailDownloadRule("http://wpad/wpad.dat"); TestCompletionCallback callback; - PacFileDecider decider(&fetcher, &dhcp_fetcher, NULL); + PacFileDecider decider(&fetcher, &dhcp_fetcher, nullptr); EXPECT_THAT(decider.Start(ProxyConfigWithAnnotation( config, TRAFFIC_ANNOTATION_FOR_TESTS), base::TimeDelta(), true, callback.callback()), @@ -779,7 +779,7 @@ TEST(PacFileDeciderTest, AutodetectDhcpFailParse) { rules.AddFailDownloadRule("http://wpad/wpad.dat"); TestCompletionCallback callback; - PacFileDecider decider(&fetcher, &dhcp_fetcher, NULL); + PacFileDecider decider(&fetcher, &dhcp_fetcher, nullptr); // Since there is fallback to DNS-based WPAD, the final error will be that // it failed downloading, not that it failed parsing. EXPECT_THAT(decider.Start(ProxyConfigWithAnnotation( @@ -846,7 +846,7 @@ TEST(PacFileDeciderTest, DhcpCancelledByDestructor) { // Scope so PacFileDecider gets destroyed early. { - PacFileDecider decider(&fetcher, dhcp_fetcher.get(), NULL); + PacFileDecider decider(&fetcher, dhcp_fetcher.get(), nullptr); decider.Start( ProxyConfigWithAnnotation(config, TRAFFIC_ANNOTATION_FOR_TESTS), base::TimeDelta(), true, callback.callback()); diff --git a/chromium/net/proxy_resolution/pac_file_fetcher_impl.cc b/chromium/net/proxy_resolution/pac_file_fetcher_impl.cc index e9e919b1ebe..126c58c1ccd 100644 --- a/chromium/net/proxy_resolution/pac_file_fetcher_impl.cc +++ b/chromium/net/proxy_resolution/pac_file_fetcher_impl.cc @@ -256,7 +256,7 @@ void PacFileFetcherImpl::OnReceivedRedirect(URLRequest* request, } void PacFileFetcherImpl::OnAuthRequired(URLRequest* request, - AuthChallengeInfo* auth_info) { + const AuthChallengeInfo& auth_info) { DCHECK_EQ(request, cur_request_.get()); // TODO(eroman): http://crbug.com/77366 LOG(WARNING) << "Auth required to fetch PAC script, aborting."; @@ -331,7 +331,7 @@ PacFileFetcherImpl::PacFileFetcherImpl(URLRequestContext* url_request_context, next_id_(0), cur_request_id_(0), result_code_(OK), - result_text_(NULL), + result_text_(nullptr), max_response_bytes_(kDefaultMaxResponseBytes), max_duration_(kDefaultMaxDuration), allow_file_url_(allow_file_url), @@ -425,7 +425,7 @@ void PacFileFetcherImpl::ResetCurRequestState() { cur_request_id_ = 0; callback_.Reset(); result_code_ = OK; - result_text_ = NULL; + result_text_ = nullptr; fetch_start_time_ = base::TimeTicks(); fetch_time_to_first_byte_ = base::TimeTicks(); } diff --git a/chromium/net/proxy_resolution/pac_file_fetcher_impl.h b/chromium/net/proxy_resolution/pac_file_fetcher_impl.h index a9e13db5196..e51e258cea6 100644 --- a/chromium/net/proxy_resolution/pac_file_fetcher_impl.h +++ b/chromium/net/proxy_resolution/pac_file_fetcher_impl.h @@ -79,7 +79,7 @@ class NET_EXPORT PacFileFetcherImpl : public PacFileFetcher, const RedirectInfo& redirect_info, bool* defer_redirect) override; void OnAuthRequired(URLRequest* request, - AuthChallengeInfo* auth_info) override; + const AuthChallengeInfo& auth_info) override; void OnSSLCertificateError(URLRequest* request, const SSLInfo& ssl_info, bool is_hsts_ok) override; diff --git a/chromium/net/proxy_resolution/polling_proxy_config_service.cc b/chromium/net/proxy_resolution/polling_proxy_config_service.cc index 1035de7e62a..1f39e6f2c6a 100644 --- a/chromium/net/proxy_resolution/polling_proxy_config_service.cc +++ b/chromium/net/proxy_resolution/polling_proxy_config_service.cc @@ -38,7 +38,7 @@ class PollingProxyConfigService::Core // (observers should not be called past this point). void Orphan() { base::AutoLock lock(lock_); - origin_task_runner_ = NULL; + origin_task_runner_ = nullptr; } bool GetLatestProxyConfig(ProxyConfigWithAnnotation* config) { diff --git a/chromium/net/proxy_resolution/proxy_config.cc b/chromium/net/proxy_resolution/proxy_config.cc index 9cfe6d1c0c0..091c685da19 100644 --- a/chromium/net/proxy_resolution/proxy_config.cc +++ b/chromium/net/proxy_resolution/proxy_config.cc @@ -150,7 +150,7 @@ const ProxyList* ProxyConfig::ProxyRules::MapUrlSchemeToProxyList( return GetProxyListForWebSocketScheme(); if (!fallback_proxies.IsEmpty()) return &fallback_proxies; - return NULL; // No mapping for this scheme. Use direct. + return nullptr; // No mapping for this scheme. Use direct. } bool ProxyConfig::ProxyRules::Equals(const ProxyRules& other) const { @@ -172,7 +172,7 @@ ProxyList* ProxyConfig::ProxyRules::MapUrlSchemeToProxyListNoFallback( return &proxies_for_https; if (scheme == "ftp") return &proxies_for_ftp; - return NULL; // No mapping for this scheme. + return nullptr; // No mapping for this scheme. } const ProxyList* ProxyConfig::ProxyRules::GetProxyListForWebSocketScheme() @@ -183,7 +183,7 @@ const ProxyList* ProxyConfig::ProxyRules::GetProxyListForWebSocketScheme() return &proxies_for_https; if (!proxies_for_http.IsEmpty()) return &proxies_for_http; - return NULL; + return nullptr; } ProxyConfig::ProxyConfig() : auto_detect_(false), pac_mandatory_(false) {} diff --git a/chromium/net/proxy_resolution/proxy_config_service_linux_unittest.cc b/chromium/net/proxy_resolution/proxy_config_service_linux_unittest.cc index 160c5795cbc..513e5d844f7 100644 --- a/chromium/net/proxy_resolution/proxy_config_service_linux_unittest.cc +++ b/chromium/net/proxy_resolution/proxy_config_service_linux_unittest.cc @@ -23,7 +23,7 @@ #include "base/strings/stringprintf.h" #include "base/synchronization/lock.h" #include "base/synchronization/waitable_event.h" -#include "base/task/task_scheduler/task_scheduler.h" +#include "base/task/thread_pool/thread_pool.h" #include "base/threading/thread.h" #include "base/threading/thread_task_runner_handle.h" #include "net/proxy_resolution/proxy_config.h" @@ -1885,7 +1885,7 @@ TEST_F(ProxyConfigServiceLinuxTest, KDEFileChanged) { // Initialization posts a task to start watching kioslaverc file. Ensure that // registration has happened before modifying it or the file change won't be // observed. - base::TaskScheduler::GetInstance()->FlushForTesting(); + base::ThreadPool::GetInstance()->FlushForTesting(); WriteFile(kioslaverc_, "[Proxy Settings]\nProxyType=2\n" diff --git a/chromium/net/proxy_resolution/proxy_config_service_win_unittest.cc b/chromium/net/proxy_resolution/proxy_config_service_win_unittest.cc index 147e86cf791..5665e3b91fa 100644 --- a/chromium/net/proxy_resolution/proxy_config_service_win_unittest.cc +++ b/chromium/net/proxy_resolution/proxy_config_service_win_unittest.cc @@ -30,171 +30,180 @@ TEST(ProxyConfigServiceWinTest, SetFromIEConfig) { ProxyRulesExpectation proxy_rules; const char* proxy_bypass_list; // newline separated } tests[] = { - // Auto detect. - { - { // Input. - TRUE, // fAutoDetect - NULL, // lpszAutoConfigUrl - NULL, // lpszProxy - NULL, // lpszProxyBypass + // Auto detect. + { + { + // Input. + TRUE, // fAutoDetect + nullptr, // lpszAutoConfigUrl + nullptr, // lpszProxy + nullptr, // lpszProxyBypass + }, + + // Expected result. + true, // auto_detect + GURL(), // pac_url + ProxyRulesExpectation::Empty(), }, - // Expected result. - true, // auto_detect - GURL(), // pac_url - ProxyRulesExpectation::Empty(), - }, - - // Valid PAC url - { - { // Input. - FALSE, // fAutoDetect - L"http://wpad/wpad.dat", // lpszAutoConfigUrl - NULL, // lpszProxy - NULL, // lpszProxy_bypass + // Valid PAC url + { + { + // Input. + FALSE, // fAutoDetect + L"http://wpad/wpad.dat", // lpszAutoConfigUrl + nullptr, // lpszProxy + nullptr, // lpszProxy_bypass + }, + + // Expected result. + false, // auto_detect + GURL("http://wpad/wpad.dat"), // pac_url + ProxyRulesExpectation::Empty(), }, - // Expected result. - false, // auto_detect - GURL("http://wpad/wpad.dat"), // pac_url - ProxyRulesExpectation::Empty(), - }, - - // Invalid PAC url string. - { - { // Input. - FALSE, // fAutoDetect - L"wpad.dat", // lpszAutoConfigUrl - NULL, // lpszProxy - NULL, // lpszProxy_bypass + // Invalid PAC url string. + { + { + // Input. + FALSE, // fAutoDetect + L"wpad.dat", // lpszAutoConfigUrl + nullptr, // lpszProxy + nullptr, // lpszProxy_bypass + }, + + // Expected result. + false, // auto_detect + GURL(), // pac_url + ProxyRulesExpectation::Empty(), }, - // Expected result. - false, // auto_detect - GURL(), // pac_url - ProxyRulesExpectation::Empty(), - }, - - // Single-host in proxy list. - { - { // Input. - FALSE, // fAutoDetect - NULL, // lpszAutoConfigUrl - L"www.google.com", // lpszProxy - NULL, // lpszProxy_bypass + // Single-host in proxy list. + { + { + // Input. + FALSE, // fAutoDetect + nullptr, // lpszAutoConfigUrl + L"www.google.com", // lpszProxy + nullptr, // lpszProxy_bypass + }, + + // Expected result. + false, // auto_detect + GURL(), // pac_url + ProxyRulesExpectation::Single("www.google.com:80", // single proxy + ""), // bypass rules }, - // Expected result. - false, // auto_detect - GURL(), // pac_url - ProxyRulesExpectation::Single( - "www.google.com:80", // single proxy - ""), // bypass rules - }, - - // Per-scheme proxy rules. - { - { // Input. - FALSE, // fAutoDetect - NULL, // lpszAutoConfigUrl - L"http=www.google.com:80;https=www.foo.com:110", // lpszProxy - NULL, // lpszProxy_bypass + // Per-scheme proxy rules. + { + { + // Input. + FALSE, // fAutoDetect + nullptr, // lpszAutoConfigUrl + L"http=www.google.com:80;https=www.foo.com:110", // lpszProxy + nullptr, // lpszProxy_bypass + }, + + // Expected result. + false, // auto_detect + GURL(), // pac_url + ProxyRulesExpectation::PerScheme("www.google.com:80", // http + "www.foo.com:110", // https + "", // ftp + ""), // bypass rules }, - // Expected result. - false, // auto_detect - GURL(), // pac_url - ProxyRulesExpectation::PerScheme( - "www.google.com:80", // http - "www.foo.com:110", // https - "", // ftp - ""), // bypass rules - }, - - // SOCKS proxy configuration. - { - { // Input. - FALSE, // fAutoDetect - NULL, // lpszAutoConfigUrl - L"http=www.google.com:80;https=www.foo.com:110;" - L"ftp=ftpproxy:20;socks=foopy:130", // lpszProxy - NULL, // lpszProxy_bypass + // SOCKS proxy configuration. + { + { + // Input. + FALSE, // fAutoDetect + nullptr, // lpszAutoConfigUrl + L"http=www.google.com:80;https=www.foo.com:110;" + L"ftp=ftpproxy:20;socks=foopy:130", // lpszProxy + nullptr, // lpszProxy_bypass + }, + + // Expected result. + // Note that "socks" is interprted as meaning "socks4", since that is + // how + // Internet Explorer applies the settings. For more details on this + // policy, see: + // http://code.google.com/p/chromium/issues/detail?id=55912#c2 + false, // auto_detect + GURL(), // pac_url + ProxyRulesExpectation::PerSchemeWithSocks( + "www.google.com:80", // http + "www.foo.com:110", // https + "ftpproxy:20", // ftp + "socks4://foopy:130", // socks + ""), // bypass rules }, - // Expected result. - // Note that "socks" is interprted as meaning "socks4", since that is how - // Internet Explorer applies the settings. For more details on this - // policy, see: - // http://code.google.com/p/chromium/issues/detail?id=55912#c2 - false, // auto_detect - GURL(), // pac_url - ProxyRulesExpectation::PerSchemeWithSocks( - "www.google.com:80", // http - "www.foo.com:110", // https - "ftpproxy:20", // ftp - "socks4://foopy:130", // socks - ""), // bypass rules - }, - - // Bypass local names. - { - { // Input. - TRUE, // fAutoDetect - NULL, // lpszAutoConfigUrl - NULL, // lpszProxy - L"<local>", // lpszProxy_bypass + // Bypass local names. + { + { + // Input. + TRUE, // fAutoDetect + nullptr, // lpszAutoConfigUrl + nullptr, // lpszProxy + L"<local>", // lpszProxy_bypass + }, + + true, // auto_detect + GURL(), // pac_url + ProxyRulesExpectation::EmptyWithBypass("<local>"), }, - true, // auto_detect - GURL(), // pac_url - ProxyRulesExpectation::EmptyWithBypass("<local>"), - }, - - // Bypass "google.com" and local names, using semicolon as delimiter - // (ignoring white space). - { - { // Input. - TRUE, // fAutoDetect - NULL, // lpszAutoConfigUrl - NULL, // lpszProxy - L"<local> ; google.com", // lpszProxy_bypass + // Bypass "google.com" and local names, using semicolon as delimiter + // (ignoring white space). + { + { + // Input. + TRUE, // fAutoDetect + nullptr, // lpszAutoConfigUrl + nullptr, // lpszProxy + L"<local> ; google.com", // lpszProxy_bypass + }, + + // Expected result. + true, // auto_detect + GURL(), // pac_url + ProxyRulesExpectation::EmptyWithBypass("<local>,google.com"), }, - // Expected result. - true, // auto_detect - GURL(), // pac_url - ProxyRulesExpectation::EmptyWithBypass("<local>,google.com"), - }, - - // Bypass "foo.com" and "google.com", using lines as delimiter. - { - { // Input. - TRUE, // fAutoDetect - NULL, // lpszAutoConfigUrl - NULL, // lpszProxy - L"foo.com\r\ngoogle.com", // lpszProxy_bypass + // Bypass "foo.com" and "google.com", using lines as delimiter. + { + { + // Input. + TRUE, // fAutoDetect + nullptr, // lpszAutoConfigUrl + nullptr, // lpszProxy + L"foo.com\r\ngoogle.com", // lpszProxy_bypass + }, + + // Expected result. + true, // auto_detect + GURL(), // pac_url + ProxyRulesExpectation::EmptyWithBypass("foo.com,google.com"), }, - // Expected result. - true, // auto_detect - GURL(), // pac_url - ProxyRulesExpectation::EmptyWithBypass("foo.com,google.com"), - }, - - // Bypass "foo.com" and "google.com", using commas as delimiter. - { - { // Input. - TRUE, // fAutoDetect - NULL, // lpszAutoConfigUrl - NULL, // lpszProxy - L"foo.com, google.com", // lpszProxy_bypass + // Bypass "foo.com" and "google.com", using commas as delimiter. + { + { + // Input. + TRUE, // fAutoDetect + nullptr, // lpszAutoConfigUrl + nullptr, // lpszProxy + L"foo.com, google.com", // lpszProxy_bypass + }, + + // Expected result. + true, // auto_detect + GURL(), // pac_url + ProxyRulesExpectation::EmptyWithBypass("foo.com,google.com"), }, - - // Expected result. - true, // auto_detect - GURL(), // pac_url - ProxyRulesExpectation::EmptyWithBypass("foo.com,google.com"), - }, }; for (size_t i = 0; i < base::size(tests); ++i) { diff --git a/chromium/net/proxy_resolution/proxy_config_unittest.cc b/chromium/net/proxy_resolution/proxy_config_unittest.cc index 2902fd8f01f..eeaacced184 100644 --- a/chromium/net/proxy_resolution/proxy_config_unittest.cc +++ b/chromium/net/proxy_resolution/proxy_config_unittest.cc @@ -13,7 +13,7 @@ namespace { void ExpectProxyServerEquals(const char* expectation, const ProxyList& proxy_servers) { - if (expectation == NULL) { + if (expectation == nullptr) { EXPECT_TRUE(proxy_servers.IsEmpty()); } else { EXPECT_EQ(expectation, proxy_servers.ToPacString()); @@ -108,202 +108,204 @@ TEST(ProxyConfigTest, ParseProxyRules) { const char* proxy_for_ftp; const char* fallback_proxy; } tests[] = { - // One HTTP proxy for all schemes. - { - "myproxy:80", - - ProxyConfig::ProxyRules::Type::PROXY_LIST, - "PROXY myproxy:80", - NULL, - NULL, - NULL, - NULL, - }, - - // Multiple HTTP proxies for all schemes. - { - "myproxy:80,https://myotherproxy", - - ProxyConfig::ProxyRules::Type::PROXY_LIST, - "PROXY myproxy:80;HTTPS myotherproxy:443", - NULL, - NULL, - NULL, - NULL, - }, - - // Only specify a proxy server for "http://" urls. - { - "http=myproxy:80", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - "PROXY myproxy:80", - NULL, - NULL, - NULL, - }, - - // Specify an HTTP proxy for "ftp://" and a SOCKS proxy for "https://" urls. - { - "ftp=ftp-proxy ; https=socks4://foopy", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - NULL, - "SOCKS foopy:1080", - "PROXY ftp-proxy:80", - NULL, - }, - - // Give a scheme-specific proxy as well as a non-scheme specific. - // The first entry "foopy" takes precedance marking this list as - // Type::PROXY_LIST. - { - "foopy ; ftp=ftp-proxy", - - ProxyConfig::ProxyRules::Type::PROXY_LIST, - "PROXY foopy:80", - NULL, - NULL, - NULL, - NULL, - }, - - // Give a scheme-specific proxy as well as a non-scheme specific. - // The first entry "ftp=ftp-proxy" takes precedance marking this list as - // Type::PROXY_LIST_PER_SCHEME. - { - "ftp=ftp-proxy ; foopy", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - NULL, - NULL, - "PROXY ftp-proxy:80", - NULL, - }, - - // Include a list of entries for a single scheme. - { - "ftp=ftp1,ftp2,ftp3", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - NULL, - NULL, - "PROXY ftp1:80;PROXY ftp2:80;PROXY ftp3:80", - NULL, - }, - - // Include multiple entries for the same scheme -- they accumulate. - { - "http=http1,http2; http=http3", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - "PROXY http1:80;PROXY http2:80;PROXY http3:80", - NULL, - NULL, - NULL, - }, - - // Include lists of entries for multiple schemes. - { - "ftp=ftp1,ftp2,ftp3 ; http=http1,http2; ", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - "PROXY http1:80;PROXY http2:80", - NULL, - "PROXY ftp1:80;PROXY ftp2:80;PROXY ftp3:80", - NULL, - }, - - // Include non-default proxy schemes. - { - "http=https://secure_proxy; ftp=socks4://socks_proxy; https=socks://foo", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - "HTTPS secure_proxy:443", - "SOCKS5 foo:1080", - "SOCKS socks_proxy:1080", - NULL, - }, - - // Only SOCKS proxy present, others being blank. - { - "socks=foopy", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - NULL, - NULL, - NULL, - "SOCKS foopy:1080", + // One HTTP proxy for all schemes. + { + "myproxy:80", + + ProxyConfig::ProxyRules::Type::PROXY_LIST, + "PROXY myproxy:80", + nullptr, + nullptr, + nullptr, + nullptr, }, - // SOCKS proxy present along with other proxies too - { - "http=httpproxy ; https=httpsproxy ; ftp=ftpproxy ; socks=foopy ", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - "PROXY httpproxy:80", - "PROXY httpsproxy:80", - "PROXY ftpproxy:80", - "SOCKS foopy:1080", - }, - - // SOCKS proxy (with modifier) present along with some proxies - // (FTP being blank) - { - "http=httpproxy ; https=httpsproxy ; socks=socks5://foopy ", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - "PROXY httpproxy:80", - "PROXY httpsproxy:80", - NULL, - "SOCKS5 foopy:1080", + // Multiple HTTP proxies for all schemes. + { + "myproxy:80,https://myotherproxy", + + ProxyConfig::ProxyRules::Type::PROXY_LIST, + "PROXY myproxy:80;HTTPS myotherproxy:443", + nullptr, + nullptr, + nullptr, + nullptr, + }, + + // Only specify a proxy server for "http://" urls. + { + "http=myproxy:80", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + "PROXY myproxy:80", + nullptr, + nullptr, + nullptr, + }, + + // Specify an HTTP proxy for "ftp://" and a SOCKS proxy for "https://" + // urls. + { + "ftp=ftp-proxy ; https=socks4://foopy", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + nullptr, + "SOCKS foopy:1080", + "PROXY ftp-proxy:80", + nullptr, + }, + + // Give a scheme-specific proxy as well as a non-scheme specific. + // The first entry "foopy" takes precedance marking this list as + // Type::PROXY_LIST. + { + "foopy ; ftp=ftp-proxy", + + ProxyConfig::ProxyRules::Type::PROXY_LIST, + "PROXY foopy:80", + nullptr, + nullptr, + nullptr, + nullptr, + }, + + // Give a scheme-specific proxy as well as a non-scheme specific. + // The first entry "ftp=ftp-proxy" takes precedance marking this list as + // Type::PROXY_LIST_PER_SCHEME. + { + "ftp=ftp-proxy ; foopy", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + nullptr, + nullptr, + "PROXY ftp-proxy:80", + nullptr, + }, + + // Include a list of entries for a single scheme. + { + "ftp=ftp1,ftp2,ftp3", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + nullptr, + nullptr, + "PROXY ftp1:80;PROXY ftp2:80;PROXY ftp3:80", + nullptr, + }, + + // Include multiple entries for the same scheme -- they accumulate. + { + "http=http1,http2; http=http3", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + "PROXY http1:80;PROXY http2:80;PROXY http3:80", + nullptr, + nullptr, + nullptr, + }, + + // Include lists of entries for multiple schemes. + { + "ftp=ftp1,ftp2,ftp3 ; http=http1,http2; ", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + "PROXY http1:80;PROXY http2:80", + nullptr, + "PROXY ftp1:80;PROXY ftp2:80;PROXY ftp3:80", + nullptr, }, - // Include unsupported schemes -- they are discarded. - { - "crazy=foopy ; foo=bar ; https=myhttpsproxy", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - NULL, - "PROXY myhttpsproxy:80", - NULL, - NULL, - }, - - // direct:// as first option for a scheme. - { - "http=direct://,myhttpproxy; https=direct://", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - "DIRECT;PROXY myhttpproxy:80", - "DIRECT", - NULL, - NULL, - }, - - // direct:// as a second option for a scheme. - { - "http=myhttpproxy,direct://", - - ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, - NULL, - "PROXY myhttpproxy:80;DIRECT", - NULL, - NULL, - NULL, - }, + // Include non-default proxy schemes. + { + "http=https://secure_proxy; ftp=socks4://socks_proxy; " + "https=socks://foo", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + "HTTPS secure_proxy:443", + "SOCKS5 foo:1080", + "SOCKS socks_proxy:1080", + nullptr, + }, + + // Only SOCKS proxy present, others being blank. + { + "socks=foopy", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + nullptr, + nullptr, + nullptr, + "SOCKS foopy:1080", + }, + + // SOCKS proxy present along with other proxies too + { + "http=httpproxy ; https=httpsproxy ; ftp=ftpproxy ; socks=foopy ", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + "PROXY httpproxy:80", + "PROXY httpsproxy:80", + "PROXY ftpproxy:80", + "SOCKS foopy:1080", + }, + + // SOCKS proxy (with modifier) present along with some proxies + // (FTP being blank) + { + "http=httpproxy ; https=httpsproxy ; socks=socks5://foopy ", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + "PROXY httpproxy:80", + "PROXY httpsproxy:80", + nullptr, + "SOCKS5 foopy:1080", + }, + + // Include unsupported schemes -- they are discarded. + { + "crazy=foopy ; foo=bar ; https=myhttpsproxy", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + nullptr, + "PROXY myhttpsproxy:80", + nullptr, + nullptr, + }, + + // direct:// as first option for a scheme. + { + "http=direct://,myhttpproxy; https=direct://", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + "DIRECT;PROXY myhttpproxy:80", + "DIRECT", + nullptr, + nullptr, + }, + + // direct:// as a second option for a scheme. + { + "http=myhttpproxy,direct://", + + ProxyConfig::ProxyRules::Type::PROXY_LIST_PER_SCHEME, + nullptr, + "PROXY myhttpproxy:80;DIRECT", + nullptr, + nullptr, + nullptr, + }, }; diff --git a/chromium/net/proxy_resolution/proxy_resolution_service.cc b/chromium/net/proxy_resolution/proxy_resolution_service.cc index a657d1ffe6f..0cb73b2594a 100644 --- a/chromium/net/proxy_resolution/proxy_resolution_service.cc +++ b/chromium/net/proxy_resolution/proxy_resolution_service.cc @@ -365,10 +365,22 @@ class UnsetProxyConfigService : public ProxyConfigService { #endif // Returns a sanitized copy of |url| which is safe to pass on to a PAC script. -// The method for sanitizing is determined by |policy|. See the comments for -// that enum for details. -GURL SanitizeUrl(const GURL& url, - ProxyResolutionService::SanitizeUrlPolicy policy) { +// +// PAC scripts are modelled as being controllable by a network-present +// attacker (since such an attacker can influence the outcome of proxy +// auto-discovery, or modify the contents of insecurely delivered PAC scripts). +// +// As such, it is important that the full path/query of https:// URLs not be +// sent to PAC scripts, since that would give an attacker access to data that +// is ordinarily protected by TLS. +// +// Obscuring the path for http:// URLs isn't being done since it doesn't matter +// for security (attacker can already route traffic through their HTTP proxy +// and see the full URL for http:// requests). +// +// TODO(https://crbug.com/882536): Use the same stripping for insecure URL +// schemes. +GURL SanitizeUrl(const GURL& url) { DCHECK(url.is_valid()); GURL::Replacements replacements; @@ -376,8 +388,7 @@ GURL SanitizeUrl(const GURL& url, replacements.ClearPassword(); replacements.ClearRef(); - if (policy == ProxyResolutionService::SanitizeUrlPolicy::SAFE && - url.SchemeIsCryptographic()) { + if (url.SchemeIsCryptographic()) { replacements.ClearPath(); replacements.ClearQuery(); } @@ -431,7 +442,7 @@ class ProxyResolutionService::InitProxyResolver { public: InitProxyResolver() : proxy_resolver_factory_(nullptr), - proxy_resolver_(NULL), + proxy_resolver_(nullptr), resolver_using_auto_detected_script_(nullptr), next_state_(STATE_NONE), quick_check_enabled_(true) {} @@ -747,7 +758,7 @@ class ProxyResolutionService::PacFileDeciderPoller { // Start the PAC file decider to see if anything has changed. // TODO(eroman): Pass a proper NetLog rather than NULL. decider_.reset( - new PacFileDecider(pac_file_fetcher_, dhcp_pac_file_fetcher_, NULL)); + new PacFileDecider(pac_file_fetcher_, dhcp_pac_file_fetcher_, nullptr)); decider_->set_quick_check_enabled(quick_check_enabled_); int result = decider_->Start( config_, TimeDelta(), proxy_resolver_expects_pac_bytes_, @@ -844,7 +855,7 @@ class ProxyResolutionService::PacFileDeciderPoller { // static const ProxyResolutionService::PacPollPolicy* - ProxyResolutionService::PacFileDeciderPoller::poll_policy_ = NULL; + ProxyResolutionService::PacFileDeciderPoller::poll_policy_ = nullptr; class ProxyResolutionService::RequestImpl : public ProxyResolutionService::Request { @@ -1056,7 +1067,6 @@ ProxyResolutionService::ProxyResolutionService( stall_proxy_auto_config_delay_( TimeDelta::FromMilliseconds(kDelayAfterNetworkChangesMs)), quick_check_enabled_(true), - sanitize_url_policy_(SanitizeUrlPolicy::SAFE), weak_ptr_factory_(this) { NetworkChangeNotifier::AddIPAddressObserver(this); NetworkChangeNotifier::AddDNSObserver(this); @@ -1097,7 +1107,7 @@ std::unique_ptr<ProxyResolutionService> ProxyResolutionService::CreateFixed( // TODO(eroman): This isn't quite right, won't work if |pc| specifies // a PAC script. return CreateUsingSystemProxyResolver( - std::make_unique<ProxyConfigServiceFixed>(pc), NULL); + std::make_unique<ProxyConfigServiceFixed>(pc), nullptr); } // static @@ -1175,7 +1185,7 @@ int ProxyResolutionService::ResolveProxy(const GURL& raw_url, // script). The goal is to remove sensitive data (like embedded user names // and password), and local data (i.e. reference fragment) which does not need // to be disclosed to the resolver. - GURL url = SanitizeUrl(raw_url, sanitize_url_policy_); + GURL url = SanitizeUrl(raw_url); // Check if the request can be completed right away. (This is the case when // using a direct connection for example). @@ -1339,7 +1349,7 @@ void ProxyResolutionService::OnInitProxyResolverComplete(int result) { base::Unretained(this)), fetched_config_.value(), resolver_factory_->expects_pac_bytes(), pac_file_fetcher_.get(), dhcp_pac_file_fetcher_.get(), result, - init_proxy_resolver_->script_data(), NULL)); + init_proxy_resolver_->script_data(), nullptr)); script_poller_->set_quick_check_enabled(quick_check_enabled_); init_proxy_resolver_.reset(); diff --git a/chromium/net/proxy_resolution/proxy_resolution_service.h b/chromium/net/proxy_resolution/proxy_resolution_service.h index 3ead15516ce..48b190d704c 100644 --- a/chromium/net/proxy_resolution/proxy_resolution_service.h +++ b/chromium/net/proxy_resolution/proxy_resolution_service.h @@ -54,25 +54,6 @@ class NET_EXPORT ProxyResolutionService public NetworkChangeNotifier::DNSObserver, public ProxyConfigService::Observer { public: - // Enumerates the policy to use when sanitizing URLs for proxy resolution - // (before passing them off to PAC scripts). - enum class SanitizeUrlPolicy { - // Do a basic level of sanitization for URLs: - // - strip embedded identities (ex: "username:password@") - // - strip the fragment (ex: "#blah") - // - // This is considered "unsafe" because it does not do any additional - // stripping for https:// URLs. - UNSAFE, - - // SAFE does the same sanitization as UNSAFE, but additionally strips - // everything but the (scheme,host,port) from cryptographic URL schemes - // (https:// and wss://). - // - // In other words, it strips the path and query portion of https:// URLs. - SAFE, - }; - // This interface defines the set of policies for when to poll the PAC // script for changes. // @@ -306,13 +287,6 @@ class NET_EXPORT ProxyResolutionService } bool quick_check_enabled_for_testing() const { return quick_check_enabled_; } - void set_sanitize_url_policy(SanitizeUrlPolicy policy) { - sanitize_url_policy_ = policy; - } - SanitizeUrlPolicy sanitize_url_policy_for_testing() const { - return sanitize_url_policy_; - } - private: FRIEND_TEST_ALL_PREFIXES(ProxyResolutionServiceTest, UpdateConfigAfterFailedAutodetect); @@ -470,9 +444,6 @@ class NET_EXPORT ProxyResolutionService // Whether child PacFileDeciders should use QuickCheck bool quick_check_enabled_; - // The method to use for sanitizing URLs seen by the proxy resolver. - SanitizeUrlPolicy sanitize_url_policy_; - THREAD_CHECKER(thread_checker_); ProxyDelegate* proxy_delegate_ = nullptr; diff --git a/chromium/net/proxy_resolution/proxy_resolution_service_unittest.cc b/chromium/net/proxy_resolution/proxy_resolution_service_unittest.cc index c747bcfe30a..2757b58bb7f 100644 --- a/chromium/net/proxy_resolution/proxy_resolution_service_unittest.cc +++ b/chromium/net/proxy_resolution/proxy_resolution_service_unittest.cc @@ -3691,10 +3691,8 @@ TEST_F(ProxyResolutionServiceTest, PACScriptRefetchAfterActivity) { EXPECT_TRUE(info3.is_direct()); } -// Helper class to exercise URL sanitization using the different policies. This -// works by submitted URLs to the ProxyResolutionService. In turn the -// ProxyResolutionService sanitizes the URL and then passes it along to the -// ProxyResolver. This helper returns the URL seen by the ProxyResolver. +// Helper class to exercise URL sanitization by submitting URLs to the +// ProxyResolutionService and returning the URL passed to the ProxyResolver. class SanitizeUrlHelper { public: SanitizeUrlHelper() { @@ -3733,12 +3731,6 @@ class SanitizeUrlHelper { EXPECT_TRUE(info.is_direct()); } - // Changes the URL sanitization policy for the underlying - // ProxyResolutionService. This will affect subsequent calls to SanitizeUrl. - void SetSanitizeUrlPolicy(ProxyResolutionService::SanitizeUrlPolicy policy) { - service_->set_sanitize_url_policy(policy); - } - // Makes a proxy resolution request through the ProxyResolutionService, and // returns the URL that was submitted to the Proxy Resolver. GURL SanitizeUrl(const GURL& raw_url) { @@ -3764,135 +3756,92 @@ class SanitizeUrlHelper { return sanitized_url; } - // Changes the ProxyResolutionService's URL sanitization policy and then - // sanitizes |raw_url|. - GURL SanitizeUrl(const GURL& raw_url, - ProxyResolutionService::SanitizeUrlPolicy policy) { - service_->set_sanitize_url_policy(policy); - return SanitizeUrl(raw_url); - } - private: MockAsyncProxyResolver resolver; MockAsyncProxyResolverFactory* factory; std::unique_ptr<ProxyResolutionService> service_; }; -TEST_F(ProxyResolutionServiceTest, SanitizeUrlDefaultsToSafe) { - SanitizeUrlHelper helper; - - // Without changing the URL sanitization policy, the default should be to - // strip https:// URLs. - EXPECT_EQ(GURL("https://example.com/"), - helper.SanitizeUrl( - GURL("https://foo:bar@example.com/foo/bar/baz?hello#sigh"))); -} - -// Tests URL sanitization with input URLs that have a // non-cryptographic -// scheme (i.e. http://). The sanitized result is consistent regardless of the -// stripping mode selected. -TEST_F(ProxyResolutionServiceTest, SanitizeUrlForPacScriptNonCryptographic) { +// Tests that input URLs to proxy resolution are sanitized before being passed +// on to the ProxyResolver (i.e. PAC script evaluator). For instance PAC +// scripts should not be able to see the path for https:// URLs. +TEST_F(ProxyResolutionServiceTest, SanitizeUrlForPacScript) { const struct { const char* raw_url; const char* sanitized_url; } kTests[] = { + // --------------------------------- + // Sanitize cryptographic URLs. + // --------------------------------- + // Embedded identity is stripped. { - "http://foo:bar@example.com/", "http://example.com/", + "https://foo:bar@example.com/", + "https://example.com/", }, + // Fragments and path are stripped. { - "ftp://foo:bar@example.com/", "ftp://example.com/", + "https://example.com/blah#hello", + "https://example.com/", }, + // Query is stripped. { - "ftp://example.com/some/path/here", - "ftp://example.com/some/path/here", + "https://example.com/?hello", + "https://example.com/", }, - // Reference fragment is stripped. + // The embedded identity and fragment are stripped. { - "http://example.com/blah#hello", "http://example.com/blah", - }, - // Query parameters are NOT stripped. - { - "http://example.com/foo/bar/baz?hello", - "http://example.com/foo/bar/baz?hello", + "https://foo:bar@example.com/foo/bar/baz?hello#sigh", + "https://example.com/", }, - // Fragment is stripped, but path and query are left intact. + // The URL's port should not be stripped. { - "http://foo:bar@example.com/foo/bar/baz?hello#sigh", - "http://example.com/foo/bar/baz?hello", + "https://example.com:88/hi", + "https://example.com:88/", }, - // Port numbers are not affected. + // Try a wss:// URL, to make sure it is treated as a cryptographic schemed + // URL. { - "http://example.com:88/hi", "http://example.com:88/hi", + "wss://example.com:88/hi", + "wss://example.com:88/", }, - }; - - SanitizeUrlHelper helper; - - for (const auto& test : kTests) { - // The result of SanitizeUrlForPacScript() is the same regardless of the - // second parameter (sanitization mode), since the input URLs do not use a - // cryptographic scheme. - GURL raw_url(test.raw_url); - ASSERT_TRUE(raw_url.is_valid()); - EXPECT_FALSE(raw_url.SchemeIsCryptographic()); - EXPECT_EQ(GURL(test.sanitized_url), - helper.SanitizeUrl( - raw_url, ProxyResolutionService::SanitizeUrlPolicy::UNSAFE)); - - EXPECT_EQ(GURL(test.sanitized_url), - helper.SanitizeUrl( - raw_url, ProxyResolutionService::SanitizeUrlPolicy::SAFE)); - } -} - -// Tests URL sanitization using input URLs that have a cryptographic schemes -// (i.e. https://). The sanitized result differs depending on the sanitization -// mode chosen. -TEST_F(ProxyResolutionServiceTest, SanitizeUrlForPacScriptCryptographic) { - const struct { - // Input URL. - const char* raw_url; + // --------------------------------- + // Sanitize non-cryptographic URLs. + // --------------------------------- - // Output URL when stripping of cryptographic URLs is disabled. - const char* sanitized_url_unstripped; - - // Output URL when stripping of cryptographic URLs is enabled. - const char* sanitized_url; - } kTests[] = { - // Embedded identity is always stripped. + // Embedded identity is stripped. { - "https://foo:bar@example.com/", "https://example.com/", - "https://example.com/", + "http://foo:bar@example.com/", + "http://example.com/", }, - // Fragments are always stripped, but stripping path is conditional on the - // mode. { - "https://example.com/blah#hello", "https://example.com/blah", - "https://example.com/", + "ftp://foo:bar@example.com/", + "ftp://example.com/", }, - // Stripping the query is conditional on the mode. { - "https://example.com/?hello", "https://example.com/?hello", - "https://example.com/", + "ftp://example.com/some/path/here", + "ftp://example.com/some/path/here", }, - // The embedded identity and fragment is always stripped, however path and - // query are conditional on the stripping mode. + // Reference fragment is stripped. { - "https://foo:bar@example.com/foo/bar/baz?hello#sigh", - "https://example.com/foo/bar/baz?hello", "https://example.com/", + "http://example.com/blah#hello", + "http://example.com/blah", }, - // The URL's port should not be stripped. + // Query parameters are NOT stripped. { - "https://example.com:88/hi", "https://example.com:88/hi", - "https://example.com:88/", + "http://example.com/foo/bar/baz?hello", + "http://example.com/foo/bar/baz?hello", }, - // Try a wss:// URL, to make sure it also strips (is is also a - // cryptographic URL). + // Fragment is stripped, but path and query are left intact. { - "wss://example.com:88/hi", "wss://example.com:88/hi", - "wss://example.com:88/", + "http://foo:bar@example.com/foo/bar/baz?hello#sigh", + "http://example.com/foo/bar/baz?hello", + }, + // Port numbers are not affected. + { + "http://example.com:88/hi", + "http://example.com:88/hi", }, }; @@ -3901,15 +3850,8 @@ TEST_F(ProxyResolutionServiceTest, SanitizeUrlForPacScriptCryptographic) { for (const auto& test : kTests) { GURL raw_url(test.raw_url); ASSERT_TRUE(raw_url.is_valid()); - EXPECT_TRUE(raw_url.SchemeIsCryptographic()); - - EXPECT_EQ(GURL(test.sanitized_url_unstripped), - helper.SanitizeUrl( - raw_url, ProxyResolutionService::SanitizeUrlPolicy::UNSAFE)); - EXPECT_EQ(GURL(test.sanitized_url), - helper.SanitizeUrl( - raw_url, ProxyResolutionService::SanitizeUrlPolicy::SAFE)); + EXPECT_EQ(GURL(test.sanitized_url), helper.SanitizeUrl(raw_url)); } } diff --git a/chromium/net/proxy_resolution/proxy_resolver_v8.cc b/chromium/net/proxy_resolution/proxy_resolver_v8.cc index 486b08deeed..2ac607283ac 100644 --- a/chromium/net/proxy_resolution/proxy_resolver_v8.cc +++ b/chromium/net/proxy_resolution/proxy_resolver_v8.cc @@ -407,7 +407,7 @@ class SharedIsolateFactory { v8::Isolate* GetSharedIsolateWithoutCreating() { base::AutoLock lock(lock_); - return holder_ ? holder_->isolate() : NULL; + return holder_ ? holder_->isolate() : nullptr; } private: @@ -567,8 +567,8 @@ class ProxyResolverV8::Context { global_template->Set(ASCIILiteralToV8String(isolate_, "isInNetEx"), is_in_net_ex_template); - v8_context_.Reset( - isolate_, v8::Context::New(isolate_, NULL, global_template)); + v8_context_.Reset(isolate_, + v8::Context::New(isolate_, nullptr, global_template)); v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate_, v8_context_); diff --git a/chromium/net/proxy_resolution/proxy_resolver_v8_tracing.cc b/chromium/net/proxy_resolution/proxy_resolver_v8_tracing.cc index 8e16acc85ff..5744166c1f2 100644 --- a/chromium/net/proxy_resolution/proxy_resolver_v8_tracing.cc +++ b/chromium/net/proxy_resolution/proxy_resolver_v8_tracing.cc @@ -412,7 +412,7 @@ void Job::Cancel() { event_.Signal(); bindings_.reset(); - owned_self_reference_ = NULL; + owned_self_reference_ = nullptr; } LoadState Job::GetLoadState() const { @@ -452,7 +452,7 @@ void Job::ReleaseCallback() { callback_.Reset(); // For good measure, clear this other user-owned pointer. - user_results_ = NULL; + user_results_ = nullptr; } ProxyResolverV8* Job::v8_resolver() { @@ -499,7 +499,7 @@ void Job::NotifyCallerOnOriginLoop(int result) { std::move(callback).Run(result); bindings_.reset(); - owned_self_reference_ = NULL; + owned_self_reference_ = nullptr; } void Job::Start(Operation op, @@ -632,7 +632,7 @@ bool Job::ResolveDnsBlocking(const std::string& host, return false; } - if (!PostDnsOperationAndWait(host, op, NULL)) + if (!PostDnsOperationAndWait(host, op, nullptr)) return false; // Was cancelled. CHECK(GetDnsFromLocalCache(host, op, output, &rv)); diff --git a/chromium/net/proxy_resolution/proxy_resolver_winhttp.cc b/chromium/net/proxy_resolution/proxy_resolver_winhttp.cc index 4ff81f7e59a..ecffcd6c5e2 100644 --- a/chromium/net/proxy_resolution/proxy_resolver_winhttp.cc +++ b/chromium/net/proxy_resolution/proxy_resolver_winhttp.cc @@ -76,7 +76,7 @@ class ProxyResolverWinHttp : public ProxyResolver { ProxyResolverWinHttp::ProxyResolverWinHttp( const scoped_refptr<PacFileData>& script_data) - : session_handle_(NULL), + : session_handle_(nullptr), pac_url_(script_data->type() == PacFileData::TYPE_AUTO_DETECT ? GURL("http://wpad/wpad.dat") : script_data->url()) {} @@ -186,11 +186,9 @@ int ProxyResolverWinHttp::GetProxyForURL(const GURL& query_url, bool ProxyResolverWinHttp::OpenWinHttpSession() { DCHECK(!session_handle_); - session_handle_ = WinHttpOpen(NULL, - WINHTTP_ACCESS_TYPE_NO_PROXY, - WINHTTP_NO_PROXY_NAME, - WINHTTP_NO_PROXY_BYPASS, - 0); + session_handle_ = + WinHttpOpen(nullptr, WINHTTP_ACCESS_TYPE_NO_PROXY, WINHTTP_NO_PROXY_NAME, + WINHTTP_NO_PROXY_BYPASS, 0); if (!session_handle_) return false; @@ -207,7 +205,7 @@ bool ProxyResolverWinHttp::OpenWinHttpSession() { void ProxyResolverWinHttp::CloseWinHttpSession() { if (session_handle_) { WinHttpCloseHandle(session_handle_); - session_handle_ = NULL; + session_handle_ = nullptr; } } |