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" // For OS_POSIX | 7 #include "build/build_config.h" // For OS_POSIX |
8 | 8 |
9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1166 } | 1166 } |
1167 | 1167 |
1168 int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { | 1168 int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { |
1169 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); | 1169 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); |
1170 if (result != io_buf_len_ || | 1170 if (result != io_buf_len_ || |
1171 !HttpCache::ParseResponseInfo(read_buf_->data(), io_buf_len_, &response_, | 1171 !HttpCache::ParseResponseInfo(read_buf_->data(), io_buf_len_, &response_, |
1172 &truncated_)) { | 1172 &truncated_)) { |
1173 return OnCacheReadError(result, true); | 1173 return OnCacheReadError(result, true); |
1174 } | 1174 } |
1175 | 1175 |
1176 const int current_size = | |
1177 entry_->disk_entry->GetDataSize(kResponseContentIndex); | |
1178 const int64_t full_response_length = response_.headers->GetContentLength(); | |
mmenke
2016/06/22 15:50:26
nit: const is generally not used for runtime cons
asanka
2016/06/22 16:31:21
Done.
| |
1179 | |
1176 // Some resources may have slipped in as truncated when they're not. | 1180 // Some resources may have slipped in as truncated when they're not. |
1177 int current_size = entry_->disk_entry->GetDataSize(kResponseContentIndex); | 1181 if (full_response_length == current_size) |
1178 if (response_.headers->GetContentLength() == current_size) | |
1179 truncated_ = false; | 1182 truncated_ = false; |
1180 | 1183 |
1184 // The SM's handling of StopCaching unfortunately doesn't deal well with | |
mmenke
2016/06/22 15:50:26
Please don't use uncommon abbreviations in comment
asanka
2016/06/22 16:31:21
I was trying to be cool and use abbreviations foun
| |
1185 // resources that are larger than 2GB when there is a truncated or sparse | |
1186 // cache entry. While the SM is reworked to resolve this, the following logic | |
1187 // is put in place to defer such requests to the network. The cache should not | |
1188 // be storing multi gigabyte resources. See http://crbug.com/89567. | |
1189 if ((truncated_ || response_.headers->response_code() == 206) && | |
1190 !range_requested_ && | |
1191 full_response_length > std::numeric_limits<int32_t>::max()) { | |
1192 // Does not yield the cache lock. If another transaction starts for this | |
mmenke
2016/06/22 15:50:25
"Does not yield the cache lock" -> "Does not yield
asanka
2016/06/22 16:31:21
Reworded to say 'Does not release the cache entry'
| |
1193 // cache entry while this transaction is active, the second transaction will | |
1194 // fallback to the network after the timeout. | |
mmenke
2016/06/22 15:50:26
fallback -> fall back ("fallback" is a noun)
asanka
2016/06/22 16:31:21
Done.
| |
1195 DCHECK(!partial_.get()); | |
mmenke
2016/06/22 15:50:26
nit: .get() not needed.
asanka
2016/06/22 16:31:21
Done.
| |
1196 mode_ = NONE; | |
1197 next_state_ = STATE_SEND_REQUEST; | |
1198 return OK; | |
1199 } | |
1200 | |
1181 if ((response_.unused_since_prefetch && | 1201 if ((response_.unused_since_prefetch && |
1182 !(request_->load_flags & LOAD_PREFETCH)) || | 1202 !(request_->load_flags & LOAD_PREFETCH)) || |
1183 (!response_.unused_since_prefetch && | 1203 (!response_.unused_since_prefetch && |
1184 (request_->load_flags & LOAD_PREFETCH))) { | 1204 (request_->load_flags & LOAD_PREFETCH))) { |
1185 // Either this is the first use of an entry since it was prefetched or | 1205 // Either this is the first use of an entry since it was prefetched or |
1186 // this is a prefetch. The value of response.unused_since_prefetch is valid | 1206 // this is a prefetch. The value of response.unused_since_prefetch is valid |
1187 // for this transaction but the bit needs to be flipped in storage. | 1207 // for this transaction but the bit needs to be flipped in storage. |
1188 next_state_ = STATE_TOGGLE_UNUSED_SINCE_PREFETCH; | 1208 next_state_ = STATE_TOGGLE_UNUSED_SINCE_PREFETCH; |
1189 return OK; | 1209 return OK; |
1190 } | 1210 } |
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2958 default: | 2978 default: |
2959 NOTREACHED(); | 2979 NOTREACHED(); |
2960 } | 2980 } |
2961 } | 2981 } |
2962 | 2982 |
2963 void HttpCache::Transaction::OnIOComplete(int result) { | 2983 void HttpCache::Transaction::OnIOComplete(int result) { |
2964 DoLoop(result); | 2984 DoLoop(result); |
2965 } | 2985 } |
2966 | 2986 |
2967 } // namespace net | 2987 } // namespace net |
OLD | NEW |