diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 00:03:19 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 00:03:19 +0000 |
commit | 74a85ce422d6b52a79b3cf159203ec7fa35c15ee (patch) | |
tree | e35947baf74dd4325b926bf44a3364ed3cfe4038 /net/disk_cache/disk_cache_perftest.cc | |
parent | 39008c0d7c9f627b6eeef41bd7ddb78b7ebe086d (diff) | |
download | chromium_src-74a85ce422d6b52a79b3cf159203ec7fa35c15ee.zip chromium_src-74a85ce422d6b52a79b3cf159203ec7fa35c15ee.tar.gz chromium_src-74a85ce422d6b52a79b3cf159203ec7fa35c15ee.tar.bz2 |
Extend the IOBuffer to the disk cache.
This is cleanup from bug 5325.
Original code review: http://codereview.chromium.org/20134/show
Review URL: http://codereview.chromium.org/20251
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9626 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/disk_cache_perftest.cc')
-rw-r--r-- | net/disk_cache/disk_cache_perftest.cc | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/net/disk_cache/disk_cache_perftest.cc b/net/disk_cache/disk_cache_perftest.cc index 0a869b2..74cac65 100644 --- a/net/disk_cache/disk_cache_perftest.cc +++ b/net/disk_cache/disk_cache_perftest.cc @@ -11,6 +11,7 @@ #include "base/string_util.h" #include "base/test_file_util.h" #include "base/timer.h" +#include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/disk_cache/block_files.h" #include "net/disk_cache/disk_cache.h" @@ -41,11 +42,12 @@ const int kMaxSize = 16 * 1024 - 1; // to kMaxSize of data to each entry. int TimeWrite(int num_entries, disk_cache::Backend* cache, TestEntries* entries) { - char buffer1[200]; - char buffer2[kMaxSize]; + const int kSize1 = 200; + scoped_refptr<net::IOBuffer> buffer1 = new net::IOBuffer(kSize1); + scoped_refptr<net::IOBuffer> buffer2 = new net::IOBuffer(kMaxSize); - CacheTestFillBuffer(buffer1, sizeof(buffer1), false); - CacheTestFillBuffer(buffer2, sizeof(buffer2), false); + CacheTestFillBuffer(buffer1->data(), kSize1, false); + CacheTestFillBuffer(buffer2->data(), kMaxSize, false); CallbackTest callback(1); g_cache_tests_error = false; @@ -60,17 +62,16 @@ int TimeWrite(int num_entries, disk_cache::Backend* cache, for (int i = 0; i < num_entries; i++) { TestEntry entry; entry.key = GenerateKey(true); - entry.data_len = rand() % sizeof(buffer2); + entry.data_len = rand() % kMaxSize; entries->push_back(entry); disk_cache::Entry* cache_entry; if (!cache->CreateEntry(entry.key, &cache_entry)) break; - int ret = cache_entry->WriteData(0, 0, buffer1, sizeof(buffer1), &callback, - false); + int ret = cache_entry->WriteData(0, 0, buffer1, kSize1, &callback, false); if (net::ERR_IO_PENDING == ret) expected++; - else if (sizeof(buffer1) != ret) + else if (kSize1 != ret) break; ret = cache_entry->WriteData(1, 0, buffer2, entry.data_len, &callback, @@ -91,11 +92,12 @@ int TimeWrite(int num_entries, disk_cache::Backend* cache, // Reads the data and metadata from each entry listed on |entries|. int TimeRead(int num_entries, disk_cache::Backend* cache, const TestEntries& entries, bool cold) { - char buffer1[200]; - char buffer2[kMaxSize]; + const int kSize1 = 200; + scoped_refptr<net::IOBuffer> buffer1 = new net::IOBuffer(kSize1); + scoped_refptr<net::IOBuffer> buffer2 = new net::IOBuffer(kMaxSize); - CacheTestFillBuffer(buffer1, sizeof(buffer1), false); - CacheTestFillBuffer(buffer2, sizeof(buffer2), false); + CacheTestFillBuffer(buffer1->data(), kSize1, false); + CacheTestFillBuffer(buffer2->data(), kMaxSize, false); CallbackTest callback(1); g_cache_tests_error = false; @@ -113,10 +115,10 @@ int TimeRead(int num_entries, disk_cache::Backend* cache, disk_cache::Entry* cache_entry; if (!cache->OpenEntry(entries[i].key, &cache_entry)) break; - int ret = cache_entry->ReadData(0, 0, buffer1, sizeof(buffer1), &callback); + int ret = cache_entry->ReadData(0, 0, buffer1, kSize1, &callback); if (net::ERR_IO_PENDING == ret) expected++; - else if (sizeof(buffer1) != ret) + else if (kSize1 != ret) break; ret = cache_entry->ReadData(1, 0, buffer2, entries[i].data_len, &callback); |