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