Index: net/disk_cache/blockfile/disk_cache_perftest.cc |
diff --git a/net/disk_cache/blockfile/disk_cache_perftest.cc b/net/disk_cache/blockfile/disk_cache_perftest.cc |
index 5087001a1306bb97e12da6664708b8c0dbeea979..3c4ac78b1f9c4ef1844ed5e1f53c69223320e816 100644 |
--- a/net/disk_cache/blockfile/disk_cache_perftest.cc |
+++ b/net/disk_cache/blockfile/disk_cache_perftest.cc |
@@ -20,13 +20,15 @@ |
#include "net/disk_cache/blockfile/backend_impl.h" |
#include "net/disk_cache/blockfile/block_files.h" |
#include "net/disk_cache/disk_cache.h" |
-#include "net/disk_cache/disk_cache_test_base.h" |
+#include "net/disk_cache/disk_cache_test.h" |
#include "net/disk_cache/disk_cache_test_util.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "testing/platform_test.h" |
using base::Time; |
+namespace disk_cache { |
+ |
namespace { |
struct TestEntry { |
@@ -39,7 +41,7 @@ const int kMaxSize = 16 * 1024 - 1; |
// Creates num_entries on the cache, and writes 200 bytes of metadata and up |
// to kMaxSize of data to each entry. |
-bool TimeWrite(int num_entries, disk_cache::Backend* cache, |
+bool TimeWrite(int num_entries, Backend* cache, |
TestEntries* entries) { |
const int kSize1 = 200; |
scoped_refptr<net::IOBuffer> buffer1(new net::IOBuffer(kSize1)); |
@@ -61,7 +63,7 @@ bool TimeWrite(int num_entries, disk_cache::Backend* cache, |
entry.data_len = rand() % kMaxSize; |
entries->push_back(entry); |
- disk_cache::Entry* cache_entry; |
+ Entry* cache_entry; |
net::TestCompletionCallback cb; |
int rv = cache->CreateEntry(entry.key, &cache_entry, cb.callback()); |
if (net::OK != cb.GetResult(rv)) |
@@ -91,7 +93,7 @@ bool TimeWrite(int num_entries, disk_cache::Backend* cache, |
} |
// Reads the data and metadata from each entry listed on |entries|. |
-bool TimeRead(int num_entries, disk_cache::Backend* cache, |
+bool TimeRead(int num_entries, Backend* cache, |
const TestEntries& entries, bool cold) { |
const int kSize1 = 200; |
scoped_refptr<net::IOBuffer> buffer1(new net::IOBuffer(kSize1)); |
@@ -110,7 +112,7 @@ bool TimeRead(int num_entries, disk_cache::Backend* cache, |
base::PerfTimeLogger timer(message); |
for (int i = 0; i < num_entries; i++) { |
- disk_cache::Entry* cache_entry; |
+ Entry* cache_entry; |
net::TestCompletionCallback cb; |
int rv = cache->OpenEntry(entries[i].key, &cache_entry, cb.callback()); |
if (net::OK != cb.GetResult(rv)) |
@@ -165,9 +167,9 @@ TEST_F(DiskCacheTest, CacheBackendPerformance) { |
ASSERT_TRUE(CleanupCacheDir()); |
net::TestCompletionCallback cb; |
- scoped_ptr<disk_cache::Backend> cache; |
- int rv = disk_cache::CreateCacheBackend( |
- net::DISK_CACHE, net::CACHE_BACKEND_BLOCKFILE, cache_path_, 0, false, |
+ scoped_ptr<Backend> cache; |
+ int rv = CreateCacheBackend( |
+ net::DISK_CACHE, net::CACHE_BACKEND_BLOCKFILE, cache_path(), 0, false, |
cache_thread.message_loop_proxy().get(), NULL, &cache, cb.callback()); |
ASSERT_EQ(net::OK, cb.GetResult(rv)); |
@@ -184,18 +186,18 @@ TEST_F(DiskCacheTest, CacheBackendPerformance) { |
cache.reset(); |
ASSERT_TRUE(file_util::EvictFileFromSystemCache( |
- cache_path_.AppendASCII("index"))); |
+ cache_path().AppendASCII("index"))); |
ASSERT_TRUE(file_util::EvictFileFromSystemCache( |
- cache_path_.AppendASCII("data_0"))); |
+ cache_path().AppendASCII("data_0"))); |
ASSERT_TRUE(file_util::EvictFileFromSystemCache( |
- cache_path_.AppendASCII("data_1"))); |
+ cache_path().AppendASCII("data_1"))); |
ASSERT_TRUE(file_util::EvictFileFromSystemCache( |
- cache_path_.AppendASCII("data_2"))); |
+ cache_path().AppendASCII("data_2"))); |
ASSERT_TRUE(file_util::EvictFileFromSystemCache( |
- cache_path_.AppendASCII("data_3"))); |
+ cache_path().AppendASCII("data_3"))); |
- rv = disk_cache::CreateCacheBackend( |
- net::DISK_CACHE, net::CACHE_BACKEND_BLOCKFILE, cache_path_, 0, false, |
+ rv = CreateCacheBackend( |
+ net::DISK_CACHE, net::CACHE_BACKEND_BLOCKFILE, cache_path(), 0, false, |
cache_thread.message_loop_proxy().get(), NULL, &cache, cb.callback()); |
ASSERT_EQ(net::OK, cb.GetResult(rv)); |
@@ -214,20 +216,20 @@ TEST_F(DiskCacheTest, CacheBackendPerformance) { |
TEST_F(DiskCacheTest, BlockFilesPerformance) { |
ASSERT_TRUE(CleanupCacheDir()); |
- disk_cache::BlockFiles files(cache_path_); |
+ BlockFiles files(cache_path()); |
ASSERT_TRUE(files.Init(true)); |
int seed = static_cast<int>(Time::Now().ToInternalValue()); |
srand(seed); |
const int kNumEntries = 60000; |
- disk_cache::Addr* address = new disk_cache::Addr[kNumEntries]; |
+ Addr* address = new Addr[kNumEntries]; |
base::PerfTimeLogger timer1("Fill three block-files"); |
// Fill up the 32-byte block file (use three files). |
for (int i = 0; i < kNumEntries; i++) { |
- EXPECT_TRUE(files.CreateBlock(disk_cache::RANKINGS, BlockSize(), |
+ EXPECT_TRUE(files.CreateBlock(RANKINGS, BlockSize(), |
&address[i])); |
} |
@@ -240,7 +242,7 @@ TEST_F(DiskCacheTest, BlockFilesPerformance) { |
entry = 0; |
files.DeleteBlock(address[entry], false); |
- EXPECT_TRUE(files.CreateBlock(disk_cache::RANKINGS, BlockSize(), |
+ EXPECT_TRUE(files.CreateBlock(RANKINGS, BlockSize(), |
&address[entry])); |
} |
@@ -248,3 +250,5 @@ TEST_F(DiskCacheTest, BlockFilesPerformance) { |
base::MessageLoop::current()->RunUntilIdle(); |
delete[] address; |
} |
+ |
+} // namespace disk_cache |