Chromium Code Reviews| 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/ftp_protocol_handler.h" | 5 #include "net/url_request/ftp_protocol_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" | |
| 8 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 9 #include "net/base/port_util.h" | 10 #include "net/base/port_util.h" |
| 10 #include "net/ftp/ftp_auth_cache.h" | 11 #include "net/ftp/ftp_auth_cache.h" |
| 12 #include "net/ftp/ftp_network_layer.h" | |
| 11 #include "net/url_request/url_request.h" | 13 #include "net/url_request/url_request.h" |
| 12 #include "net/url_request/url_request_error_job.h" | 14 #include "net/url_request/url_request_error_job.h" |
| 13 #include "net/url_request/url_request_ftp_job.h" | 15 #include "net/url_request/url_request_ftp_job.h" |
| 14 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 15 | 17 |
| 16 namespace net { | 18 namespace net { |
| 17 | 19 |
| 18 FtpProtocolHandler::FtpProtocolHandler( | 20 std::unique_ptr<FtpProtocolHandler> FtpProtocolHandler::Create( |
| 19 FtpTransactionFactory* ftp_transaction_factory) | 21 HostResolver* host_resolver) { |
|
eroman
2016/10/19 16:29:51
It would be good to have DCHECK that |host_resolve
mmenke
2016/10/19 17:09:35
SGTM, done. Added to FtpNetworkLayer (Wider cover
| |
| 20 : ftp_transaction_factory_(ftp_transaction_factory), | 22 return base::WrapUnique( |
|
eroman
2016/10/19 16:29:51
style: this line uses both WrapUnique and MakeUniq
mmenke
2016/10/19 17:09:35
Switched to WrapUnique (Due to the private constru
| |
| 21 ftp_auth_cache_(new FtpAuthCache) { | 23 new FtpProtocolHandler(base::MakeUnique<FtpNetworkLayer>(host_resolver))); |
| 22 DCHECK(ftp_transaction_factory_); | 24 } |
| 25 | |
| 26 std::unique_ptr<FtpProtocolHandler> FtpProtocolHandler::CreateForTesting( | |
| 27 std::unique_ptr<FtpTransactionFactory> ftp_transaction_factory) { | |
| 28 return base::WrapUnique( | |
| 29 new FtpProtocolHandler(std::move(ftp_transaction_factory))); | |
| 23 } | 30 } |
| 24 | 31 |
| 25 FtpProtocolHandler::~FtpProtocolHandler() { | 32 FtpProtocolHandler::~FtpProtocolHandler() { |
| 26 } | 33 } |
| 27 | 34 |
| 28 URLRequestJob* FtpProtocolHandler::MaybeCreateJob( | 35 URLRequestJob* FtpProtocolHandler::MaybeCreateJob( |
| 29 URLRequest* request, NetworkDelegate* network_delegate) const { | 36 URLRequest* request, NetworkDelegate* network_delegate) const { |
| 30 DCHECK_EQ("ftp", request->url().scheme()); | 37 DCHECK_EQ("ftp", request->url().scheme()); |
| 31 | 38 |
| 32 if (!IsPortAllowedForScheme(request->url().EffectiveIntPort(), | 39 if (!IsPortAllowedForScheme(request->url().EffectiveIntPort(), |
| 33 request->url().scheme())) { | 40 request->url().scheme())) { |
| 34 return new URLRequestErrorJob(request, network_delegate, ERR_UNSAFE_PORT); | 41 return new URLRequestErrorJob(request, network_delegate, ERR_UNSAFE_PORT); |
| 35 } | 42 } |
| 36 | 43 |
| 37 return new URLRequestFtpJob(request, | 44 return new URLRequestFtpJob(request, network_delegate, |
| 38 network_delegate, | 45 ftp_transaction_factory_.get(), |
| 39 ftp_transaction_factory_, | |
| 40 ftp_auth_cache_.get()); | 46 ftp_auth_cache_.get()); |
| 41 } | 47 } |
| 42 | 48 |
| 49 FtpProtocolHandler::FtpProtocolHandler( | |
| 50 std::unique_ptr<FtpTransactionFactory> ftp_transaction_factory) | |
| 51 : ftp_transaction_factory_(std::move(ftp_transaction_factory)), | |
| 52 ftp_auth_cache_(new FtpAuthCache) { | |
| 53 DCHECK(ftp_transaction_factory_); | |
| 54 } | |
| 55 | |
| 43 } // namespace net | 56 } // namespace net |
| OLD | NEW |