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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1075 | 1072 |
1076 next_state_ = STATE_SEND_REQUEST_COMPLETE; | 1073 next_state_ = STATE_SEND_REQUEST_COMPLETE; |
1077 rv = network_trans_->Start(request_, io_callback_, net_log_); | 1074 rv = network_trans_->Start(request_, io_callback_, net_log_); |
1078 return rv; | 1075 return rv; |
1079 } | 1076 } |
1080 | 1077 |
1081 int HttpCache::Transaction::DoSendRequestComplete(int result) { | 1078 int HttpCache::Transaction::DoSendRequestComplete(int result) { |
1082 if (!cache_.get()) | 1079 if (!cache_.get()) |
1083 return ERR_UNEXPECTED; | 1080 return ERR_UNEXPECTED; |
1084 | 1081 |
1082 const HttpResponseInfo* response = network_trans_->GetResponseInfo(); | |
1083 if (response) | |
davidben
2015/05/14 22:28:14
This can't ever be NULL, can it? That one testing
Deprecated (see juliatuttle)
2015/05/14 23:52:10
Not anymore, no.
| |
1084 response_.network_accessed = response->network_accessed; | |
1085 | |
davidben
2015/05/14 22:28:14
Let's move this after line 1094. In the non-error
Deprecated (see juliatuttle)
2015/05/14 23:52:10
Done.
| |
1085 // If we tried to conditionalize the request and failed, we know | 1086 // If we tried to conditionalize the request and failed, we know |
1086 // we won't be reading from the cache after this point. | 1087 // we won't be reading from the cache after this point. |
1087 if (couldnt_conditionalize_request_) | 1088 if (couldnt_conditionalize_request_) |
1088 mode_ = WRITE; | 1089 mode_ = WRITE; |
1089 | 1090 |
1090 if (result == OK) { | 1091 if (result == OK) { |
1091 next_state_ = STATE_SUCCESSFUL_SEND_REQUEST; | 1092 next_state_ = STATE_SUCCESSFUL_SEND_REQUEST; |
1092 return OK; | 1093 return OK; |
1093 } | 1094 } |
1094 | 1095 |
1095 // Do not record requests that have network errors or restarts. | 1096 // Do not record requests that have network errors or restarts. |
1096 UpdateTransactionPattern(PATTERN_NOT_COVERED); | 1097 UpdateTransactionPattern(PATTERN_NOT_COVERED); |
1097 if (IsCertificateError(result)) { | 1098 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, | 1099 // If we get a certificate error, then there is a certificate in ssl_info, |
1100 // so GetResponseInfo() should never return NULL here. | 1100 // so GetResponseInfo() should never return NULL here. |
1101 DCHECK(response); | 1101 DCHECK(response); |
1102 response_.ssl_info = response->ssl_info; | 1102 response_.ssl_info = response->ssl_info; |
1103 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { | 1103 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { |
1104 const HttpResponseInfo* response = network_trans_->GetResponseInfo(); | |
1105 DCHECK(response); | 1104 DCHECK(response); |
1106 response_.cert_request_info = response->cert_request_info; | 1105 response_.cert_request_info = response->cert_request_info; |
1107 } else if (response_.was_cached) { | 1106 } else if (response_.was_cached) { |
1108 DoneWritingToEntry(true); | 1107 DoneWritingToEntry(true); |
1109 } | 1108 } |
1109 | |
1110 return result; | 1110 return result; |
1111 } | 1111 } |
1112 | 1112 |
1113 // We received the response headers and there is no error. | 1113 // We received the response headers and there is no error. |
1114 int HttpCache::Transaction::DoSuccessfulSendRequest() { | 1114 int HttpCache::Transaction::DoSuccessfulSendRequest() { |
1115 DCHECK(!new_response_); | 1115 DCHECK(!new_response_); |
1116 const HttpResponseInfo* new_response = network_trans_->GetResponseInfo(); | 1116 const HttpResponseInfo* new_response = network_trans_->GetResponseInfo(); |
1117 bool authentication_failure = false; | 1117 bool authentication_failure = false; |
1118 | 1118 |
1119 if (new_response->headers->response_code() == 401 || | 1119 if (new_response->headers->response_code() == 401 || |
(...skipping 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2979 default: | 2979 default: |
2980 NOTREACHED(); | 2980 NOTREACHED(); |
2981 } | 2981 } |
2982 } | 2982 } |
2983 | 2983 |
2984 void HttpCache::Transaction::OnIOComplete(int result) { | 2984 void HttpCache::Transaction::OnIOComplete(int result) { |
2985 DoLoop(result); | 2985 DoLoop(result); |
2986 } | 2986 } |
2987 | 2987 |
2988 } // namespace net | 2988 } // namespace net |
OLD | NEW |