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

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

Issue 7461106: Inform disk cache of WebKit memory cache hits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move http check Created 9 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/string_util.h" 7 #include "base/string_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 char buffer1[kSize]; 2111 char buffer1[kSize];
2112 char buffer2[kSize]; 2112 char buffer2[kSize];
2113 memset(buffer1, 't', kSize); 2113 memset(buffer1, 't', kSize);
2114 memset(buffer2, 0, kSize); 2114 memset(buffer2, 0, kSize);
2115 EXPECT_TRUE(file->Write(buffer1, kSize, 0)); 2115 EXPECT_TRUE(file->Write(buffer1, kSize, 0));
2116 EXPECT_TRUE(file->Read(buffer2, kSize, 0)); 2116 EXPECT_TRUE(file->Read(buffer2, kSize, 0));
2117 EXPECT_EQ(0, memcmp(buffer1, buffer2, kSize)); 2117 EXPECT_EQ(0, memcmp(buffer1, buffer2, kSize));
2118 2118
2119 EXPECT_TRUE(disk_cache::DeleteCacheFile(name)); 2119 EXPECT_TRUE(disk_cache::DeleteCacheFile(name));
2120 } 2120 }
2121
2122 TEST_F(DiskCacheBackendTest, UpdateRankForExternalCacheHit) {
2123 SetDirectMode();
2124 InitCache();
2125
2126 disk_cache::Entry* entry;
2127
2128 for (int i = 0; i < 2; ++i) {
2129 std::string key = StringPrintf("key%d", i);
2130 ASSERT_EQ(net::OK, CreateEntry(key, &entry));
2131 entry->Close();
2132 }
2133
2134 // Ping the oldest entry.
2135 cache_->OnExternalCacheHit("key0");
2136
2137 TrimForTest(false);
2138
2139 // Make sure the older key remains.
2140 EXPECT_EQ(1, cache_->GetEntryCount());
2141 ASSERT_EQ(net::OK, OpenEntry("key0", &entry));
2142 entry->Close();
2143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698