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 #include "net/http/http_cache_transaction.h" | 5 #include "net/http/http_cache_transaction.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 return ERR_UNEXPECTED; | 434 return ERR_UNEXPECTED; |
435 | 435 |
436 SetRequest(net_log, request); | 436 SetRequest(net_log, request); |
437 | 437 |
438 // We have to wait until the backend is initialized so we start the SM. | 438 // We have to wait until the backend is initialized so we start the SM. |
439 next_state_ = STATE_GET_BACKEND; | 439 next_state_ = STATE_GET_BACKEND; |
440 int rv = DoLoop(OK); | 440 int rv = DoLoop(OK); |
441 | 441 |
442 // Setting this here allows us to check for the existence of a callback_ to | 442 // Setting this here allows us to check for the existence of a callback_ to |
443 // determine if we are still inside Start. | 443 // determine if we are still inside Start. |
444 if (rv == ERR_IO_PENDING) { | 444 if (rv == ERR_IO_PENDING) |
445 callback_ = tracked_objects::ScopedTracker::TrackCallback( | 445 callback_ = callback; |
446 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
447 "422516 HttpCache::Transaction::Start"), | |
448 callback); | |
449 } | |
450 | 446 |
451 return rv; | 447 return rv; |
452 } | 448 } |
453 | 449 |
454 int HttpCache::Transaction::RestartIgnoringLastError( | 450 int HttpCache::Transaction::RestartIgnoringLastError( |
455 const CompletionCallback& callback) { | 451 const CompletionCallback& callback) { |
456 DCHECK(!callback.is_null()); | 452 DCHECK(!callback.is_null()); |
457 | 453 |
458 // Ensure that we only have one asynchronous call at a time. | 454 // Ensure that we only have one asynchronous call at a time. |
459 DCHECK(callback_.is_null()); | 455 DCHECK(callback_.is_null()); |
460 | 456 |
461 if (!cache_.get()) | 457 if (!cache_.get()) |
462 return ERR_UNEXPECTED; | 458 return ERR_UNEXPECTED; |
463 | 459 |
464 int rv = RestartNetworkRequest(); | 460 int rv = RestartNetworkRequest(); |
465 | 461 |
466 if (rv == ERR_IO_PENDING) { | 462 if (rv == ERR_IO_PENDING) |
467 callback_ = tracked_objects::ScopedTracker::TrackCallback( | 463 callback_ = callback; |
468 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
469 "422516 HttpCache::Transaction::RestartIgnoringLastError"), | |
470 callback); | |
471 } | |
472 | 464 |
473 return rv; | 465 return rv; |
474 } | 466 } |
475 | 467 |
476 int HttpCache::Transaction::RestartWithCertificate( | 468 int HttpCache::Transaction::RestartWithCertificate( |
477 X509Certificate* client_cert, | 469 X509Certificate* client_cert, |
478 const CompletionCallback& callback) { | 470 const CompletionCallback& callback) { |
479 DCHECK(!callback.is_null()); | 471 DCHECK(!callback.is_null()); |
480 | 472 |
481 // Ensure that we only have one asynchronous call at a time. | 473 // Ensure that we only have one asynchronous call at a time. |
482 DCHECK(callback_.is_null()); | 474 DCHECK(callback_.is_null()); |
483 | 475 |
484 if (!cache_.get()) | 476 if (!cache_.get()) |
485 return ERR_UNEXPECTED; | 477 return ERR_UNEXPECTED; |
486 | 478 |
487 int rv = RestartNetworkRequestWithCertificate(client_cert); | 479 int rv = RestartNetworkRequestWithCertificate(client_cert); |
488 | 480 |
489 if (rv == ERR_IO_PENDING) { | 481 if (rv == ERR_IO_PENDING) |
490 callback_ = tracked_objects::ScopedTracker::TrackCallback( | 482 callback_ = callback; |
491 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
492 "422516 HttpCache::Transaction::RestartWithCertificate"), | |
493 callback); | |
494 } | |
495 | 483 |
496 return rv; | 484 return rv; |
497 } | 485 } |
498 | 486 |
499 int HttpCache::Transaction::RestartWithAuth( | 487 int HttpCache::Transaction::RestartWithAuth( |
500 const AuthCredentials& credentials, | 488 const AuthCredentials& credentials, |
501 const CompletionCallback& callback) { | 489 const CompletionCallback& callback) { |
502 DCHECK(auth_response_.headers.get()); | 490 DCHECK(auth_response_.headers.get()); |
503 DCHECK(!callback.is_null()); | 491 DCHECK(!callback.is_null()); |
504 | 492 |
505 // Ensure that we only have one asynchronous call at a time. | 493 // Ensure that we only have one asynchronous call at a time. |
506 DCHECK(callback_.is_null()); | 494 DCHECK(callback_.is_null()); |
507 | 495 |
508 if (!cache_.get()) | 496 if (!cache_.get()) |
509 return ERR_UNEXPECTED; | 497 return ERR_UNEXPECTED; |
510 | 498 |
511 // Clear the intermediate response since we are going to start over. | 499 // Clear the intermediate response since we are going to start over. |
512 auth_response_ = HttpResponseInfo(); | 500 auth_response_ = HttpResponseInfo(); |
513 | 501 |
514 int rv = RestartNetworkRequestWithAuth(credentials); | 502 int rv = RestartNetworkRequestWithAuth(credentials); |
515 | 503 |
516 if (rv == ERR_IO_PENDING) { | 504 if (rv == ERR_IO_PENDING) |
517 callback_ = tracked_objects::ScopedTracker::TrackCallback( | 505 callback_ = callback; |
518 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
519 "422516 HttpCache::Transaction::RestartWithAuth"), | |
520 callback); | |
521 } | |
522 | 506 |
523 return rv; | 507 return rv; |
524 } | 508 } |
525 | 509 |
526 bool HttpCache::Transaction::IsReadyToRestartForAuth() { | 510 bool HttpCache::Transaction::IsReadyToRestartForAuth() { |
527 if (!network_trans_.get()) | 511 if (!network_trans_.get()) |
528 return false; | 512 return false; |
529 return network_trans_->IsReadyToRestartForAuth(); | 513 return network_trans_->IsReadyToRestartForAuth(); |
530 } | 514 } |
531 | 515 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 case READ: | 553 case READ: |
570 rv = ReadFromEntry(buf, buf_len); | 554 rv = ReadFromEntry(buf, buf_len); |
571 break; | 555 break; |
572 default: | 556 default: |
573 NOTREACHED(); | 557 NOTREACHED(); |
574 rv = ERR_FAILED; | 558 rv = ERR_FAILED; |
575 } | 559 } |
576 | 560 |
577 if (rv == ERR_IO_PENDING) { | 561 if (rv == ERR_IO_PENDING) { |
578 DCHECK(callback_.is_null()); | 562 DCHECK(callback_.is_null()); |
579 callback_ = tracked_objects::ScopedTracker::TrackCallback( | 563 callback_ = callback; |
580 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 HttpCache::Transaction::Read"), | |
581 callback); | |
582 } | 564 } |
583 return rv; | 565 return rv; |
584 } | 566 } |
585 | 567 |
586 void HttpCache::Transaction::StopCaching() { | 568 void HttpCache::Transaction::StopCaching() { |
587 // We really don't know where we are now. Hopefully there is no operation in | 569 // We really don't know where we are now. Hopefully there is no operation in |
588 // progress, but nothing really prevents this method to be called after we | 570 // progress, but nothing really prevents this method to be called after we |
589 // returned ERR_IO_PENDING. We cannot attempt to truncate the entry at this | 571 // returned ERR_IO_PENDING. We cannot attempt to truncate the entry at this |
590 // point because we need the state machine for that (and even if we are really | 572 // point because we need the state machine for that (and even if we are really |
591 // free, that would be an asynchronous operation). In other words, keep the | 573 // free, that would be an asynchronous operation). In other words, keep the |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 | 692 |
711 int HttpCache::Transaction::ResumeNetworkStart() { | 693 int HttpCache::Transaction::ResumeNetworkStart() { |
712 if (network_trans_) | 694 if (network_trans_) |
713 return network_trans_->ResumeNetworkStart(); | 695 return network_trans_->ResumeNetworkStart(); |
714 return ERR_UNEXPECTED; | 696 return ERR_UNEXPECTED; |
715 } | 697 } |
716 | 698 |
717 //----------------------------------------------------------------------------- | 699 //----------------------------------------------------------------------------- |
718 | 700 |
719 void HttpCache::Transaction::DoCallback(int rv) { | 701 void HttpCache::Transaction::DoCallback(int rv) { |
720 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
721 tracked_objects::ScopedTracker tracking_profile( | |
722 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
723 "422516 HttpCache::Transaction::DoCallback")); | |
724 | |
725 DCHECK(rv != ERR_IO_PENDING); | 702 DCHECK(rv != ERR_IO_PENDING); |
726 DCHECK(!callback_.is_null()); | 703 DCHECK(!callback_.is_null()); |
727 | 704 |
728 read_buf_ = NULL; // Release the buffer before invoking the callback. | 705 read_buf_ = NULL; // Release the buffer before invoking the callback. |
729 | 706 |
730 // Since Run may result in Read being called, clear callback_ up front. | 707 // Since Run may result in Read being called, clear callback_ up front. |
731 CompletionCallback c = callback_; | 708 CompletionCallback c = callback_; |
732 callback_.Reset(); | 709 callback_.Reset(); |
733 c.Run(rv); | 710 c.Run(rv); |
734 } | 711 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 } | 1007 } |
1031 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); | 1008 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); |
1032 | 1009 |
1033 if (rv != ERR_IO_PENDING) | 1010 if (rv != ERR_IO_PENDING) |
1034 HandleResult(rv); | 1011 HandleResult(rv); |
1035 | 1012 |
1036 return rv; | 1013 return rv; |
1037 } | 1014 } |
1038 | 1015 |
1039 int HttpCache::Transaction::DoGetBackend() { | 1016 int HttpCache::Transaction::DoGetBackend() { |
1040 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1041 tracked_objects::ScopedTracker tracking_profile( | |
1042 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1043 "422516 HttpCache::Transaction::DoGetBackend")); | |
1044 | |
1045 cache_pending_ = true; | 1017 cache_pending_ = true; |
1046 next_state_ = STATE_GET_BACKEND_COMPLETE; | 1018 next_state_ = STATE_GET_BACKEND_COMPLETE; |
1047 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_GET_BACKEND); | 1019 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_GET_BACKEND); |
1048 return cache_->GetBackendForTransaction(this); | 1020 return cache_->GetBackendForTransaction(this); |
1049 } | 1021 } |
1050 | 1022 |
1051 int HttpCache::Transaction::DoGetBackendComplete(int result) { | 1023 int HttpCache::Transaction::DoGetBackendComplete(int result) { |
1052 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1053 tracked_objects::ScopedTracker tracking_profile( | |
1054 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1055 "422516 HttpCache::Transaction::DoGetBackendComplete")); | |
1056 | |
1057 DCHECK(result == OK || result == ERR_FAILED); | 1024 DCHECK(result == OK || result == ERR_FAILED); |
1058 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_GET_BACKEND, | 1025 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_GET_BACKEND, |
1059 result); | 1026 result); |
1060 cache_pending_ = false; | 1027 cache_pending_ = false; |
1061 | 1028 |
1062 if (!ShouldPassThrough()) { | 1029 if (!ShouldPassThrough()) { |
1063 cache_key_ = cache_->GenerateCacheKey(request_); | 1030 cache_key_ = cache_->GenerateCacheKey(request_); |
1064 | 1031 |
1065 // Requested cache access mode. | 1032 // Requested cache access mode. |
1066 if (effective_load_flags_ & LOAD_ONLY_FROM_CACHE) { | 1033 if (effective_load_flags_ & LOAD_ONLY_FROM_CACHE) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 next_state_ = STATE_INIT_ENTRY; | 1079 next_state_ = STATE_INIT_ENTRY; |
1113 } | 1080 } |
1114 | 1081 |
1115 // This is only set if we have something to do with the response. | 1082 // This is only set if we have something to do with the response. |
1116 range_requested_ = (partial_.get() != NULL); | 1083 range_requested_ = (partial_.get() != NULL); |
1117 | 1084 |
1118 return OK; | 1085 return OK; |
1119 } | 1086 } |
1120 | 1087 |
1121 int HttpCache::Transaction::DoSendRequest() { | 1088 int HttpCache::Transaction::DoSendRequest() { |
1122 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1123 tracked_objects::ScopedTracker tracking_profile( | |
1124 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1125 "422516 HttpCache::Transaction::DoSendRequest")); | |
1126 | |
1127 DCHECK(mode_ & WRITE || mode_ == NONE); | 1089 DCHECK(mode_ & WRITE || mode_ == NONE); |
1128 DCHECK(!network_trans_.get()); | 1090 DCHECK(!network_trans_.get()); |
1129 | 1091 |
1130 send_request_since_ = TimeTicks::Now(); | 1092 send_request_since_ = TimeTicks::Now(); |
1131 | 1093 |
1132 // Create a network transaction. | 1094 // Create a network transaction. |
1133 int rv = cache_->network_layer_->CreateTransaction(priority_, | 1095 int rv = cache_->network_layer_->CreateTransaction(priority_, |
1134 &network_trans_); | 1096 &network_trans_); |
1135 if (rv != OK) | 1097 if (rv != OK) |
1136 return rv; | 1098 return rv; |
1137 network_trans_->SetBeforeNetworkStartCallback(before_network_start_callback_); | 1099 network_trans_->SetBeforeNetworkStartCallback(before_network_start_callback_); |
1138 network_trans_->SetBeforeProxyHeadersSentCallback( | 1100 network_trans_->SetBeforeProxyHeadersSentCallback( |
1139 before_proxy_headers_sent_callback_); | 1101 before_proxy_headers_sent_callback_); |
1140 | 1102 |
1141 // Old load timing information, if any, is now obsolete. | 1103 // Old load timing information, if any, is now obsolete. |
1142 old_network_trans_load_timing_.reset(); | 1104 old_network_trans_load_timing_.reset(); |
1143 | 1105 |
1144 if (websocket_handshake_stream_base_create_helper_) | 1106 if (websocket_handshake_stream_base_create_helper_) |
1145 network_trans_->SetWebSocketHandshakeStreamCreateHelper( | 1107 network_trans_->SetWebSocketHandshakeStreamCreateHelper( |
1146 websocket_handshake_stream_base_create_helper_); | 1108 websocket_handshake_stream_base_create_helper_); |
1147 | 1109 |
1148 next_state_ = STATE_SEND_REQUEST_COMPLETE; | 1110 next_state_ = STATE_SEND_REQUEST_COMPLETE; |
1149 rv = network_trans_->Start(request_, io_callback_, net_log_); | 1111 rv = network_trans_->Start(request_, io_callback_, net_log_); |
1150 return rv; | 1112 return rv; |
1151 } | 1113 } |
1152 | 1114 |
1153 int HttpCache::Transaction::DoSendRequestComplete(int result) { | 1115 int HttpCache::Transaction::DoSendRequestComplete(int result) { |
1154 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1155 tracked_objects::ScopedTracker tracking_profile( | |
1156 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1157 "422516 HttpCache::Transaction::DoSendRequestComplete")); | |
1158 | |
1159 if (!cache_.get()) | 1116 if (!cache_.get()) |
1160 return ERR_UNEXPECTED; | 1117 return ERR_UNEXPECTED; |
1161 | 1118 |
1162 // If requested, and we have a readable cache entry, and we have | 1119 // If requested, and we have a readable cache entry, and we have |
1163 // an error indicating that we're offline as opposed to in contact | 1120 // an error indicating that we're offline as opposed to in contact |
1164 // with a bad server, read from cache anyway. | 1121 // with a bad server, read from cache anyway. |
1165 if (IsOfflineError(result)) { | 1122 if (IsOfflineError(result)) { |
1166 if (mode_ == READ_WRITE && entry_ && !partial_) { | 1123 if (mode_ == READ_WRITE && entry_ && !partial_) { |
1167 RecordOfflineStatus(effective_load_flags_, | 1124 RecordOfflineStatus(effective_load_flags_, |
1168 OFFLINE_STATUS_DATA_AVAILABLE_OFFLINE); | 1125 OFFLINE_STATUS_DATA_AVAILABLE_OFFLINE); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 DCHECK(response); | 1161 DCHECK(response); |
1205 response_.cert_request_info = response->cert_request_info; | 1162 response_.cert_request_info = response->cert_request_info; |
1206 } else if (response_.was_cached) { | 1163 } else if (response_.was_cached) { |
1207 DoneWritingToEntry(true); | 1164 DoneWritingToEntry(true); |
1208 } | 1165 } |
1209 return result; | 1166 return result; |
1210 } | 1167 } |
1211 | 1168 |
1212 // We received the response headers and there is no error. | 1169 // We received the response headers and there is no error. |
1213 int HttpCache::Transaction::DoSuccessfulSendRequest() { | 1170 int HttpCache::Transaction::DoSuccessfulSendRequest() { |
1214 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1215 tracked_objects::ScopedTracker tracking_profile( | |
1216 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1217 "422516 HttpCache::Transaction::DoSuccessfulSendRequest")); | |
1218 | |
1219 DCHECK(!new_response_); | 1171 DCHECK(!new_response_); |
1220 const HttpResponseInfo* new_response = network_trans_->GetResponseInfo(); | 1172 const HttpResponseInfo* new_response = network_trans_->GetResponseInfo(); |
1221 bool authentication_failure = false; | 1173 bool authentication_failure = false; |
1222 | 1174 |
1223 if (new_response->headers->response_code() == 401 || | 1175 if (new_response->headers->response_code() == 401 || |
1224 new_response->headers->response_code() == 407) { | 1176 new_response->headers->response_code() == 407) { |
1225 auth_response_ = *new_response; | 1177 auth_response_ = *new_response; |
1226 if (!reading_) | 1178 if (!reading_) |
1227 return OK; | 1179 return OK; |
1228 | 1180 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 } | 1263 } |
1312 UpdateTransactionPattern(PATTERN_ENTRY_UPDATED); | 1264 UpdateTransactionPattern(PATTERN_ENTRY_UPDATED); |
1313 mode_ = WRITE; | 1265 mode_ = WRITE; |
1314 } | 1266 } |
1315 | 1267 |
1316 next_state_ = STATE_OVERWRITE_CACHED_RESPONSE; | 1268 next_state_ = STATE_OVERWRITE_CACHED_RESPONSE; |
1317 return OK; | 1269 return OK; |
1318 } | 1270 } |
1319 | 1271 |
1320 int HttpCache::Transaction::DoNetworkRead() { | 1272 int HttpCache::Transaction::DoNetworkRead() { |
1321 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1322 tracked_objects::ScopedTracker tracking_profile( | |
1323 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1324 "422516 HttpCache::Transaction::DoNetworkRead")); | |
1325 | |
1326 next_state_ = STATE_NETWORK_READ_COMPLETE; | 1273 next_state_ = STATE_NETWORK_READ_COMPLETE; |
1327 return network_trans_->Read(read_buf_.get(), io_buf_len_, io_callback_); | 1274 return network_trans_->Read(read_buf_.get(), io_buf_len_, io_callback_); |
1328 } | 1275 } |
1329 | 1276 |
1330 int HttpCache::Transaction::DoNetworkReadComplete(int result) { | 1277 int HttpCache::Transaction::DoNetworkReadComplete(int result) { |
1331 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1332 tracked_objects::ScopedTracker tracking_profile( | |
1333 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1334 "422516 HttpCache::Transaction::DoNetworkReadComplete")); | |
1335 | |
1336 DCHECK(mode_ & WRITE || mode_ == NONE); | 1278 DCHECK(mode_ & WRITE || mode_ == NONE); |
1337 | 1279 |
1338 if (!cache_.get()) | 1280 if (!cache_.get()) |
1339 return ERR_UNEXPECTED; | 1281 return ERR_UNEXPECTED; |
1340 | 1282 |
1341 // If there is an error or we aren't saving the data, we are done; just wait | 1283 // If there is an error or we aren't saving the data, we are done; just wait |
1342 // until the destructor runs to see if we can keep the data. | 1284 // until the destructor runs to see if we can keep the data. |
1343 if (mode_ == NONE || result < 0) | 1285 if (mode_ == NONE || result < 0) |
1344 return result; | 1286 return result; |
1345 | 1287 |
1346 next_state_ = STATE_CACHE_WRITE_DATA; | 1288 next_state_ = STATE_CACHE_WRITE_DATA; |
1347 return result; | 1289 return result; |
1348 } | 1290 } |
1349 | 1291 |
1350 int HttpCache::Transaction::DoInitEntry() { | 1292 int HttpCache::Transaction::DoInitEntry() { |
1351 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1352 tracked_objects::ScopedTracker tracking_profile( | |
1353 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1354 "422516 HttpCache::Transaction::DoInitEntry")); | |
1355 | |
1356 DCHECK(!new_entry_); | 1293 DCHECK(!new_entry_); |
1357 | 1294 |
1358 if (!cache_.get()) | 1295 if (!cache_.get()) |
1359 return ERR_UNEXPECTED; | 1296 return ERR_UNEXPECTED; |
1360 | 1297 |
1361 if (mode_ == WRITE) { | 1298 if (mode_ == WRITE) { |
1362 next_state_ = STATE_DOOM_ENTRY; | 1299 next_state_ = STATE_DOOM_ENTRY; |
1363 return OK; | 1300 return OK; |
1364 } | 1301 } |
1365 | 1302 |
1366 next_state_ = STATE_OPEN_ENTRY; | 1303 next_state_ = STATE_OPEN_ENTRY; |
1367 return OK; | 1304 return OK; |
1368 } | 1305 } |
1369 | 1306 |
1370 int HttpCache::Transaction::DoOpenEntry() { | 1307 int HttpCache::Transaction::DoOpenEntry() { |
1371 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1372 tracked_objects::ScopedTracker tracking_profile( | |
1373 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1374 "422516 HttpCache::Transaction::DoOpenEntry")); | |
1375 | |
1376 DCHECK(!new_entry_); | 1308 DCHECK(!new_entry_); |
1377 next_state_ = STATE_OPEN_ENTRY_COMPLETE; | 1309 next_state_ = STATE_OPEN_ENTRY_COMPLETE; |
1378 cache_pending_ = true; | 1310 cache_pending_ = true; |
1379 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY); | 1311 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY); |
1380 first_cache_access_since_ = TimeTicks::Now(); | 1312 first_cache_access_since_ = TimeTicks::Now(); |
1381 return cache_->OpenEntry(cache_key_, &new_entry_, this); | 1313 return cache_->OpenEntry(cache_key_, &new_entry_, this); |
1382 } | 1314 } |
1383 | 1315 |
1384 int HttpCache::Transaction::DoOpenEntryComplete(int result) { | 1316 int HttpCache::Transaction::DoOpenEntryComplete(int result) { |
1385 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1386 tracked_objects::ScopedTracker tracking_profile( | |
1387 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1388 "422516 HttpCache::Transaction::DoOpenEntryComplete")); | |
1389 | |
1390 // It is important that we go to STATE_ADD_TO_ENTRY whenever the result is | 1317 // It is important that we go to STATE_ADD_TO_ENTRY whenever the result is |
1391 // OK, otherwise the cache will end up with an active entry without any | 1318 // OK, otherwise the cache will end up with an active entry without any |
1392 // transaction attached. | 1319 // transaction attached. |
1393 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY, result); | 1320 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY, result); |
1394 cache_pending_ = false; | 1321 cache_pending_ = false; |
1395 if (result == OK) { | 1322 if (result == OK) { |
1396 next_state_ = STATE_ADD_TO_ENTRY; | 1323 next_state_ = STATE_ADD_TO_ENTRY; |
1397 return OK; | 1324 return OK; |
1398 } | 1325 } |
1399 | 1326 |
(...skipping 21 matching lines...) Expand all Loading... |
1421 next_state_ = STATE_SEND_REQUEST; | 1348 next_state_ = STATE_SEND_REQUEST; |
1422 return OK; | 1349 return OK; |
1423 } | 1350 } |
1424 | 1351 |
1425 // The entry does not exist, and we are not permitted to create a new entry, | 1352 // The entry does not exist, and we are not permitted to create a new entry, |
1426 // so we must fail. | 1353 // so we must fail. |
1427 return ERR_CACHE_MISS; | 1354 return ERR_CACHE_MISS; |
1428 } | 1355 } |
1429 | 1356 |
1430 int HttpCache::Transaction::DoCreateEntry() { | 1357 int HttpCache::Transaction::DoCreateEntry() { |
1431 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1432 tracked_objects::ScopedTracker tracking_profile( | |
1433 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1434 "422516 HttpCache::Transaction::DoCreateEntry")); | |
1435 | |
1436 DCHECK(!new_entry_); | 1358 DCHECK(!new_entry_); |
1437 next_state_ = STATE_CREATE_ENTRY_COMPLETE; | 1359 next_state_ = STATE_CREATE_ENTRY_COMPLETE; |
1438 cache_pending_ = true; | 1360 cache_pending_ = true; |
1439 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY); | 1361 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY); |
1440 return cache_->CreateEntry(cache_key_, &new_entry_, this); | 1362 return cache_->CreateEntry(cache_key_, &new_entry_, this); |
1441 } | 1363 } |
1442 | 1364 |
1443 int HttpCache::Transaction::DoCreateEntryComplete(int result) { | 1365 int HttpCache::Transaction::DoCreateEntryComplete(int result) { |
1444 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1445 tracked_objects::ScopedTracker tracking_profile( | |
1446 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1447 "422516 HttpCache::Transaction::DoCreateEntryComplete")); | |
1448 | |
1449 // It is important that we go to STATE_ADD_TO_ENTRY whenever the result is | 1366 // It is important that we go to STATE_ADD_TO_ENTRY whenever the result is |
1450 // OK, otherwise the cache will end up with an active entry without any | 1367 // OK, otherwise the cache will end up with an active entry without any |
1451 // transaction attached. | 1368 // transaction attached. |
1452 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY, | 1369 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY, |
1453 result); | 1370 result); |
1454 cache_pending_ = false; | 1371 cache_pending_ = false; |
1455 next_state_ = STATE_ADD_TO_ENTRY; | 1372 next_state_ = STATE_ADD_TO_ENTRY; |
1456 | 1373 |
1457 if (result == ERR_CACHE_RACE) { | 1374 if (result == ERR_CACHE_RACE) { |
1458 next_state_ = STATE_INIT_ENTRY; | 1375 next_state_ = STATE_INIT_ENTRY; |
1459 return OK; | 1376 return OK; |
1460 } | 1377 } |
1461 | 1378 |
1462 if (result != OK) { | 1379 if (result != OK) { |
1463 // We have a race here: Maybe we failed to open the entry and decided to | 1380 // We have a race here: Maybe we failed to open the entry and decided to |
1464 // create one, but by the time we called create, another transaction already | 1381 // create one, but by the time we called create, another transaction already |
1465 // created the entry. If we want to eliminate this issue, we need an atomic | 1382 // created the entry. If we want to eliminate this issue, we need an atomic |
1466 // OpenOrCreate() method exposed by the disk cache. | 1383 // OpenOrCreate() method exposed by the disk cache. |
1467 DLOG(WARNING) << "Unable to create cache entry"; | 1384 DLOG(WARNING) << "Unable to create cache entry"; |
1468 mode_ = NONE; | 1385 mode_ = NONE; |
1469 if (partial_.get()) | 1386 if (partial_.get()) |
1470 partial_->RestoreHeaders(&custom_request_->extra_headers); | 1387 partial_->RestoreHeaders(&custom_request_->extra_headers); |
1471 next_state_ = STATE_SEND_REQUEST; | 1388 next_state_ = STATE_SEND_REQUEST; |
1472 } | 1389 } |
1473 return OK; | 1390 return OK; |
1474 } | 1391 } |
1475 | 1392 |
1476 int HttpCache::Transaction::DoDoomEntry() { | 1393 int HttpCache::Transaction::DoDoomEntry() { |
1477 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1478 tracked_objects::ScopedTracker tracking_profile( | |
1479 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1480 "422516 HttpCache::Transaction::DoDoomEntry")); | |
1481 | |
1482 next_state_ = STATE_DOOM_ENTRY_COMPLETE; | 1394 next_state_ = STATE_DOOM_ENTRY_COMPLETE; |
1483 cache_pending_ = true; | 1395 cache_pending_ = true; |
1484 if (first_cache_access_since_.is_null()) | 1396 if (first_cache_access_since_.is_null()) |
1485 first_cache_access_since_ = TimeTicks::Now(); | 1397 first_cache_access_since_ = TimeTicks::Now(); |
1486 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY); | 1398 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY); |
1487 return cache_->DoomEntry(cache_key_, this); | 1399 return cache_->DoomEntry(cache_key_, this); |
1488 } | 1400 } |
1489 | 1401 |
1490 int HttpCache::Transaction::DoDoomEntryComplete(int result) { | 1402 int HttpCache::Transaction::DoDoomEntryComplete(int result) { |
1491 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1492 tracked_objects::ScopedTracker tracking_profile( | |
1493 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1494 "422516 HttpCache::Transaction::DoDoomEntryComplete")); | |
1495 | |
1496 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY, result); | 1403 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY, result); |
1497 next_state_ = STATE_CREATE_ENTRY; | 1404 next_state_ = STATE_CREATE_ENTRY; |
1498 cache_pending_ = false; | 1405 cache_pending_ = false; |
1499 if (result == ERR_CACHE_RACE) | 1406 if (result == ERR_CACHE_RACE) |
1500 next_state_ = STATE_INIT_ENTRY; | 1407 next_state_ = STATE_INIT_ENTRY; |
1501 return OK; | 1408 return OK; |
1502 } | 1409 } |
1503 | 1410 |
1504 int HttpCache::Transaction::DoAddToEntry() { | 1411 int HttpCache::Transaction::DoAddToEntry() { |
1505 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1506 tracked_objects::ScopedTracker tracking_profile( | |
1507 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1508 "422516 HttpCache::Transaction::DoAddToEntry")); | |
1509 | |
1510 DCHECK(new_entry_); | 1412 DCHECK(new_entry_); |
1511 cache_pending_ = true; | 1413 cache_pending_ = true; |
1512 next_state_ = STATE_ADD_TO_ENTRY_COMPLETE; | 1414 next_state_ = STATE_ADD_TO_ENTRY_COMPLETE; |
1513 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY); | 1415 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY); |
1514 DCHECK(entry_lock_waiting_since_.is_null()); | 1416 DCHECK(entry_lock_waiting_since_.is_null()); |
1515 entry_lock_waiting_since_ = TimeTicks::Now(); | 1417 entry_lock_waiting_since_ = TimeTicks::Now(); |
1516 int rv = cache_->AddTransactionToEntry(new_entry_, this); | 1418 int rv = cache_->AddTransactionToEntry(new_entry_, this); |
1517 if (rv == ERR_IO_PENDING) { | 1419 if (rv == ERR_IO_PENDING) { |
1518 if (bypass_lock_for_test_) { | 1420 if (bypass_lock_for_test_) { |
1519 OnAddToEntryTimeout(entry_lock_waiting_since_); | 1421 OnAddToEntryTimeout(entry_lock_waiting_since_); |
(...skipping 21 matching lines...) Expand all Loading... |
1541 FROM_HERE, | 1443 FROM_HERE, |
1542 base::Bind(&HttpCache::Transaction::OnAddToEntryTimeout, | 1444 base::Bind(&HttpCache::Transaction::OnAddToEntryTimeout, |
1543 weak_factory_.GetWeakPtr(), entry_lock_waiting_since_), | 1445 weak_factory_.GetWeakPtr(), entry_lock_waiting_since_), |
1544 TimeDelta::FromMilliseconds(timeout_milliseconds)); | 1446 TimeDelta::FromMilliseconds(timeout_milliseconds)); |
1545 } | 1447 } |
1546 } | 1448 } |
1547 return rv; | 1449 return rv; |
1548 } | 1450 } |
1549 | 1451 |
1550 int HttpCache::Transaction::DoAddToEntryComplete(int result) { | 1452 int HttpCache::Transaction::DoAddToEntryComplete(int result) { |
1551 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1552 tracked_objects::ScopedTracker tracking_profile( | |
1553 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1554 "422516 HttpCache::Transaction::DoAddToEntryComplete")); | |
1555 | |
1556 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, | 1453 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, |
1557 result); | 1454 result); |
1558 const TimeDelta entry_lock_wait = | 1455 const TimeDelta entry_lock_wait = |
1559 TimeTicks::Now() - entry_lock_waiting_since_; | 1456 TimeTicks::Now() - entry_lock_waiting_since_; |
1560 UMA_HISTOGRAM_TIMES("HttpCache.EntryLockWait", entry_lock_wait); | 1457 UMA_HISTOGRAM_TIMES("HttpCache.EntryLockWait", entry_lock_wait); |
1561 | 1458 |
1562 entry_lock_waiting_since_ = TimeTicks(); | 1459 entry_lock_waiting_since_ = TimeTicks(); |
1563 DCHECK(new_entry_); | 1460 DCHECK(new_entry_); |
1564 cache_pending_ = false; | 1461 cache_pending_ = false; |
1565 | 1462 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 } else { | 1494 } else { |
1598 // We have to read the headers from the cached entry. | 1495 // We have to read the headers from the cached entry. |
1599 DCHECK(mode_ & READ_META); | 1496 DCHECK(mode_ & READ_META); |
1600 next_state_ = STATE_CACHE_READ_RESPONSE; | 1497 next_state_ = STATE_CACHE_READ_RESPONSE; |
1601 } | 1498 } |
1602 return OK; | 1499 return OK; |
1603 } | 1500 } |
1604 | 1501 |
1605 // We may end up here multiple times for a given request. | 1502 // We may end up here multiple times for a given request. |
1606 int HttpCache::Transaction::DoStartPartialCacheValidation() { | 1503 int HttpCache::Transaction::DoStartPartialCacheValidation() { |
1607 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1608 tracked_objects::ScopedTracker tracking_profile( | |
1609 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1610 "422516 HttpCache::Transaction::DoStartPartialCacheValidation")); | |
1611 | |
1612 if (mode_ == NONE) | 1504 if (mode_ == NONE) |
1613 return OK; | 1505 return OK; |
1614 | 1506 |
1615 next_state_ = STATE_COMPLETE_PARTIAL_CACHE_VALIDATION; | 1507 next_state_ = STATE_COMPLETE_PARTIAL_CACHE_VALIDATION; |
1616 return partial_->ShouldValidateCache(entry_->disk_entry, io_callback_); | 1508 return partial_->ShouldValidateCache(entry_->disk_entry, io_callback_); |
1617 } | 1509 } |
1618 | 1510 |
1619 int HttpCache::Transaction::DoCompletePartialCacheValidation(int result) { | 1511 int HttpCache::Transaction::DoCompletePartialCacheValidation(int result) { |
1620 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1621 tracked_objects::ScopedTracker tracking_profile( | |
1622 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1623 "422516 HttpCache::Transaction::DoCompletePartialCacheValidation")); | |
1624 | |
1625 if (!result) { | 1512 if (!result) { |
1626 // This is the end of the request. | 1513 // This is the end of the request. |
1627 if (mode_ & WRITE) { | 1514 if (mode_ & WRITE) { |
1628 DoneWritingToEntry(true); | 1515 DoneWritingToEntry(true); |
1629 } else { | 1516 } else { |
1630 cache_->DoneReadingFromEntry(entry_, this); | 1517 cache_->DoneReadingFromEntry(entry_, this); |
1631 entry_ = NULL; | 1518 entry_ = NULL; |
1632 } | 1519 } |
1633 return result; | 1520 return result; |
1634 } | 1521 } |
1635 | 1522 |
1636 if (result < 0) | 1523 if (result < 0) |
1637 return result; | 1524 return result; |
1638 | 1525 |
1639 partial_->PrepareCacheValidation(entry_->disk_entry, | 1526 partial_->PrepareCacheValidation(entry_->disk_entry, |
1640 &custom_request_->extra_headers); | 1527 &custom_request_->extra_headers); |
1641 | 1528 |
1642 if (reading_ && partial_->IsCurrentRangeCached()) { | 1529 if (reading_ && partial_->IsCurrentRangeCached()) { |
1643 next_state_ = STATE_CACHE_READ_DATA; | 1530 next_state_ = STATE_CACHE_READ_DATA; |
1644 return OK; | 1531 return OK; |
1645 } | 1532 } |
1646 | 1533 |
1647 return BeginCacheValidation(); | 1534 return BeginCacheValidation(); |
1648 } | 1535 } |
1649 | 1536 |
1650 // We received 304 or 206 and we want to update the cached response headers. | 1537 // We received 304 or 206 and we want to update the cached response headers. |
1651 int HttpCache::Transaction::DoUpdateCachedResponse() { | 1538 int HttpCache::Transaction::DoUpdateCachedResponse() { |
1652 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1653 tracked_objects::ScopedTracker tracking_profile( | |
1654 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1655 "422516 HttpCache::Transaction::DoUpdateCachedResponse")); | |
1656 | |
1657 next_state_ = STATE_UPDATE_CACHED_RESPONSE_COMPLETE; | 1539 next_state_ = STATE_UPDATE_CACHED_RESPONSE_COMPLETE; |
1658 int rv = OK; | 1540 int rv = OK; |
1659 // Update cached response based on headers in new_response. | 1541 // Update cached response based on headers in new_response. |
1660 // TODO(wtc): should we update cached certificate (response_.ssl_info), too? | 1542 // TODO(wtc): should we update cached certificate (response_.ssl_info), too? |
1661 response_.headers->Update(*new_response_->headers.get()); | 1543 response_.headers->Update(*new_response_->headers.get()); |
1662 response_.response_time = new_response_->response_time; | 1544 response_.response_time = new_response_->response_time; |
1663 response_.request_time = new_response_->request_time; | 1545 response_.request_time = new_response_->request_time; |
1664 response_.network_accessed = new_response_->network_accessed; | 1546 response_.network_accessed = new_response_->network_accessed; |
1665 response_.unused_since_prefetch = new_response_->unused_since_prefetch; | 1547 response_.unused_since_prefetch = new_response_->unused_since_prefetch; |
1666 if (new_response_->vary_data.is_valid()) { | 1548 if (new_response_->vary_data.is_valid()) { |
(...skipping 17 matching lines...) Expand all Loading... |
1684 if (!reading_) { | 1566 if (!reading_) { |
1685 target_state_ = STATE_UPDATE_CACHED_RESPONSE_COMPLETE; | 1567 target_state_ = STATE_UPDATE_CACHED_RESPONSE_COMPLETE; |
1686 next_state_ = STATE_CACHE_WRITE_RESPONSE; | 1568 next_state_ = STATE_CACHE_WRITE_RESPONSE; |
1687 rv = OK; | 1569 rv = OK; |
1688 } | 1570 } |
1689 } | 1571 } |
1690 return rv; | 1572 return rv; |
1691 } | 1573 } |
1692 | 1574 |
1693 int HttpCache::Transaction::DoUpdateCachedResponseComplete(int result) { | 1575 int HttpCache::Transaction::DoUpdateCachedResponseComplete(int result) { |
1694 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1695 tracked_objects::ScopedTracker tracking_profile( | |
1696 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1697 "422516 HttpCache::Transaction::DoUpdateCachedResponseComplete")); | |
1698 | |
1699 if (mode_ == UPDATE) { | 1576 if (mode_ == UPDATE) { |
1700 DCHECK(!handling_206_); | 1577 DCHECK(!handling_206_); |
1701 // We got a "not modified" response and already updated the corresponding | 1578 // We got a "not modified" response and already updated the corresponding |
1702 // cache entry above. | 1579 // cache entry above. |
1703 // | 1580 // |
1704 // By closing the cached entry now, we make sure that the 304 rather than | 1581 // By closing the cached entry now, we make sure that the 304 rather than |
1705 // the cached 200 response, is what will be returned to the user. | 1582 // the cached 200 response, is what will be returned to the user. |
1706 DoneWritingToEntry(true); | 1583 DoneWritingToEntry(true); |
1707 } else if (entry_ && !handling_206_) { | 1584 } else if (entry_ && !handling_206_) { |
1708 DCHECK_EQ(READ_WRITE, mode_); | 1585 DCHECK_EQ(READ_WRITE, mode_); |
(...skipping 13 matching lines...) Expand all Loading... |
1722 new_response_ = NULL; | 1599 new_response_ = NULL; |
1723 next_state_ = STATE_START_PARTIAL_CACHE_VALIDATION; | 1600 next_state_ = STATE_START_PARTIAL_CACHE_VALIDATION; |
1724 partial_->SetRangeToStartDownload(); | 1601 partial_->SetRangeToStartDownload(); |
1725 return OK; | 1602 return OK; |
1726 } | 1603 } |
1727 next_state_ = STATE_OVERWRITE_CACHED_RESPONSE; | 1604 next_state_ = STATE_OVERWRITE_CACHED_RESPONSE; |
1728 return OK; | 1605 return OK; |
1729 } | 1606 } |
1730 | 1607 |
1731 int HttpCache::Transaction::DoOverwriteCachedResponse() { | 1608 int HttpCache::Transaction::DoOverwriteCachedResponse() { |
1732 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1733 tracked_objects::ScopedTracker tracking_profile( | |
1734 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1735 "422516 HttpCache::Transaction::DoOverwriteCachedResponse")); | |
1736 | |
1737 if (mode_ & READ) { | 1609 if (mode_ & READ) { |
1738 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; | 1610 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; |
1739 return OK; | 1611 return OK; |
1740 } | 1612 } |
1741 | 1613 |
1742 // We change the value of Content-Length for partial content. | 1614 // We change the value of Content-Length for partial content. |
1743 if (handling_206_ && partial_.get()) | 1615 if (handling_206_ && partial_.get()) |
1744 partial_->FixContentLength(new_response_->headers.get()); | 1616 partial_->FixContentLength(new_response_->headers.get()); |
1745 | 1617 |
1746 response_ = *new_response_; | 1618 response_ = *new_response_; |
(...skipping 16 matching lines...) Expand all Loading... |
1763 return OK; | 1635 return OK; |
1764 } | 1636 } |
1765 | 1637 |
1766 target_state_ = STATE_TRUNCATE_CACHED_DATA; | 1638 target_state_ = STATE_TRUNCATE_CACHED_DATA; |
1767 next_state_ = truncated_ ? STATE_CACHE_WRITE_TRUNCATED_RESPONSE : | 1639 next_state_ = truncated_ ? STATE_CACHE_WRITE_TRUNCATED_RESPONSE : |
1768 STATE_CACHE_WRITE_RESPONSE; | 1640 STATE_CACHE_WRITE_RESPONSE; |
1769 return OK; | 1641 return OK; |
1770 } | 1642 } |
1771 | 1643 |
1772 int HttpCache::Transaction::DoTruncateCachedData() { | 1644 int HttpCache::Transaction::DoTruncateCachedData() { |
1773 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1774 tracked_objects::ScopedTracker tracking_profile( | |
1775 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1776 "422516 HttpCache::Transaction::DoTruncateCachedData")); | |
1777 | |
1778 next_state_ = STATE_TRUNCATE_CACHED_DATA_COMPLETE; | 1645 next_state_ = STATE_TRUNCATE_CACHED_DATA_COMPLETE; |
1779 if (!entry_) | 1646 if (!entry_) |
1780 return OK; | 1647 return OK; |
1781 if (net_log_.IsLogging()) | 1648 if (net_log_.IsLogging()) |
1782 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA); | 1649 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA); |
1783 // Truncate the stream. | 1650 // Truncate the stream. |
1784 return WriteToEntry(kResponseContentIndex, 0, NULL, 0, io_callback_); | 1651 return WriteToEntry(kResponseContentIndex, 0, NULL, 0, io_callback_); |
1785 } | 1652 } |
1786 | 1653 |
1787 int HttpCache::Transaction::DoTruncateCachedDataComplete(int result) { | 1654 int HttpCache::Transaction::DoTruncateCachedDataComplete(int result) { |
1788 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1789 tracked_objects::ScopedTracker tracking_profile( | |
1790 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1791 "422516 HttpCache::Transaction::DoTruncateCachedDataComplete")); | |
1792 | |
1793 if (entry_) { | 1655 if (entry_) { |
1794 if (net_log_.IsLogging()) { | 1656 if (net_log_.IsLogging()) { |
1795 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, | 1657 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, |
1796 result); | 1658 result); |
1797 } | 1659 } |
1798 } | 1660 } |
1799 | 1661 |
1800 next_state_ = STATE_TRUNCATE_CACHED_METADATA; | 1662 next_state_ = STATE_TRUNCATE_CACHED_METADATA; |
1801 return OK; | 1663 return OK; |
1802 } | 1664 } |
1803 | 1665 |
1804 int HttpCache::Transaction::DoTruncateCachedMetadata() { | 1666 int HttpCache::Transaction::DoTruncateCachedMetadata() { |
1805 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1806 tracked_objects::ScopedTracker tracking_profile( | |
1807 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1808 "422516 HttpCache::Transaction::DoTruncateCachedMetadata")); | |
1809 | |
1810 next_state_ = STATE_TRUNCATE_CACHED_METADATA_COMPLETE; | 1667 next_state_ = STATE_TRUNCATE_CACHED_METADATA_COMPLETE; |
1811 if (!entry_) | 1668 if (!entry_) |
1812 return OK; | 1669 return OK; |
1813 | 1670 |
1814 if (net_log_.IsLogging()) | 1671 if (net_log_.IsLogging()) |
1815 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); | 1672 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); |
1816 return WriteToEntry(kMetadataIndex, 0, NULL, 0, io_callback_); | 1673 return WriteToEntry(kMetadataIndex, 0, NULL, 0, io_callback_); |
1817 } | 1674 } |
1818 | 1675 |
1819 int HttpCache::Transaction::DoTruncateCachedMetadataComplete(int result) { | 1676 int HttpCache::Transaction::DoTruncateCachedMetadataComplete(int result) { |
1820 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1821 tracked_objects::ScopedTracker tracking_profile( | |
1822 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1823 "422516 HttpCache::Transaction::DoTruncateCachedMetadataComplete")); | |
1824 | |
1825 if (entry_) { | 1677 if (entry_) { |
1826 if (net_log_.IsLogging()) { | 1678 if (net_log_.IsLogging()) { |
1827 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, | 1679 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, |
1828 result); | 1680 result); |
1829 } | 1681 } |
1830 } | 1682 } |
1831 | 1683 |
1832 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; | 1684 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; |
1833 return OK; | 1685 return OK; |
1834 } | 1686 } |
1835 | 1687 |
1836 int HttpCache::Transaction::DoPartialHeadersReceived() { | 1688 int HttpCache::Transaction::DoPartialHeadersReceived() { |
1837 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1838 tracked_objects::ScopedTracker tracking_profile( | |
1839 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1840 "422516 HttpCache::Transaction::DoPartialHeadersReceived")); | |
1841 | |
1842 new_response_ = NULL; | 1689 new_response_ = NULL; |
1843 if (entry_ && !partial_.get() && | 1690 if (entry_ && !partial_.get() && |
1844 entry_->disk_entry->GetDataSize(kMetadataIndex)) | 1691 entry_->disk_entry->GetDataSize(kMetadataIndex)) |
1845 next_state_ = STATE_CACHE_READ_METADATA; | 1692 next_state_ = STATE_CACHE_READ_METADATA; |
1846 | 1693 |
1847 if (!partial_.get()) | 1694 if (!partial_.get()) |
1848 return OK; | 1695 return OK; |
1849 | 1696 |
1850 if (reading_) { | 1697 if (reading_) { |
1851 if (network_trans_.get()) { | 1698 if (network_trans_.get()) { |
1852 next_state_ = STATE_NETWORK_READ; | 1699 next_state_ = STATE_NETWORK_READ; |
1853 } else { | 1700 } else { |
1854 next_state_ = STATE_CACHE_READ_DATA; | 1701 next_state_ = STATE_CACHE_READ_DATA; |
1855 } | 1702 } |
1856 } else if (mode_ != NONE) { | 1703 } else if (mode_ != NONE) { |
1857 // We are about to return the headers for a byte-range request to the user, | 1704 // We are about to return the headers for a byte-range request to the user, |
1858 // so let's fix them. | 1705 // so let's fix them. |
1859 partial_->FixResponseHeaders(response_.headers.get(), true); | 1706 partial_->FixResponseHeaders(response_.headers.get(), true); |
1860 } | 1707 } |
1861 return OK; | 1708 return OK; |
1862 } | 1709 } |
1863 | 1710 |
1864 int HttpCache::Transaction::DoCacheReadResponse() { | 1711 int HttpCache::Transaction::DoCacheReadResponse() { |
1865 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1866 tracked_objects::ScopedTracker tracking_profile( | |
1867 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1868 "422516 HttpCache::Transaction::DoCacheReadResponse")); | |
1869 | |
1870 DCHECK(entry_); | 1712 DCHECK(entry_); |
1871 next_state_ = STATE_CACHE_READ_RESPONSE_COMPLETE; | 1713 next_state_ = STATE_CACHE_READ_RESPONSE_COMPLETE; |
1872 | 1714 |
1873 io_buf_len_ = entry_->disk_entry->GetDataSize(kResponseInfoIndex); | 1715 io_buf_len_ = entry_->disk_entry->GetDataSize(kResponseInfoIndex); |
1874 read_buf_ = new IOBuffer(io_buf_len_); | 1716 read_buf_ = new IOBuffer(io_buf_len_); |
1875 | 1717 |
1876 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); | 1718 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); |
1877 return entry_->disk_entry->ReadData(kResponseInfoIndex, 0, read_buf_.get(), | 1719 return entry_->disk_entry->ReadData(kResponseInfoIndex, 0, read_buf_.get(), |
1878 io_buf_len_, io_callback_); | 1720 io_buf_len_, io_callback_); |
1879 } | 1721 } |
1880 | 1722 |
1881 int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { | 1723 int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { |
1882 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1883 tracked_objects::ScopedTracker tracking_profile( | |
1884 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1885 "422516 HttpCache::Transaction::DoCacheReadResponseComplete")); | |
1886 | |
1887 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); | 1724 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); |
1888 if (result != io_buf_len_ || | 1725 if (result != io_buf_len_ || |
1889 !HttpCache::ParseResponseInfo(read_buf_->data(), io_buf_len_, | 1726 !HttpCache::ParseResponseInfo(read_buf_->data(), io_buf_len_, |
1890 &response_, &truncated_)) { | 1727 &response_, &truncated_)) { |
1891 return OnCacheReadError(result, true); | 1728 return OnCacheReadError(result, true); |
1892 } | 1729 } |
1893 | 1730 |
1894 // cert_cache() will be null if the CertCacheTrial field trial is disabled. | 1731 // cert_cache() will be null if the CertCacheTrial field trial is disabled. |
1895 if (cache_->cert_cache() && response_.ssl_info.is_valid()) | 1732 if (cache_->cert_cache() && response_.ssl_info.is_valid()) |
1896 ReadCertChain(); | 1733 ReadCertChain(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 | 1799 |
1963 int HttpCache::Transaction::DoCacheToggleUnusedSincePrefetchComplete( | 1800 int HttpCache::Transaction::DoCacheToggleUnusedSincePrefetchComplete( |
1964 int result) { | 1801 int result) { |
1965 // Restore the original value for this transaction. | 1802 // Restore the original value for this transaction. |
1966 response_.unused_since_prefetch = !response_.unused_since_prefetch; | 1803 response_.unused_since_prefetch = !response_.unused_since_prefetch; |
1967 next_state_ = STATE_CACHE_DISPATCH_VALIDATION; | 1804 next_state_ = STATE_CACHE_DISPATCH_VALIDATION; |
1968 return OK; | 1805 return OK; |
1969 } | 1806 } |
1970 | 1807 |
1971 int HttpCache::Transaction::DoCacheWriteResponse() { | 1808 int HttpCache::Transaction::DoCacheWriteResponse() { |
1972 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 1809 // TODO(rtenneti): Remove ScopedTracker below once crbug.com/422516 is fixed. |
1973 tracked_objects::ScopedTracker tracking_profile( | 1810 tracked_objects::ScopedTracker tracking_profile( |
1974 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1811 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
1975 "422516 HttpCache::Transaction::DoCacheWriteResponse")); | 1812 "422516 HttpCache::Transaction::DoCacheWriteResponse")); |
1976 | 1813 |
1977 if (entry_) { | 1814 if (entry_) { |
1978 if (net_log_.IsLogging()) | 1815 if (net_log_.IsLogging()) |
1979 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); | 1816 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); |
1980 } | 1817 } |
1981 return WriteResponseInfoToEntry(false); | 1818 return WriteResponseInfoToEntry(false); |
1982 } | 1819 } |
1983 | 1820 |
1984 int HttpCache::Transaction::DoCacheWriteTruncatedResponse() { | 1821 int HttpCache::Transaction::DoCacheWriteTruncatedResponse() { |
1985 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1986 tracked_objects::ScopedTracker tracking_profile( | |
1987 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
1988 "422516 HttpCache::Transaction::DoCacheWriteTruncatedResponse")); | |
1989 | |
1990 if (entry_) { | 1822 if (entry_) { |
1991 if (net_log_.IsLogging()) | 1823 if (net_log_.IsLogging()) |
1992 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); | 1824 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); |
1993 } | 1825 } |
1994 return WriteResponseInfoToEntry(true); | 1826 return WriteResponseInfoToEntry(true); |
1995 } | 1827 } |
1996 | 1828 |
1997 int HttpCache::Transaction::DoCacheWriteResponseComplete(int result) { | 1829 int HttpCache::Transaction::DoCacheWriteResponseComplete(int result) { |
1998 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
1999 tracked_objects::ScopedTracker tracking_profile( | |
2000 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
2001 "422516 HttpCache::Transaction::DoCacheWriteResponseComplete")); | |
2002 | |
2003 next_state_ = target_state_; | 1830 next_state_ = target_state_; |
2004 target_state_ = STATE_NONE; | 1831 target_state_ = STATE_NONE; |
2005 if (!entry_) | 1832 if (!entry_) |
2006 return OK; | 1833 return OK; |
2007 if (net_log_.IsLogging()) { | 1834 if (net_log_.IsLogging()) { |
2008 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, | 1835 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, |
2009 result); | 1836 result); |
2010 } | 1837 } |
2011 | 1838 |
2012 // Balance the AddRef from WriteResponseInfoToEntry. | 1839 // Balance the AddRef from WriteResponseInfoToEntry. |
2013 if (result != io_buf_len_) { | 1840 if (result != io_buf_len_) { |
2014 DLOG(ERROR) << "failed to write response info to cache"; | 1841 DLOG(ERROR) << "failed to write response info to cache"; |
2015 DoneWritingToEntry(false); | 1842 DoneWritingToEntry(false); |
2016 } | 1843 } |
2017 return OK; | 1844 return OK; |
2018 } | 1845 } |
2019 | 1846 |
2020 int HttpCache::Transaction::DoCacheReadMetadata() { | 1847 int HttpCache::Transaction::DoCacheReadMetadata() { |
2021 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
2022 tracked_objects::ScopedTracker tracking_profile( | |
2023 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
2024 "422516 HttpCache::Transaction::DoCacheReadMetadata")); | |
2025 | |
2026 DCHECK(entry_); | 1848 DCHECK(entry_); |
2027 DCHECK(!response_.metadata.get()); | 1849 DCHECK(!response_.metadata.get()); |
2028 next_state_ = STATE_CACHE_READ_METADATA_COMPLETE; | 1850 next_state_ = STATE_CACHE_READ_METADATA_COMPLETE; |
2029 | 1851 |
2030 response_.metadata = | 1852 response_.metadata = |
2031 new IOBufferWithSize(entry_->disk_entry->GetDataSize(kMetadataIndex)); | 1853 new IOBufferWithSize(entry_->disk_entry->GetDataSize(kMetadataIndex)); |
2032 | 1854 |
2033 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); | 1855 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); |
2034 return entry_->disk_entry->ReadData(kMetadataIndex, 0, | 1856 return entry_->disk_entry->ReadData(kMetadataIndex, 0, |
2035 response_.metadata.get(), | 1857 response_.metadata.get(), |
2036 response_.metadata->size(), | 1858 response_.metadata->size(), |
2037 io_callback_); | 1859 io_callback_); |
2038 } | 1860 } |
2039 | 1861 |
2040 int HttpCache::Transaction::DoCacheReadMetadataComplete(int result) { | 1862 int HttpCache::Transaction::DoCacheReadMetadataComplete(int result) { |
2041 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
2042 tracked_objects::ScopedTracker tracking_profile( | |
2043 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
2044 "422516 HttpCache::Transaction::DoCacheReadMetadataComplete")); | |
2045 | |
2046 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); | 1863 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); |
2047 if (result != response_.metadata->size()) | 1864 if (result != response_.metadata->size()) |
2048 return OnCacheReadError(result, false); | 1865 return OnCacheReadError(result, false); |
2049 return OK; | 1866 return OK; |
2050 } | 1867 } |
2051 | 1868 |
2052 int HttpCache::Transaction::DoCacheQueryData() { | 1869 int HttpCache::Transaction::DoCacheQueryData() { |
2053 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
2054 tracked_objects::ScopedTracker tracking_profile( | |
2055 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
2056 "422516 HttpCache::Transaction::DoCacheQueryData")); | |
2057 | |
2058 next_state_ = STATE_CACHE_QUERY_DATA_COMPLETE; | 1870 next_state_ = STATE_CACHE_QUERY_DATA_COMPLETE; |
2059 return entry_->disk_entry->ReadyForSparseIO(io_callback_); | 1871 return entry_->disk_entry->ReadyForSparseIO(io_callback_); |
2060 } | 1872 } |
2061 | 1873 |
2062 int HttpCache::Transaction::DoCacheQueryDataComplete(int result) { | 1874 int HttpCache::Transaction::DoCacheQueryDataComplete(int result) { |
2063 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
2064 tracked_objects::ScopedTracker tracking_profile( | |
2065 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
2066 "422516 HttpCache::Transaction::DoCacheQueryDataComplete")); | |
2067 | |
2068 DCHECK_EQ(OK, result); | 1875 DCHECK_EQ(OK, result); |
2069 if (!cache_.get()) | 1876 if (!cache_.get()) |
2070 return ERR_UNEXPECTED; | 1877 return ERR_UNEXPECTED; |
2071 | 1878 |
2072 return ValidateEntryHeadersAndContinue(); | 1879 return ValidateEntryHeadersAndContinue(); |
2073 } | 1880 } |
2074 | 1881 |
2075 int HttpCache::Transaction::DoCacheReadData() { | 1882 int HttpCache::Transaction::DoCacheReadData() { |
2076 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
2077 tracked_objects::ScopedTracker tracking_profile( | |
2078 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
2079 "422516 HttpCache::Transaction::DoCacheReadData")); | |
2080 | |
2081 DCHECK(entry_); | 1883 DCHECK(entry_); |
2082 next_state_ = STATE_CACHE_READ_DATA_COMPLETE; | 1884 next_state_ = STATE_CACHE_READ_DATA_COMPLETE; |
2083 | 1885 |
2084 if (net_log_.IsLogging()) | 1886 if (net_log_.IsLogging()) |
2085 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_DATA); | 1887 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_DATA); |
2086 if (partial_.get()) { | 1888 if (partial_.get()) { |
2087 return partial_->CacheRead(entry_->disk_entry, read_buf_.get(), io_buf_len_, | 1889 return partial_->CacheRead(entry_->disk_entry, read_buf_.get(), io_buf_len_, |
2088 io_callback_); | 1890 io_callback_); |
2089 } | 1891 } |
2090 | 1892 |
2091 return entry_->disk_entry->ReadData(kResponseContentIndex, read_offset_, | 1893 return entry_->disk_entry->ReadData(kResponseContentIndex, read_offset_, |
2092 read_buf_.get(), io_buf_len_, | 1894 read_buf_.get(), io_buf_len_, |
2093 io_callback_); | 1895 io_callback_); |
2094 } | 1896 } |
2095 | 1897 |
2096 int HttpCache::Transaction::DoCacheReadDataComplete(int result) { | 1898 int HttpCache::Transaction::DoCacheReadDataComplete(int result) { |
2097 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
2098 tracked_objects::ScopedTracker tracking_profile( | |
2099 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
2100 "422516 HttpCache::Transaction::DoCacheReadDataComplete")); | |
2101 | |
2102 if (net_log_.IsLogging()) { | 1899 if (net_log_.IsLogging()) { |
2103 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_DATA, | 1900 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_DATA, |
2104 result); | 1901 result); |
2105 } | 1902 } |
2106 | 1903 |
2107 if (!cache_.get()) | 1904 if (!cache_.get()) |
2108 return ERR_UNEXPECTED; | 1905 return ERR_UNEXPECTED; |
2109 | 1906 |
2110 if (partial_.get()) { | 1907 if (partial_.get()) { |
2111 // Partial requests are confusing to report in histograms because they may | 1908 // Partial requests are confusing to report in histograms because they may |
2112 // have multiple underlying requests. | 1909 // have multiple underlying requests. |
2113 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 1910 UpdateTransactionPattern(PATTERN_NOT_COVERED); |
2114 return DoPartialCacheReadCompleted(result); | 1911 return DoPartialCacheReadCompleted(result); |
2115 } | 1912 } |
2116 | 1913 |
2117 if (result > 0) { | 1914 if (result > 0) { |
2118 read_offset_ += result; | 1915 read_offset_ += result; |
2119 } else if (result == 0) { // End of file. | 1916 } else if (result == 0) { // End of file. |
2120 RecordHistograms(); | 1917 RecordHistograms(); |
2121 cache_->DoneReadingFromEntry(entry_, this); | 1918 cache_->DoneReadingFromEntry(entry_, this); |
2122 entry_ = NULL; | 1919 entry_ = NULL; |
2123 } else { | 1920 } else { |
2124 return OnCacheReadError(result, false); | 1921 return OnCacheReadError(result, false); |
2125 } | 1922 } |
2126 return result; | 1923 return result; |
2127 } | 1924 } |
2128 | 1925 |
2129 int HttpCache::Transaction::DoCacheWriteData(int num_bytes) { | 1926 int HttpCache::Transaction::DoCacheWriteData(int num_bytes) { |
2130 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
2131 tracked_objects::ScopedTracker tracking_profile( | |
2132 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
2133 "422516 HttpCache::Transaction::DoCacheWriteData")); | |
2134 | |
2135 next_state_ = STATE_CACHE_WRITE_DATA_COMPLETE; | 1927 next_state_ = STATE_CACHE_WRITE_DATA_COMPLETE; |
2136 write_len_ = num_bytes; | 1928 write_len_ = num_bytes; |
2137 if (entry_) { | 1929 if (entry_) { |
2138 if (net_log_.IsLogging()) | 1930 if (net_log_.IsLogging()) |
2139 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA); | 1931 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA); |
2140 } | 1932 } |
2141 | 1933 |
2142 return AppendResponseDataToEntry(read_buf_.get(), num_bytes, io_callback_); | 1934 return AppendResponseDataToEntry(read_buf_.get(), num_bytes, io_callback_); |
2143 } | 1935 } |
2144 | 1936 |
2145 int HttpCache::Transaction::DoCacheWriteDataComplete(int result) { | 1937 int HttpCache::Transaction::DoCacheWriteDataComplete(int result) { |
2146 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
2147 tracked_objects::ScopedTracker tracking_profile( | |
2148 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
2149 "422516 HttpCache::Transaction::DoCacheWriteDataComplete")); | |
2150 | |
2151 if (entry_) { | 1938 if (entry_) { |
2152 if (net_log_.IsLogging()) { | 1939 if (net_log_.IsLogging()) { |
2153 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, | 1940 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, |
2154 result); | 1941 result); |
2155 } | 1942 } |
2156 } | 1943 } |
2157 // Balance the AddRef from DoCacheWriteData. | 1944 // Balance the AddRef from DoCacheWriteData. |
2158 if (!cache_.get()) | 1945 if (!cache_.get()) |
2159 return ERR_UNEXPECTED; | 1946 return ERR_UNEXPECTED; |
2160 | 1947 |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3241 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.Updated", | 3028 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.Updated", |
3242 before_send_sample); | 3029 before_send_sample); |
3243 break; | 3030 break; |
3244 } | 3031 } |
3245 default: | 3032 default: |
3246 NOTREACHED(); | 3033 NOTREACHED(); |
3247 } | 3034 } |
3248 } | 3035 } |
3249 | 3036 |
3250 void HttpCache::Transaction::OnIOComplete(int result) { | 3037 void HttpCache::Transaction::OnIOComplete(int result) { |
3251 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
3252 tracked_objects::ScopedTracker tracking_profile( | |
3253 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 Transaction::OnIOComplete")); | |
3254 | |
3255 DoLoop(result); | 3038 DoLoop(result); |
3256 } | 3039 } |
3257 | 3040 |
3258 } // namespace net | 3041 } // namespace net |
OLD | NEW |