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

Unified Diff: net/http/http_stream_factory_test_util.cc

Issue 2895443002: Return Job as unique_ptr from factory methods. (Closed)
Patch Set: Created 3 years, 7 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/http/http_stream_factory_test_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory_test_util.cc
diff --git a/net/http/http_stream_factory_test_util.cc b/net/http/http_stream_factory_test_util.cc
index e2d018bce4ad97ff0a221403e3126b86d13d9c0c..2c8fc625ef7eec1c7992f7f9b5c9135b45012c85 100644
--- a/net/http/http_stream_factory_test_util.cc
+++ b/net/http/http_stream_factory_test_util.cc
@@ -4,6 +4,8 @@
#include "net/http/http_stream_factory_test_util.h"
+#include <utility>
+
#include "net/proxy/proxy_info.h"
using ::testing::_;
@@ -80,7 +82,7 @@ TestJobFactory::TestJobFactory()
TestJobFactory::~TestJobFactory() {}
-HttpStreamFactoryImpl::Job* TestJobFactory::CreateMainJob(
+std::unique_ptr<HttpStreamFactoryImpl::Job> TestJobFactory::CreateMainJob(
HttpStreamFactoryImpl::Job::Delegate* delegate,
HttpStreamFactoryImpl::JobType job_type,
HttpNetworkSession* session,
@@ -96,15 +98,18 @@ HttpStreamFactoryImpl::Job* TestJobFactory::CreateMainJob(
if (override_main_job_url_)
origin_url = main_job_alternative_url_;
- main_job_ = new MockHttpStreamFactoryImplJob(
+ auto main_job = base::MakeUnique<MockHttpStreamFactoryImplJob>(
delegate, job_type, session, request_info, priority, proxy_info,
SSLConfig(), SSLConfig(), destination, origin_url,
enable_ip_based_pooling, nullptr);
- return main_job_;
+ // Keep raw pointer to Job but pass ownership.
+ main_job_ = main_job.get();
+
+ return std::move(main_job);
}
-HttpStreamFactoryImpl::Job* TestJobFactory::CreateAltSvcJob(
+std::unique_ptr<HttpStreamFactoryImpl::Job> TestJobFactory::CreateAltSvcJob(
HttpStreamFactoryImpl::Job::Delegate* delegate,
HttpStreamFactoryImpl::JobType job_type,
HttpNetworkSession* session,
@@ -118,15 +123,18 @@ HttpStreamFactoryImpl::Job* TestJobFactory::CreateAltSvcJob(
AlternativeService alternative_service,
bool enable_ip_based_pooling,
NetLog* net_log) {
- alternative_job_ = new MockHttpStreamFactoryImplJob(
+ auto alternative_job = base::MakeUnique<MockHttpStreamFactoryImplJob>(
delegate, job_type, session, request_info, priority, proxy_info,
SSLConfig(), SSLConfig(), destination, origin_url, alternative_service,
ProxyServer(), enable_ip_based_pooling, nullptr);
- return alternative_job_;
+ // Keep raw pointer to Job but pass ownership.
+ alternative_job_ = alternative_job.get();
+
+ return std::move(alternative_job);
}
-HttpStreamFactoryImpl::Job* TestJobFactory::CreateAltProxyJob(
+std::unique_ptr<HttpStreamFactoryImpl::Job> TestJobFactory::CreateAltProxyJob(
HttpStreamFactoryImpl::Job::Delegate* delegate,
HttpStreamFactoryImpl::JobType job_type,
HttpNetworkSession* session,
@@ -140,12 +148,15 @@ HttpStreamFactoryImpl::Job* TestJobFactory::CreateAltProxyJob(
const ProxyServer& alternative_proxy_server,
bool enable_ip_based_pooling,
NetLog* net_log) {
- alternative_job_ = new MockHttpStreamFactoryImplJob(
+ auto alternative_job = base::MakeUnique<MockHttpStreamFactoryImplJob>(
delegate, job_type, session, request_info, priority, proxy_info,
SSLConfig(), SSLConfig(), destination, origin_url, AlternativeService(),
alternative_proxy_server, enable_ip_based_pooling, nullptr);
- return alternative_job_;
+ // Keep raw pointer to Job but pass ownership.
+ alternative_job_ = alternative_job.get();
+
+ return std::move(alternative_job);
}
} // namespace net
« no previous file with comments | « net/http/http_stream_factory_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698