Chromium Code Reviews| Index: net/url_request/url_request_ftp_job.cc |
| diff --git a/net/url_request/url_request_ftp_job.cc b/net/url_request/url_request_ftp_job.cc |
| index 63dcc863d444650535718a4acd904826cdae03f2..e2829f8f8ca4d2ea8190c6eb9cdbd6d96729b5ca 100644 |
| --- a/net/url_request/url_request_ftp_job.cc |
| +++ b/net/url_request/url_request_ftp_job.cc |
| @@ -19,10 +19,20 @@ |
| namespace net { |
| -URLRequestFtpJob::URLRequestFtpJob(URLRequest* request) |
| +URLRequestFtpJob::URLRequestFtpJob( |
| + URLRequest* request, |
| + NetworkDelegate* network_delegate, |
| + FtpTransactionFactory* ftp_transaction_factory, |
| + FtpAuthCache* ftp_auth_cache) |
| : URLRequestJob(request), |
| read_in_progress_(false), |
| - ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
| + network_delegate_(network_delegate), |
| + ftp_transaction_factory_(ftp_transaction_factory), |
| + ftp_auth_cache_(ftp_auth_cache) { |
| + DCHECK(ftp_transaction_factory); |
| + DCHECK(ftp_auth_cache); |
| + DCHECK(network_delegate); |
| } |
| // static |
| @@ -35,9 +45,10 @@ URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request, |
| !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port)) |
| return new URLRequestErrorJob(request, ERR_UNSAFE_PORT); |
| - DCHECK(request->context()); |
|
Paweł Hajdan Jr.
2012/06/07 19:30:21
Please keep the DCHECKs. In fact, add even more: f
erikwright (departed)
2012/06/07 19:40:40
I'm indifferent as to DCHECKing network_delegate e
shalev
2012/06/21 20:04:55
Done.
|
| - DCHECK(request->context()->ftp_transaction_factory()); |
| - return new URLRequestFtpJob(request); |
| + return new URLRequestFtpJob(request, |
| + request->context()->network_delegate(), |
| + request->context()->ftp_transaction_factory(), |
| + request->context()->ftp_auth_cache()); |
| } |
| bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const { |
| @@ -61,11 +72,9 @@ URLRequestFtpJob::~URLRequestFtpJob() { |
| void URLRequestFtpJob::StartTransaction() { |
| // Create a transaction. |
| DCHECK(!transaction_.get()); |
| - DCHECK(request_->context()); |
| - DCHECK(request_->context()->ftp_transaction_factory()); |
| + DCHECK(ftp_transaction_factory_); |
|
erikwright (departed)
2012/06/07 19:14:51
Remove.
shalev
2012/06/21 20:04:55
Done.
shalev
2012/06/21 20:04:55
Done.
|
| - transaction_.reset( |
| - request_->context()->ftp_transaction_factory()->CreateTransaction()); |
| + transaction_.reset(ftp_transaction_factory_->CreateTransaction()); |
| // No matter what, we want to report our status as IO pending since we will |
| // be notifying our consumer asynchronously via OnStartCompleted. |
| @@ -104,16 +113,14 @@ void URLRequestFtpJob::OnStartCompleted(int result) { |
| } else if (transaction_->GetResponseInfo()->needs_auth) { |
| GURL origin = request_->url().GetOrigin(); |
| if (server_auth_ && server_auth_->state == AUTH_STATE_HAVE_AUTH) { |
| - request_->context()->ftp_auth_cache()->Remove( |
| - origin, server_auth_->credentials); |
| + ftp_auth_cache_->Remove(origin, server_auth_->credentials); |
| } else if (!server_auth_) { |
| server_auth_ = new AuthData(); |
| } |
| server_auth_->state = AUTH_STATE_NEED_AUTH; |
| FtpAuthCache::Entry* cached_auth = |
| - request_->context()->ftp_auth_cache()->Lookup(origin); |
| - |
| + ftp_auth_cache_->Lookup(origin); |
| if (cached_auth) { |
| // Retry using cached auth data. |
| SetAuth(cached_auth->credentials); |
| @@ -204,8 +211,8 @@ void URLRequestFtpJob::SetAuth(const AuthCredentials& credentials) { |
| server_auth_->state = AUTH_STATE_HAVE_AUTH; |
| server_auth_->credentials = credentials; |
| - request_->context()->ftp_auth_cache()->Add(request_->url().GetOrigin(), |
| - server_auth_->credentials); |
| + ftp_auth_cache_->Add(request_->url().GetOrigin(), |
| + server_auth_->credentials); |
| RestartTransactionWithAuth(); |
| } |