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

Side by Side Diff: net/http/http_stream_factory_impl_job.h

Issue 1162893003: Remove HttpStreamFactoryImpl::Job::MarkAsAlternate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re: #3. Created 5 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
« no previous file with comments | « net/http/http_stream_factory_impl.cc ('k') | net/http/http_stream_factory_impl_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_
6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 18 matching lines...) Expand all
29 class HttpAuthController; 29 class HttpAuthController;
30 class HttpNetworkSession; 30 class HttpNetworkSession;
31 class HttpStream; 31 class HttpStream;
32 class SpdySessionPool; 32 class SpdySessionPool;
33 class QuicHttpStream; 33 class QuicHttpStream;
34 34
35 // An HttpStreamRequestImpl exists for each stream which is in progress of being 35 // An HttpStreamRequestImpl exists for each stream which is in progress of being
36 // created for the StreamFactory. 36 // created for the StreamFactory.
37 class HttpStreamFactoryImpl::Job { 37 class HttpStreamFactoryImpl::Job {
38 public: 38 public:
39 // Constructor for non-alternative Job.
39 Job(HttpStreamFactoryImpl* stream_factory, 40 Job(HttpStreamFactoryImpl* stream_factory,
40 HttpNetworkSession* session, 41 HttpNetworkSession* session,
41 const HttpRequestInfo& request_info, 42 const HttpRequestInfo& request_info,
42 RequestPriority priority, 43 RequestPriority priority,
43 const SSLConfig& server_ssl_config, 44 const SSLConfig& server_ssl_config,
44 const SSLConfig& proxy_ssl_config, 45 const SSLConfig& proxy_ssl_config,
45 NetLog* net_log); 46 NetLog* net_log);
47 // Constructor for alternative Job.
48 Job(HttpStreamFactoryImpl* stream_factory,
49 HttpNetworkSession* session,
50 const HttpRequestInfo& request_info,
51 RequestPriority priority,
52 const SSLConfig& server_ssl_config,
53 const SSLConfig& proxy_ssl_config,
54 AlternativeService alternative_service,
55 NetLog* net_log);
46 ~Job(); 56 ~Job();
47 57
48 // Start initiates the process of creating a new HttpStream. |request| will be 58 // Start initiates the process of creating a new HttpStream. |request| will be
49 // notified upon completion if the Job has not been Orphan()'d. 59 // notified upon completion if the Job has not been Orphan()'d.
50 void Start(Request* request); 60 void Start(Request* request);
51 61
52 // Preconnect will attempt to request |num_streams| sockets from the 62 // Preconnect will attempt to request |num_streams| sockets from the
53 // appropriate ClientSocketPool. 63 // appropriate ClientSocketPool.
54 int Preconnect(int num_streams); 64 int Preconnect(int num_streams);
55 65
56 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials); 66 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials);
57 LoadState GetLoadState() const; 67 LoadState GetLoadState() const;
58 68
59 // Marks this Job as the "alternate" job, from Alternate-Protocol or Alt-Svc
60 // using the specified alternate service.
61 void MarkAsAlternate(AlternativeService alternative_service);
62
63 // Tells |this| to wait for |job| to resume it. 69 // Tells |this| to wait for |job| to resume it.
64 void WaitFor(Job* job); 70 void WaitFor(Job* job);
65 71
66 // Tells |this| that |job| has determined it still needs to continue 72 // Tells |this| that |job| has determined it still needs to continue
67 // connecting, so allow |this| to continue. If this is not called, then 73 // connecting, so allow |this| to continue. If this is not called, then
68 // |request_| is expected to cancel |this| by deleting it. 74 // |request_| is expected to cancel |this| by deleting it.
69 void Resume(Job* job); 75 void Resume(Job* job);
70 76
71 // Used to detach the Job from |request|. 77 // Used to detach the Job from |request|.
72 void Orphan(const Request* request); 78 void Orphan(const Request* request);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 STATUS_BROKEN, 145 STATUS_BROKEN,
140 STATUS_SUCCEEDED 146 STATUS_SUCCEEDED
141 }; 147 };
142 148
143 // Wrapper class for SpdySessionPool methods to enforce certificate 149 // Wrapper class for SpdySessionPool methods to enforce certificate
144 // requirements for SpdySessions. 150 // requirements for SpdySessions.
145 class ValidSpdySessionPool { 151 class ValidSpdySessionPool {
146 public: 152 public:
147 ValidSpdySessionPool(SpdySessionPool* spdy_session_pool, 153 ValidSpdySessionPool(SpdySessionPool* spdy_session_pool,
148 GURL& origin_url, 154 GURL& origin_url,
149 bool is_spdy_alternate); 155 bool is_spdy_alternative);
150 156
151 // Returns OK if a SpdySession was not found (in which case |spdy_session| 157 // Returns OK if a SpdySession was not found (in which case |spdy_session|
152 // is set to nullptr), or if one was found (in which case |spdy_session| is 158 // is set to nullptr), or if one was found (in which case |spdy_session| is
153 // set to it) and it has an associated SSL certificate with is valid for 159 // set to it) and it has an associated SSL certificate with is valid for
154 // |origin_url_|, or if this requirement does not apply because the Job is 160 // |origin_url_|, or if this requirement does not apply because the Job is
155 // not a SPDY alternate job. Returns the appropriate error code otherwise, 161 // not a SPDY alternative job. Returns the appropriate error code
162 // otherwise,
156 // in which case |spdy_session| should not be used. 163 // in which case |spdy_session| should not be used.
157 int FindAvailableSession(const SpdySessionKey& key, 164 int FindAvailableSession(const SpdySessionKey& key,
158 const BoundNetLog& net_log, 165 const BoundNetLog& net_log,
159 base::WeakPtr<SpdySession>* spdy_session); 166 base::WeakPtr<SpdySession>* spdy_session);
160 167
161 // Creates a SpdySession and sets |spdy_session| to point to it. Returns OK 168 // Creates a SpdySession and sets |spdy_session| to point to it. Returns OK
162 // if the associated SSL certificate is valid for |origin_url_|, or if this 169 // if the associated SSL certificate is valid for |origin_url_|, or if this
163 // requirement does not apply because the Job is not a SPDY alternate job. 170 // requirement does not apply because the Job is not a SPDY alternative job.
164 // Returns the appropriate error code otherwise, in which case 171 // Returns the appropriate error code otherwise, in which case
165 // |spdy_session| should not be used. 172 // |spdy_session| should not be used.
166 int CreateAvailableSessionFromSocket( 173 int CreateAvailableSessionFromSocket(
167 const SpdySessionKey& key, 174 const SpdySessionKey& key,
168 scoped_ptr<ClientSocketHandle> connection, 175 scoped_ptr<ClientSocketHandle> connection,
169 const BoundNetLog& net_log, 176 const BoundNetLog& net_log,
170 int certificate_error_code, 177 int certificate_error_code,
171 bool is_secure, 178 bool is_secure,
172 base::WeakPtr<SpdySession>* spdy_session); 179 base::WeakPtr<SpdySession>* spdy_session);
173 180
174 private: 181 private:
175 // Returns OK if |spdy_session| has an associated SSL certificate with is 182 // Returns OK if |spdy_session| has an associated SSL certificate with is
176 // valid for |origin_url_|, or if this requirement does not apply because 183 // valid for |origin_url_|, or if this requirement does not apply because
177 // the Job is not a SPDY alternate job, or if |spdy_session| is null. 184 // the Job is not a SPDY alternative job, or if |spdy_session| is null.
178 // Returns appropriate error code otherwise. 185 // Returns appropriate error code otherwise.
179 int CheckAlternativeServiceValidityForOrigin( 186 int CheckAlternativeServiceValidityForOrigin(
180 base::WeakPtr<SpdySession> spdy_session); 187 base::WeakPtr<SpdySession> spdy_session);
181 188
182 SpdySessionPool* const spdy_session_pool_; 189 SpdySessionPool* const spdy_session_pool_;
183 const GURL origin_url_; 190 const GURL origin_url_;
184 const bool is_spdy_alternate_; 191 const bool is_spdy_alternative_;
185 }; 192 };
186 193
187 void OnStreamReadyCallback(); 194 void OnStreamReadyCallback();
188 void OnWebSocketHandshakeStreamReadyCallback(); 195 void OnWebSocketHandshakeStreamReadyCallback();
189 // This callback function is called when a new SPDY session is created. 196 // This callback function is called when a new SPDY session is created.
190 void OnNewSpdySessionReadyCallback(); 197 void OnNewSpdySessionReadyCallback();
191 void OnStreamFailedCallback(int result); 198 void OnStreamFailedCallback(int result);
192 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); 199 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info);
193 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, 200 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info,
194 HttpAuthController* auth_controller); 201 HttpAuthController* auth_controller);
(...skipping 29 matching lines...) Expand all
224 int SetSpdyHttpStream(base::WeakPtr<SpdySession> session, bool direct); 231 int SetSpdyHttpStream(base::WeakPtr<SpdySession> session, bool direct);
225 232
226 // Returns to STATE_INIT_CONNECTION and resets some state. 233 // Returns to STATE_INIT_CONNECTION and resets some state.
227 void ReturnToStateInitConnection(bool close_connection); 234 void ReturnToStateInitConnection(bool close_connection);
228 235
229 // Set the motivation for this request onto the underlying socket. 236 // Set the motivation for this request onto the underlying socket.
230 void SetSocketMotivation(); 237 void SetSocketMotivation();
231 238
232 bool IsHttpsProxyAndHttpUrl() const; 239 bool IsHttpsProxyAndHttpUrl() const;
233 240
234 // Returns true iff this Job is an alternate, that is, iff MarkAsAlternate has 241 // Is this a SPDY or QUIC alternative Job?
235 // been called. 242 bool IsSpdyAlternative() const;
236 bool IsAlternate() const; 243 bool IsQuicAlternative() const;
237
238 // Returns true if this Job is a SPDY alternate job.
239 bool IsSpdyAlternate() const;
240 244
241 // Sets several fields of |ssl_config| for |server| based on the proxy info 245 // Sets several fields of |ssl_config| for |server| based on the proxy info
242 // and other factors. 246 // and other factors.
243 void InitSSLConfig(const HostPortPair& server, 247 void InitSSLConfig(const HostPortPair& server,
244 SSLConfig* ssl_config, 248 SSLConfig* ssl_config,
245 bool is_proxy) const; 249 bool is_proxy) const;
246 250
247 // Retrieve SSLInfo from our SSL Socket. 251 // Retrieve SSLInfo from our SSL Socket.
248 // This must only be called when we are using an SSLSocket. 252 // This must only be called when we are using an SSLSocket.
249 // After calling, the caller can use ssl_info_. 253 // After calling, the caller can use ssl_info_.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 SSLInfo ssl_info_; 316 SSLInfo ssl_info_;
313 317
314 // The server we are trying to reach, could be that of the origin or of the 318 // The server we are trying to reach, could be that of the origin or of the
315 // alternative service. 319 // alternative service.
316 HostPortPair server_; 320 HostPortPair server_;
317 321
318 // The origin url we're trying to reach. This url may be different from the 322 // The origin url we're trying to reach. This url may be different from the
319 // original request when host mapping rules are set-up. 323 // original request when host mapping rules are set-up.
320 GURL origin_url_; 324 GURL origin_url_;
321 325
322 // AlternateProtocol for this job if this is an alternate job. 326 // AlternativeService for this Job if this is an alternative Job.
323 AlternativeService alternative_service_; 327 const AlternativeService alternative_service_;
324 328
325 // AlternateProtocol for the other job if this is not an alternate job. 329 // AlternativeService for the other Job if this is not an alternative Job.
326 AlternativeService other_job_alternative_service_; 330 AlternativeService other_job_alternative_service_;
327 331
328 // This is the Job we're dependent on. It will notify us if/when it's OK to 332 // This is the Job we're dependent on. It will notify us if/when it's OK to
329 // proceed. 333 // proceed.
330 Job* blocking_job_; 334 Job* blocking_job_;
331 335
332 // |waiting_job_| is a Job waiting to see if |this| can reuse a connection. 336 // |waiting_job_| is a Job waiting to see if |this| can reuse a connection.
333 // If |this| is unable to do so, we'll notify |waiting_job_| that it's ok to 337 // If |this| is unable to do so, we'll notify |waiting_job_| that it's ok to
334 // proceed and then race the two Jobs. 338 // proceed and then race the two Jobs.
335 Job* waiting_job_; 339 Job* waiting_job_;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 JobStatus other_job_status_; 392 JobStatus other_job_status_;
389 393
390 base::WeakPtrFactory<Job> ptr_factory_; 394 base::WeakPtrFactory<Job> ptr_factory_;
391 395
392 DISALLOW_COPY_AND_ASSIGN(Job); 396 DISALLOW_COPY_AND_ASSIGN(Job);
393 }; 397 };
394 398
395 } // namespace net 399 } // namespace net
396 400
397 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ 401 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl.cc ('k') | net/http/http_stream_factory_impl_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698