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

Unified Diff: net/url_request/ftp_protocol_handler.cc

Issue 2428143002: Clean up FtpTransactionFacory ownership. (Closed)
Patch Set: --typos Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/ftp_protocol_handler.h ('k') | net/url_request/url_request_context_builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/ftp_protocol_handler.cc
diff --git a/net/url_request/ftp_protocol_handler.cc b/net/url_request/ftp_protocol_handler.cc
index 4c10124ceed561394fb91791304affe231f7b684..5a71ecbbc759fd70ae0c00b87dc7126f75188224 100644
--- a/net/url_request/ftp_protocol_handler.cc
+++ b/net/url_request/ftp_protocol_handler.cc
@@ -5,9 +5,11 @@
#include "net/url_request/ftp_protocol_handler.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "net/base/net_errors.h"
#include "net/base/port_util.h"
#include "net/ftp/ftp_auth_cache.h"
+#include "net/ftp/ftp_network_layer.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_error_job.h"
#include "net/url_request/url_request_ftp_job.h"
@@ -15,11 +17,16 @@
namespace net {
-FtpProtocolHandler::FtpProtocolHandler(
- FtpTransactionFactory* ftp_transaction_factory)
- : ftp_transaction_factory_(ftp_transaction_factory),
- ftp_auth_cache_(new FtpAuthCache) {
- DCHECK(ftp_transaction_factory_);
+std::unique_ptr<FtpProtocolHandler> FtpProtocolHandler::Create(
+ HostResolver* host_resolver) {
+ return base::WrapUnique(new FtpProtocolHandler(
+ base::WrapUnique(new FtpNetworkLayer(host_resolver))));
+}
+
+std::unique_ptr<FtpProtocolHandler> FtpProtocolHandler::CreateForTesting(
+ std::unique_ptr<FtpTransactionFactory> ftp_transaction_factory) {
+ return base::WrapUnique(
+ new FtpProtocolHandler(std::move(ftp_transaction_factory)));
}
FtpProtocolHandler::~FtpProtocolHandler() {
@@ -34,10 +41,16 @@ URLRequestJob* FtpProtocolHandler::MaybeCreateJob(
return new URLRequestErrorJob(request, network_delegate, ERR_UNSAFE_PORT);
}
- return new URLRequestFtpJob(request,
- network_delegate,
- ftp_transaction_factory_,
+ return new URLRequestFtpJob(request, network_delegate,
+ ftp_transaction_factory_.get(),
ftp_auth_cache_.get());
}
+FtpProtocolHandler::FtpProtocolHandler(
+ std::unique_ptr<FtpTransactionFactory> ftp_transaction_factory)
+ : ftp_transaction_factory_(std::move(ftp_transaction_factory)),
+ ftp_auth_cache_(new FtpAuthCache) {
+ DCHECK(ftp_transaction_factory_);
+}
+
} // namespace net
« no previous file with comments | « net/url_request/ftp_protocol_handler.h ('k') | net/url_request/url_request_context_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698