Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1311)

Side by Side Diff: net/disk_cache/backend_unittest.cc

Issue 27345: New disk cache eviction algorithm. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | net/disk_cache/disk_cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/platform_thread.h" 8 #include "base/platform_thread.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 NULL, false)); 252 NULL, false));
253 253
254 // Let's fill up the cache!. 254 // Let's fill up the cache!.
255 SetMaxSize(cache_size * 10); 255 SetMaxSize(cache_size * 10);
256 EXPECT_EQ(cache_size * 3 / 4, entry->WriteData(0, 0, buffer, 256 EXPECT_EQ(cache_size * 3 / 4, entry->WriteData(0, 0, buffer,
257 cache_size * 3 / 4, NULL, false)); 257 cache_size * 3 / 4, NULL, false));
258 entry->Close(); 258 entry->Close();
259 259
260 SetMaxSize(cache_size); 260 SetMaxSize(cache_size);
261 261
262 // Verify that the cache is 95% full. 262 // The cache is 95% full.
263 ASSERT_TRUE(cache_->OpenEntry(first, &entry));
264 EXPECT_EQ(cache_size * 3 / 4, entry->GetDataSize(0));
265 EXPECT_EQ(cache_size / 5, entry->GetDataSize(1));
266 entry->Close();
267 263
268 ASSERT_TRUE(cache_->CreateEntry(second, &entry)); 264 ASSERT_TRUE(cache_->CreateEntry(second, &entry));
269 EXPECT_EQ(cache_size / 10, entry->WriteData(0, 0, buffer, cache_size / 10, 265 EXPECT_EQ(cache_size / 10, entry->WriteData(0, 0, buffer, cache_size / 10,
270 NULL, false)) << "trim the cache"; 266 NULL, false)) << "trim the cache";
271 entry->Close(); 267 entry->Close();
272 268
273 EXPECT_FALSE(cache_->OpenEntry(first, &entry)); 269 EXPECT_FALSE(cache_->OpenEntry(first, &entry));
274 ASSERT_TRUE(cache_->OpenEntry(second, &entry)); 270 ASSERT_TRUE(cache_->OpenEntry(second, &entry));
275 EXPECT_EQ(cache_size / 10, entry->GetDataSize(0)); 271 EXPECT_EQ(cache_size / 10, entry->GetDataSize(0));
276 entry->Close(); 272 entry->Close();
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 ASSERT_TRUE(cache_->CreateEntry("second", &entry)); 681 ASSERT_TRUE(cache_->CreateEntry("second", &entry));
686 entry->Close(); 682 entry->Close();
687 ASSERT_TRUE(cache_->CreateEntry("third", &entry)); 683 ASSERT_TRUE(cache_->CreateEntry("third", &entry));
688 entry->Close(); 684 entry->Close();
689 685
690 PlatformThread::Sleep(20); 686 PlatformThread::Sleep(20);
691 Time middle_end = Time::Now(); 687 Time middle_end = Time::Now();
692 688
693 ASSERT_TRUE(cache_->CreateEntry("fourth", &entry)); 689 ASSERT_TRUE(cache_->CreateEntry("fourth", &entry));
694 entry->Close(); 690 entry->Close();
691 ASSERT_TRUE(cache_->OpenEntry("fourth", &entry));
692 entry->Close();
695 693
696 PlatformThread::Sleep(20); 694 PlatformThread::Sleep(20);
697 Time final = Time::Now(); 695 Time final = Time::Now();
698 696
699 ASSERT_EQ(4, cache_->GetEntryCount()); 697 ASSERT_EQ(4, cache_->GetEntryCount());
700 EXPECT_TRUE(cache_->DoomEntriesBetween(middle_start, middle_end)); 698 EXPECT_TRUE(cache_->DoomEntriesBetween(middle_start, middle_end));
701 ASSERT_EQ(2, cache_->GetEntryCount()); 699 ASSERT_EQ(2, cache_->GetEntryCount());
702 700
703 ASSERT_TRUE(cache_->OpenEntry("fourth", &entry)); 701 ASSERT_TRUE(cache_->OpenEntry("fourth", &entry));
704 entry->Close(); 702 entry->Close();
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 InitCache(); 978 InitCache();
981 BackendDoomAll(); 979 BackendDoomAll();
982 } 980 }
983 981
984 TEST_F(DiskCacheBackendTest, MemoryOnlyDoomAll) { 982 TEST_F(DiskCacheBackendTest, MemoryOnlyDoomAll) {
985 SetMemoryOnlyMode(); 983 SetMemoryOnlyMode();
986 InitCache(); 984 InitCache();
987 BackendDoomAll(); 985 BackendDoomAll();
988 } 986 }
989 987
OLDNEW
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | net/disk_cache/disk_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698