summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-20 21:24:49 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-20 21:24:49 +0000
commitb07c8d9a926a89d0aa7c0de2e1d2685b728a887e (patch)
tree5eeee9a1bf93c768df34b2064552a94d10968d24 /net
parentf553c3826590d980973269d17be1f09e075f98af (diff)
downloadchromium_src-b07c8d9a926a89d0aa7c0de2e1d2685b728a887e.zip
chromium_src-b07c8d9a926a89d0aa7c0de2e1d2685b728a887e.tar.gz
chromium_src-b07c8d9a926a89d0aa7c0de2e1d2685b728a887e.tar.bz2
Disk cache: Change the request throttling logic so that we
don't post all queued requests when we stop throttling them. BUG=54338 TEST=none Review URL: http://codereview.chromium.org/5993002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69754 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/disk_cache/entry_unittest.cc4
-rw-r--r--net/disk_cache/in_flight_backend_io.cc27
-rw-r--r--net/disk_cache/in_flight_backend_io.h3
3 files changed, 16 insertions, 18 deletions
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc
index 4f4149d..cb7f680 100644
--- a/net/disk_cache/entry_unittest.cc
+++ b/net/disk_cache/entry_unittest.cc
@@ -515,7 +515,7 @@ TEST_F(DiskCacheEntryTest, RequestThrottling) {
int ret = entry->WriteData(0, 0, buffer, kSize, &cb, false);
EXPECT_EQ(net::ERR_IO_PENDING, ret);
}
- // We have 9 queued requests, lets dispatch them all at once.
+ // We have 9 queued requests, let's dispatch them all.
cache_impl_->ThrottleRequestsForTest(false);
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
@@ -858,7 +858,7 @@ void DiskCacheEntryTest::ZeroLengthIO() {
EXPECT_EQ(0, ReadData(entry, 0, 50000, NULL, 0));
EXPECT_EQ(100000, entry->GetDataSize(0));
- // Lets verify the actual content.
+ // Let's verify the actual content.
const int kSize = 20;
const char zeros[kSize] = {};
scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kSize));
diff --git a/net/disk_cache/in_flight_backend_io.cc b/net/disk_cache/in_flight_backend_io.cc
index d83bd10..5752353 100644
--- a/net/disk_cache/in_flight_backend_io.cc
+++ b/net/disk_cache/in_flight_backend_io.cc
@@ -287,6 +287,7 @@ InFlightBackendIO::InFlightBackendIO(BackendImpl* backend,
base::MessageLoopProxy* background_thread)
: backend_(backend),
background_thread_(background_thread),
+ max_queue_len_(0),
queue_entry_ops_(false) {
}
@@ -445,10 +446,16 @@ void InFlightBackendIO::WaitForPendingIO() {
void InFlightBackendIO::StartQueingOperations() {
queue_entry_ops_ = true;
+ CACHE_UMA(COUNTS_10000, "InitialQueuedOperations", 0, pending_ops_.size());
+ if (!pending_ops_.size()) {
+ queueing_start_ = base::TimeTicks::Now();
+ max_queue_len_ = 0;
+ }
}
void InFlightBackendIO::StopQueingOperations() {
queue_entry_ops_ = false;
+ CACHE_UMA(COUNTS_10000, "FinalQueuedOperations", 0, pending_ops_.size());
}
void InFlightBackendIO::OnOperationComplete(BackgroundIO* operation,
@@ -461,13 +468,10 @@ void InFlightBackendIO::OnOperationComplete(BackgroundIO* operation,
// Process the next request. Note that invoking the callback may result
// in the backend destruction (and with it this object), so we should deal
// with the next operation before invoking the callback.
- if (queue_entry_ops_) {
- PostQueuedOperation();
- } else {
- // If we are not throttling requests anymore, dispatch the whole queue.
- CACHE_UMA(COUNTS_10000, "FinalQueuedOperations", 0,
- pending_ops_.size());
- PostAllQueuedOperations();
+ PostQueuedOperation();
+ if (!pending_ops_.size() && !queue_entry_ops_) {
+ CACHE_UMA(AGE_MS, "ThrottleTime", 0, queueing_start_);
+ CACHE_UMA(COUNTS_10000, "MaxQueuedOperations", 0, max_queue_len_);
}
}
}
@@ -498,6 +502,7 @@ void InFlightBackendIO::QueueOperation(BackendIO* operation) {
// We keep the operation that we are executing in the list so that we know
// when it completes.
pending_ops_.push_back(operation);
+ max_queue_len_ = std::max(max_queue_len_, pending_ops_.size());
if (empty_list)
PostOperation(operation);
}
@@ -517,14 +522,6 @@ void InFlightBackendIO::PostQueuedOperation() {
PostOperation(next_op);
}
-void InFlightBackendIO::PostAllQueuedOperations() {
- for (OperationList::iterator it = pending_ops_.begin();
- it != pending_ops_.end(); ++it) {
- PostOperation(*it);
- }
- pending_ops_.clear();
-}
-
bool InFlightBackendIO::RemoveFirstQueuedOperation(BackendIO* operation) {
DCHECK(!pending_ops_.empty());
scoped_refptr<BackendIO> next_op = pending_ops_.front();
diff --git a/net/disk_cache/in_flight_backend_io.h b/net/disk_cache/in_flight_backend_io.h
index ca239dd..7b4b111 100644
--- a/net/disk_cache/in_flight_backend_io.h
+++ b/net/disk_cache/in_flight_backend_io.h
@@ -200,12 +200,13 @@ class InFlightBackendIO : public InFlightIO {
void QueueOperation(BackendIO* operation);
void PostOperation(BackendIO* operation);
void PostQueuedOperation();
- void PostAllQueuedOperations();
bool RemoveFirstQueuedOperation(BackendIO* operation);
BackendImpl* backend_;
scoped_refptr<base::MessageLoopProxy> background_thread_;
OperationList pending_ops_; // Entry (async) operations to be posted.
+ base::TimeTicks queueing_start_;
+ size_t max_queue_len_;
bool queue_entry_ops_; // True if we are queuing entry (async) operations.
DISALLOW_COPY_AND_ASSIGN(InFlightBackendIO);