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" // 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 LoadState state = GetWriterLoadState(); | 466 LoadState state = GetWriterLoadState(); |
467 if (state != LOAD_STATE_WAITING_FOR_CACHE) | 467 if (state != LOAD_STATE_WAITING_FOR_CACHE) |
468 return state; | 468 return state; |
469 | 469 |
470 if (cache_.get()) | 470 if (cache_.get()) |
471 return cache_->GetLoadStateForPendingTransaction(this); | 471 return cache_->GetLoadStateForPendingTransaction(this); |
472 | 472 |
473 return LOAD_STATE_IDLE; | 473 return LOAD_STATE_IDLE; |
474 } | 474 } |
475 | 475 |
476 UploadProgress HttpCache::Transaction::GetUploadProgress() const { | |
477 if (network_trans_.get()) | |
478 return network_trans_->GetUploadProgress(); | |
479 return final_upload_progress_; | |
480 } | |
481 | |
482 void HttpCache::Transaction::SetQuicServerInfo( | 476 void HttpCache::Transaction::SetQuicServerInfo( |
483 QuicServerInfo* quic_server_info) {} | 477 QuicServerInfo* quic_server_info) {} |
484 | 478 |
485 bool HttpCache::Transaction::GetLoadTimingInfo( | 479 bool HttpCache::Transaction::GetLoadTimingInfo( |
486 LoadTimingInfo* load_timing_info) const { | 480 LoadTimingInfo* load_timing_info) const { |
487 if (network_trans_) | 481 if (network_trans_) |
488 return network_trans_->GetLoadTimingInfo(load_timing_info); | 482 return network_trans_->GetLoadTimingInfo(load_timing_info); |
489 | 483 |
490 if (old_network_trans_load_timing_) { | 484 if (old_network_trans_load_timing_) { |
491 *load_timing_info = *old_network_trans_load_timing_; | 485 *load_timing_info = *old_network_trans_load_timing_; |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 // By closing the cached entry now, we make sure that the 304 rather than | 1542 // By closing the cached entry now, we make sure that the 304 rather than |
1549 // the cached 200 response, is what will be returned to the user. | 1543 // the cached 200 response, is what will be returned to the user. |
1550 DoneWritingToEntry(true); | 1544 DoneWritingToEntry(true); |
1551 } else if (entry_ && !handling_206_) { | 1545 } else if (entry_ && !handling_206_) { |
1552 DCHECK_EQ(READ_WRITE, mode_); | 1546 DCHECK_EQ(READ_WRITE, mode_); |
1553 if (!partial_ || partial_->IsLastRange()) { | 1547 if (!partial_ || partial_->IsLastRange()) { |
1554 cache_->ConvertWriterToReader(entry_); | 1548 cache_->ConvertWriterToReader(entry_); |
1555 mode_ = READ; | 1549 mode_ = READ; |
1556 } | 1550 } |
1557 // We no longer need the network transaction, so destroy it. | 1551 // We no longer need the network transaction, so destroy it. |
1558 final_upload_progress_ = network_trans_->GetUploadProgress(); | |
1559 ResetNetworkTransaction(); | 1552 ResetNetworkTransaction(); |
1560 } else if (entry_ && handling_206_ && truncated_ && | 1553 } else if (entry_ && handling_206_ && truncated_ && |
1561 partial_->initial_validation()) { | 1554 partial_->initial_validation()) { |
1562 // We just finished the validation of a truncated entry, and the server | 1555 // We just finished the validation of a truncated entry, and the server |
1563 // is willing to resume the operation. Now we go back and start serving | 1556 // is willing to resume the operation. Now we go back and start serving |
1564 // the first part to the user. | 1557 // the first part to the user. |
1565 ResetNetworkTransaction(); | 1558 ResetNetworkTransaction(); |
1566 new_response_ = NULL; | 1559 new_response_ = NULL; |
1567 next_state_ = STATE_START_PARTIAL_CACHE_VALIDATION; | 1560 next_state_ = STATE_START_PARTIAL_CACHE_VALIDATION; |
1568 partial_->SetRangeToStartDownload(); | 1561 partial_->SetRangeToStartDownload(); |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3020 default: | 3013 default: |
3021 NOTREACHED(); | 3014 NOTREACHED(); |
3022 } | 3015 } |
3023 } | 3016 } |
3024 | 3017 |
3025 void HttpCache::Transaction::OnIOComplete(int result) { | 3018 void HttpCache::Transaction::OnIOComplete(int result) { |
3026 DoLoop(result); | 3019 DoLoop(result); |
3027 } | 3020 } |
3028 | 3021 |
3029 } // namespace net | 3022 } // namespace net |
OLD | NEW |