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