| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/url_request/url_request_ftp_job.h" | 5 #include "net/url_request/url_request_ftp_job.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ptr_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "net/base/auth.h" | 13 #include "net/base/auth.h" |
| 13 #include "net/base/host_port_pair.h" | 14 #include "net/base/host_port_pair.h" |
| 14 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
| 15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 16 #include "net/ftp/ftp_auth_cache.h" | 17 #include "net/ftp/ftp_auth_cache.h" |
| 17 #include "net/ftp/ftp_response_info.h" | 18 #include "net/ftp/ftp_response_info.h" |
| 18 #include "net/ftp/ftp_transaction_factory.h" | 19 #include "net/ftp/ftp_transaction_factory.h" |
| 19 #include "net/http/http_response_headers.h" | 20 #include "net/http/http_response_headers.h" |
| 20 #include "net/http/http_transaction_factory.h" | 21 #include "net/http/http_transaction_factory.h" |
| 21 #include "net/url_request/url_request.h" | 22 #include "net/url_request/url_request.h" |
| 22 #include "net/url_request/url_request_context.h" | 23 #include "net/url_request/url_request_context.h" |
| 23 #include "net/url_request/url_request_error_job.h" | 24 #include "net/url_request/url_request_error_job.h" |
| 24 | 25 |
| 25 namespace net { | 26 namespace net { |
| 26 | 27 |
| 28 URLRequestFtpJob::AuthData::AuthData() : state(AUTH_STATE_NEED_AUTH) {} |
| 29 |
| 30 URLRequestFtpJob::AuthData::~AuthData() {} |
| 31 |
| 27 URLRequestFtpJob::URLRequestFtpJob( | 32 URLRequestFtpJob::URLRequestFtpJob( |
| 28 URLRequest* request, | 33 URLRequest* request, |
| 29 NetworkDelegate* network_delegate, | 34 NetworkDelegate* network_delegate, |
| 30 FtpTransactionFactory* ftp_transaction_factory, | 35 FtpTransactionFactory* ftp_transaction_factory, |
| 31 FtpAuthCache* ftp_auth_cache) | 36 FtpAuthCache* ftp_auth_cache) |
| 32 : URLRequestJob(request, network_delegate), | 37 : URLRequestJob(request, network_delegate), |
| 33 priority_(DEFAULT_PRIORITY), | 38 priority_(DEFAULT_PRIORITY), |
| 34 proxy_service_(request_->context()->proxy_service()), | 39 proxy_service_(request_->context()->proxy_service()), |
| 35 pac_request_(NULL), | 40 pac_request_(NULL), |
| 36 http_response_info_(NULL), | 41 http_response_info_(NULL), |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 356 |
| 352 if (auth_data_.get()) { | 357 if (auth_data_.get()) { |
| 353 if (auth_data_->state == AUTH_STATE_CANCELED) { | 358 if (auth_data_->state == AUTH_STATE_CANCELED) { |
| 354 NotifyHeadersComplete(); | 359 NotifyHeadersComplete(); |
| 355 return; | 360 return; |
| 356 } | 361 } |
| 357 | 362 |
| 358 if (ftp_transaction_ && auth_data_->state == AUTH_STATE_HAVE_AUTH) | 363 if (ftp_transaction_ && auth_data_->state == AUTH_STATE_HAVE_AUTH) |
| 359 ftp_auth_cache_->Remove(origin, auth_data_->credentials); | 364 ftp_auth_cache_->Remove(origin, auth_data_->credentials); |
| 360 } else { | 365 } else { |
| 361 auth_data_ = new AuthData; | 366 auth_data_ = base::MakeUnique<AuthData>(); |
| 362 } | 367 } |
| 363 auth_data_->state = AUTH_STATE_NEED_AUTH; | 368 auth_data_->state = AUTH_STATE_NEED_AUTH; |
| 364 | 369 |
| 365 FtpAuthCache::Entry* cached_auth = NULL; | 370 FtpAuthCache::Entry* cached_auth = NULL; |
| 366 if (ftp_transaction_ && ftp_transaction_->GetResponseInfo()->needs_auth) | 371 if (ftp_transaction_ && ftp_transaction_->GetResponseInfo()->needs_auth) |
| 367 cached_auth = ftp_auth_cache_->Lookup(origin); | 372 cached_auth = ftp_auth_cache_->Lookup(origin); |
| 368 if (cached_auth) { | 373 if (cached_auth) { |
| 369 // Retry using cached auth data. | 374 // Retry using cached auth data. |
| 370 SetAuth(cached_auth->credentials); | 375 SetAuth(cached_auth->credentials); |
| 371 } else { | 376 } else { |
| 372 // Prompt for a username/password. | 377 // Prompt for a username/password. |
| 373 NotifyHeadersComplete(); | 378 NotifyHeadersComplete(); |
| 374 } | 379 } |
| 375 } | 380 } |
| 376 | 381 |
| 377 } // namespace net | 382 } // namespace net |
| OLD | NEW |