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

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

Issue 1901533002: Implementation of network level throttler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated latest round of comments." . 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
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
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
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,
154 STATE_THROTTLE_COMPLETE,
148 STATE_NOTIFY_BEFORE_CREATE_STREAM, 155 STATE_NOTIFY_BEFORE_CREATE_STREAM,
149 STATE_CREATE_STREAM, 156 STATE_CREATE_STREAM,
150 STATE_CREATE_STREAM_COMPLETE, 157 STATE_CREATE_STREAM_COMPLETE,
151 STATE_INIT_STREAM, 158 STATE_INIT_STREAM,
152 STATE_INIT_STREAM_COMPLETE, 159 STATE_INIT_STREAM_COMPLETE,
153 STATE_GENERATE_PROXY_AUTH_TOKEN, 160 STATE_GENERATE_PROXY_AUTH_TOKEN,
154 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE, 161 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE,
155 STATE_GENERATE_SERVER_AUTH_TOKEN, 162 STATE_GENERATE_SERVER_AUTH_TOKEN,
156 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE, 163 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE,
157 STATE_GET_PROVIDED_TOKEN_BINDING_KEY, 164 STATE_GET_PROVIDED_TOKEN_BINDING_KEY,
(...skipping 26 matching lines...) Expand all
184 void DoCallback(int result); 191 void DoCallback(int result);
185 void OnIOComplete(int result); 192 void OnIOComplete(int result);
186 193
187 // Runs the state transition loop. 194 // Runs the state transition loop.
188 int DoLoop(int result); 195 int DoLoop(int result);
189 196
190 // Each of these methods corresponds to a State value. Those with an input 197 // 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 198 // 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 199 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the
193 // next state method as the result arg. 200 // next state method as the result arg.
201 int DoThrottle();
202 int DoThrottleComplete();
194 int DoNotifyBeforeCreateStream(); 203 int DoNotifyBeforeCreateStream();
195 int DoCreateStream(); 204 int DoCreateStream();
196 int DoCreateStreamComplete(int result); 205 int DoCreateStreamComplete(int result);
197 int DoInitStream(); 206 int DoInitStream();
198 int DoInitStreamComplete(int result); 207 int DoInitStreamComplete(int result);
199 int DoGenerateProxyAuthToken(); 208 int DoGenerateProxyAuthToken();
200 int DoGenerateProxyAuthTokenComplete(int result); 209 int DoGenerateProxyAuthTokenComplete(int result);
201 int DoGenerateServerAuthToken(); 210 int DoGenerateServerAuthToken();
202 int DoGenerateServerAuthTokenComplete(int result); 211 int DoGenerateServerAuthTokenComplete(int result);
203 int DoGetProvidedTokenBindingKey(); 212 int DoGetProvidedTokenBindingKey();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 WebSocketHandshakeStreamBase::CreateHelper* 396 WebSocketHandshakeStreamBase::CreateHelper*
388 websocket_handshake_stream_base_create_helper_; 397 websocket_handshake_stream_base_create_helper_;
389 398
390 BeforeNetworkStartCallback before_network_start_callback_; 399 BeforeNetworkStartCallback before_network_start_callback_;
391 BeforeProxyHeadersSentCallback before_proxy_headers_sent_callback_; 400 BeforeProxyHeadersSentCallback before_proxy_headers_sent_callback_;
392 401
393 ConnectionAttempts connection_attempts_; 402 ConnectionAttempts connection_attempts_;
394 IPEndPoint remote_endpoint_; 403 IPEndPoint remote_endpoint_;
395 // Network error details for this transaction. 404 // Network error details for this transaction.
396 NetErrorDetails net_error_details_; 405 NetErrorDetails net_error_details_;
406
407 // Communciate lifetime of transaction to the throttler, and
408 // throttled state to the transaction.
409 std::unique_ptr<NetworkStreamThrottler::Throttle> throttle_;
410
397 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); 411 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction);
398 }; 412 };
399 413
400 } // namespace net 414 } // namespace net
401 415
402 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ 416 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698