OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_NETWORK_TRANSACTION_H_ | 5 #ifndef NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ |
6 #define NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ | 6 #define NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "net/proxy/proxy_service.h" | 29 #include "net/proxy/proxy_service.h" |
30 #include "net/socket/client_socket_pool.h" | 30 #include "net/socket/client_socket_pool.h" |
31 | 31 |
32 namespace net { | 32 namespace net { |
33 | 33 |
34 class ClientSocketFactory; | 34 class ClientSocketFactory; |
35 class ClientSocketHandle; | 35 class ClientSocketHandle; |
36 class HttpNetworkSession; | 36 class HttpNetworkSession; |
37 class HttpRequestHeaders; | 37 class HttpRequestHeaders; |
38 class HttpStream; | 38 class HttpStream; |
39 class SpdyHttpStream; | 39 class SpdySession; |
40 | 40 |
41 class HttpNetworkTransaction : public HttpTransaction { | 41 class HttpNetworkTransaction : public HttpTransaction { |
42 public: | 42 public: |
43 explicit HttpNetworkTransaction(HttpNetworkSession* session); | 43 explicit HttpNetworkTransaction(HttpNetworkSession* session); |
44 | 44 |
45 virtual ~HttpNetworkTransaction(); | 45 virtual ~HttpNetworkTransaction(); |
46 | 46 |
47 static void SetHostMappingRules(const std::string& rules); | 47 static void SetHostMappingRules(const std::string& rules); |
48 | 48 |
49 // Controls whether or not we use the Alternate-Protocol header. | 49 // Controls whether or not we use the Alternate-Protocol header. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 virtual uint64 GetUploadProgress() const; | 84 virtual uint64 GetUploadProgress() const; |
85 | 85 |
86 private: | 86 private: |
87 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, ResetStateForRestart); | 87 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, ResetStateForRestart); |
88 | 88 |
89 enum State { | 89 enum State { |
90 STATE_RESOLVE_PROXY, | 90 STATE_RESOLVE_PROXY, |
91 STATE_RESOLVE_PROXY_COMPLETE, | 91 STATE_RESOLVE_PROXY_COMPLETE, |
92 STATE_INIT_CONNECTION, | 92 STATE_INIT_CONNECTION, |
93 STATE_INIT_CONNECTION_COMPLETE, | 93 STATE_INIT_CONNECTION_COMPLETE, |
| 94 STATE_INIT_STREAM, |
| 95 STATE_INIT_STREAM_COMPLETE, |
94 STATE_RESTART_TUNNEL_AUTH, | 96 STATE_RESTART_TUNNEL_AUTH, |
95 STATE_RESTART_TUNNEL_AUTH_COMPLETE, | 97 STATE_RESTART_TUNNEL_AUTH_COMPLETE, |
96 STATE_GENERATE_PROXY_AUTH_TOKEN, | 98 STATE_GENERATE_PROXY_AUTH_TOKEN, |
97 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE, | 99 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE, |
98 STATE_GENERATE_SERVER_AUTH_TOKEN, | 100 STATE_GENERATE_SERVER_AUTH_TOKEN, |
99 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE, | 101 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE, |
100 STATE_SEND_REQUEST, | 102 STATE_SEND_REQUEST, |
101 STATE_SEND_REQUEST_COMPLETE, | 103 STATE_SEND_REQUEST_COMPLETE, |
102 STATE_READ_HEADERS, | 104 STATE_READ_HEADERS, |
103 STATE_READ_HEADERS_COMPLETE, | 105 STATE_READ_HEADERS_COMPLETE, |
104 STATE_READ_BODY, | 106 STATE_READ_BODY, |
105 STATE_READ_BODY_COMPLETE, | 107 STATE_READ_BODY_COMPLETE, |
106 STATE_DRAIN_BODY_FOR_AUTH_RESTART, | 108 STATE_DRAIN_BODY_FOR_AUTH_RESTART, |
107 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, | 109 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, |
108 STATE_SPDY_GET_STREAM, | |
109 STATE_SPDY_GET_STREAM_COMPLETE, | |
110 STATE_SPDY_SEND_REQUEST, | |
111 STATE_SPDY_SEND_REQUEST_COMPLETE, | |
112 STATE_SPDY_READ_HEADERS, | |
113 STATE_SPDY_READ_HEADERS_COMPLETE, | |
114 STATE_SPDY_READ_BODY, | |
115 STATE_SPDY_READ_BODY_COMPLETE, | |
116 STATE_NONE | 110 STATE_NONE |
117 }; | 111 }; |
118 | 112 |
119 enum AlternateProtocolMode { | 113 enum AlternateProtocolMode { |
120 kUnspecified, // Unspecified, check HttpAlternateProtocols | 114 kUnspecified, // Unspecified, check HttpAlternateProtocols |
121 kUsingAlternateProtocol, // Using an alternate protocol | 115 kUsingAlternateProtocol, // Using an alternate protocol |
122 kDoNotUseAlternateProtocol, // Failed to connect once, do not try again. | 116 kDoNotUseAlternateProtocol, // Failed to connect once, do not try again. |
123 }; | 117 }; |
124 | 118 |
125 void DoCallback(int result); | 119 void DoCallback(int result); |
126 void OnIOComplete(int result); | 120 void OnIOComplete(int result); |
127 | 121 |
128 // Runs the state transition loop. | 122 // Runs the state transition loop. |
129 int DoLoop(int result); | 123 int DoLoop(int result); |
130 | 124 |
131 // Each of these methods corresponds to a State value. Those with an input | 125 // Each of these methods corresponds to a State value. Those with an input |
132 // argument receive the result from the previous state. If a method returns | 126 // argument receive the result from the previous state. If a method returns |
133 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the | 127 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the |
134 // next state method as the result arg. | 128 // next state method as the result arg. |
135 int DoResolveProxy(); | 129 int DoResolveProxy(); |
136 int DoResolveProxyComplete(int result); | 130 int DoResolveProxyComplete(int result); |
137 int DoInitConnection(); | 131 int DoInitConnection(); |
138 int DoInitConnectionComplete(int result); | 132 int DoInitConnectionComplete(int result); |
| 133 int DoInitStream(); |
| 134 int DoInitStreamComplete(int result); |
139 int DoRestartTunnelAuth(); | 135 int DoRestartTunnelAuth(); |
140 int DoRestartTunnelAuthComplete(int result); | 136 int DoRestartTunnelAuthComplete(int result); |
141 int DoGenerateProxyAuthToken(); | 137 int DoGenerateProxyAuthToken(); |
142 int DoGenerateProxyAuthTokenComplete(int result); | 138 int DoGenerateProxyAuthTokenComplete(int result); |
143 int DoGenerateServerAuthToken(); | 139 int DoGenerateServerAuthToken(); |
144 int DoGenerateServerAuthTokenComplete(int result); | 140 int DoGenerateServerAuthTokenComplete(int result); |
145 int DoSendRequest(); | 141 int DoSendRequest(); |
146 int DoSendRequestComplete(int result); | 142 int DoSendRequestComplete(int result); |
147 int DoReadHeaders(); | 143 int DoReadHeaders(); |
148 int DoReadHeadersComplete(int result); | 144 int DoReadHeadersComplete(int result); |
149 int DoReadBody(); | 145 int DoReadBody(); |
150 int DoReadBodyComplete(int result); | 146 int DoReadBodyComplete(int result); |
151 int DoDrainBodyForAuthRestart(); | 147 int DoDrainBodyForAuthRestart(); |
152 int DoDrainBodyForAuthRestartComplete(int result); | 148 int DoDrainBodyForAuthRestartComplete(int result); |
153 int DoSpdyGetStream(); | |
154 int DoSpdyGetStreamComplete(int result); | |
155 int DoSpdySendRequest(); | |
156 int DoSpdySendRequestComplete(int result); | |
157 int DoSpdyReadHeaders(); | |
158 int DoSpdyReadHeadersComplete(int result); | |
159 int DoSpdyReadBody(); | |
160 int DoSpdyReadBodyComplete(int result); | |
161 | 149 |
162 // Record histograms of latency until Connect() completes. | 150 // Record histograms of latency until Connect() completes. |
163 static void LogHttpConnectedMetrics(const ClientSocketHandle& handle); | 151 static void LogHttpConnectedMetrics(const ClientSocketHandle& handle); |
164 | 152 |
165 // Record histogram of time until first byte of header is received. | 153 // Record histogram of time until first byte of header is received. |
166 void LogTransactionConnectedMetrics(); | 154 void LogTransactionConnectedMetrics(); |
167 | 155 |
168 // Record histogram of latency (durations until last byte received). | 156 // Record histogram of latency (durations until last byte received). |
169 void LogTransactionMetrics() const; | 157 void LogTransactionMetrics() const; |
170 | 158 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 scoped_refptr<HttpNetworkSession> session_; | 258 scoped_refptr<HttpNetworkSession> session_; |
271 | 259 |
272 BoundNetLog net_log_; | 260 BoundNetLog net_log_; |
273 const HttpRequestInfo* request_; | 261 const HttpRequestInfo* request_; |
274 HttpResponseInfo response_; | 262 HttpResponseInfo response_; |
275 | 263 |
276 ProxyService::PacRequest* pac_request_; | 264 ProxyService::PacRequest* pac_request_; |
277 ProxyInfo proxy_info_; | 265 ProxyInfo proxy_info_; |
278 | 266 |
279 scoped_ptr<ClientSocketHandle> connection_; | 267 scoped_ptr<ClientSocketHandle> connection_; |
280 scoped_ptr<HttpStream> http_stream_; | 268 scoped_ptr<HttpStream> stream_; |
281 scoped_ptr<SpdyHttpStream> spdy_http_stream_; | 269 scoped_refptr<SpdySession> spdy_session_; |
282 bool reused_socket_; | 270 bool reused_socket_; |
283 | 271 |
284 // True if we've validated the headers that the stream parser has returned. | 272 // True if we've validated the headers that the stream parser has returned. |
285 bool headers_valid_; | 273 bool headers_valid_; |
286 | 274 |
287 // True if we've logged the time of the first response byte. Used to | 275 // True if we've logged the time of the first response byte. Used to |
288 // prevent logging across authentication activity where we see multiple | 276 // prevent logging across authentication activity where we see multiple |
289 // responses. | 277 // responses. |
290 bool logged_response_time_; | 278 bool logged_response_time_; |
291 | 279 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 bool establishing_tunnel_; | 326 bool establishing_tunnel_; |
339 | 327 |
340 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); | 328 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); |
341 }; | 329 }; |
342 | 330 |
343 int ConvertRequestPriorityToSpdyPriority(RequestPriority priority); | 331 int ConvertRequestPriorityToSpdyPriority(RequestPriority priority); |
344 | 332 |
345 } // namespace net | 333 } // namespace net |
346 | 334 |
347 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ | 335 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ |
OLD | NEW |