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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 HttpRequestHeaders* headers) const { | 442 HttpRequestHeaders* headers) const { |
443 if (network_trans_) | 443 if (network_trans_) |
444 return network_trans_->GetFullRequestHeaders(headers); | 444 return network_trans_->GetFullRequestHeaders(headers); |
445 | 445 |
446 // TODO(ttuttle): Read headers from cache. | 446 // TODO(ttuttle): Read headers from cache. |
447 return false; | 447 return false; |
448 } | 448 } |
449 | 449 |
450 void HttpCache::Transaction::DoneReading() { | 450 void HttpCache::Transaction::DoneReading() { |
451 if (cache_.get() && entry_) { | 451 if (cache_.get() && entry_) { |
452 DCHECK(reading_); | |
453 DCHECK_NE(mode_, UPDATE); | 452 DCHECK_NE(mode_, UPDATE); |
454 if (mode_ & WRITE) | 453 if (mode_ & WRITE) { |
455 DoneWritingToEntry(true); | 454 DoneWritingToEntry(true); |
| 455 } else { |
| 456 cache_->DoneReadingFromEntry(entry_, this); |
| 457 entry_ = NULL; |
| 458 } |
456 } | 459 } |
457 } | 460 } |
458 | 461 |
459 const HttpResponseInfo* HttpCache::Transaction::GetResponseInfo() const { | 462 const HttpResponseInfo* HttpCache::Transaction::GetResponseInfo() const { |
460 // Null headers means we encountered an error or haven't a response yet | 463 // Null headers means we encountered an error or haven't a response yet |
461 if (auth_response_.headers.get()) | 464 if (auth_response_.headers.get()) |
462 return &auth_response_; | 465 return &auth_response_; |
463 return (response_.headers.get() || response_.ssl_info.cert.get() || | 466 return (response_.headers.get() || response_.ssl_info.cert.get() || |
464 response_.cert_request_info.get()) | 467 response_.cert_request_info.get()) |
465 ? &response_ | 468 ? &response_ |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 | 1336 |
1334 int HttpCache::Transaction::DoTruncateCachedMetadataComplete(int result) { | 1337 int HttpCache::Transaction::DoTruncateCachedMetadataComplete(int result) { |
1335 if (entry_) { | 1338 if (entry_) { |
1336 ReportCacheActionFinish(); | 1339 ReportCacheActionFinish(); |
1337 if (net_log_.IsLoggingAllEvents()) { | 1340 if (net_log_.IsLoggingAllEvents()) { |
1338 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, | 1341 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, |
1339 result); | 1342 result); |
1340 } | 1343 } |
1341 } | 1344 } |
1342 | 1345 |
1343 // If this response is a redirect, then we can stop writing now. (We don't | |
1344 // need to cache the response body of a redirect.) | |
1345 if (response_.headers->IsRedirect(NULL)) | |
1346 DoneWritingToEntry(true); | |
1347 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; | 1346 next_state_ = STATE_PARTIAL_HEADERS_RECEIVED; |
1348 return OK; | 1347 return OK; |
1349 } | 1348 } |
1350 | 1349 |
1351 int HttpCache::Transaction::DoPartialHeadersReceived() { | 1350 int HttpCache::Transaction::DoPartialHeadersReceived() { |
1352 new_response_ = NULL; | 1351 new_response_ = NULL; |
1353 if (entry_ && !partial_.get() && | 1352 if (entry_ && !partial_.get() && |
1354 entry_->disk_entry->GetDataSize(kMetadataIndex)) | 1353 entry_->disk_entry->GetDataSize(kMetadataIndex)) |
1355 next_state_ = STATE_CACHE_READ_METADATA; | 1354 next_state_ = STATE_CACHE_READ_METADATA; |
1356 | 1355 |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2499 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.Updated", | 2498 UMA_HISTOGRAM_PERCENTAGE("HttpCache.PercentBeforeSend.Updated", |
2500 before_send_percent); | 2499 before_send_percent); |
2501 break; | 2500 break; |
2502 } | 2501 } |
2503 default: | 2502 default: |
2504 NOTREACHED(); | 2503 NOTREACHED(); |
2505 } | 2504 } |
2506 } | 2505 } |
2507 | 2506 |
2508 } // namespace net | 2507 } // namespace net |
OLD | NEW |