| OLD | NEW |
| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 ASSERT_TRUE(mem_cache_->Init()); | 51 ASSERT_TRUE(mem_cache_->Init()); |
| 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 return InitDiskCacheImpl(path); | 60 return InitDiskCacheImpl(FilePath::FromWStringHack(path)); |
| 61 | 61 |
| 62 cache_ = disk_cache::BackendImpl::CreateBackend(path, force_creation_, size_, | 62 cache_ = disk_cache::BackendImpl::CreateBackend(path, force_creation_, size_, |
| 63 net::DISK_CACHE, | 63 net::DISK_CACHE, |
| 64 disk_cache::kNoRandom); | 64 disk_cache::kNoRandom); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void DiskCacheTestWithCache::InitDiskCacheImpl(const std::wstring& path) { | 67 void DiskCacheTestWithCache::InitDiskCacheImpl(const FilePath& path) { |
| 68 if (mask_) | 68 if (mask_) |
| 69 cache_impl_ = new disk_cache::BackendImpl(path, mask_); | 69 cache_impl_ = new disk_cache::BackendImpl(path, mask_); |
| 70 else | 70 else |
| 71 cache_impl_ = new disk_cache::BackendImpl(path); | 71 cache_impl_ = new disk_cache::BackendImpl(path); |
| 72 | 72 |
| 73 cache_ = cache_impl_; | 73 cache_ = cache_impl_; |
| 74 ASSERT_TRUE(NULL != cache_); | 74 ASSERT_TRUE(NULL != cache_); |
| 75 | 75 |
| 76 if (size_) | 76 if (size_) |
| 77 EXPECT_TRUE(cache_impl_->SetMaxSize(size_)); | 77 EXPECT_TRUE(cache_impl_->SetMaxSize(size_)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 97 | 97 |
| 98 // We are expected to leak memory when simulating crashes. | 98 // We are expected to leak memory when simulating crashes. |
| 99 void DiskCacheTestWithCache::SimulateCrash() { | 99 void DiskCacheTestWithCache::SimulateCrash() { |
| 100 ASSERT_TRUE(implementation_ && !memory_only_); | 100 ASSERT_TRUE(implementation_ && !memory_only_); |
| 101 cache_impl_->ClearRefCountForTest(); | 101 cache_impl_->ClearRefCountForTest(); |
| 102 | 102 |
| 103 delete cache_impl_; | 103 delete cache_impl_; |
| 104 std::wstring path = GetCachePath(); | 104 std::wstring path = GetCachePath(); |
| 105 EXPECT_TRUE(CheckCacheIntegrity(path, new_eviction_)); | 105 EXPECT_TRUE(CheckCacheIntegrity(path, new_eviction_)); |
| 106 | 106 |
| 107 InitDiskCacheImpl(path); | 107 InitDiskCacheImpl(FilePath::FromWStringHack(path)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void DiskCacheTestWithCache::SetTestMode() { | 110 void DiskCacheTestWithCache::SetTestMode() { |
| 111 ASSERT_TRUE(implementation_ && !memory_only_); | 111 ASSERT_TRUE(implementation_ && !memory_only_); |
| 112 cache_impl_->SetUnitTestMode(); | 112 cache_impl_->SetUnitTestMode(); |
| 113 } | 113 } |
| OLD | NEW |