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

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

Issue 160485: Disk cache: Open the disk cache experiment for new users.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | no next file » | 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 "net/disk_cache/disk_cache_test_base.h" 5 #include "net/disk_cache/disk_cache_test_base.h"
6 6
7 #include "net/disk_cache/backend_impl.h" 7 #include "net/disk_cache/backend_impl.h"
8 #include "net/disk_cache/disk_cache_test_util.h" 8 #include "net/disk_cache/disk_cache_test_util.h"
9 #include "net/disk_cache/mem_backend_impl.h" 9 #include "net/disk_cache/mem_backend_impl.h"
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 void DiskCacheTestWithCache::InitDiskCache() { 54 void DiskCacheTestWithCache::InitDiskCache() {
55 std::wstring path = GetCachePath(); 55 std::wstring path = GetCachePath();
56 if (first_cleanup_) 56 if (first_cleanup_)
57 ASSERT_TRUE(DeleteCache(path.c_str())); 57 ASSERT_TRUE(DeleteCache(path.c_str()));
58 58
59 if (!implementation_) { 59 if (!implementation_) {
60 cache_ = disk_cache::CreateCacheBackend(path, force_creation_, size_, 60 cache_ = disk_cache::CreateCacheBackend(path, force_creation_, size_,
61 net::DISK_CACHE); 61 net::DISK_CACHE);
62 disk_cache::BackendImpl* impl =
63 static_cast<disk_cache::BackendImpl*>(cache_);
64 if (impl)
65 impl->SetFlags(disk_cache::kNoRandom);
62 return; 66 return;
63 } 67 }
64 68
65 InitDiskCacheImpl(path); 69 InitDiskCacheImpl(path);
66 } 70 }
67 71
68 void DiskCacheTestWithCache::InitDiskCacheImpl(const std::wstring& path) { 72 void DiskCacheTestWithCache::InitDiskCacheImpl(const std::wstring& path) {
69 if (mask_) 73 if (mask_)
70 cache_impl_ = new disk_cache::BackendImpl(path, mask_); 74 cache_impl_ = new disk_cache::BackendImpl(path, mask_);
71 else 75 else
72 cache_impl_ = new disk_cache::BackendImpl(path); 76 cache_impl_ = new disk_cache::BackendImpl(path);
73 77
74 cache_ = cache_impl_; 78 cache_ = cache_impl_;
75 ASSERT_TRUE(NULL != cache_); 79 ASSERT_TRUE(NULL != cache_);
76 80
77 if (size_) 81 if (size_)
78 EXPECT_TRUE(cache_impl_->SetMaxSize(size_)); 82 EXPECT_TRUE(cache_impl_->SetMaxSize(size_));
79 83
80 if (new_eviction_) 84 if (new_eviction_)
81 cache_impl_->SetNewEviction(); 85 cache_impl_->SetNewEviction();
82 86
87 cache_impl_->SetFlags(disk_cache::kNoRandom);
83 ASSERT_TRUE(cache_impl_->Init()); 88 ASSERT_TRUE(cache_impl_->Init());
84 } 89 }
85 90
86 void DiskCacheTestWithCache::TearDown() { 91 void DiskCacheTestWithCache::TearDown() {
87 MessageLoop::current()->RunAllPending(); 92 MessageLoop::current()->RunAllPending();
88 delete cache_; 93 delete cache_;
89 94
90 if (!memory_only_ && integrity_) { 95 if (!memory_only_ && integrity_) {
91 std::wstring path = GetCachePath(); 96 std::wstring path = GetCachePath();
92 EXPECT_TRUE(CheckCacheIntegrity(path, new_eviction_)); 97 EXPECT_TRUE(CheckCacheIntegrity(path, new_eviction_));
(...skipping 11 matching lines...) Expand all
104 std::wstring path = GetCachePath(); 109 std::wstring path = GetCachePath();
105 EXPECT_TRUE(CheckCacheIntegrity(path, new_eviction_)); 110 EXPECT_TRUE(CheckCacheIntegrity(path, new_eviction_));
106 111
107 InitDiskCacheImpl(path); 112 InitDiskCacheImpl(path);
108 } 113 }
109 114
110 void DiskCacheTestWithCache::SetTestMode() { 115 void DiskCacheTestWithCache::SetTestMode() {
111 ASSERT_TRUE(implementation_ && !memory_only_); 116 ASSERT_TRUE(implementation_ && !memory_only_);
112 cache_impl_->SetUnitTestMode(); 117 cache_impl_->SetUnitTestMode();
113 } 118 }
OLDNEW
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698