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

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

Issue 10534129: NetLogEventParameter to Callback refactoring 5. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Add back original URLs Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_pipelined_connection_impl.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 #include "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 case ERR_BAD_SSL_CLIENT_AUTH_CERT: 86 case ERR_BAD_SSL_CLIENT_AUTH_CERT:
87 case ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED: 87 case ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED:
88 case ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY: 88 case ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY:
89 case ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED: 89 case ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED:
90 return true; 90 return true;
91 default: 91 default:
92 return false; 92 return false;
93 } 93 }
94 } 94 }
95 95
96 class SSLVersionFallbackParams : public NetLog::EventParameters { 96 Value* NetLogSSLVersionFallbackCallback(const GURL* url,
97 public: 97 int net_error,
98 SSLVersionFallbackParams(const std::string& host_and_port, 98 uint16 version_before,
99 int net_error, 99 uint16 version_after,
100 uint16 version_before, 100 NetLog::LogLevel /* log_level */) {
101 uint16 version_after) 101 DictionaryValue* dict = new DictionaryValue();
102 : host_and_port_(host_and_port), 102 dict->SetString("host_and_port", GetHostAndPort(*url));
103 net_error_(net_error), 103 dict->SetInteger("net_error", net_error);
104 version_before_(version_before), 104 dict->SetInteger("version_before", version_before);
105 version_after_(version_after) { 105 dict->SetInteger("version_after", version_after);
106 } 106 return dict;
107 107 }
108 virtual Value* ToValue() const {
109 DictionaryValue* dict = new DictionaryValue();
110 dict->SetString("host_and_port", host_and_port_);
111 dict->SetInteger("net_error", net_error_);
112 dict->SetInteger("version_before", version_before_);
113 dict->SetInteger("version_after", version_after_);
114 return dict;
115 }
116
117 protected:
118 virtual ~SSLVersionFallbackParams() {}
119
120 private:
121 const std::string host_and_port_;
122 const int net_error_; // Network error code that caused the fallback.
123 const uint16 version_before_; // SSL version before the fallback.
124 const uint16 version_after_; // SSL version after the fallback.
125 };
126 108
127 } // namespace 109 } // namespace
128 110
129 //----------------------------------------------------------------------------- 111 //-----------------------------------------------------------------------------
130 112
131 HttpNetworkTransaction::HttpNetworkTransaction(HttpNetworkSession* session) 113 HttpNetworkTransaction::HttpNetworkTransaction(HttpNetworkSession* session)
132 : pending_auth_target_(HttpAuth::AUTH_NONE), 114 : pending_auth_target_(HttpAuth::AUTH_NONE),
133 ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_( 115 ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_(
134 base::Bind(&HttpNetworkTransaction::OnIOComplete, 116 base::Bind(&HttpNetworkTransaction::OnIOComplete,
135 base::Unretained(this)))), 117 base::Unretained(this)))),
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 break; 529 break;
548 case STATE_GENERATE_SERVER_AUTH_TOKEN: 530 case STATE_GENERATE_SERVER_AUTH_TOKEN:
549 DCHECK_EQ(OK, rv); 531 DCHECK_EQ(OK, rv);
550 rv = DoGenerateServerAuthToken(); 532 rv = DoGenerateServerAuthToken();
551 break; 533 break;
552 case STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE: 534 case STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE:
553 rv = DoGenerateServerAuthTokenComplete(rv); 535 rv = DoGenerateServerAuthTokenComplete(rv);
554 break; 536 break;
555 case STATE_BUILD_REQUEST: 537 case STATE_BUILD_REQUEST:
556 DCHECK_EQ(OK, rv); 538 DCHECK_EQ(OK, rv);
557 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, NULL); 539 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST);
558 rv = DoBuildRequest(); 540 rv = DoBuildRequest();
559 break; 541 break;
560 case STATE_BUILD_REQUEST_COMPLETE: 542 case STATE_BUILD_REQUEST_COMPLETE:
561 rv = DoBuildRequestComplete(rv); 543 rv = DoBuildRequestComplete(rv);
562 break; 544 break;
563 case STATE_SEND_REQUEST: 545 case STATE_SEND_REQUEST:
564 DCHECK_EQ(OK, rv); 546 DCHECK_EQ(OK, rv);
565 rv = DoSendRequest(); 547 rv = DoSendRequest();
566 break; 548 break;
567 case STATE_SEND_REQUEST_COMPLETE: 549 case STATE_SEND_REQUEST_COMPLETE:
568 rv = DoSendRequestComplete(rv); 550 rv = DoSendRequestComplete(rv);
569 net_log_.EndEventWithNetErrorCode( 551 net_log_.EndEventWithNetErrorCode(
570 NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, rv); 552 NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, rv);
571 break; 553 break;
572 case STATE_READ_HEADERS: 554 case STATE_READ_HEADERS:
573 DCHECK_EQ(OK, rv); 555 DCHECK_EQ(OK, rv);
574 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS, NULL); 556 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS);
575 rv = DoReadHeaders(); 557 rv = DoReadHeaders();
576 break; 558 break;
577 case STATE_READ_HEADERS_COMPLETE: 559 case STATE_READ_HEADERS_COMPLETE:
578 rv = DoReadHeadersComplete(rv); 560 rv = DoReadHeadersComplete(rv);
579 net_log_.EndEventWithNetErrorCode( 561 net_log_.EndEventWithNetErrorCode(
580 NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS, rv); 562 NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS, rv);
581 break; 563 break;
582 case STATE_READ_BODY: 564 case STATE_READ_BODY:
583 DCHECK_EQ(OK, rv); 565 DCHECK_EQ(OK, rv);
584 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_BODY, NULL); 566 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_BODY);
585 rv = DoReadBody(); 567 rv = DoReadBody();
586 break; 568 break;
587 case STATE_READ_BODY_COMPLETE: 569 case STATE_READ_BODY_COMPLETE:
588 rv = DoReadBodyComplete(rv); 570 rv = DoReadBodyComplete(rv);
589 net_log_.EndEventWithNetErrorCode( 571 net_log_.EndEventWithNetErrorCode(
590 NetLog::TYPE_HTTP_TRANSACTION_READ_BODY, rv); 572 NetLog::TYPE_HTTP_TRANSACTION_READ_BODY, rv);
591 break; 573 break;
592 case STATE_DRAIN_BODY_FOR_AUTH_RESTART: 574 case STATE_DRAIN_BODY_FOR_AUTH_RESTART:
593 DCHECK_EQ(OK, rv); 575 DCHECK_EQ(OK, rv);
594 net_log_.BeginEvent( 576 net_log_.BeginEvent(
595 NetLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART, NULL); 577 NetLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART);
596 rv = DoDrainBodyForAuthRestart(); 578 rv = DoDrainBodyForAuthRestart();
597 break; 579 break;
598 case STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE: 580 case STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE:
599 rv = DoDrainBodyForAuthRestartComplete(rv); 581 rv = DoDrainBodyForAuthRestartComplete(rv);
600 net_log_.EndEventWithNetErrorCode( 582 net_log_.EndEventWithNetErrorCode(
601 NetLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART, rv); 583 NetLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART, rv);
602 break; 584 break;
603 default: 585 default:
604 NOTREACHED() << "bad state"; 586 NOTREACHED() << "bad state";
605 rv = ERR_FAILED; 587 rv = ERR_FAILED;
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 // NOTE: if the SSLClientSocket class doesn't support TLS 1.1, 1182 // NOTE: if the SSLClientSocket class doesn't support TLS 1.1,
1201 // specifying TLS 1.1 in version_max will result in a TLS 1.0 1183 // specifying TLS 1.1 in version_max will result in a TLS 1.0
1202 // handshake, so falling back from TLS 1.1 to TLS 1.0 will simply 1184 // handshake, so falling back from TLS 1.1 to TLS 1.0 will simply
1203 // repeat the TLS 1.0 handshake. To avoid this problem, the default 1185 // repeat the TLS 1.0 handshake. To avoid this problem, the default
1204 // version_max should match the maximum protocol version supported 1186 // version_max should match the maximum protocol version supported
1205 // by the SSLClientSocket class. 1187 // by the SSLClientSocket class.
1206 uint16 version_before = server_ssl_config_.version_max; 1188 uint16 version_before = server_ssl_config_.version_max;
1207 server_ssl_config_.version_max--; 1189 server_ssl_config_.version_max--;
1208 net_log_.AddEvent( 1190 net_log_.AddEvent(
1209 NetLog::TYPE_SSL_VERSION_FALLBACK, 1191 NetLog::TYPE_SSL_VERSION_FALLBACK,
1210 make_scoped_refptr(new SSLVersionFallbackParams( 1192 base::Bind(&NetLogSSLVersionFallbackCallback,
1211 GetHostAndPort(request_->url), error, 1193 &request_->url, error, version_before,
1212 version_before, server_ssl_config_.version_max))); 1194 server_ssl_config_.version_max));
1213 server_ssl_config_.version_fallback = true; 1195 server_ssl_config_.version_fallback = true;
1214 ResetConnectionAndRequestForResend(); 1196 ResetConnectionAndRequestForResend();
1215 error = OK; 1197 error = OK;
1216 } 1198 }
1217 break; 1199 break;
1218 case ERR_SSL_DECOMPRESSION_FAILURE_ALERT: 1200 case ERR_SSL_DECOMPRESSION_FAILURE_ALERT:
1219 case ERR_SSL_BAD_RECORD_MAC_ALERT: 1201 case ERR_SSL_BAD_RECORD_MAC_ALERT:
1220 if (server_ssl_config_.version_max >= SSL_PROTOCOL_VERSION_TLS1 && 1202 if (server_ssl_config_.version_max >= SSL_PROTOCOL_VERSION_TLS1 &&
1221 server_ssl_config_.version_min == SSL_PROTOCOL_VERSION_SSL3) { 1203 server_ssl_config_.version_min == SSL_PROTOCOL_VERSION_SSL3) {
1222 // This could be a server with buggy DEFLATE support. Turn off TLS, 1204 // This could be a server with buggy DEFLATE support. Turn off TLS,
1223 // DEFLATE support and retry. 1205 // DEFLATE support and retry.
1224 // TODO(wtc): turn off DEFLATE support only. Do not tie it to TLS. 1206 // TODO(wtc): turn off DEFLATE support only. Do not tie it to TLS.
1225 uint16 version_before = server_ssl_config_.version_max; 1207 uint16 version_before = server_ssl_config_.version_max;
1226 server_ssl_config_.version_max = SSL_PROTOCOL_VERSION_SSL3; 1208 server_ssl_config_.version_max = SSL_PROTOCOL_VERSION_SSL3;
1227 net_log_.AddEvent( 1209 net_log_.AddEvent(
1228 NetLog::TYPE_SSL_VERSION_FALLBACK, 1210 NetLog::TYPE_SSL_VERSION_FALLBACK,
1229 make_scoped_refptr(new SSLVersionFallbackParams( 1211 base::Bind(&NetLogSSLVersionFallbackCallback,
1230 GetHostAndPort(request_->url), error, 1212 &request_->url, error, version_before,
1231 version_before, server_ssl_config_.version_max))); 1213 server_ssl_config_.version_max));
1232 server_ssl_config_.version_fallback = true; 1214 server_ssl_config_.version_fallback = true;
1233 ResetConnectionAndRequestForResend(); 1215 ResetConnectionAndRequestForResend();
1234 error = OK; 1216 error = OK;
1235 } 1217 }
1236 break; 1218 break;
1237 } 1219 }
1238 return error; 1220 return error;
1239 } 1221 }
1240 1222
1241 // This method determines whether it is safe to resend the request after an 1223 // This method determines whether it is safe to resend the request after an
(...skipping 19 matching lines...) Expand all
1261 case ERR_CONNECTION_ABORTED: 1243 case ERR_CONNECTION_ABORTED:
1262 // There can be a race between the socket pool checking checking whether a 1244 // There can be a race between the socket pool checking checking whether a
1263 // socket is still connected, receiving the FIN, and sending/reading data 1245 // socket is still connected, receiving the FIN, and sending/reading data
1264 // on a reused socket. If we receive the FIN between the connectedness 1246 // on a reused socket. If we receive the FIN between the connectedness
1265 // check and writing/reading from the socket, we may first learn the socket 1247 // check and writing/reading from the socket, we may first learn the socket
1266 // is disconnected when we get a ERR_SOCKET_NOT_CONNECTED. This will most 1248 // is disconnected when we get a ERR_SOCKET_NOT_CONNECTED. This will most
1267 // likely happen when trying to retrieve its IP address. 1249 // likely happen when trying to retrieve its IP address.
1268 // See http://crbug.com/105824 for more details. 1250 // See http://crbug.com/105824 for more details.
1269 case ERR_SOCKET_NOT_CONNECTED: 1251 case ERR_SOCKET_NOT_CONNECTED:
1270 if (ShouldResendRequest(error)) { 1252 if (ShouldResendRequest(error)) {
1271 net_log_.AddEvent( 1253 net_log_.AddEventWithNetErrorCode(
1272 NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR, 1254 NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR, error);
1273 make_scoped_refptr(new NetLogIntegerParameter("net_error", error)));
1274 ResetConnectionAndRequestForResend(); 1255 ResetConnectionAndRequestForResend();
1275 error = OK; 1256 error = OK;
1276 } 1257 }
1277 break; 1258 break;
1278 case ERR_PIPELINE_EVICTION: 1259 case ERR_PIPELINE_EVICTION:
1279 if (!session_->force_http_pipelining()) { 1260 if (!session_->force_http_pipelining()) {
1280 net_log_.AddEvent( 1261 net_log_.AddEventWithNetErrorCode(
1281 NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR, 1262 NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR, error);
1282 make_scoped_refptr(new NetLogIntegerParameter("net_error", error)));
1283 ResetConnectionAndRequestForResend(); 1263 ResetConnectionAndRequestForResend();
1284 error = OK; 1264 error = OK;
1285 } 1265 }
1286 break; 1266 break;
1287 case ERR_SPDY_PING_FAILED: 1267 case ERR_SPDY_PING_FAILED:
1288 case ERR_SPDY_SERVER_REFUSED_STREAM: 1268 case ERR_SPDY_SERVER_REFUSED_STREAM:
1289 net_log_.AddEvent( 1269 net_log_.AddEventWithNetErrorCode(
1290 NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR, 1270 NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR, error);
1291 make_scoped_refptr(new NetLogIntegerParameter("net_error", error)));
1292 ResetConnectionAndRequestForResend(); 1271 ResetConnectionAndRequestForResend();
1293 error = OK; 1272 error = OK;
1294 break; 1273 break;
1295 } 1274 }
1296 return error; 1275 return error;
1297 } 1276 }
1298 1277
1299 void HttpNetworkTransaction::ResetStateForRestart() { 1278 void HttpNetworkTransaction::ResetStateForRestart() {
1300 ResetStateForAuthRestart(); 1279 ResetStateForAuthRestart();
1301 stream_.reset(); 1280 stream_.reset();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 1409 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
1431 state); 1410 state);
1432 break; 1411 break;
1433 } 1412 }
1434 return description; 1413 return description;
1435 } 1414 }
1436 1415
1437 #undef STATE_CASE 1416 #undef STATE_CASE
1438 1417
1439 } // namespace net 1418 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_pipelined_connection_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698