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

Side by Side Diff: net/http/http_stream_factory_test_util.cc

Issue 2910463004: Revert "Revert CLs landed in HttpStreamFactoryImpl to track down a crasher" (Closed)
Patch Set: Fix Preconnect AltSvc Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/http/http_stream_factory_test_util.h" 5 #include "net/http/http_stream_factory_test_util.h"
6 6
7 #include <utility>
8
7 #include "net/proxy/proxy_info.h" 9 #include "net/proxy/proxy_info.h"
8 10
9 using ::testing::_; 11 using ::testing::_;
10 12
11 namespace net { 13 namespace net {
12 MockHttpStreamRequestDelegate::MockHttpStreamRequestDelegate() {} 14 MockHttpStreamRequestDelegate::MockHttpStreamRequestDelegate() {}
13 15
14 MockHttpStreamRequestDelegate::~MockHttpStreamRequestDelegate() {} 16 MockHttpStreamRequestDelegate::~MockHttpStreamRequestDelegate() {}
15 17
16 MockHttpStreamFactoryImplJob::MockHttpStreamFactoryImplJob( 18 MockHttpStreamFactoryImplJob::MockHttpStreamFactoryImplJob(
17 HttpStreamFactoryImpl::Job::Delegate* delegate, 19 HttpStreamFactoryImpl::Job::Delegate* delegate,
18 HttpStreamFactoryImpl::JobType job_type, 20 HttpStreamFactoryImpl::JobType job_type,
19 HttpNetworkSession* session, 21 HttpNetworkSession* session,
20 const HttpRequestInfo& request_info, 22 const HttpRequestInfo& request_info,
21 RequestPriority priority, 23 RequestPriority priority,
24 ProxyInfo proxy_info,
22 const SSLConfig& server_ssl_config, 25 const SSLConfig& server_ssl_config,
23 const SSLConfig& proxy_ssl_config, 26 const SSLConfig& proxy_ssl_config,
24 HostPortPair destination, 27 HostPortPair destination,
25 GURL origin_url, 28 GURL origin_url,
26 bool enable_ip_based_pooling, 29 bool enable_ip_based_pooling,
27 NetLog* net_log) 30 NetLog* net_log)
28 : HttpStreamFactoryImpl::Job(delegate, 31 : HttpStreamFactoryImpl::Job(delegate,
29 job_type, 32 job_type,
30 session, 33 session,
31 request_info, 34 request_info,
32 priority, 35 priority,
36 proxy_info,
33 server_ssl_config, 37 server_ssl_config,
34 proxy_ssl_config, 38 proxy_ssl_config,
35 destination, 39 destination,
36 origin_url, 40 origin_url,
37 enable_ip_based_pooling, 41 enable_ip_based_pooling,
38 net_log) { 42 net_log) {
39 DCHECK(!is_waiting()); 43 DCHECK(!is_waiting());
40 } 44 }
41 45
42 MockHttpStreamFactoryImplJob::MockHttpStreamFactoryImplJob( 46 MockHttpStreamFactoryImplJob::MockHttpStreamFactoryImplJob(
43 HttpStreamFactoryImpl::Job::Delegate* delegate, 47 HttpStreamFactoryImpl::Job::Delegate* delegate,
44 HttpStreamFactoryImpl::JobType job_type, 48 HttpStreamFactoryImpl::JobType job_type,
45 HttpNetworkSession* session, 49 HttpNetworkSession* session,
46 const HttpRequestInfo& request_info, 50 const HttpRequestInfo& request_info,
47 RequestPriority priority, 51 RequestPriority priority,
52 ProxyInfo proxy_info,
48 const SSLConfig& server_ssl_config, 53 const SSLConfig& server_ssl_config,
49 const SSLConfig& proxy_ssl_config, 54 const SSLConfig& proxy_ssl_config,
50 HostPortPair destination, 55 HostPortPair destination,
51 GURL origin_url, 56 GURL origin_url,
52 AlternativeService alternative_service, 57 AlternativeService alternative_service,
53 const ProxyServer& alternative_proxy_server, 58 const ProxyServer& alternative_proxy_server,
54 bool enable_ip_based_pooling, 59 bool enable_ip_based_pooling,
55 NetLog* net_log) 60 NetLog* net_log)
56 : HttpStreamFactoryImpl::Job(delegate, 61 : HttpStreamFactoryImpl::Job(delegate,
57 job_type, 62 job_type,
58 session, 63 session,
59 request_info, 64 request_info,
60 priority, 65 priority,
66 proxy_info,
61 server_ssl_config, 67 server_ssl_config,
62 proxy_ssl_config, 68 proxy_ssl_config,
63 destination, 69 destination,
64 origin_url, 70 origin_url,
65 alternative_service, 71 alternative_service,
66 alternative_proxy_server, 72 alternative_proxy_server,
67 enable_ip_based_pooling, 73 enable_ip_based_pooling,
68 net_log) {} 74 net_log) {}
69 75
70 MockHttpStreamFactoryImplJob::~MockHttpStreamFactoryImplJob() {} 76 MockHttpStreamFactoryImplJob::~MockHttpStreamFactoryImplJob() {}
71 77
72 TestJobFactory::TestJobFactory() 78 TestJobFactory::TestJobFactory()
73 : main_job_(nullptr), 79 : main_job_(nullptr),
74 alternative_job_(nullptr), 80 alternative_job_(nullptr),
75 override_main_job_url_(false) {} 81 override_main_job_url_(false) {}
76 82
77 TestJobFactory::~TestJobFactory() {} 83 TestJobFactory::~TestJobFactory() {}
78 84
79 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( 85 std::unique_ptr<HttpStreamFactoryImpl::Job> TestJobFactory::CreateMainJob(
80 HttpStreamFactoryImpl::Job::Delegate* delegate, 86 HttpStreamFactoryImpl::Job::Delegate* delegate,
81 HttpStreamFactoryImpl::JobType job_type, 87 HttpStreamFactoryImpl::JobType job_type,
82 HttpNetworkSession* session, 88 HttpNetworkSession* session,
83 const HttpRequestInfo& request_info, 89 const HttpRequestInfo& request_info,
84 RequestPriority priority, 90 RequestPriority priority,
91 const ProxyInfo& proxy_info,
85 const SSLConfig& server_ssl_config, 92 const SSLConfig& server_ssl_config,
86 const SSLConfig& proxy_ssl_config, 93 const SSLConfig& proxy_ssl_config,
87 HostPortPair destination, 94 HostPortPair destination,
88 GURL origin_url, 95 GURL origin_url,
89 bool enable_ip_based_pooling, 96 bool enable_ip_based_pooling,
90 NetLog* net_log) { 97 NetLog* net_log) {
91 DCHECK(!main_job_);
92
93 if (override_main_job_url_) 98 if (override_main_job_url_)
94 origin_url = main_job_alternative_url_; 99 origin_url = main_job_alternative_url_;
95 100
96 main_job_ = new MockHttpStreamFactoryImplJob( 101 auto main_job = base::MakeUnique<MockHttpStreamFactoryImplJob>(
97 delegate, job_type, session, request_info, priority, SSLConfig(), 102 delegate, job_type, session, request_info, priority, proxy_info,
98 SSLConfig(), destination, origin_url, enable_ip_based_pooling, nullptr); 103 SSLConfig(), SSLConfig(), destination, origin_url,
104 enable_ip_based_pooling, nullptr);
99 105
100 return main_job_; 106 // Keep raw pointer to Job but pass ownership.
107 main_job_ = main_job.get();
108
109 return std::move(main_job);
101 } 110 }
102 111
103 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( 112 std::unique_ptr<HttpStreamFactoryImpl::Job> TestJobFactory::CreateAltSvcJob(
104 HttpStreamFactoryImpl::Job::Delegate* delegate, 113 HttpStreamFactoryImpl::Job::Delegate* delegate,
105 HttpStreamFactoryImpl::JobType job_type, 114 HttpStreamFactoryImpl::JobType job_type,
106 HttpNetworkSession* session, 115 HttpNetworkSession* session,
107 const HttpRequestInfo& request_info, 116 const HttpRequestInfo& request_info,
108 RequestPriority priority, 117 RequestPriority priority,
118 const ProxyInfo& proxy_info,
109 const SSLConfig& server_ssl_config, 119 const SSLConfig& server_ssl_config,
110 const SSLConfig& proxy_ssl_config, 120 const SSLConfig& proxy_ssl_config,
111 HostPortPair destination, 121 HostPortPair destination,
112 GURL origin_url, 122 GURL origin_url,
113 AlternativeService alternative_service, 123 AlternativeService alternative_service,
114 bool enable_ip_based_pooling, 124 bool enable_ip_based_pooling,
115 NetLog* net_log) { 125 NetLog* net_log) {
116 DCHECK(!alternative_job_); 126 auto alternative_job = base::MakeUnique<MockHttpStreamFactoryImplJob>(
117 alternative_job_ = new MockHttpStreamFactoryImplJob( 127 delegate, job_type, session, request_info, priority, proxy_info,
118 delegate, job_type, session, request_info, priority, SSLConfig(), 128 SSLConfig(), SSLConfig(), destination, origin_url, alternative_service,
119 SSLConfig(), destination, origin_url, alternative_service, ProxyServer(), 129 ProxyServer(), enable_ip_based_pooling, nullptr);
120 enable_ip_based_pooling, nullptr);
121 130
122 return alternative_job_; 131 // Keep raw pointer to Job but pass ownership.
132 alternative_job_ = alternative_job.get();
133
134 return std::move(alternative_job);
123 } 135 }
124 136
125 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( 137 std::unique_ptr<HttpStreamFactoryImpl::Job> TestJobFactory::CreateAltProxyJob(
126 HttpStreamFactoryImpl::Job::Delegate* delegate, 138 HttpStreamFactoryImpl::Job::Delegate* delegate,
127 HttpStreamFactoryImpl::JobType job_type, 139 HttpStreamFactoryImpl::JobType job_type,
128 HttpNetworkSession* session, 140 HttpNetworkSession* session,
129 const HttpRequestInfo& request_info, 141 const HttpRequestInfo& request_info,
130 RequestPriority priority, 142 RequestPriority priority,
143 const ProxyInfo& proxy_info,
131 const SSLConfig& server_ssl_config, 144 const SSLConfig& server_ssl_config,
132 const SSLConfig& proxy_ssl_config, 145 const SSLConfig& proxy_ssl_config,
133 HostPortPair destination, 146 HostPortPair destination,
134 GURL origin_url, 147 GURL origin_url,
135 const ProxyServer& alternative_proxy_server, 148 const ProxyServer& alternative_proxy_server,
136 bool enable_ip_based_pooling, 149 bool enable_ip_based_pooling,
137 NetLog* net_log) { 150 NetLog* net_log) {
138 DCHECK(!alternative_job_); 151 auto alternative_job = base::MakeUnique<MockHttpStreamFactoryImplJob>(
139 alternative_job_ = new MockHttpStreamFactoryImplJob( 152 delegate, job_type, session, request_info, priority, proxy_info,
140 delegate, job_type, session, request_info, priority, SSLConfig(), 153 SSLConfig(), SSLConfig(), destination, origin_url, AlternativeService(),
141 SSLConfig(), destination, origin_url, AlternativeService(),
142 alternative_proxy_server, enable_ip_based_pooling, nullptr); 154 alternative_proxy_server, enable_ip_based_pooling, nullptr);
143 155
144 return alternative_job_; 156 // Keep raw pointer to Job but pass ownership.
157 alternative_job_ = alternative_job.get();
158
159 return std::move(alternative_job);
145 } 160 }
146 161
147 } // namespace net 162 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698