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