| OLD | NEW |
| 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_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 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "crypto/ec_private_key.h" | 17 #include "crypto/ec_private_key.h" |
| 18 #include "net/base/net_error_details.h" | 18 #include "net/base/net_error_details.h" |
| 19 #include "net/base/network_stream_throttler.h" |
| 19 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
| 20 #include "net/http/http_auth.h" | 21 #include "net/http/http_auth.h" |
| 21 #include "net/http/http_request_headers.h" | 22 #include "net/http/http_request_headers.h" |
| 22 #include "net/http/http_response_info.h" | 23 #include "net/http/http_response_info.h" |
| 23 #include "net/http/http_stream_factory.h" | 24 #include "net/http/http_stream_factory.h" |
| 24 #include "net/http/http_transaction.h" | 25 #include "net/http/http_transaction.h" |
| 25 #include "net/log/net_log.h" | 26 #include "net/log/net_log.h" |
| 26 #include "net/proxy/proxy_service.h" | 27 #include "net/proxy/proxy_service.h" |
| 27 #include "net/socket/connection_attempts.h" | 28 #include "net/socket/connection_attempts.h" |
| 28 #include "net/ssl/channel_id_service.h" | 29 #include "net/ssl/channel_id_service.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 43 class HttpStream; | 44 class HttpStream; |
| 44 class HttpStreamRequest; | 45 class HttpStreamRequest; |
| 45 class IOBuffer; | 46 class IOBuffer; |
| 46 class ProxyInfo; | 47 class ProxyInfo; |
| 47 class SpdySession; | 48 class SpdySession; |
| 48 class SSLPrivateKey; | 49 class SSLPrivateKey; |
| 49 struct HttpRequestInfo; | 50 struct HttpRequestInfo; |
| 50 | 51 |
| 51 class NET_EXPORT_PRIVATE HttpNetworkTransaction | 52 class NET_EXPORT_PRIVATE HttpNetworkTransaction |
| 52 : public HttpTransaction, | 53 : public HttpTransaction, |
| 53 public HttpStreamRequest::Delegate { | 54 public HttpStreamRequest::Delegate, |
| 55 public NetworkStreamThrottler::Delegate { |
| 54 public: | 56 public: |
| 55 HttpNetworkTransaction(RequestPriority priority, | 57 HttpNetworkTransaction(RequestPriority priority, |
| 56 HttpNetworkSession* session); | 58 HttpNetworkSession* session); |
| 57 | 59 |
| 58 ~HttpNetworkTransaction() override; | 60 ~HttpNetworkTransaction() override; |
| 59 | 61 |
| 60 // HttpTransaction methods: | 62 // HttpTransaction methods: |
| 61 int Start(const HttpRequestInfo* request_info, | 63 int Start(const HttpRequestInfo* request_info, |
| 62 const CompletionCallback& callback, | 64 const CompletionCallback& callback, |
| 63 const BoundNetLog& net_log) override; | 65 const BoundNetLog& net_log) override; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void OnNeedsClientAuth(const SSLConfig& used_ssl_config, | 119 void OnNeedsClientAuth(const SSLConfig& used_ssl_config, |
| 118 SSLCertRequestInfo* cert_info) override; | 120 SSLCertRequestInfo* cert_info) override; |
| 119 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info, | 121 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info, |
| 120 const SSLConfig& used_ssl_config, | 122 const SSLConfig& used_ssl_config, |
| 121 const ProxyInfo& used_proxy_info, | 123 const ProxyInfo& used_proxy_info, |
| 122 HttpStream* stream) override; | 124 HttpStream* stream) override; |
| 123 | 125 |
| 124 void OnQuicBroken() override; | 126 void OnQuicBroken() override; |
| 125 void GetConnectionAttempts(ConnectionAttempts* out) const override; | 127 void GetConnectionAttempts(ConnectionAttempts* out) const override; |
| 126 | 128 |
| 129 // NetworkStreamThrottler::Delegate methods: |
| 130 void OnThrottleStateChanged() override; |
| 131 |
| 127 private: | 132 private: |
| 128 friend class HttpNetworkTransactionSSLTest; | 133 friend class HttpNetworkTransactionSSLTest; |
| 129 | 134 |
| 130 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, | 135 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, |
| 131 ResetStateForRestart); | 136 ResetStateForRestart); |
| 132 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, EnableNPN); | 137 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, EnableNPN); |
| 133 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, DisableNPN); | 138 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, DisableNPN); |
| 134 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, | 139 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, |
| 135 WindowUpdateReceived); | 140 WindowUpdateReceived); |
| 136 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, | 141 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, |
| 137 WindowUpdateSent); | 142 WindowUpdateSent); |
| 138 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, | 143 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, |
| 139 WindowUpdateOverflow); | 144 WindowUpdateOverflow); |
| 140 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, | 145 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, |
| 141 FlowControlStallResume); | 146 FlowControlStallResume); |
| 142 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, | 147 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, |
| 143 FlowControlStallResumeAfterSettings); | 148 FlowControlStallResumeAfterSettings); |
| 144 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, | 149 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, |
| 145 FlowControlNegativeSendWindowSize); | 150 FlowControlNegativeSendWindowSize); |
| 146 | 151 |
| 147 enum State { | 152 enum State { |
| 153 STATE_THROTTLE, |
| 148 STATE_NOTIFY_BEFORE_CREATE_STREAM, | 154 STATE_NOTIFY_BEFORE_CREATE_STREAM, |
| 149 STATE_CREATE_STREAM, | 155 STATE_CREATE_STREAM, |
| 150 STATE_CREATE_STREAM_COMPLETE, | 156 STATE_CREATE_STREAM_COMPLETE, |
| 151 STATE_INIT_STREAM, | 157 STATE_INIT_STREAM, |
| 152 STATE_INIT_STREAM_COMPLETE, | 158 STATE_INIT_STREAM_COMPLETE, |
| 153 STATE_GENERATE_PROXY_AUTH_TOKEN, | 159 STATE_GENERATE_PROXY_AUTH_TOKEN, |
| 154 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE, | 160 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE, |
| 155 STATE_GENERATE_SERVER_AUTH_TOKEN, | 161 STATE_GENERATE_SERVER_AUTH_TOKEN, |
| 156 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE, | 162 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE, |
| 157 STATE_GET_PROVIDED_TOKEN_BINDING_KEY, | 163 STATE_GET_PROVIDED_TOKEN_BINDING_KEY, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 184 void DoCallback(int result); | 190 void DoCallback(int result); |
| 185 void OnIOComplete(int result); | 191 void OnIOComplete(int result); |
| 186 | 192 |
| 187 // Runs the state transition loop. | 193 // Runs the state transition loop. |
| 188 int DoLoop(int result); | 194 int DoLoop(int result); |
| 189 | 195 |
| 190 // Each of these methods corresponds to a State value. Those with an input | 196 // Each of these methods corresponds to a State value. Those with an input |
| 191 // argument receive the result from the previous state. If a method returns | 197 // argument receive the result from the previous state. If a method returns |
| 192 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the | 198 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the |
| 193 // next state method as the result arg. | 199 // next state method as the result arg. |
| 200 int DoThrottle(); |
| 194 int DoNotifyBeforeCreateStream(); | 201 int DoNotifyBeforeCreateStream(); |
| 195 int DoCreateStream(); | 202 int DoCreateStream(); |
| 196 int DoCreateStreamComplete(int result); | 203 int DoCreateStreamComplete(int result); |
| 197 int DoInitStream(); | 204 int DoInitStream(); |
| 198 int DoInitStreamComplete(int result); | 205 int DoInitStreamComplete(int result); |
| 199 int DoGenerateProxyAuthToken(); | 206 int DoGenerateProxyAuthToken(); |
| 200 int DoGenerateProxyAuthTokenComplete(int result); | 207 int DoGenerateProxyAuthTokenComplete(int result); |
| 201 int DoGenerateServerAuthToken(); | 208 int DoGenerateServerAuthToken(); |
| 202 int DoGenerateServerAuthTokenComplete(int result); | 209 int DoGenerateServerAuthTokenComplete(int result); |
| 203 int DoGetProvidedTokenBindingKey(); | 210 int DoGetProvidedTokenBindingKey(); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 WebSocketHandshakeStreamBase::CreateHelper* | 394 WebSocketHandshakeStreamBase::CreateHelper* |
| 388 websocket_handshake_stream_base_create_helper_; | 395 websocket_handshake_stream_base_create_helper_; |
| 389 | 396 |
| 390 BeforeNetworkStartCallback before_network_start_callback_; | 397 BeforeNetworkStartCallback before_network_start_callback_; |
| 391 BeforeProxyHeadersSentCallback before_proxy_headers_sent_callback_; | 398 BeforeProxyHeadersSentCallback before_proxy_headers_sent_callback_; |
| 392 | 399 |
| 393 ConnectionAttempts connection_attempts_; | 400 ConnectionAttempts connection_attempts_; |
| 394 IPEndPoint remote_endpoint_; | 401 IPEndPoint remote_endpoint_; |
| 395 // Network error details for this transaction. | 402 // Network error details for this transaction. |
| 396 NetErrorDetails net_error_details_; | 403 NetErrorDetails net_error_details_; |
| 404 |
| 405 // Communciate lifetime of transaction to the throttler, and |
| 406 // throttled state to the transaction. |
| 407 std::unique_ptr<NetworkStreamThrottler::Throttle> throttle_; |
| 408 |
| 397 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); | 409 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); |
| 398 }; | 410 }; |
| 399 | 411 |
| 400 } // namespace net | 412 } // namespace net |
| 401 | 413 |
| 402 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ | 414 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ |
| OLD | NEW |