Index: net/http/http_cache_transaction.cc |
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc |
index 07fa4dbacc4dbb68763c70cfde3c639a809e6677..090e8f25783348beaa5675555556fac47248ec27 100644 |
--- a/net/http/http_cache_transaction.cc |
+++ b/net/http/http_cache_transaction.cc |
@@ -1385,6 +1385,17 @@ int HttpCache::Transaction::DoCacheReadResponse() { |
next_state_ = STATE_CACHE_READ_RESPONSE_COMPLETE; |
io_buf_len_ = entry_->disk_entry->GetDataSize(kResponseInfoIndex); |
+ if (io_buf_len_ > 0) { |
+ UMA_HISTOGRAM_BOOLEAN("HttpCache.HeaderTruncated", false); |
+ } else { |
+ UMA_HISTOGRAM_BOOLEAN("HttpCache.HeaderTruncated", true); |
+ DLOG(WARNING) << "Truncated cache entry header encountered"; |
+ mode_ = NONE; |
+ if (partial_.get()) |
+ partial_->RestoreHeaders(&custom_request_->extra_headers); |
+ next_state_ = STATE_SEND_REQUEST; |
+ return OK; |
+ } |
read_buf_ = new IOBuffer(io_buf_len_); |
net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); |
@@ -1482,8 +1493,19 @@ int HttpCache::Transaction::DoCacheReadMetadata() { |
DCHECK(!response_.metadata); |
next_state_ = STATE_CACHE_READ_METADATA_COMPLETE; |
- response_.metadata = |
- new IOBufferWithSize(entry_->disk_entry->GetDataSize(kMetadataIndex)); |
+ int32 data_size = entry_->disk_entry->GetDataSize(kMetadataIndex); |
+ if (data_size > 0) { |
+ UMA_HISTOGRAM_BOOLEAN("HttpCache.MetadataTruncated", false); |
+ } else { |
+ UMA_HISTOGRAM_BOOLEAN("HttpCache.MetadataTruncated", true); |
+ DLOG(WARNING) << "Truncated cache entry metadata encountered"; |
+ mode_ = NONE; |
+ if (partial_.get()) |
+ partial_->RestoreHeaders(&custom_request_->extra_headers); |
+ next_state_ = STATE_SEND_REQUEST; |
+ return OK; |
+ } |
+ response_.metadata = new IOBufferWithSize(data_size); |
net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); |
ReportCacheActionStart(); |