summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authordharani@google.com <dharani@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-12 04:00:17 +0000
committerdharani@google.com <dharani@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-12 04:00:17 +0000
commite58d994f9bed7226a0e18a991135529d42c2d75b (patch)
tree9fa77b8958cc59d961f138895d923c830243244f /net/http
parent137c1e7c75ea4af3e776dba084c8167c6fcc923c (diff)
downloadchromium_src-e58d994f9bed7226a0e18a991135529d42c2d75b.zip
chromium_src-e58d994f9bed7226a0e18a991135529d42c2d75b.tar.gz
chromium_src-e58d994f9bed7226a0e18a991135529d42c2d75b.tar.bz2
Revert 167031 - For Cache Sensitivity Analysis, fix createentry/openentry race condition
related to AddToEntry. Revert reason: check bug 160398 R=rvargas Review URL: https://codereview.chromium.org/11369141 TBR=tburkard@chromium.org Review URL: https://codereview.chromium.org/11364198 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167140 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_cache_transaction.cc48
-rw-r--r--net/http/http_cache_transaction.h13
2 files changed, 16 insertions, 45 deletions
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index f109fc3..025f869 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -147,7 +147,6 @@ HttpCache::Transaction::Transaction(
transaction_pattern_(PATTERN_UNDEFINED),
bytes_read_from_cache_(0),
bytes_read_from_network_(0),
- defer_cache_sensitivity_delay_(false),
transaction_delegate_(transaction_delegate) {
COMPILE_ASSERT(HttpCache::Transaction::kNumValidationHeaders ==
arraysize(kValidationHeaders),
@@ -164,7 +163,6 @@ HttpCache::Transaction::~Transaction() {
transaction_delegate_ = NULL;
cache_io_start_ = base::TimeTicks();
- deferred_cache_sensitivity_delay_ = base::TimeDelta();
if (cache_) {
if (entry_) {
@@ -925,8 +923,7 @@ int HttpCache::Transaction::DoOpenEntry() {
net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY);
first_cache_access_since_ = TimeTicks::Now();
ReportCacheActionStart();
- defer_cache_sensitivity_delay_ = true;
- return ResetCacheIOStart(cache_->OpenEntry(cache_key_, &new_entry_, this));
+ return cache_->OpenEntry(cache_key_, &new_entry_, this);
}
int HttpCache::Transaction::DoOpenEntryComplete(int result) {
@@ -978,8 +975,7 @@ int HttpCache::Transaction::DoCreateEntry() {
cache_pending_ = true;
net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY);
ReportCacheActionStart();
- defer_cache_sensitivity_delay_ = true;
- return ResetCacheIOStart(cache_->CreateEntry(cache_key_, &new_entry_, this));
+ return cache_->CreateEntry(cache_key_, &new_entry_, this);
}
int HttpCache::Transaction::DoCreateEntryComplete(int result) {
@@ -1018,7 +1014,7 @@ int HttpCache::Transaction::DoDoomEntry() {
first_cache_access_since_ = TimeTicks::Now();
net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY);
ReportCacheActionStart();
- return ResetCacheIOStart(cache_->DoomEntry(cache_key_, this));
+ return cache_->DoomEntry(cache_key_, this);
}
int HttpCache::Transaction::DoDoomEntryComplete(int result) {
@@ -1044,15 +1040,7 @@ int HttpCache::Transaction::DoAddToEntry() {
int HttpCache::Transaction::DoAddToEntryComplete(int result) {
net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY,
result);
- if (deferred_cache_sensitivity_delay_ != base::TimeDelta()) {
- next_state_ = STATE_ADD_TO_ENTRY_COMPLETE;
- base::TimeDelta delay = deferred_cache_sensitivity_delay_;
- deferred_cache_sensitivity_delay_ = base::TimeDelta();
- ScheduleDelayedLoop(delay, result);
- return ERR_IO_PENDING;
- }
- DCHECK(defer_cache_sensitivity_delay_);
- defer_cache_sensitivity_delay_ = false;
+
const TimeDelta entry_lock_wait =
TimeTicks::Now() - entry_lock_waiting_since_;
UMA_HISTOGRAM_TIMES("HttpCache.EntryLockWait", entry_lock_wait);
@@ -2301,30 +2289,21 @@ void HttpCache::Transaction::OnIOComplete(int result) {
if (sensitivity_analysis_percent_increase_ > 0) {
cache_time *= sensitivity_analysis_percent_increase_;
cache_time /= 100;
- if (!defer_cache_sensitivity_delay_) {
- ScheduleDelayedLoop(cache_time, result);
- return;
- } else {
- deferred_cache_sensitivity_delay_ += cache_time;
- }
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&HttpCache::Transaction::RunDelayedLoop,
+ weak_factory_.GetWeakPtr(),
+ base::TimeTicks::Now(),
+ cache_time,
+ result),
+ cache_time);
+ return;
}
}
DCHECK(cache_io_start_.is_null());
DoLoop(result);
}
-void HttpCache::Transaction::ScheduleDelayedLoop(base::TimeDelta delay,
- int result) {
- MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&HttpCache::Transaction::RunDelayedLoop,
- weak_factory_.GetWeakPtr(),
- base::TimeTicks::Now(),
- delay,
- result),
- delay);
-}
-
void HttpCache::Transaction::RunDelayedLoop(base::TimeTicks delay_start_time,
base::TimeDelta intended_delay,
int result) {
@@ -2361,7 +2340,6 @@ void HttpCache::Transaction::RunDelayedLoop(base::TimeTicks delay_start_time,
}
DCHECK(cache_io_start_.is_null());
- DCHECK(deferred_cache_sensitivity_delay_ == base::TimeDelta());
DoLoop(result);
}
diff --git a/net/http/http_cache_transaction.h b/net/http/http_cache_transaction.h
index 84fa230..7046a93 100644
--- a/net/http/http_cache_transaction.h
+++ b/net/http/http_cache_transaction.h
@@ -367,10 +367,6 @@ class HttpCache::Transaction : public HttpTransaction {
// Returns |return_value|.
int ResetCacheIOStart(int return_value);
- void ScheduleDelayedLoop(base::TimeDelta delay, int result);
- void RunDelayedLoop(base::TimeTicks delay_start_time,
- base::TimeDelta intended_delay, int result);
-
State next_state_;
const HttpRequestInfo* request_;
BoundNetLog net_log_;
@@ -422,16 +418,13 @@ class HttpCache::Transaction : public HttpTransaction {
// if no cache IO action is currently in progress.
base::TimeTicks cache_io_start_;
- // For OpenEntry and CreateEntry, if sensitivity analysis would mandate
- // a delay on return, we must defer that delay until AddToEntry has been
- // called, to avoid a race condition on the address returned.
- base::TimeDelta deferred_cache_sensitivity_delay_;
- bool defer_cache_sensitivity_delay_;
-
// For sensitivity analysis, the simulated increase in cache service times,
// in percent.
int sensitivity_analysis_percent_increase_;
+ void RunDelayedLoop(base::TimeTicks delay_start_time,
+ base::TimeDelta intended_delay, int result);
+
HttpTransactionDelegate* transaction_delegate_;
};