| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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 #ifndef NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ | 5 #ifndef NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ |
| 6 #define NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ | 6 #define NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/thread.h" | 10 #include "base/thread.h" |
| 11 #include "net/base/cache_type.h" | 11 #include "net/base/cache_type.h" |
| 12 #include "net/disk_cache/disk_cache_test_util.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
| 14 | 15 |
| 15 class FilePath; | 16 class FilePath; |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 | 19 |
| 19 class IOBuffer; | 20 class IOBuffer; |
| 20 | 21 |
| 21 } // namespace net | 22 } // namespace net |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 86 } |
| 86 | 87 |
| 87 void UseCurrentThread() { | 88 void UseCurrentThread() { |
| 88 use_current_thread_ = true; | 89 use_current_thread_ = true; |
| 89 } | 90 } |
| 90 | 91 |
| 91 void SetCacheType(net::CacheType type) { | 92 void SetCacheType(net::CacheType type) { |
| 92 type_ = type; | 93 type_ = type; |
| 93 } | 94 } |
| 94 | 95 |
| 96 FilePath path() const { |
| 97 return test_cache_.path(); |
| 98 } |
| 99 |
| 95 // Utility methods to access the cache and wait for each operation to finish. | 100 // Utility methods to access the cache and wait for each operation to finish. |
| 96 int OpenEntry(const std::string& key, disk_cache::Entry** entry); | 101 int OpenEntry(const std::string& key, disk_cache::Entry** entry); |
| 97 int CreateEntry(const std::string& key, disk_cache::Entry** entry); | 102 int CreateEntry(const std::string& key, disk_cache::Entry** entry); |
| 98 int DoomEntry(const std::string& key); | 103 int DoomEntry(const std::string& key); |
| 99 int DoomAllEntries(); | 104 int DoomAllEntries(); |
| 100 int DoomEntriesBetween(const base::Time initial_time, | 105 int DoomEntriesBetween(const base::Time initial_time, |
| 101 const base::Time end_time); | 106 const base::Time end_time); |
| 102 int DoomEntriesSince(const base::Time initial_time); | 107 int DoomEntriesSince(const base::Time initial_time); |
| 103 int OpenNextEntry(void** iter, disk_cache::Entry** next_entry); | 108 int OpenNextEntry(void** iter, disk_cache::Entry** next_entry); |
| 104 void FlushQueueForTest(); | 109 void FlushQueueForTest(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 129 bool integrity_; | 134 bool integrity_; |
| 130 bool use_current_thread_; | 135 bool use_current_thread_; |
| 131 // This is intentionally left uninitialized, to be used by any test. | 136 // This is intentionally left uninitialized, to be used by any test. |
| 132 bool success_; | 137 bool success_; |
| 133 | 138 |
| 134 private: | 139 private: |
| 135 void InitMemoryCache(); | 140 void InitMemoryCache(); |
| 136 void InitDiskCache(); | 141 void InitDiskCache(); |
| 137 void InitDiskCacheImpl(const FilePath& path); | 142 void InitDiskCacheImpl(const FilePath& path); |
| 138 | 143 |
| 144 ScopedTestCache test_cache_; |
| 139 base::Thread cache_thread_; | 145 base::Thread cache_thread_; |
| 146 |
| 140 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache); | 147 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache); |
| 141 }; | 148 }; |
| 142 | 149 |
| 143 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ | 150 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ |
| OLD | NEW |