summaryrefslogtreecommitdiffstats
path: root/net/http/http_cache_transaction.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 21:06:24 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 21:06:24 +0000
commit7e6a4f39d228f64a9f666ea8ccbe88bcff3850d2 (patch)
treecdec59f4684bf672a94b37179a5352ab18bb0e58 /net/http/http_cache_transaction.cc
parentc32f04146677ab69289f661de3236fda5791c953 (diff)
downloadchromium_src-7e6a4f39d228f64a9f666ea8ccbe88bcff3850d2.zip
chromium_src-7e6a4f39d228f64a9f666ea8ccbe88bcff3850d2.tar.gz
chromium_src-7e6a4f39d228f64a9f666ea8ccbe88bcff3850d2.tar.bz2
Http Cache: Eliminate EntryAvailable() and make the cache use
callbacks to notify the transaction about the completion of AddTransactionToEntry. BUG=26729 TEST=current tests. Review URL: http://codereview.chromium.org/593058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache_transaction.cc')
-rw-r--r--net/http/http_cache_transaction.cc35
1 files changed, 19 insertions, 16 deletions
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index b35fd55..4870d5b 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -497,28 +497,32 @@ int HttpCache::Transaction::DoCreateEntryComplete(int result) {
int HttpCache::Transaction::DoAddToEntry() {
DCHECK(new_entry_);
cache_pending_ = true;
+ next_state_ = STATE_ADD_TO_ENTRY_COMPLETE;
LoadLog::BeginEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_WAITING);
- int rv = cache_->AddTransactionToEntry(new_entry_, this);
- new_entry_ = NULL;
- return rv;
+ return cache_->AddTransactionToEntry(new_entry_, this);
}
-int HttpCache::Transaction::EntryAvailable(ActiveEntry* entry) {
+int HttpCache::Transaction::DoAddToEntryComplete(int result) {
LoadLog::EndEvent(load_log_, LoadLog::TYPE_HTTP_CACHE_WAITING);
+ DCHECK(new_entry_);
cache_pending_ = false;
- entry_ = entry;
- next_state_ = STATE_ENTRY_AVAILABLE;
- if (new_entry_) {
- // We are inside AddTransactionToEntry() so avoid reentering DoLoop().
- DCHECK_EQ(new_entry_, entry);
+ if (result == ERR_CACHE_RACE) {
+ new_entry_ = NULL;
+ next_state_ = STATE_INIT_ENTRY;
return OK;
}
- return DoLoop(OK);
-}
-int HttpCache::Transaction::DoEntryAvailable() {
- DCHECK(!new_entry_);
+ if (result != OK) {
+ // If there is a failure, the cache should have taken care of new_entry_.
+ NOTREACHED();
+ new_entry_ = NULL;
+ return result;
+ }
+
+ entry_ = new_entry_;
+ new_entry_ = NULL;
+
if (mode_ == WRITE) {
if (partial_.get())
partial_->RestoreHeaders(&custom_request_->extra_headers);
@@ -667,9 +671,8 @@ int HttpCache::Transaction::DoLoop(int result) {
DCHECK_EQ(OK, rv);
rv = DoAddToEntry();
break;
- case STATE_ENTRY_AVAILABLE:
- DCHECK_EQ(OK, rv);
- rv = DoEntryAvailable();
+ case STATE_ADD_TO_ENTRY_COMPLETE:
+ rv = DoAddToEntryComplete(rv);
break;
case STATE_PARTIAL_CACHE_VALIDATION:
DCHECK_EQ(OK, rv);