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 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 DoneWritingToEntry(false); | 1554 DoneWritingToEntry(false); |
1555 } | 1555 } |
1556 | 1556 |
1557 if (mode_ == WRITE && | 1557 if (mode_ == WRITE && |
1558 cache_entry_status_ != CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE) { | 1558 cache_entry_status_ != CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE) { |
1559 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_NOT_IN_CACHE); | 1559 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_NOT_IN_CACHE); |
1560 } | 1560 } |
1561 | 1561 |
1562 // Invalidate any cached GET with a successful PUT or DELETE. | 1562 // Invalidate any cached GET with a successful PUT or DELETE. |
1563 if (mode_ == WRITE && (method_ == "PUT" || method_ == "DELETE")) { | 1563 if (mode_ == WRITE && (method_ == "PUT" || method_ == "DELETE")) { |
1564 if (NonErrorResponse(new_response->headers->response_code())) { | 1564 if (NonErrorResponse(new_response->headers->response_code()) && |
| 1565 (entry_ && !entry_->doomed)) { |
1565 int ret = cache_->DoomEntry(cache_key_, NULL); | 1566 int ret = cache_->DoomEntry(cache_key_, NULL); |
1566 DCHECK_EQ(OK, ret); | 1567 DCHECK_EQ(OK, ret); |
1567 } | 1568 } |
1568 cache_->DoneWritingToEntry(entry_, true, this); | 1569 cache_->DoneWritingToEntry(entry_, true, this); |
1569 entry_ = NULL; | 1570 entry_ = NULL; |
1570 mode_ = NONE; | 1571 mode_ = NONE; |
1571 } | 1572 } |
1572 | 1573 |
1573 // Invalidate any cached GET with a successful POST. | 1574 // Invalidate any cached GET with a successful POST. |
1574 if (!(effective_load_flags_ & LOAD_DISABLE_CACHE) && method_ == "POST" && | 1575 if (!(effective_load_flags_ & LOAD_DISABLE_CACHE) && method_ == "POST" && |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2839 | 2840 |
2840 if (next_state_ == STATE_ADD_TO_ENTRY_COMPLETE) | 2841 if (next_state_ == STATE_ADD_TO_ENTRY_COMPLETE) |
2841 cache_->RemovePendingTransaction(this); | 2842 cache_->RemovePendingTransaction(this); |
2842 else | 2843 else |
2843 cache_->DoneWithEntry(entry_, this, false, partial_ != nullptr); | 2844 cache_->DoneWithEntry(entry_, this, false, partial_ != nullptr); |
2844 OnIOComplete(ERR_CACHE_LOCK_TIMEOUT); | 2845 OnIOComplete(ERR_CACHE_LOCK_TIMEOUT); |
2845 } | 2846 } |
2846 | 2847 |
2847 void HttpCache::Transaction::DoomPartialEntry(bool delete_object) { | 2848 void HttpCache::Transaction::DoomPartialEntry(bool delete_object) { |
2848 DVLOG(2) << "DoomPartialEntry"; | 2849 DVLOG(2) << "DoomPartialEntry"; |
2849 int rv = cache_->DoomEntry(cache_key_, NULL); | 2850 if (entry_ && !entry_->doomed) { |
2850 DCHECK_EQ(OK, rv); | 2851 int rv = cache_->DoomEntry(cache_key_, NULL); |
| 2852 DCHECK_EQ(OK, rv); |
| 2853 } |
2851 cache_->DoneWithEntry(entry_, this, false /* process_cancel */, | 2854 cache_->DoneWithEntry(entry_, this, false /* process_cancel */, |
2852 partial_ != nullptr); | 2855 partial_ != nullptr); |
2853 entry_ = NULL; | 2856 entry_ = NULL; |
2854 is_sparse_ = false; | 2857 is_sparse_ = false; |
2855 truncated_ = false; | 2858 truncated_ = false; |
2856 if (delete_object) | 2859 if (delete_object) |
2857 partial_.reset(NULL); | 2860 partial_.reset(NULL); |
2858 } | 2861 } |
2859 | 2862 |
2860 int HttpCache::Transaction::DoPartialNetworkReadCompleted(int result) { | 2863 int HttpCache::Transaction::DoPartialNetworkReadCompleted(int result) { |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3163 } | 3166 } |
3164 | 3167 |
3165 void HttpCache::Transaction::TransitionToState(State state) { | 3168 void HttpCache::Transaction::TransitionToState(State state) { |
3166 // Ensure that the state is only set once per Do* state. | 3169 // Ensure that the state is only set once per Do* state. |
3167 DCHECK(in_do_loop_); | 3170 DCHECK(in_do_loop_); |
3168 DCHECK_EQ(STATE_UNSET, next_state_) << "Next state is " << state; | 3171 DCHECK_EQ(STATE_UNSET, next_state_) << "Next state is " << state; |
3169 next_state_ = state; | 3172 next_state_ = state; |
3170 } | 3173 } |
3171 | 3174 |
3172 } // namespace net | 3175 } // namespace net |
OLD | NEW |