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