| 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 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_VERSION_UPGRADE_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_VERSION_UPGRADE_H_ |
| 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_VERSION_UPGRADE_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_VERSION_UPGRADE_H_ |
| 7 | 7 |
| 8 // Defines functionality to upgrade the file structure of the Simple Cache | 8 // Defines functionality to upgrade the file structure of the Simple Cache |
| 9 // Backend on disk. Assumes no backend operations are running simultaneously. | 9 // Backend on disk. Assumes no backend operations are running simultaneously. |
| 10 // Hence must be run at cache initialization step. | 10 // Hence must be run at cache initialization step. |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include <stdint.h> |
| 13 |
| 13 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
| 14 | 15 |
| 15 namespace base { | 16 namespace base { |
| 16 class FilePath; | 17 class FilePath; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace disk_cache { | 20 namespace disk_cache { |
| 20 | 21 |
| 21 // Performs all necessary disk IO to upgrade the cache structure if it is | 22 // Performs all necessary disk IO to upgrade the cache structure if it is |
| 22 // needed. | 23 // needed. |
| 23 // | 24 // |
| 24 // Returns true iff no errors were found during consistency checks and all | 25 // Returns true iff no errors were found during consistency checks and all |
| 25 // necessary transitions succeeded. If this function fails, there is nothing | 26 // necessary transitions succeeded. If this function fails, there is nothing |
| 26 // left to do other than dropping the whole cache directory. | 27 // left to do other than dropping the whole cache directory. |
| 27 NET_EXPORT_PRIVATE bool UpgradeSimpleCacheOnDisk(const base::FilePath& path); | 28 NET_EXPORT_PRIVATE bool UpgradeSimpleCacheOnDisk(const base::FilePath& path); |
| 28 | 29 |
| 29 // The format for the fake index has mistakenly acquired two extra fields that | 30 // The format for the fake index has mistakenly acquired two extra fields that |
| 30 // do not contain any useful data. Since they were equal to zero, they are now | 31 // do not contain any useful data. Since they were equal to zero, they are now |
| 31 // mandatated to be zero. | 32 // mandatated to be zero. |
| 32 struct NET_EXPORT_PRIVATE FakeIndexData { | 33 struct NET_EXPORT_PRIVATE FakeIndexData { |
| 33 FakeIndexData(); | 34 FakeIndexData(); |
| 34 | 35 |
| 35 // Must be equal to simplecache_v4::kSimpleInitialMagicNumber. | 36 // Must be equal to simplecache_v4::kSimpleInitialMagicNumber. |
| 36 uint64 initial_magic_number; | 37 uint64_t initial_magic_number; |
| 37 | 38 |
| 38 // Must be equal kSimpleVersion when the cache backend is instantiated. | 39 // Must be equal kSimpleVersion when the cache backend is instantiated. |
| 39 uint32 version; | 40 uint32_t version; |
| 40 | 41 |
| 41 uint32 unused_must_be_zero1; | 42 uint32_t unused_must_be_zero1; |
| 42 uint32 unused_must_be_zero2; | 43 uint32_t unused_must_be_zero2; |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 // Exposed for testing. | 46 // Exposed for testing. |
| 46 NET_EXPORT_PRIVATE bool UpgradeIndexV5V6(const base::FilePath& cache_directory); | 47 NET_EXPORT_PRIVATE bool UpgradeIndexV5V6(const base::FilePath& cache_directory); |
| 47 | 48 |
| 48 } // namespace disk_cache | 49 } // namespace disk_cache |
| 49 | 50 |
| 50 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_VERSION_UPGRADE_H_ | 51 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_VERSION_UPGRADE_H_ |
| OLD | NEW |