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

Unified Diff: net/url_request/url_request_ftp_job_unittest.cc

Issue 2428143002: Clean up FtpTransactionFacory ownership. (Closed)
Patch Set: Oops 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
Index: net/url_request/url_request_ftp_job_unittest.cc
diff --git a/net/url_request/url_request_ftp_job_unittest.cc b/net/url_request/url_request_ftp_job_unittest.cc
index 6f2642106cf96b91391bfb86575fcd4406395409..214abb8ba127396a0084c3014789bd8412d9d1a5 100644
--- a/net/url_request/url_request_ftp_job_unittest.cc
+++ b/net/url_request/url_request_ftp_job_unittest.cc
@@ -64,37 +64,46 @@ class MockProxyResolverFactory : public ProxyResolverFactory {
MockAsyncProxyResolver* resolver_;
};
+class MockFtpTransactionFactory : public FtpTransactionFactory {
+ public:
+ std::unique_ptr<FtpTransaction> CreateTransaction() override {
+ return std::unique_ptr<FtpTransaction>();
+ }
+
+ void Suspend(bool suspend) override {}
+};
+
} // namespace
class FtpTestURLRequestContext : public TestURLRequestContext {
public:
FtpTestURLRequestContext(ClientSocketFactory* socket_factory,
std::unique_ptr<ProxyService> proxy_service,
- NetworkDelegate* network_delegate,
- FtpTransactionFactory* ftp_transaction_factory)
- : TestURLRequestContext(true),
- ftp_protocol_handler_(new FtpProtocolHandler(ftp_transaction_factory)) {
+ NetworkDelegate* network_delegate)
+ : TestURLRequestContext(true) {
set_client_socket_factory(socket_factory);
context_storage_.set_proxy_service(std::move(proxy_service));
set_network_delegate(network_delegate);
+ std::unique_ptr<FtpProtocolHandler> ftp_protocol_handler(
+ FtpProtocolHandler::CreateForTesting(
+ base::MakeUnique<MockFtpTransactionFactory>()));
+ auth_cache_ = ftp_protocol_handler->ftp_auth_cache_.get();
std::unique_ptr<URLRequestJobFactoryImpl> job_factory =
base::WrapUnique(new URLRequestJobFactoryImpl);
- job_factory->SetProtocolHandler("ftp",
- base::WrapUnique(ftp_protocol_handler_));
+ job_factory->SetProtocolHandler("ftp", std::move(ftp_protocol_handler));
context_storage_.set_job_factory(std::move(job_factory));
Init();
}
- FtpAuthCache* GetFtpAuthCache() {
- return ftp_protocol_handler_->ftp_auth_cache_.get();
- }
+ FtpAuthCache* GetFtpAuthCache() { return auth_cache_; }
void set_proxy_service(std::unique_ptr<ProxyService> proxy_service) {
context_storage_.set_proxy_service(std::move(proxy_service));
}
private:
- FtpProtocolHandler* ftp_protocol_handler_;
+ // Owned by the JobFactory's FtpProtocolHandler.
+ FtpAuthCache* auth_cache_;
};
namespace {
@@ -147,15 +156,6 @@ class TestURLRequestFtpJob : public URLRequestFtpJob {
protected:
};
-class MockFtpTransactionFactory : public FtpTransactionFactory {
- public:
- std::unique_ptr<FtpTransaction> CreateTransaction() override {
- return std::unique_ptr<FtpTransaction>();
- }
-
- void Suspend(bool suspend) override {}
-};
-
// Fixture for priority-related tests. Priority matters when there is
// an HTTP proxy.
class URLRequestFtpJobPriorityTest : public testing::Test {
@@ -257,8 +257,7 @@ class URLRequestFtpJobTest : public testing::Test {
base::WrapUnique(new SimpleProxyConfigService),
nullptr,
nullptr),
- &network_delegate_,
- &ftp_transaction_factory_) {}
+ &network_delegate_) {}
~URLRequestFtpJobTest() override {
// Clean up any remaining tasks that mess up unrelated tests.
@@ -283,7 +282,6 @@ class URLRequestFtpJobTest : public testing::Test {
std::vector<std::unique_ptr<SequencedSocketData>> socket_data_;
MockClientSocketFactory socket_factory_;
TestNetworkDelegate network_delegate_;
- MockFtpTransactionFactory ftp_transaction_factory_;
FtpTestURLRequestContext request_context_;
};

Powered by Google App Engine
This is Rietveld 408576698