Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: net/http/http_cache_transaction.cc

Issue 8569005: HTTP Cache: Implement StopCaching(), to avoid caching (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_transaction.cc
===================================================================
--- net/http/http_cache_transaction.cc (revision 110637)
+++ net/http/http_cache_transaction.cc (working copy)
@@ -183,7 +183,7 @@
}
bool HttpCache::Transaction::AddTruncatedFlag() {
- DCHECK(mode_ & WRITE);
+ DCHECK(mode_ & WRITE || mode_ == NONE);
// Don't set the flag for sparse entries.
if (partial_.get() && !truncated_)
@@ -362,6 +362,16 @@
}
void HttpCache::Transaction::StopCaching() {
+ // We really don't know where we are now. Hopefully there is no operation in
+ // progress, but nothing really prevents this method to be called after we
+ // returned ERR_IO_PENDING. We cannot attempt to truncate the entry at this
+ // point because we need the state machine for that (and even if we are really
+ // free, that would be an asynchronous operation). In other words, keep the
+ // entry how it is (it will be marked as truncated at destruction), and let
+ // the next piece of code that executes know that we are now reading directly
+ // from the net.
+ if (cache_ && entry_ && (mode_ & WRITE))
+ mode_ = NONE;
}
void HttpCache::Transaction::DoneReading() {
@@ -794,9 +804,9 @@
if (!cache_)
return ERR_UNEXPECTED;
- // If there is an error and we are saving the data, just tell the user about
- // it and wait until the destructor runs to see if we can keep the data.
- if (mode_ != NONE && result < 0)
+ // If there is an error or we aren't saving the data, we are done; just wait
+ // until the destructor runs to see if we can keep the data.
+ if (mode_ == NONE || result < 0)
return result;
next_state_ = STATE_CACHE_WRITE_DATA;
« no previous file with comments | « no previous file | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698