| 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 SpdySession; | 39 class SpdyHttpStream; |
| 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, | |
| 96 STATE_RESTART_TUNNEL_AUTH, | 94 STATE_RESTART_TUNNEL_AUTH, |
| 97 STATE_RESTART_TUNNEL_AUTH_COMPLETE, | 95 STATE_RESTART_TUNNEL_AUTH_COMPLETE, |
| 98 STATE_GENERATE_PROXY_AUTH_TOKEN, | 96 STATE_GENERATE_PROXY_AUTH_TOKEN, |
| 99 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE, | 97 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE, |
| 100 STATE_GENERATE_SERVER_AUTH_TOKEN, | 98 STATE_GENERATE_SERVER_AUTH_TOKEN, |
| 101 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE, | 99 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE, |
| 102 STATE_SEND_REQUEST, | 100 STATE_SEND_REQUEST, |
| 103 STATE_SEND_REQUEST_COMPLETE, | 101 STATE_SEND_REQUEST_COMPLETE, |
| 104 STATE_READ_HEADERS, | 102 STATE_READ_HEADERS, |
| 105 STATE_READ_HEADERS_COMPLETE, | 103 STATE_READ_HEADERS_COMPLETE, |
| 106 STATE_READ_BODY, | 104 STATE_READ_BODY, |
| 107 STATE_READ_BODY_COMPLETE, | 105 STATE_READ_BODY_COMPLETE, |
| 108 STATE_DRAIN_BODY_FOR_AUTH_RESTART, | 106 STATE_DRAIN_BODY_FOR_AUTH_RESTART, |
| 109 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, | 107 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, |
| 110 STATE_NONE | 116 STATE_NONE |
| 111 }; | 117 }; |
| 112 | 118 |
| 113 enum AlternateProtocolMode { | 119 enum AlternateProtocolMode { |
| 114 kUnspecified, // Unspecified, check HttpAlternateProtocols | 120 kUnspecified, // Unspecified, check HttpAlternateProtocols |
| 115 kUsingAlternateProtocol, // Using an alternate protocol | 121 kUsingAlternateProtocol, // Using an alternate protocol |
| 116 kDoNotUseAlternateProtocol, // Failed to connect once, do not try again. | 122 kDoNotUseAlternateProtocol, // Failed to connect once, do not try again. |
| 117 }; | 123 }; |
| 118 | 124 |
| 119 void DoCallback(int result); | 125 void DoCallback(int result); |
| 120 void OnIOComplete(int result); | 126 void OnIOComplete(int result); |
| 121 | 127 |
| 122 // Runs the state transition loop. | 128 // Runs the state transition loop. |
| 123 int DoLoop(int result); | 129 int DoLoop(int result); |
| 124 | 130 |
| 125 // Each of these methods corresponds to a State value. Those with an input | 131 // Each of these methods corresponds to a State value. Those with an input |
| 126 // argument receive the result from the previous state. If a method returns | 132 // argument receive the result from the previous state. If a method returns |
| 127 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the | 133 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the |
| 128 // next state method as the result arg. | 134 // next state method as the result arg. |
| 129 int DoResolveProxy(); | 135 int DoResolveProxy(); |
| 130 int DoResolveProxyComplete(int result); | 136 int DoResolveProxyComplete(int result); |
| 131 int DoInitConnection(); | 137 int DoInitConnection(); |
| 132 int DoInitConnectionComplete(int result); | 138 int DoInitConnectionComplete(int result); |
| 133 int DoInitStream(); | |
| 134 int DoInitStreamComplete(int result); | |
| 135 int DoRestartTunnelAuth(); | 139 int DoRestartTunnelAuth(); |
| 136 int DoRestartTunnelAuthComplete(int result); | 140 int DoRestartTunnelAuthComplete(int result); |
| 137 int DoGenerateProxyAuthToken(); | 141 int DoGenerateProxyAuthToken(); |
| 138 int DoGenerateProxyAuthTokenComplete(int result); | 142 int DoGenerateProxyAuthTokenComplete(int result); |
| 139 int DoGenerateServerAuthToken(); | 143 int DoGenerateServerAuthToken(); |
| 140 int DoGenerateServerAuthTokenComplete(int result); | 144 int DoGenerateServerAuthTokenComplete(int result); |
| 141 int DoSendRequest(); | 145 int DoSendRequest(); |
| 142 int DoSendRequestComplete(int result); | 146 int DoSendRequestComplete(int result); |
| 143 int DoReadHeaders(); | 147 int DoReadHeaders(); |
| 144 int DoReadHeadersComplete(int result); | 148 int DoReadHeadersComplete(int result); |
| 145 int DoReadBody(); | 149 int DoReadBody(); |
| 146 int DoReadBodyComplete(int result); | 150 int DoReadBodyComplete(int result); |
| 147 int DoDrainBodyForAuthRestart(); | 151 int DoDrainBodyForAuthRestart(); |
| 148 int DoDrainBodyForAuthRestartComplete(int result); | 152 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); |
| 149 | 161 |
| 150 // Record histograms of latency until Connect() completes. | 162 // Record histograms of latency until Connect() completes. |
| 151 static void LogHttpConnectedMetrics(const ClientSocketHandle& handle); | 163 static void LogHttpConnectedMetrics(const ClientSocketHandle& handle); |
| 152 | 164 |
| 153 // Record histogram of time until first byte of header is received. | 165 // Record histogram of time until first byte of header is received. |
| 154 void LogTransactionConnectedMetrics(); | 166 void LogTransactionConnectedMetrics(); |
| 155 | 167 |
| 156 // Record histogram of latency (durations until last byte received). | 168 // Record histogram of latency (durations until last byte received). |
| 157 void LogTransactionMetrics() const; | 169 void LogTransactionMetrics() const; |
| 158 | 170 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 scoped_refptr<HttpNetworkSession> session_; | 270 scoped_refptr<HttpNetworkSession> session_; |
| 259 | 271 |
| 260 BoundNetLog net_log_; | 272 BoundNetLog net_log_; |
| 261 const HttpRequestInfo* request_; | 273 const HttpRequestInfo* request_; |
| 262 HttpResponseInfo response_; | 274 HttpResponseInfo response_; |
| 263 | 275 |
| 264 ProxyService::PacRequest* pac_request_; | 276 ProxyService::PacRequest* pac_request_; |
| 265 ProxyInfo proxy_info_; | 277 ProxyInfo proxy_info_; |
| 266 | 278 |
| 267 scoped_ptr<ClientSocketHandle> connection_; | 279 scoped_ptr<ClientSocketHandle> connection_; |
| 268 scoped_ptr<HttpStream> stream_; | 280 scoped_ptr<HttpStream> http_stream_; |
| 269 scoped_refptr<SpdySession> spdy_session_; | 281 scoped_ptr<SpdyHttpStream> spdy_http_stream_; |
| 270 bool reused_socket_; | 282 bool reused_socket_; |
| 271 | 283 |
| 272 // True if we've validated the headers that the stream parser has returned. | 284 // True if we've validated the headers that the stream parser has returned. |
| 273 bool headers_valid_; | 285 bool headers_valid_; |
| 274 | 286 |
| 275 // True if we've logged the time of the first response byte. Used to | 287 // True if we've logged the time of the first response byte. Used to |
| 276 // prevent logging across authentication activity where we see multiple | 288 // prevent logging across authentication activity where we see multiple |
| 277 // responses. | 289 // responses. |
| 278 bool logged_response_time_; | 290 bool logged_response_time_; |
| 279 | 291 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 bool establishing_tunnel_; | 338 bool establishing_tunnel_; |
| 327 | 339 |
| 328 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); | 340 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); |
| 329 }; | 341 }; |
| 330 | 342 |
| 331 int ConvertRequestPriorityToSpdyPriority(RequestPriority priority); | 343 int ConvertRequestPriorityToSpdyPriority(RequestPriority priority); |
| 332 | 344 |
| 333 } // namespace net | 345 } // namespace net |
| 334 | 346 |
| 335 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ | 347 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ |
| OLD | NEW |