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 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 partial_->FixResponseHeaders(response_.headers, true); | 1378 partial_->FixResponseHeaders(response_.headers, true); |
1379 } | 1379 } |
1380 return OK; | 1380 return OK; |
1381 } | 1381 } |
1382 | 1382 |
1383 int HttpCache::Transaction::DoCacheReadResponse() { | 1383 int HttpCache::Transaction::DoCacheReadResponse() { |
1384 DCHECK(entry_); | 1384 DCHECK(entry_); |
1385 next_state_ = STATE_CACHE_READ_RESPONSE_COMPLETE; | 1385 next_state_ = STATE_CACHE_READ_RESPONSE_COMPLETE; |
1386 | 1386 |
1387 io_buf_len_ = entry_->disk_entry->GetDataSize(kResponseInfoIndex); | 1387 io_buf_len_ = entry_->disk_entry->GetDataSize(kResponseInfoIndex); |
| 1388 if (io_buf_len_ > 0) { |
| 1389 UMA_HISTOGRAM_BOOLEAN("HttpCache.HeaderTruncated", false); |
| 1390 } else { |
| 1391 UMA_HISTOGRAM_BOOLEAN("HttpCache.HeaderTruncated", true); |
| 1392 DLOG(WARNING) << "Truncated cache entry header encountered"; |
| 1393 mode_ = NONE; |
| 1394 if (partial_.get()) |
| 1395 partial_->RestoreHeaders(&custom_request_->extra_headers); |
| 1396 next_state_ = STATE_SEND_REQUEST; |
| 1397 return OK; |
| 1398 } |
1388 read_buf_ = new IOBuffer(io_buf_len_); | 1399 read_buf_ = new IOBuffer(io_buf_len_); |
1389 | 1400 |
1390 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); | 1401 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); |
1391 ReportCacheActionStart(); | 1402 ReportCacheActionStart(); |
1392 return ResetCacheIOStart( | 1403 return ResetCacheIOStart( |
1393 entry_->disk_entry->ReadData(kResponseInfoIndex, 0, read_buf_, | 1404 entry_->disk_entry->ReadData(kResponseInfoIndex, 0, read_buf_, |
1394 io_buf_len_, io_callback_)); | 1405 io_buf_len_, io_callback_)); |
1395 } | 1406 } |
1396 | 1407 |
1397 int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { | 1408 int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 DoneWritingToEntry(false); | 1486 DoneWritingToEntry(false); |
1476 } | 1487 } |
1477 return OK; | 1488 return OK; |
1478 } | 1489 } |
1479 | 1490 |
1480 int HttpCache::Transaction::DoCacheReadMetadata() { | 1491 int HttpCache::Transaction::DoCacheReadMetadata() { |
1481 DCHECK(entry_); | 1492 DCHECK(entry_); |
1482 DCHECK(!response_.metadata); | 1493 DCHECK(!response_.metadata); |
1483 next_state_ = STATE_CACHE_READ_METADATA_COMPLETE; | 1494 next_state_ = STATE_CACHE_READ_METADATA_COMPLETE; |
1484 | 1495 |
1485 response_.metadata = | 1496 int32 data_size = entry_->disk_entry->GetDataSize(kMetadataIndex); |
1486 new IOBufferWithSize(entry_->disk_entry->GetDataSize(kMetadataIndex)); | 1497 if (data_size > 0) { |
| 1498 UMA_HISTOGRAM_BOOLEAN("HttpCache.MetadataTruncated", false); |
| 1499 } else { |
| 1500 UMA_HISTOGRAM_BOOLEAN("HttpCache.MetadataTruncated", true); |
| 1501 DLOG(WARNING) << "Truncated cache entry metadata encountered"; |
| 1502 mode_ = NONE; |
| 1503 if (partial_.get()) |
| 1504 partial_->RestoreHeaders(&custom_request_->extra_headers); |
| 1505 next_state_ = STATE_SEND_REQUEST; |
| 1506 return OK; |
| 1507 } |
| 1508 response_.metadata = new IOBufferWithSize(data_size); |
1487 | 1509 |
1488 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); | 1510 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); |
1489 ReportCacheActionStart(); | 1511 ReportCacheActionStart(); |
1490 return ResetCacheIOStart( | 1512 return ResetCacheIOStart( |
1491 entry_->disk_entry->ReadData(kMetadataIndex, 0, response_.metadata, | 1513 entry_->disk_entry->ReadData(kMetadataIndex, 0, response_.metadata, |
1492 response_.metadata->size(), | 1514 response_.metadata->size(), |
1493 io_callback_)); | 1515 io_callback_)); |
1494 } | 1516 } |
1495 | 1517 |
1496 int HttpCache::Transaction::DoCacheReadMetadataComplete(int result) { | 1518 int HttpCache::Transaction::DoCacheReadMetadataComplete(int result) { |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2556 } | 2578 } |
2557 | 2579 |
2558 int HttpCache::Transaction::ResetCacheIOStart(int return_value) { | 2580 int HttpCache::Transaction::ResetCacheIOStart(int return_value) { |
2559 DCHECK(cache_io_start_.is_null()); | 2581 DCHECK(cache_io_start_.is_null()); |
2560 if (return_value == ERR_IO_PENDING) | 2582 if (return_value == ERR_IO_PENDING) |
2561 cache_io_start_ = base::TimeTicks::Now(); | 2583 cache_io_start_ = base::TimeTicks::Now(); |
2562 return return_value; | 2584 return return_value; |
2563 } | 2585 } |
2564 | 2586 |
2565 } // namespace net | 2587 } // namespace net |
OLD | NEW |