[email protected] | 5138d5f | 2011-05-07 00:49:34 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
[email protected] | 408d35f5 | 2008-08-13 18:30:22 | [diff] [blame] | 4 | |
5 | #ifndef NET_DISK_CACHE_CACHE_UTIL_H_ | ||||
6 | #define NET_DISK_CACHE_CACHE_UTIL_H_ | ||||
7 | |||||
avi | d0181f3 | 2015-12-10 19:41:47 | [diff] [blame^] | 8 | #include <stdint.h> |
9 | |||||
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 10 | #include "net/base/net_export.h" |
[email protected] | 398ad13 | 2013-04-02 15:11:01 | [diff] [blame] | 11 | #include "net/disk_cache/disk_cache.h" |
[email protected] | 408d35f5 | 2008-08-13 18:30:22 | [diff] [blame] | 12 | |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 13 | namespace base { |
[email protected] | cfaa1f2 | 2009-10-12 17:14:59 | [diff] [blame] | 14 | class FilePath; |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 15 | } |
[email protected] | cfaa1f2 | 2009-10-12 17:14:59 | [diff] [blame] | 16 | |
[email protected] | 408d35f5 | 2008-08-13 18:30:22 | [diff] [blame] | 17 | namespace disk_cache { |
18 | |||||
[email protected] | 408d35f5 | 2008-08-13 18:30:22 | [diff] [blame] | 19 | // Moves the cache files from the given path to another location. |
[email protected] | 831a1a76 | 2010-10-12 05:57:08 | [diff] [blame] | 20 | // Fails if the destination exists already, or if it doesn't have |
21 | // permission for the operation. This is basically a rename operation | ||||
22 | // for the cache directory. Returns true if successful. On ChromeOS, | ||||
23 | // this moves the cache contents, and leaves the empty cache | ||||
24 | // directory. | ||||
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 25 | NET_EXPORT_PRIVATE bool MoveCache(const base::FilePath& from_path, |
26 | const base::FilePath& to_path); | ||||
[email protected] | 408d35f5 | 2008-08-13 18:30:22 | [diff] [blame] | 27 | |
28 | // Deletes the cache files stored on |path|, and optionally also attempts to | ||||
29 | // delete the folder itself. | ||||
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 30 | NET_EXPORT_PRIVATE void DeleteCache(const base::FilePath& path, |
31 | bool remove_folder); | ||||
[email protected] | 408d35f5 | 2008-08-13 18:30:22 | [diff] [blame] | 32 | |
[email protected] | a88d601f | 2008-08-15 20:36:21 | [diff] [blame] | 33 | // Deletes a cache file. |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 34 | NET_EXPORT_PRIVATE bool DeleteCacheFile(const base::FilePath& name); |
[email protected] | a88d601f | 2008-08-15 20:36:21 | [diff] [blame] | 35 | |
[email protected] | 398ad13 | 2013-04-02 15:11:01 | [diff] [blame] | 36 | // Renames cache directory synchronously and fires off a background cleanup |
37 | // task. Used by cache creator itself or by backends for self-restart on error. | ||||
38 | bool DelayedCacheCleanup(const base::FilePath& full_path); | ||||
39 | |||||
[email protected] | 18b5b26 | 2013-11-19 18:41:37 | [diff] [blame] | 40 | // Returns the preferred max cache size given the available disk space. |
avi | d0181f3 | 2015-12-10 19:41:47 | [diff] [blame^] | 41 | NET_EXPORT_PRIVATE int PreferredCacheSize(int64_t available); |
[email protected] | 18b5b26 | 2013-11-19 18:41:37 | [diff] [blame] | 42 | |
43 | // The default cache size should not ideally be exposed, but the blockfile | ||||
44 | // backend uses it for reasons that include testing. | ||||
45 | NET_EXPORT_PRIVATE extern const int kDefaultCacheSize; | ||||
46 | |||||
[email protected] | 408d35f5 | 2008-08-13 18:30:22 | [diff] [blame] | 47 | } // namespace disk_cache |
48 | |||||
49 | #endif // NET_DISK_CACHE_CACHE_UTIL_H_ |