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

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

Issue 2089783002: [net/cache] Avoid the cache for responses exceeding 2GB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build for configurations where DCHECK is disabled. Created 4 years, 5 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 | « no previous file | net/http/http_cache_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" // 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
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 int current_size = entry_->disk_entry->GetDataSize(kResponseContentIndex);
1177 int64_t full_response_length = response_.headers->GetContentLength();
1178
1176 // Some resources may have slipped in as truncated when they're not. 1179 // Some resources may have slipped in as truncated when they're not.
1177 int current_size = entry_->disk_entry->GetDataSize(kResponseContentIndex); 1180 if (full_response_length == current_size)
1178 if (response_.headers->GetContentLength() == current_size)
1179 truncated_ = false; 1181 truncated_ = false;
1180 1182
1183 // The state machine's handling of StopCaching unfortunately doesn't deal well
1184 // with resources that are larger than 2GB when there is a truncated or sparse
1185 // cache entry. While the state machine is reworked to resolve this, the
1186 // following logic is put in place to defer such requests to the network. The
1187 // cache should not be storing multi gigabyte resources. See
1188 // 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 release the cache entry. If another transaction wants to use
1193 // this cache entry while this transaction is active, the second transaction
1194 // will fall back to the network after the timeout.
1195 DCHECK(!partial_);
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
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
OLDNEW
« no previous file with comments | « no previous file | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698