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

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

Issue 1941083002: JobController 1: Adding a new class HttpStreamFactoryImpl::JobController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove multiple refs to Job in JobController Created 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_
6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_
7
8 #include "net/http/http_stream_factory_impl.h"
9
10 namespace net {
11
12 // HttpStreamFactoryImpl::JobController manages Request and Jobs.
13 class HttpStreamFactoryImpl::JobController {
14 public:
15 JobController(HttpStreamFactoryImpl* factory,
16 HttpStreamRequest::Delegate* delegate,
17 HttpNetworkSession* session);
18 ~JobController();
19
20 // Creates request and hands out to HttpStreamFactoryImpl, creates Job(s) and
21 // starts serving the created request.
22 Request* Start(const HttpRequestInfo& request_info,
23 HttpStreamRequest::Delegate* delegate,
24 WebSocketHandshakeStreamBase::CreateHelper*
25 websocket_handshake_stream_create_helper,
26 const BoundNetLog& net_log,
27 HttpStreamRequest::StreamType stream_type,
28 RequestPriority priority,
29 const SSLConfig& server_ssl_config,
30 const SSLConfig& proxy_ssl_config);
31
32 void Preconnect(int num_streams,
33 const HttpRequestInfo& request_info,
34 const SSLConfig& server_ssl_config,
35 const SSLConfig& proxy_ssl_config);
36
37 LoadState GetLoadState() const;
38
39 void SetPriority(RequestPriority priority);
40
41 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials);
42
43 // Used to bind |job| to the |request_| and orphan all other jobs in |jobs_|.
44 void BindJob(Job* job);
45
46 // Used to orphan all jobs in |jobs_|.
47 void OrphanJobs();
48
49 // Called when a Job succeeds.
50 void CancelJobs();
51
52 // Called when a Job succeeds.
53 void OnJobSucceeded(Job* job);
54
55 void OnRequestFinish();
56
57 // Marks completion of the |request_|. Must be called before OnStreamReady().
58 void MarkRequestComplete(bool was_npn_negotiated,
59 NextProto protocol_negotiated,
60 bool using_spdy);
61
62 void OnStreamReady(Job* job,
63 const SSLConfig& used_ssl_config,
64 const ProxyInfo& used_proxy_info);
65
66 void OnBidirectionalStreamImplReady(Job* job,
67 const SSLConfig& used_ssl_config,
68 const ProxyInfo& used_proxy_info);
69
70 void OnWebSocketHandshakeStreamReady(Job* job,
71 const SSLConfig& used_ssl_config,
72 const ProxyInfo& used_proxy_info,
73 WebSocketHandshakeStreamBase* stream);
74
75 void OnStreamFailed(Job* job,
76 int status,
77 const SSLConfig& used_ssl_config,
78 SSLFailureState ssl_failure_state);
79
80 void OnCertificateError(Job* job,
81 int status,
82 const SSLConfig& used_ssl_config,
83 const SSLInfo& ssl_info);
84
85 void OnNeedsProxyAuth(Job* job,
86 const HttpResponseInfo& proxy_response,
87 const SSLConfig& used_ssl_config,
88 const ProxyInfo& used_proxy_info,
89 HttpAuthController* auth_controller);
90
91 void OnNeedsClientAuth(Job* job,
92 const SSLConfig& used_ssl_config,
93 SSLCertRequestInfo* cert_info);
94
95 void OnHttpsProxyTunnelResponse(Job* job,
96 const HttpResponseInfo& response_info,
97 const SSLConfig& used_ssl_config,
98 const ProxyInfo& used_proxy_info,
99 HttpStream* stream);
100
101 // Notify the |request_| and |factoy_| of the readiness of new SPDY session.
102 void OnNewSpdySessionReady(Job* job,
103 const base::WeakPtr<SpdySession>& spdy_session,
104 bool direct);
105
106 // Invoked when the Job finishes pre-connecting sockets.
107 void OnPreconnectsComplete(Job* job);
108
109 // Invoked when an orphaned Job finishes.
110 void OnOrphanedJobComplete(const Job* job);
111
112 // Called by an attached Job to record connection attempts made by the socket
113 // layer to |request_|.
114 void AddConnectionAttemptsToRequest(Job* job,
115 const ConnectionAttempts& attempts);
116
117 // Called when Job determines the appropriate |spdy_session_key| for the
118 // Request. Note that this does not mean that SPDY is necessarily supported
119 // for this SpdySessionKey, since we may need to wait for NPN to complete
120 // before knowing if SPDY is available.
121 void SetSpdySessionKey(Job* job, const SpdySessionKey& spdy_session_key);
122
123 // Remove session from the SpdySessionRequestMap.
124 void RemoveRequestFromSpdySessionRequestMap(Job* job);
125
126 void MaybeNotifyFactoryOfCompletion();
127
128 const BoundNetLog* GetNetLog(Job* job) const;
129
130 bool for_websockets() { return factory_->for_websockets_; }
131
132 WebSocketHandshakeStreamBase::CreateHelper*
133 websocket_handshake_stream_create_helper();
134
135 private:
136 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority);
137 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob);
138
139 // Creates Job(s) for |request_|. Job(s) will be owned by |this|.
140 void CreateJobs(const HttpRequestInfo& request_info,
141 RequestPriority priority,
142 const SSLConfig& server_ssl_config,
143 const SSLConfig& proxy_ssl_config,
144 HttpStreamRequest::Delegate* delegate,
145 HttpStreamRequest::StreamType stream_type,
146 const BoundNetLog& net_log);
147
148 // Attaches |job| to |request_|. Does not mean that |request_| will use |job|.
149 void AttachJob(Job* job);
150
151 GURL ApplyHostMappingRules(const GURL& url, HostPortPair* endpoint);
152
153 // Returns true if QUIC is whitelisted for |host|.
154 bool IsQuicWhitelistedForHost(const std::string& host);
155
156 AlternativeService GetAlternativeServiceFor(
157 const HttpRequestInfo& request_info,
158 HttpStreamRequest::Delegate* delegate,
159 HttpStreamRequest::StreamType stream_type);
160
161 // Remove session from the SpdySessionRequestMap.
162 void RemoveRequestFromSpdySessionRequestMap();
163
164 HttpStreamFactoryImpl* factory_;
165 HttpNetworkSession* session_;
166 // Request will be handed out to factory once created. This just keeps an
167 // reference. It will be set to NULL once the request is completed.
168 Request* request_;
169
170 HttpStreamRequest::Delegate* const delegate_;
171
172 // True if this JobController is used to preconnect streams.
173 bool is_preconnect_;
174
175 // |main_job_| is a job waiting to see if |alternative_job_| can reuse a
176 // connection. If |alternative_job_| is unable to do so, |this| will notify
177 // |main_job_| to proceed and then race the two jobs.
178 std::unique_ptr<Job> main_job_;
179 std::unique_ptr<Job> alternative_job_;
180
181 // True if ever a job is explicitly bounded to the |request_|.
182 bool job_bounded_;
183
184 // At the point where a Job is irrevocably tied to |request_|, we set this.
185 Job* bound_job_;
186 };
187
188 } // namespace net
189
190 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698