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

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: Destroy transaction before session in QuicUploadWriteError. Created 4 years, 1 month 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
« no previous file with comments | « net/http/http_network_session_peer.cc ('k') | net/http/http_network_transaction.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/net_export.h" 19 #include "net/base/net_export.h"
20 #include "net/base/network_throttle_manager.h"
20 #include "net/base/request_priority.h" 21 #include "net/base/request_priority.h"
21 #include "net/http/http_auth.h" 22 #include "net/http/http_auth.h"
22 #include "net/http/http_request_headers.h" 23 #include "net/http/http_request_headers.h"
23 #include "net/http/http_response_info.h" 24 #include "net/http/http_response_info.h"
24 #include "net/http/http_stream_factory.h" 25 #include "net/http/http_stream_factory.h"
25 #include "net/http/http_transaction.h" 26 #include "net/http/http_transaction.h"
26 #include "net/log/net_log_with_source.h" 27 #include "net/log/net_log_with_source.h"
27 #include "net/proxy/proxy_service.h" 28 #include "net/proxy/proxy_service.h"
28 #include "net/socket/connection_attempts.h" 29 #include "net/socket/connection_attempts.h"
29 #include "net/ssl/channel_id_service.h" 30 #include "net/ssl/channel_id_service.h"
(...skipping 13 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 NetworkThrottleManager::ThrottleDelegate {
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 NetLogWithSource& net_log) override; 65 const NetLogWithSource& net_log) override;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 void OnNeedsClientAuth(const SSLConfig& used_ssl_config, 116 void OnNeedsClientAuth(const SSLConfig& used_ssl_config,
115 SSLCertRequestInfo* cert_info) override; 117 SSLCertRequestInfo* cert_info) override;
116 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info, 118 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info,
117 const SSLConfig& used_ssl_config, 119 const SSLConfig& used_ssl_config,
118 const ProxyInfo& used_proxy_info, 120 const ProxyInfo& used_proxy_info,
119 HttpStream* stream) override; 121 HttpStream* stream) override;
120 122
121 void OnQuicBroken() override; 123 void OnQuicBroken() override;
122 void GetConnectionAttempts(ConnectionAttempts* out) const override; 124 void GetConnectionAttempts(ConnectionAttempts* out) const override;
123 125
126 // NetworkThrottleManager::Delegate methods:
127 void OnThrottleStateChanged() override;
128
124 private: 129 private:
125 friend class HttpNetworkTransactionSSLTest; 130 friend class HttpNetworkTransactionSSLTest;
126 131
127 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, 132 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest,
128 ResetStateForRestart); 133 ResetStateForRestart);
129 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, EnableNPN); 134 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, EnableNPN);
130 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, DisableNPN); 135 FRIEND_TEST_ALL_PREFIXES(HttpNetworkTransactionTest, DisableNPN);
131 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, 136 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest,
132 WindowUpdateReceived); 137 WindowUpdateReceived);
133 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, 138 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest,
134 WindowUpdateSent); 139 WindowUpdateSent);
135 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, 140 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest,
136 WindowUpdateOverflow); 141 WindowUpdateOverflow);
137 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, 142 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest,
138 FlowControlStallResume); 143 FlowControlStallResume);
139 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, 144 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest,
140 FlowControlStallResumeAfterSettings); 145 FlowControlStallResumeAfterSettings);
141 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, 146 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest,
142 FlowControlNegativeSendWindowSize); 147 FlowControlNegativeSendWindowSize);
143 148
144 enum State { 149 enum State {
150 STATE_THROTTLE,
151 STATE_THROTTLE_COMPLETE,
145 STATE_NOTIFY_BEFORE_CREATE_STREAM, 152 STATE_NOTIFY_BEFORE_CREATE_STREAM,
146 STATE_CREATE_STREAM, 153 STATE_CREATE_STREAM,
147 STATE_CREATE_STREAM_COMPLETE, 154 STATE_CREATE_STREAM_COMPLETE,
148 STATE_INIT_STREAM, 155 STATE_INIT_STREAM,
149 STATE_INIT_STREAM_COMPLETE, 156 STATE_INIT_STREAM_COMPLETE,
150 STATE_GENERATE_PROXY_AUTH_TOKEN, 157 STATE_GENERATE_PROXY_AUTH_TOKEN,
151 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE, 158 STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE,
152 STATE_GENERATE_SERVER_AUTH_TOKEN, 159 STATE_GENERATE_SERVER_AUTH_TOKEN,
153 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE, 160 STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE,
154 STATE_GET_PROVIDED_TOKEN_BINDING_KEY, 161 STATE_GET_PROVIDED_TOKEN_BINDING_KEY,
(...skipping 26 matching lines...) Expand all
181 void DoCallback(int result); 188 void DoCallback(int result);
182 void OnIOComplete(int result); 189 void OnIOComplete(int result);
183 190
184 // Runs the state transition loop. 191 // Runs the state transition loop.
185 int DoLoop(int result); 192 int DoLoop(int result);
186 193
187 // Each of these methods corresponds to a State value. Those with an input 194 // Each of these methods corresponds to a State value. Those with an input
188 // argument receive the result from the previous state. If a method returns 195 // argument receive the result from the previous state. If a method returns
189 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the 196 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the
190 // next state method as the result arg. 197 // next state method as the result arg.
198 int DoThrottle();
199 int DoThrottleComplete();
191 int DoNotifyBeforeCreateStream(); 200 int DoNotifyBeforeCreateStream();
192 int DoCreateStream(); 201 int DoCreateStream();
193 int DoCreateStreamComplete(int result); 202 int DoCreateStreamComplete(int result);
194 int DoInitStream(); 203 int DoInitStream();
195 int DoInitStreamComplete(int result); 204 int DoInitStreamComplete(int result);
196 int DoGenerateProxyAuthToken(); 205 int DoGenerateProxyAuthToken();
197 int DoGenerateProxyAuthTokenComplete(int result); 206 int DoGenerateProxyAuthTokenComplete(int result);
198 int DoGenerateServerAuthToken(); 207 int DoGenerateServerAuthToken();
199 int DoGenerateServerAuthTokenComplete(int result); 208 int DoGenerateServerAuthTokenComplete(int result);
200 int DoGetProvidedTokenBindingKey(); 209 int DoGetProvidedTokenBindingKey();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 WebSocketHandshakeStreamBase::CreateHelper* 385 WebSocketHandshakeStreamBase::CreateHelper*
377 websocket_handshake_stream_base_create_helper_; 386 websocket_handshake_stream_base_create_helper_;
378 387
379 BeforeNetworkStartCallback before_network_start_callback_; 388 BeforeNetworkStartCallback before_network_start_callback_;
380 BeforeHeadersSentCallback before_headers_sent_callback_; 389 BeforeHeadersSentCallback before_headers_sent_callback_;
381 390
382 ConnectionAttempts connection_attempts_; 391 ConnectionAttempts connection_attempts_;
383 IPEndPoint remote_endpoint_; 392 IPEndPoint remote_endpoint_;
384 // Network error details for this transaction. 393 // Network error details for this transaction.
385 NetErrorDetails net_error_details_; 394 NetErrorDetails net_error_details_;
395
396 // Communicate lifetime of transaction to the throttler, and
397 // throttled state to the transaction.
398 std::unique_ptr<NetworkThrottleManager::Throttle> throttle_;
399
386 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); 400 DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction);
387 }; 401 };
388 402
389 } // namespace net 403 } // namespace net
390 404
391 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ 405 #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_
OLDNEW
« no previous file with comments | « net/http/http_network_session_peer.cc ('k') | net/http/http_network_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698