| 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;
|
|
|