summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-09 02:35:24 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-09 02:35:24 +0000
commit5147c47289ff5694f7bad0ef2dda3cedc524e635 (patch)
tree49c77eb1a903871f9927572fa30083a01a80b0ea /net/disk_cache
parent0ef6505463da88209fae979b265b599f1dec08fb (diff)
downloadchromium_src-5147c47289ff5694f7bad0ef2dda3cedc524e635.zip
chromium_src-5147c47289ff5694f7bad0ef2dda3cedc524e635.tar.gz
chromium_src-5147c47289ff5694f7bad0ef2dda3cedc524e635.tar.bz2
Disk Cache: Simplify CallbackTest.
Remove the callback id... it's not useful anymore. BUG=none TEST=current unit tests. Review URL: http://codereview.chromium.org/118407 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17924 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r--net/disk_cache/disk_cache_perftest.cc7
-rw-r--r--net/disk_cache/disk_cache_test_util.cc6
-rw-r--r--net/disk_cache/disk_cache_test_util.h6
-rw-r--r--net/disk_cache/entry_unittest.cc57
4 files changed, 28 insertions, 48 deletions
diff --git a/net/disk_cache/disk_cache_perftest.cc b/net/disk_cache/disk_cache_perftest.cc
index b9997c4..34b69d7 100644
--- a/net/disk_cache/disk_cache_perftest.cc
+++ b/net/disk_cache/disk_cache_perftest.cc
@@ -22,7 +22,6 @@
using base::Time;
-extern int g_cache_tests_max_id;
extern volatile int g_cache_tests_received;
extern volatile bool g_cache_tests_error;
@@ -49,9 +48,8 @@ int TimeWrite(int num_entries, disk_cache::Backend* cache,
CacheTestFillBuffer(buffer1->data(), kSize1, false);
CacheTestFillBuffer(buffer2->data(), kMaxSize, false);
- CallbackTest callback(1);
+ CallbackTest callback(true);
g_cache_tests_error = false;
- g_cache_tests_max_id = 1;
g_cache_tests_received = 0;
int expected = 0;
@@ -99,9 +97,8 @@ int TimeRead(int num_entries, disk_cache::Backend* cache,
CacheTestFillBuffer(buffer1->data(), kSize1, false);
CacheTestFillBuffer(buffer2->data(), kMaxSize, false);
- CallbackTest callback(1);
+ CallbackTest callback(true);
g_cache_tests_error = false;
- g_cache_tests_max_id = 1;
g_cache_tests_received = 0;
int expected = 0;
diff --git a/net/disk_cache/disk_cache_test_util.cc b/net/disk_cache/disk_cache_test_util.cc
index 99c4500..b05f59d 100644
--- a/net/disk_cache/disk_cache_test_util.cc
+++ b/net/disk_cache/disk_cache_test_util.cc
@@ -105,17 +105,13 @@ ScopedTestCache::~ScopedTestCache() {
// -----------------------------------------------------------------------
-int g_cache_tests_max_id = 0;
volatile int g_cache_tests_received = 0;
volatile bool g_cache_tests_error = 0;
// On the actual callback, increase the number of tests received and check for
// errors (an unexpected test received)
void CallbackTest::RunWithParams(const Tuple1<int>& params) {
- if (id_ > g_cache_tests_max_id) {
- NOTREACHED();
- g_cache_tests_error = true;
- } else if (reuse_) {
+ if (reuse_) {
DCHECK(1 == reuse_);
if (2 == reuse_)
g_cache_tests_error = true;
diff --git a/net/disk_cache/disk_cache_test_util.h b/net/disk_cache/disk_cache_test_util.h
index ed960fd..45abe5b 100644
--- a/net/disk_cache/disk_cache_test_util.h
+++ b/net/disk_cache/disk_cache_test_util.h
@@ -56,14 +56,14 @@ class ScopedTestCache {
// Simple callback to process IO completions from the cache.
class CallbackTest : public CallbackRunner< Tuple1<int> > {
public:
- explicit CallbackTest(int id) : id_(id), reuse_(0) {}
- explicit CallbackTest(int id, bool reuse) : id_(id), reuse_(reuse ? 0 : 1) {}
+ explicit CallbackTest(bool reuse) : result_(-1), reuse_(reuse ? 0 : 1) {}
~CallbackTest() {}
virtual void RunWithParams(const Tuple1<int>& params);
+ int result() const { return result_; }
private:
- int id_;
+ int result_;
int reuse_;
DISALLOW_COPY_AND_ASSIGN(CallbackTest);
};
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc
index e48acb5..17bb4e9 100644
--- a/net/disk_cache/entry_unittest.cc
+++ b/net/disk_cache/entry_unittest.cc
@@ -15,7 +15,6 @@
using base::Time;
-extern int g_cache_tests_max_id;
extern volatile int g_cache_tests_received;
extern volatile bool g_cache_tests_error;
@@ -95,22 +94,21 @@ void DiskCacheEntryTest::InternalAsyncIO() {
ASSERT_TRUE(NULL != entry1);
// Let's verify that each IO goes to the right callback object.
- CallbackTest callback1(1, false);
- CallbackTest callback2(2, false);
- CallbackTest callback3(3, false);
- CallbackTest callback4(4, false);
- CallbackTest callback5(5, false);
- CallbackTest callback6(6, false);
- CallbackTest callback7(7, false);
- CallbackTest callback8(8, false);
- CallbackTest callback9(9, false);
- CallbackTest callback10(10, false);
- CallbackTest callback11(11, false);
- CallbackTest callback12(12, false);
- CallbackTest callback13(13, false);
+ CallbackTest callback1(false);
+ CallbackTest callback2(false);
+ CallbackTest callback3(false);
+ CallbackTest callback4(false);
+ CallbackTest callback5(false);
+ CallbackTest callback6(false);
+ CallbackTest callback7(false);
+ CallbackTest callback8(false);
+ CallbackTest callback9(false);
+ CallbackTest callback10(false);
+ CallbackTest callback11(false);
+ CallbackTest callback12(false);
+ CallbackTest callback13(false);
g_cache_tests_error = false;
- g_cache_tests_max_id = 0;
g_cache_tests_received = 0;
MessageLoopHelper helper;
@@ -139,7 +137,6 @@ void DiskCacheEntryTest::InternalAsyncIO() {
if (net::ERR_IO_PENDING == ret)
expected++;
- g_cache_tests_max_id = 3;
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
EXPECT_STREQ("the data", buffer2->data());
@@ -155,7 +152,6 @@ void DiskCacheEntryTest::InternalAsyncIO() {
if (net::ERR_IO_PENDING == ret)
expected++;
- g_cache_tests_max_id = 5;
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
EXPECT_STREQ("big data goes here", buffer3->data());
ret = entry1->ReadData(1, 0, buffer2, kSize2, &callback6);
@@ -165,7 +161,6 @@ void DiskCacheEntryTest::InternalAsyncIO() {
memset(buffer3->data(), 0, kSize3);
- g_cache_tests_max_id = 6;
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
EXPECT_EQ(0, memcmp(buffer2->data(), buffer3->data(), 1500));
ret = entry1->ReadData(1, 5000, buffer2, kSize2, &callback7);
@@ -201,7 +196,6 @@ void DiskCacheEntryTest::InternalAsyncIO() {
if (net::ERR_IO_PENDING == ret)
expected++;
- g_cache_tests_max_id = 13;
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
EXPECT_FALSE(g_cache_tests_error);
@@ -274,18 +268,17 @@ void DiskCacheEntryTest::ExternalAsyncIO() {
ASSERT_TRUE(cache_->CreateEntry("the first key", &entry1));
// Let's verify that each IO goes to the right callback object.
- CallbackTest callback1(1, false);
- CallbackTest callback2(2, false);
- CallbackTest callback3(3, false);
- CallbackTest callback4(4, false);
- CallbackTest callback5(5, false);
- CallbackTest callback6(6, false);
- CallbackTest callback7(7, false);
- CallbackTest callback8(8, false);
- CallbackTest callback9(9, false);
+ CallbackTest callback1(false);
+ CallbackTest callback2(false);
+ CallbackTest callback3(false);
+ CallbackTest callback4(false);
+ CallbackTest callback5(false);
+ CallbackTest callback6(false);
+ CallbackTest callback7(false);
+ CallbackTest callback8(false);
+ CallbackTest callback9(false);
g_cache_tests_error = false;
- g_cache_tests_max_id = 0;
g_cache_tests_received = 0;
int expected = 0;
@@ -306,7 +299,6 @@ void DiskCacheEntryTest::ExternalAsyncIO() {
if (net::ERR_IO_PENDING == ret)
expected++;
- g_cache_tests_max_id = 1;
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
memset(buffer2->data(), 0, kSize1);
@@ -315,7 +307,6 @@ void DiskCacheEntryTest::ExternalAsyncIO() {
if (net::ERR_IO_PENDING == ret)
expected++;
- g_cache_tests_max_id = 2;
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
EXPECT_STREQ("the data", buffer1->data());
@@ -325,7 +316,6 @@ void DiskCacheEntryTest::ExternalAsyncIO() {
if (net::ERR_IO_PENDING == ret)
expected++;
- g_cache_tests_max_id = 3;
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
memset(buffer3->data(), 0, kSize3);
@@ -334,7 +324,6 @@ void DiskCacheEntryTest::ExternalAsyncIO() {
if (net::ERR_IO_PENDING == ret)
expected++;
- g_cache_tests_max_id = 4;
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
EXPECT_STREQ("big data goes here", buffer3->data());
ret = entry1->ReadData(1, 0, buffer2, kSize2, &callback5);
@@ -342,7 +331,6 @@ void DiskCacheEntryTest::ExternalAsyncIO() {
if (net::ERR_IO_PENDING == ret)
expected++;
- g_cache_tests_max_id = 5;
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
EXPECT_EQ(0, memcmp(buffer2->data(), buffer2->data(), 10000));
ret = entry1->ReadData(1, 30000, buffer2, kSize2, &callback6);
@@ -361,7 +349,6 @@ void DiskCacheEntryTest::ExternalAsyncIO() {
expected++;
EXPECT_EQ(37000, entry1->GetDataSize(1));
- g_cache_tests_max_id = 9;
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
EXPECT_FALSE(g_cache_tests_error);