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

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

Issue 1894733002: Change scoped_ptr to std::unique_ptr in //net/disk_cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « net/disk_cache/disk_cache.h ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
11
10 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
11 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
15 #include "net/base/cache_type.h" 16 #include "net/base/cache_type.h"
16 #include "net/disk_cache/disk_cache.h" 17 #include "net/disk_cache/disk_cache.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/platform_test.h" 19 #include "testing/platform_test.h"
19 20
20 namespace net { 21 namespace net {
21 22
22 class IOBuffer; 23 class IOBuffer;
23 24
(...skipping 23 matching lines...) Expand all
47 48
48 // Deletes the contents of |cache_path_|. 49 // Deletes the contents of |cache_path_|.
49 bool CleanupCacheDir(); 50 bool CleanupCacheDir();
50 51
51 void TearDown() override; 52 void TearDown() override;
52 53
53 base::FilePath cache_path_; 54 base::FilePath cache_path_;
54 55
55 private: 56 private:
56 base::ScopedTempDir temp_dir_; 57 base::ScopedTempDir temp_dir_;
57 scoped_ptr<base::MessageLoop> message_loop_; 58 std::unique_ptr<base::MessageLoop> message_loop_;
58 }; 59 };
59 60
60 // Provides basic support for cache related tests. 61 // Provides basic support for cache related tests.
61 class DiskCacheTestWithCache : public DiskCacheTest { 62 class DiskCacheTestWithCache : public DiskCacheTest {
62 protected: 63 protected:
63 class TestIterator { 64 class TestIterator {
64 public: 65 public:
65 explicit TestIterator(scoped_ptr<disk_cache::Backend::Iterator> iterator); 66 explicit TestIterator(
67 std::unique_ptr<disk_cache::Backend::Iterator> iterator);
66 ~TestIterator(); 68 ~TestIterator();
67 69
68 int OpenNextEntry(disk_cache::Entry** next_entry); 70 int OpenNextEntry(disk_cache::Entry** next_entry);
69 71
70 private: 72 private:
71 scoped_ptr<disk_cache::Backend::Iterator> iterator_; 73 std::unique_ptr<disk_cache::Backend::Iterator> iterator_;
72 }; 74 };
73 75
74 DiskCacheTestWithCache(); 76 DiskCacheTestWithCache();
75 ~DiskCacheTestWithCache() override; 77 ~DiskCacheTestWithCache() override;
76 78
77 void CreateBackend(uint32_t flags, base::Thread* thread); 79 void CreateBackend(uint32_t flags, base::Thread* thread);
78 80
79 void InitCache(); 81 void InitCache();
80 void SimulateCrash(); 82 void SimulateCrash();
81 void SetTestMode(); 83 void SetTestMode();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 125
124 // Utility methods to access the cache and wait for each operation to finish. 126 // Utility methods to access the cache and wait for each operation to finish.
125 int OpenEntry(const std::string& key, disk_cache::Entry** entry); 127 int OpenEntry(const std::string& key, disk_cache::Entry** entry);
126 int CreateEntry(const std::string& key, disk_cache::Entry** entry); 128 int CreateEntry(const std::string& key, disk_cache::Entry** entry);
127 int DoomEntry(const std::string& key); 129 int DoomEntry(const std::string& key);
128 int DoomAllEntries(); 130 int DoomAllEntries();
129 int DoomEntriesBetween(const base::Time initial_time, 131 int DoomEntriesBetween(const base::Time initial_time,
130 const base::Time end_time); 132 const base::Time end_time);
131 int CalculateSizeOfAllEntries(); 133 int CalculateSizeOfAllEntries();
132 int DoomEntriesSince(const base::Time initial_time); 134 int DoomEntriesSince(const base::Time initial_time);
133 scoped_ptr<TestIterator> CreateIterator(); 135 std::unique_ptr<TestIterator> CreateIterator();
134 void FlushQueueForTest(); 136 void FlushQueueForTest();
135 void RunTaskForTest(const base::Closure& closure); 137 void RunTaskForTest(const base::Closure& closure);
136 int ReadData(disk_cache::Entry* entry, int index, int offset, 138 int ReadData(disk_cache::Entry* entry, int index, int offset,
137 net::IOBuffer* buf, int len); 139 net::IOBuffer* buf, int len);
138 int WriteData(disk_cache::Entry* entry, int index, int offset, 140 int WriteData(disk_cache::Entry* entry, int index, int offset,
139 net::IOBuffer* buf, int len, bool truncate); 141 net::IOBuffer* buf, int len, bool truncate);
140 int ReadSparseData(disk_cache::Entry* entry, 142 int ReadSparseData(disk_cache::Entry* entry,
141 int64_t offset, 143 int64_t offset,
142 net::IOBuffer* buf, 144 net::IOBuffer* buf,
143 int len); 145 int len);
(...skipping 12 matching lines...) Expand all
156 158
157 // Makes sure that some time passes before continuing the test. Time::Now() 159 // Makes sure that some time passes before continuing the test. Time::Now()
158 // before and after this method will not be the same. 160 // before and after this method will not be the same.
159 void AddDelay(); 161 void AddDelay();
160 162
161 // DiskCacheTest: 163 // DiskCacheTest:
162 void TearDown() override; 164 void TearDown() override;
163 165
164 // cache_ will always have a valid object, regardless of how the cache was 166 // cache_ will always have a valid object, regardless of how the cache was
165 // initialized. The implementation pointers can be NULL. 167 // initialized. The implementation pointers can be NULL.
166 scoped_ptr<disk_cache::Backend> cache_; 168 std::unique_ptr<disk_cache::Backend> cache_;
167 disk_cache::BackendImpl* cache_impl_; 169 disk_cache::BackendImpl* cache_impl_;
168 disk_cache::SimpleBackendImpl* simple_cache_impl_; 170 disk_cache::SimpleBackendImpl* simple_cache_impl_;
169 disk_cache::MemBackendImpl* mem_cache_; 171 disk_cache::MemBackendImpl* mem_cache_;
170 172
171 uint32_t mask_; 173 uint32_t mask_;
172 int size_; 174 int size_;
173 net::CacheType type_; 175 net::CacheType type_;
174 bool memory_only_; 176 bool memory_only_;
175 bool simple_cache_mode_; 177 bool simple_cache_mode_;
176 bool simple_cache_wait_for_index_; 178 bool simple_cache_wait_for_index_;
177 bool force_creation_; 179 bool force_creation_;
178 bool new_eviction_; 180 bool new_eviction_;
179 bool first_cleanup_; 181 bool first_cleanup_;
180 bool integrity_; 182 bool integrity_;
181 bool use_current_thread_; 183 bool use_current_thread_;
182 // This is intentionally left uninitialized, to be used by any test. 184 // This is intentionally left uninitialized, to be used by any test.
183 bool success_; 185 bool success_;
184 186
185 private: 187 private:
186 void InitMemoryCache(); 188 void InitMemoryCache();
187 void InitDiskCache(); 189 void InitDiskCache();
188 190
189 base::Thread cache_thread_; 191 base::Thread cache_thread_;
190 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache); 192 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache);
191 }; 193 };
192 194
193 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ 195 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_
OLDNEW
« no previous file with comments | « net/disk_cache/disk_cache.h ('k') | net/disk_cache/disk_cache_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698