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

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

Issue 1072423005: Set network_accessed earlier, when network transaction creates stream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't break build on iOS Created 5 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
« no previous file with comments | « net/http/failing_http_transaction_factory.cc ('k') | net/http/http_network_layer_unittest.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_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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 cache_->DoneReadingFromEntry(entry_, this); 566 cache_->DoneReadingFromEntry(entry_, this);
567 entry_ = NULL; 567 entry_ = NULL;
568 } 568 }
569 } 569 }
570 } 570 }
571 571
572 const HttpResponseInfo* HttpCache::Transaction::GetResponseInfo() const { 572 const HttpResponseInfo* HttpCache::Transaction::GetResponseInfo() const {
573 // Null headers means we encountered an error or haven't a response yet 573 // Null headers means we encountered an error or haven't a response yet
574 if (auth_response_.headers.get()) 574 if (auth_response_.headers.get())
575 return &auth_response_; 575 return &auth_response_;
576 return (response_.headers.get() || response_.ssl_info.cert.get() || 576 return &response_;
577 response_.cert_request_info.get())
578 ? &response_
579 : NULL;
580 } 577 }
581 578
582 LoadState HttpCache::Transaction::GetLoadState() const { 579 LoadState HttpCache::Transaction::GetLoadState() const {
583 LoadState state = GetWriterLoadState(); 580 LoadState state = GetWriterLoadState();
584 if (state != LOAD_STATE_WAITING_FOR_CACHE) 581 if (state != LOAD_STATE_WAITING_FOR_CACHE)
585 return state; 582 return state;
586 583
587 if (cache_.get()) 584 if (cache_.get())
588 return cache_->GetLoadStateForPendingTransaction(this); 585 return cache_->GetLoadStateForPendingTransaction(this);
589 586
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 // If we tried to conditionalize the request and failed, we know 1082 // If we tried to conditionalize the request and failed, we know
1086 // we won't be reading from the cache after this point. 1083 // we won't be reading from the cache after this point.
1087 if (couldnt_conditionalize_request_) 1084 if (couldnt_conditionalize_request_)
1088 mode_ = WRITE; 1085 mode_ = WRITE;
1089 1086
1090 if (result == OK) { 1087 if (result == OK) {
1091 next_state_ = STATE_SUCCESSFUL_SEND_REQUEST; 1088 next_state_ = STATE_SUCCESSFUL_SEND_REQUEST;
1092 return OK; 1089 return OK;
1093 } 1090 }
1094 1091
1092 const HttpResponseInfo* response = network_trans_->GetResponseInfo();
1093 response_.network_accessed = response->network_accessed;
1094
1095 // Do not record requests that have network errors or restarts. 1095 // Do not record requests that have network errors or restarts.
1096 UpdateTransactionPattern(PATTERN_NOT_COVERED); 1096 UpdateTransactionPattern(PATTERN_NOT_COVERED);
1097 if (IsCertificateError(result)) { 1097 if (IsCertificateError(result)) {
1098 const HttpResponseInfo* response = network_trans_->GetResponseInfo();
1099 // If we get a certificate error, then there is a certificate in ssl_info, 1098 // If we get a certificate error, then there is a certificate in ssl_info,
1100 // so GetResponseInfo() should never return NULL here. 1099 // so GetResponseInfo() should never return NULL here.
1101 DCHECK(response); 1100 DCHECK(response);
1102 response_.ssl_info = response->ssl_info; 1101 response_.ssl_info = response->ssl_info;
1103 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { 1102 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
1104 const HttpResponseInfo* response = network_trans_->GetResponseInfo();
1105 DCHECK(response); 1103 DCHECK(response);
1106 response_.cert_request_info = response->cert_request_info; 1104 response_.cert_request_info = response->cert_request_info;
1107 } else if (response_.was_cached) { 1105 } else if (response_.was_cached) {
1108 DoneWritingToEntry(true); 1106 DoneWritingToEntry(true);
1109 } 1107 }
1108
1110 return result; 1109 return result;
1111 } 1110 }
1112 1111
1113 // We received the response headers and there is no error. 1112 // We received the response headers and there is no error.
1114 int HttpCache::Transaction::DoSuccessfulSendRequest() { 1113 int HttpCache::Transaction::DoSuccessfulSendRequest() {
1115 DCHECK(!new_response_); 1114 DCHECK(!new_response_);
1116 const HttpResponseInfo* new_response = network_trans_->GetResponseInfo(); 1115 const HttpResponseInfo* new_response = network_trans_->GetResponseInfo();
1117 bool authentication_failure = false; 1116 bool authentication_failure = false;
1118 1117
1119 if (new_response->headers->response_code() == 401 || 1118 if (new_response->headers->response_code() == 401 ||
(...skipping 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 default: 2978 default:
2980 NOTREACHED(); 2979 NOTREACHED();
2981 } 2980 }
2982 } 2981 }
2983 2982
2984 void HttpCache::Transaction::OnIOComplete(int result) { 2983 void HttpCache::Transaction::OnIOComplete(int result) {
2985 DoLoop(result); 2984 DoLoop(result);
2986 } 2985 }
2987 2986
2988 } // namespace net 2987 } // namespace net
OLDNEW
« no previous file with comments | « net/http/failing_http_transaction_factory.cc ('k') | net/http/http_network_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698