| 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 15 matching lines...) Expand all Loading... |
| 26 FtpAuthCache* ftp_auth_cache) | 26 FtpAuthCache* ftp_auth_cache) |
| 27 : URLRequestJob(request, network_delegate), | 27 : URLRequestJob(request, network_delegate), |
| 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 | |
| 37 URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request, | |
| 38 NetworkDelegate* network_delegate, | |
| 39 const std::string& scheme) { | |
| 40 DCHECK_EQ(scheme, "ftp"); | |
| 41 | |
| 42 int port = request->url().IntPort(); | |
| 43 if (request->url().has_port() && | |
| 44 !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port)) { | |
| 45 return new URLRequestErrorJob(request, | |
| 46 network_delegate, | |
| 47 ERR_UNSAFE_PORT); | |
| 48 } | |
| 49 | |
| 50 return new URLRequestFtpJob(request, | |
| 51 network_delegate, | |
| 52 request->context()->ftp_transaction_factory(), | |
| 53 request->context()->ftp_auth_cache()); | |
| 54 } | |
| 55 | |
| 56 bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const { | 36 bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const { |
| 57 if (transaction_->GetResponseInfo()->is_directory_listing) { | 37 if (transaction_->GetResponseInfo()->is_directory_listing) { |
| 58 *mime_type = "text/vnd.chromium.ftp-dir"; | 38 *mime_type = "text/vnd.chromium.ftp-dir"; |
| 59 return true; | 39 return true; |
| 60 } | 40 } |
| 61 return false; | 41 return false; |
| 62 } | 42 } |
| 63 | 43 |
| 64 HostPortPair URLRequestFtpJob::GetSocketAddress() const { | 44 HostPortPair URLRequestFtpJob::GetSocketAddress() const { |
| 65 if (!transaction_.get()) { | 45 if (!transaction_.get()) { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 if (rv == ERR_IO_PENDING) { | 235 if (rv == ERR_IO_PENDING) { |
| 256 read_in_progress_ = true; | 236 read_in_progress_ = true; |
| 257 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); | 237 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); |
| 258 } else { | 238 } else { |
| 259 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 239 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
| 260 } | 240 } |
| 261 return false; | 241 return false; |
| 262 } | 242 } |
| 263 | 243 |
| 264 } // namespace net | 244 } // namespace net |
| OLD | NEW |