Chromium Code Reviews| Index: net/http/http_cache_transaction.cc |
| =================================================================== |
| --- net/http/http_cache_transaction.cc (revision 155282) |
| +++ net/http/http_cache_transaction.cc (working copy) |
| @@ -114,13 +114,15 @@ |
| HttpCache::Transaction::Transaction( |
| HttpCache* cache, |
| - HttpTransactionDelegate* transaction_delegate) |
| + HttpTransactionDelegate* transaction_delegate, |
| + InfiniteCacheTransaction* infinite_cache_transaction) |
| : next_state_(STATE_NONE), |
| request_(NULL), |
| cache_(cache->AsWeakPtr()), |
| entry_(NULL), |
| new_entry_(NULL), |
| network_trans_(NULL), |
| + infinite_cache_transaction_(infinite_cache_transaction), |
| new_response_(NULL), |
| mode_(NONE), |
| target_state_(STATE_NONE), |
| @@ -211,6 +213,9 @@ |
| if (done_reading_) |
| return true; |
| + if (infinite_cache_transaction_.get()) |
| + infinite_cache_transaction_->OnTruncatedResponse(); |
| + |
| truncated_ = true; |
| target_state_ = STATE_NONE; |
| next_state_ = STATE_CACHE_WRITE_TRUNCATED_RESPONSE; |
| @@ -246,6 +251,18 @@ |
| return ERR_UNEXPECTED; |
| SetRequest(net_log, request); |
| + if (infinite_cache_transaction_.get()) { |
| + if ((effective_load_flags_ & LOAD_BYPASS_CACHE) || |
|
willchan no longer on Chromium
2012/09/10 20:47:05
I'm not really sure how to evaluate this section o
|
| + (effective_load_flags_ & LOAD_ONLY_FROM_CACHE) || |
| + (effective_load_flags_ & LOAD_DISABLE_CACHE) || |
| + (effective_load_flags_ & LOAD_VALIDATE_CACHE) || |
| + (effective_load_flags_ & LOAD_PREFERRING_CACHE) || |
| + partial_.get()) { |
| + infinite_cache_transaction_.reset(); |
| + } else { |
| + infinite_cache_transaction_->OnRequestStart(request); |
| + } |
| + } |
| // We have to wait until the backend is initialized so we start the SM. |
| next_state_ = STATE_GET_BACKEND; |
| @@ -784,6 +801,9 @@ |
| int HttpCache::Transaction::DoSuccessfulSendRequest() { |
| DCHECK(!new_response_); |
| const HttpResponseInfo* new_response = network_trans_->GetResponseInfo(); |
| + if (infinite_cache_transaction_.get()) |
| + infinite_cache_transaction_->OnResponseReceived(new_response); |
| + |
| if (new_response->headers->response_code() == 401 || |
| new_response->headers->response_code() == 407) { |
| auth_response_ = *new_response; |
| @@ -860,6 +880,9 @@ |
| if (result > 0) |
| bytes_read_from_network_ += result; |
| + if (infinite_cache_transaction_.get()) |
| + infinite_cache_transaction_->OnDataRead(read_buf_->data(), result); |
| + |
| // 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) |
| @@ -1395,6 +1418,9 @@ |
| DCHECK(entry_); |
| next_state_ = STATE_CACHE_READ_DATA_COMPLETE; |
| + if (infinite_cache_transaction_.get()) |
| + infinite_cache_transaction_->OnServedFromCache(); |
| + |
| if (net_log_.IsLoggingAllEvents()) |
| net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_DATA); |
| ReportCacheActionStart(); |