Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: trunk/src/net/url_request/url_request_ftp_job.cc

Issue 12605011: Revert 188912 "Removed static factories for data, ftp, file, and..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "net/base/host_port_pair.h" 11 #include "net/base/host_port_pair.h"
12 #include "net/base/load_flags.h" 12 #include "net/base/load_flags.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/base/net_util.h" 14 #include "net/base/net_util.h"
15 #include "net/ftp/ftp_auth_cache.h"
16 #include "net/ftp/ftp_response_info.h" 15 #include "net/ftp/ftp_response_info.h"
17 #include "net/ftp/ftp_transaction_factory.h" 16 #include "net/ftp/ftp_transaction_factory.h"
18 #include "net/http/http_response_headers.h" 17 #include "net/http/http_response_headers.h"
19 #include "net/http/http_transaction_factory.h" 18 #include "net/http/http_transaction_factory.h"
20 #include "net/url_request/url_request.h" 19 #include "net/url_request/url_request.h"
21 #include "net/url_request/url_request_context.h" 20 #include "net/url_request/url_request_context.h"
22 #include "net/url_request/url_request_error_job.h" 21 #include "net/url_request/url_request_error_job.h"
23 22
24 namespace net { 23 namespace net {
25 24
26 URLRequestFtpJob::URLRequestFtpJob( 25 URLRequestFtpJob::URLRequestFtpJob(
27 URLRequest* request, 26 URLRequest* request,
28 NetworkDelegate* network_delegate, 27 NetworkDelegate* network_delegate,
29 FtpTransactionFactory* ftp_transaction_factory, 28 FtpTransactionFactory* ftp_transaction_factory,
30 FtpAuthCache* ftp_auth_cache) 29 FtpAuthCache* ftp_auth_cache)
31 : URLRequestJob(request, network_delegate), 30 : URLRequestJob(request, network_delegate),
32 pac_request_(NULL), 31 pac_request_(NULL),
33 response_info_(NULL), 32 response_info_(NULL),
34 read_in_progress_(false), 33 read_in_progress_(false),
35 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 34 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
36 ftp_transaction_factory_(ftp_transaction_factory), 35 ftp_transaction_factory_(ftp_transaction_factory),
37 ftp_auth_cache_(ftp_auth_cache) { 36 ftp_auth_cache_(ftp_auth_cache) {
38 DCHECK(ftp_transaction_factory); 37 DCHECK(ftp_transaction_factory);
39 DCHECK(ftp_auth_cache); 38 DCHECK(ftp_auth_cache);
40 } 39 }
41 40
41 // static
42 URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request,
43 NetworkDelegate* network_delegate,
44 const std::string& scheme) {
45 DCHECK_EQ(scheme, "ftp");
46
47 int port = request->url().IntPort();
48 if (request->url().has_port() &&
49 !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port)) {
50 return new URLRequestErrorJob(request,
51 network_delegate,
52 ERR_UNSAFE_PORT);
53 }
54
55 return new URLRequestFtpJob(request,
56 network_delegate,
57 request->context()->ftp_transaction_factory(),
58 request->context()->ftp_auth_cache());
59 }
60
42 bool URLRequestFtpJob::IsSafeRedirect(const GURL& location) { 61 bool URLRequestFtpJob::IsSafeRedirect(const GURL& location) {
43 // Disallow all redirects. 62 // Disallow all redirects.
44 return false; 63 return false;
45 } 64 }
46 65
47 bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const { 66 bool URLRequestFtpJob::GetMimeType(std::string* mime_type) const {
48 if (proxy_info_.is_direct()) { 67 if (proxy_info_.is_direct()) {
49 if (ftp_transaction_->GetResponseInfo()->is_directory_listing) { 68 if (ftp_transaction_->GetResponseInfo()->is_directory_listing) {
50 *mime_type = "text/vnd.chromium.ftp-dir"; 69 *mime_type = "text/vnd.chromium.ftp-dir";
51 return true; 70 return true;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 if (rv == ERR_IO_PENDING) { 380 if (rv == ERR_IO_PENDING) {
362 read_in_progress_ = true; 381 read_in_progress_ = true;
363 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); 382 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
364 } else { 383 } else {
365 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 384 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
366 } 385 }
367 return false; 386 return false;
368 } 387 }
369 388
370 } // namespace net 389 } // namespace net
OLDNEW
« no previous file with comments | « trunk/src/net/url_request/url_request_ftp_job.h ('k') | trunk/src/net/url_request/url_request_ftp_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698