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

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

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

Powered by Google App Engine
This is Rietveld 408576698