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 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 DoneWritingToEntry(false); | 1602 DoneWritingToEntry(false); |
1603 } | 1603 } |
1604 | 1604 |
1605 if (mode_ == WRITE && | 1605 if (mode_ == WRITE && |
1606 cache_entry_status_ != CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE) { | 1606 cache_entry_status_ != CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE) { |
1607 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_NOT_IN_CACHE); | 1607 UpdateCacheEntryStatus(CacheEntryStatus::ENTRY_NOT_IN_CACHE); |
1608 } | 1608 } |
1609 | 1609 |
1610 // Invalidate any cached GET with a successful PUT or DELETE. | 1610 // Invalidate any cached GET with a successful PUT or DELETE. |
1611 if (mode_ == WRITE && (method_ == "PUT" || method_ == "DELETE")) { | 1611 if (mode_ == WRITE && (method_ == "PUT" || method_ == "DELETE")) { |
1612 if (NonErrorResponse(new_response->headers->response_code())) { | 1612 if (NonErrorResponse(new_response->headers->response_code()) && |
| 1613 (entry_ && !entry_->doomed)) { |
1613 int ret = cache_->DoomEntry(cache_key_, NULL); | 1614 int ret = cache_->DoomEntry(cache_key_, NULL); |
1614 DCHECK_EQ(OK, ret); | 1615 DCHECK_EQ(OK, ret); |
1615 } | 1616 } |
1616 cache_->DoneWritingToEntry(entry_, true, this); | 1617 cache_->DoneWritingToEntry(entry_, true, this); |
1617 entry_ = NULL; | 1618 entry_ = NULL; |
1618 mode_ = NONE; | 1619 mode_ = NONE; |
1619 } | 1620 } |
1620 | 1621 |
1621 // Invalidate any cached GET with a successful POST. | 1622 // Invalidate any cached GET with a successful POST. |
1622 if (!(effective_load_flags_ & LOAD_DISABLE_CACHE) && method_ == "POST" && | 1623 if (!(effective_load_flags_ & LOAD_DISABLE_CACHE) && method_ == "POST" && |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2895 | 2896 |
2896 if (next_state_ == STATE_ADD_TO_ENTRY_COMPLETE) | 2897 if (next_state_ == STATE_ADD_TO_ENTRY_COMPLETE) |
2897 cache_->RemovePendingTransaction(this); | 2898 cache_->RemovePendingTransaction(this); |
2898 else | 2899 else |
2899 cache_->DoneWithEntry(entry_, this, false, partial_ != nullptr); | 2900 cache_->DoneWithEntry(entry_, this, false, partial_ != nullptr); |
2900 OnIOComplete(ERR_CACHE_LOCK_TIMEOUT); | 2901 OnIOComplete(ERR_CACHE_LOCK_TIMEOUT); |
2901 } | 2902 } |
2902 | 2903 |
2903 void HttpCache::Transaction::DoomPartialEntry(bool delete_object) { | 2904 void HttpCache::Transaction::DoomPartialEntry(bool delete_object) { |
2904 DVLOG(2) << "DoomPartialEntry"; | 2905 DVLOG(2) << "DoomPartialEntry"; |
2905 int rv = cache_->DoomEntry(cache_key_, NULL); | 2906 if (entry_ && !entry_->doomed) { |
2906 DCHECK_EQ(OK, rv); | 2907 int rv = cache_->DoomEntry(cache_key_, NULL); |
| 2908 DCHECK_EQ(OK, rv); |
| 2909 } |
2907 cache_->DoneWithEntry(entry_, this, false /* process_cancel */, | 2910 cache_->DoneWithEntry(entry_, this, false /* process_cancel */, |
2908 partial_ != nullptr); | 2911 partial_ != nullptr); |
2909 entry_ = NULL; | 2912 entry_ = NULL; |
2910 is_sparse_ = false; | 2913 is_sparse_ = false; |
2911 truncated_ = false; | 2914 truncated_ = false; |
2912 if (delete_object) | 2915 if (delete_object) |
2913 partial_.reset(NULL); | 2916 partial_.reset(NULL); |
2914 } | 2917 } |
2915 | 2918 |
2916 int HttpCache::Transaction::DoPartialNetworkReadCompleted(int result) { | 2919 int HttpCache::Transaction::DoPartialNetworkReadCompleted(int result) { |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3219 } | 3222 } |
3220 | 3223 |
3221 void HttpCache::Transaction::TransitionToState(State state) { | 3224 void HttpCache::Transaction::TransitionToState(State state) { |
3222 // Ensure that the state is only set once per Do* state. | 3225 // Ensure that the state is only set once per Do* state. |
3223 DCHECK(in_do_loop_); | 3226 DCHECK(in_do_loop_); |
3224 DCHECK_EQ(STATE_UNSET, next_state_) << "Next state is " << state; | 3227 DCHECK_EQ(STATE_UNSET, next_state_) << "Next state is " << state; |
3225 next_state_ = state; | 3228 next_state_ = state; |
3226 } | 3229 } |
3227 | 3230 |
3228 } // namespace net | 3231 } // namespace net |
OLD | NEW |