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

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

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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_unittest.cc ('k') | net/disk_cache/disk_cache_test_base.cc » ('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) 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/hash.h" 10 #include "base/hash.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 TEST_F(DiskCacheTest, CacheBackendPerformance) { 175 TEST_F(DiskCacheTest, CacheBackendPerformance) {
176 base::Thread cache_thread("CacheThread"); 176 base::Thread cache_thread("CacheThread");
177 ASSERT_TRUE(cache_thread.StartWithOptions( 177 ASSERT_TRUE(cache_thread.StartWithOptions(
178 base::Thread::Options(base::MessageLoop::TYPE_IO, 0))); 178 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)));
179 179
180 ASSERT_TRUE(CleanupCacheDir()); 180 ASSERT_TRUE(CleanupCacheDir());
181 net::TestCompletionCallback cb; 181 net::TestCompletionCallback cb;
182 disk_cache::Backend* cache; 182 disk_cache::Backend* cache;
183 int rv = disk_cache::CreateCacheBackend( 183 int rv =
184 net::DISK_CACHE, net::CACHE_BACKEND_BLOCKFILE, cache_path_, 0, false, 184 disk_cache::CreateCacheBackend(net::DISK_CACHE,
185 cache_thread.message_loop_proxy(), NULL, &cache, cb.callback()); 185 net::CACHE_BACKEND_BLOCKFILE,
186 cache_path_,
187 0,
188 false,
189 cache_thread.message_loop_proxy().get(),
190 NULL,
191 &cache,
192 cb.callback());
186 193
187 ASSERT_EQ(net::OK, cb.GetResult(rv)); 194 ASSERT_EQ(net::OK, cb.GetResult(rv));
188 195
189 int seed = static_cast<int>(Time::Now().ToInternalValue()); 196 int seed = static_cast<int>(Time::Now().ToInternalValue());
190 srand(seed); 197 srand(seed);
191 198
192 TestEntries entries; 199 TestEntries entries;
193 int num_entries = 1000; 200 int num_entries = 1000;
194 201
195 EXPECT_TRUE(TimeWrite(num_entries, cache, &entries)); 202 EXPECT_TRUE(TimeWrite(num_entries, cache, &entries));
196 203
197 base::MessageLoop::current()->RunUntilIdle(); 204 base::MessageLoop::current()->RunUntilIdle();
198 delete cache; 205 delete cache;
199 206
200 ASSERT_TRUE(file_util::EvictFileFromSystemCache( 207 ASSERT_TRUE(file_util::EvictFileFromSystemCache(
201 cache_path_.AppendASCII("index"))); 208 cache_path_.AppendASCII("index")));
202 ASSERT_TRUE(file_util::EvictFileFromSystemCache( 209 ASSERT_TRUE(file_util::EvictFileFromSystemCache(
203 cache_path_.AppendASCII("data_0"))); 210 cache_path_.AppendASCII("data_0")));
204 ASSERT_TRUE(file_util::EvictFileFromSystemCache( 211 ASSERT_TRUE(file_util::EvictFileFromSystemCache(
205 cache_path_.AppendASCII("data_1"))); 212 cache_path_.AppendASCII("data_1")));
206 ASSERT_TRUE(file_util::EvictFileFromSystemCache( 213 ASSERT_TRUE(file_util::EvictFileFromSystemCache(
207 cache_path_.AppendASCII("data_2"))); 214 cache_path_.AppendASCII("data_2")));
208 ASSERT_TRUE(file_util::EvictFileFromSystemCache( 215 ASSERT_TRUE(file_util::EvictFileFromSystemCache(
209 cache_path_.AppendASCII("data_3"))); 216 cache_path_.AppendASCII("data_3")));
210 217
211 rv = disk_cache::CreateCacheBackend( 218 rv = disk_cache::CreateCacheBackend(net::DISK_CACHE,
212 net::DISK_CACHE, net::CACHE_BACKEND_BLOCKFILE, cache_path_, 0, false, 219 net::CACHE_BACKEND_BLOCKFILE,
213 cache_thread.message_loop_proxy(), 220 cache_path_,
214 NULL, &cache, cb.callback()); 221 0,
222 false,
223 cache_thread.message_loop_proxy().get(),
224 NULL,
225 &cache,
226 cb.callback());
215 ASSERT_EQ(net::OK, cb.GetResult(rv)); 227 ASSERT_EQ(net::OK, cb.GetResult(rv));
216 228
217 EXPECT_TRUE(TimeRead(num_entries, cache, entries, true)); 229 EXPECT_TRUE(TimeRead(num_entries, cache, entries, true));
218 230
219 EXPECT_TRUE(TimeRead(num_entries, cache, entries, false)); 231 EXPECT_TRUE(TimeRead(num_entries, cache, entries, false));
220 232
221 base::MessageLoop::current()->RunUntilIdle(); 233 base::MessageLoop::current()->RunUntilIdle();
222 delete cache; 234 delete cache;
223 } 235 }
224 236
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 269
258 files.DeleteBlock(address[entry], false); 270 files.DeleteBlock(address[entry], false);
259 EXPECT_TRUE(files.CreateBlock(disk_cache::RANKINGS, BlockSize(), 271 EXPECT_TRUE(files.CreateBlock(disk_cache::RANKINGS, BlockSize(),
260 &address[entry])); 272 &address[entry]));
261 } 273 }
262 274
263 timer2.Done(); 275 timer2.Done();
264 base::MessageLoop::current()->RunUntilIdle(); 276 base::MessageLoop::current()->RunUntilIdle();
265 delete[] address; 277 delete[] address;
266 } 278 }
OLDNEW
« no previous file with comments | « net/disk_cache/backend_unittest.cc ('k') | net/disk_cache/disk_cache_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698