| 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/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 read_in_progress_(false), | 28 read_in_progress_(false), |
| 29 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 29 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
| 30 ftp_transaction_factory_(ftp_transaction_factory), | 30 ftp_transaction_factory_(ftp_transaction_factory), |
| 31 ftp_auth_cache_(ftp_auth_cache) { | 31 ftp_auth_cache_(ftp_auth_cache) { |
| 32 DCHECK(ftp_transaction_factory); | 32 DCHECK(ftp_transaction_factory); |
| 33 DCHECK(ftp_auth_cache); | 33 DCHECK(ftp_auth_cache); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request, | 37 URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request, |
| 38 NetworkDelegate* network_delegate, |
| 38 const std::string& scheme) { | 39 const std::string& scheme) { |
| 39 DCHECK_EQ(scheme, "ftp"); | 40 DCHECK_EQ(scheme, "ftp"); |
| 40 | 41 |
| 41 int port = request->url().IntPort(); | 42 int port = request->url().IntPort(); |
| 42 if (request->url().has_port() && | 43 if (request->url().has_port() && |
| 43 !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port)) { | 44 !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port)) { |
| 44 return new URLRequestErrorJob(request, ERR_UNSAFE_PORT); | 45 return new URLRequestErrorJob(request, |
| 46 network_delegate, |
| 47 ERR_UNSAFE_PORT); |
| 45 } | 48 } |
| 46 | 49 |
| 47 return new URLRequestFtpJob(request, | 50 return new URLRequestFtpJob(request, |
| 48 request->context()->network_delegate(), | 51 network_delegate, |
| 49 request->context()->ftp_transaction_factory(), | 52 request->context()->ftp_transaction_factory(), |
| 50 request->context()->ftp_auth_cache()); | 53 request->context()->ftp_auth_cache()); |
| 51 } | 54 } |
| 52 | 55 |
| 53 bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const { | 56 bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const { |
| 54 if (transaction_->GetResponseInfo()->is_directory_listing) { | 57 if (transaction_->GetResponseInfo()->is_directory_listing) { |
| 55 *mime_type = "text/vnd.chromium.ftp-dir"; | 58 *mime_type = "text/vnd.chromium.ftp-dir"; |
| 56 return true; | 59 return true; |
| 57 } | 60 } |
| 58 return false; | 61 return false; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 if (rv == ERR_IO_PENDING) { | 255 if (rv == ERR_IO_PENDING) { |
| 253 read_in_progress_ = true; | 256 read_in_progress_ = true; |
| 254 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); | 257 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); |
| 255 } else { | 258 } else { |
| 256 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 259 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
| 257 } | 260 } |
| 258 return false; | 261 return false; |
| 259 } | 262 } |
| 260 | 263 |
| 261 } // namespace net | 264 } // namespace net |
| OLD | NEW |