OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/simple/simple_version_upgrade.h" | 5 #include "net/disk_cache/simple/simple_version_upgrade.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Same as |disk_cache::kSimpleInitialMagicNumber|. | 24 // Same as |disk_cache::kSimpleInitialMagicNumber|. |
25 const uint64 kSimpleInitialMagicNumber = GG_UINT64_C(0xfcfb6d1ba7725c30); | 25 const uint64 kSimpleInitialMagicNumber = GG_UINT64_C(0xfcfb6d1ba7725c30); |
26 | 26 |
27 // The "fake index" file that cache backends use to distinguish whether the | 27 // The "fake index" file that cache backends use to distinguish whether the |
28 // cache belongs to one backend or another. | 28 // cache belongs to one backend or another. |
29 const char kFakeIndexFileName[] = "index"; | 29 const char kFakeIndexFileName[] = "index"; |
30 | 30 |
31 // Same as |SimpleIndexFile::kIndexFileName|. | 31 // Same as |SimpleIndexFile::kIndexFileName|. |
32 const char kIndexFileName[] = "the-real-index"; | 32 const char kIndexFileName[] = "the-real-index"; |
33 | 33 |
34 // Same as |SimpleIndexFile::kIndexDirectory|. | |
35 const char kIndexDirectory[] = "index-dir"; | |
36 | |
37 // Same as |SimpleIndexFile::kTempIndexFileName|. | |
38 const char kTempIndexFileName[] = "temp-index"; | |
39 | |
40 bool WriteFakeIndexFileV5(const base::FilePath& cache_path) { | 34 bool WriteFakeIndexFileV5(const base::FilePath& cache_path) { |
41 disk_cache::FakeIndexData data; | 35 disk_cache::FakeIndexData data; |
42 data.version = 5; | 36 data.version = 5; |
43 data.initial_magic_number = kSimpleInitialMagicNumber; | 37 data.initial_magic_number = kSimpleInitialMagicNumber; |
44 data.unused_must_be_zero1 = 0; | 38 data.unused_must_be_zero1 = 0; |
45 data.unused_must_be_zero2 = 0; | 39 data.unused_must_be_zero2 = 0; |
46 const base::FilePath file_name = cache_path.AppendASCII("index"); | 40 const base::FilePath file_name = cache_path.AppendASCII("index"); |
47 return sizeof(data) == | 41 return sizeof(data) == |
48 file_util::WriteFile( | 42 file_util::WriteFile( |
49 file_name, reinterpret_cast<const char*>(&data), sizeof(data)); | 43 file_name, reinterpret_cast<const char*>(&data), sizeof(data)); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 EXPECT_TRUE(base::ReadFileToString(cache_path.AppendASCII(file_name), | 131 EXPECT_TRUE(base::ReadFileToString(cache_path.AppendASCII(file_name), |
138 &real_contents)); | 132 &real_contents)); |
139 EXPECT_EQ(expected_contents, real_contents); | 133 EXPECT_EQ(expected_contents, real_contents); |
140 } | 134 } |
141 } | 135 } |
142 } | 136 } |
143 | 137 |
144 } // namespace | 138 } // namespace |
145 | 139 |
146 #endif // defined(OS_POSIX) | 140 #endif // defined(OS_POSIX) |
OLD | NEW |