| 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..be6adac5cbf07bfede7fdeb637cbc2d2b1740123 100644
|
| --- a/net/url_request/url_request_ftp_job.cc
|
| +++ b/net/url_request/url_request_ftp_job.cc
|
| @@ -19,10 +19,19 @@
|
|
|
| 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);
|
| }
|
|
|
| // static
|
| @@ -37,7 +46,12 @@ URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request,
|
|
|
| DCHECK(request->context());
|
| DCHECK(request->context()->ftp_transaction_factory());
|
| - return new URLRequestFtpJob(request);
|
| + DCHECK(request->context()->ftp_auth_cache());
|
| +
|
| + 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 +75,8 @@ URLRequestFtpJob::~URLRequestFtpJob() {
|
| void URLRequestFtpJob::StartTransaction() {
|
| // Create a transaction.
|
| DCHECK(!transaction_.get());
|
| - DCHECK(request_->context());
|
| - DCHECK(request_->context()->ftp_transaction_factory());
|
|
|
| - 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 +115,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 +213,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();
|
| }
|
|
|