blob: 259401242770a13478511c4eb3699289cfe8b8f7 [file] [log] [blame]
[email protected]5138d5f2011-05-07 00:49:341// Copyright (c) 2011 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
[email protected]408d35f52008-08-13 18:30:224
5#ifndef NET_DISK_CACHE_CACHE_UTIL_H_
6#define NET_DISK_CACHE_CACHE_UTIL_H_
7
avid0181f32015-12-10 19:41:478#include <stdint.h>
9
[email protected]172da1b2011-08-12 15:52:2610#include "net/base/net_export.h"
[email protected]398ad132013-04-02 15:11:0111#include "net/disk_cache/disk_cache.h"
[email protected]408d35f52008-08-13 18:30:2212
[email protected]a3ef4832013-02-02 05:12:3313namespace base {
[email protected]cfaa1f22009-10-12 17:14:5914class FilePath;
[email protected]a3ef4832013-02-02 05:12:3315}
[email protected]cfaa1f22009-10-12 17:14:5916
[email protected]408d35f52008-08-13 18:30:2217namespace disk_cache {
18
[email protected]408d35f52008-08-13 18:30:2219// Moves the cache files from the given path to another location.
[email protected]831a1a762010-10-12 05:57:0820// 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]a3ef4832013-02-02 05:12:3325NET_EXPORT_PRIVATE bool MoveCache(const base::FilePath& from_path,
26 const base::FilePath& to_path);
[email protected]408d35f52008-08-13 18:30:2227
28// Deletes the cache files stored on |path|, and optionally also attempts to
29// delete the folder itself.
[email protected]a3ef4832013-02-02 05:12:3330NET_EXPORT_PRIVATE void DeleteCache(const base::FilePath& path,
31 bool remove_folder);
[email protected]408d35f52008-08-13 18:30:2232
[email protected]a88d601f2008-08-15 20:36:2133// Deletes a cache file.
[email protected]a3ef4832013-02-02 05:12:3334NET_EXPORT_PRIVATE bool DeleteCacheFile(const base::FilePath& name);
[email protected]a88d601f2008-08-15 20:36:2135
[email protected]398ad132013-04-02 15:11:0136// 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.
38bool DelayedCacheCleanup(const base::FilePath& full_path);
39
[email protected]18b5b262013-11-19 18:41:3740// Returns the preferred max cache size given the available disk space.
avid0181f32015-12-10 19:41:4741NET_EXPORT_PRIVATE int PreferredCacheSize(int64_t available);
[email protected]18b5b262013-11-19 18:41:3742
43// The default cache size should not ideally be exposed, but the blockfile
44// backend uses it for reasons that include testing.
45NET_EXPORT_PRIVATE extern const int kDefaultCacheSize;
46
[email protected]408d35f52008-08-13 18:30:2247} // namespace disk_cache
48
49#endif // NET_DISK_CACHE_CACHE_UTIL_H_