OLD | NEW |
---|---|
1 // Copyright (c) 2006-2010 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 "net/disk_cache/disk_cache_test_util.h" | 5 #include "net/disk_cache/disk_cache_test_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/memory/scoped_temp_dir.h" | |
11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
12 #include "net/disk_cache/backend_impl.h" | 13 #include "net/disk_cache/backend_impl.h" |
13 #include "net/disk_cache/cache_util.h" | 14 #include "net/disk_cache/cache_util.h" |
14 #include "net/disk_cache/file.h" | 15 #include "net/disk_cache/file.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | |
15 | 17 |
16 using base::Time; | 18 using base::Time; |
17 using base::TimeDelta; | 19 using base::TimeDelta; |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
23 ScopedTempDir temp_dir_; | |
24 | |
21 FilePath BuildCachePath(const std::string& name) { | 25 FilePath BuildCachePath(const std::string& name) { |
22 FilePath path; | 26 if (!temp_dir_.IsValid()) |
Paweł Hajdan Jr.
2011/04/11 18:16:53
Oh, let's leave this one as-is. I know Ricardo Var
Mike West
2011/04/12 07:04:04
Great, this is exactly why I'm thrilled you're rev
| |
23 PathService::Get(base::DIR_TEMP, &path); // Ignore return value; | 27 DCHECK(temp_dir_.CreateUniqueTempDir()); |
28 | |
29 FilePath path = temp_dir_.path(); | |
24 path = path.AppendASCII(name); | 30 path = path.AppendASCII(name); |
25 if (!file_util::PathExists(path)) | 31 if (!file_util::PathExists(path)) |
26 file_util::CreateDirectory(path); | 32 file_util::CreateDirectory(path); |
27 | 33 |
28 return path; | 34 return path; |
29 } | 35 } |
30 | 36 |
31 } // namespace. | 37 } // namespace. |
32 | 38 |
33 std::string GenerateKey(bool same_length) { | 39 std::string GenerateKey(bool same_length) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 } else { | 184 } else { |
179 // Not finished yet. See if we have to abort. | 185 // Not finished yet. See if we have to abort. |
180 if (last_ == g_cache_tests_received) | 186 if (last_ == g_cache_tests_received) |
181 num_iterations_++; | 187 num_iterations_++; |
182 else | 188 else |
183 last_ = g_cache_tests_received; | 189 last_ = g_cache_tests_received; |
184 if (40 == num_iterations_) | 190 if (40 == num_iterations_) |
185 MessageLoop::current()->Quit(); | 191 MessageLoop::current()->Quit(); |
186 } | 192 } |
187 } | 193 } |
OLD | NEW |