blob: 22da27450b01fb6ff37c183f7d651d7ad2405bc8 [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2011 The Chromium Authors
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
Yutaka Hiranobc3b4ddb2022-04-29 14:15:4410#include "base/callback_forward.h"
Matt Menkeb0f4c7c2018-07-06 19:25:3011#include "base/feature_list.h"
[email protected]172da1b2011-08-12 15:52:2612#include "net/base/net_export.h"
[email protected]398ad132013-04-02 15:11:0113#include "net/disk_cache/disk_cache.h"
[email protected]408d35f52008-08-13 18:30:2214
[email protected]a3ef4832013-02-02 05:12:3315namespace base {
[email protected]cfaa1f22009-10-12 17:14:5916class FilePath;
[email protected]a3ef4832013-02-02 05:12:3317}
[email protected]cfaa1f22009-10-12 17:14:5918
[email protected]408d35f52008-08-13 18:30:2219namespace disk_cache {
20
shivanigithub19b2f342020-12-30 01:57:4321// Experiment to increase the cache size to see the impact on various
22// performance metrics.
Daniel Cheng3617b732022-10-01 03:36:3523NET_EXPORT_PRIVATE BASE_DECLARE_FEATURE(kChangeDiskCacheSizeExperiment);
shivanigithub19b2f342020-12-30 01:57:4324
[email protected]408d35f52008-08-13 18:30:2225// Moves the cache files from the given path to another location.
[email protected]831a1a762010-10-12 05:57:0826// Fails if the destination exists already, or if it doesn't have
27// permission for the operation. This is basically a rename operation
28// for the cache directory. Returns true if successful. On ChromeOS,
29// this moves the cache contents, and leaves the empty cache
30// directory.
[email protected]a3ef4832013-02-02 05:12:3331NET_EXPORT_PRIVATE bool MoveCache(const base::FilePath& from_path,
32 const base::FilePath& to_path);
[email protected]408d35f52008-08-13 18:30:2233
34// Deletes the cache files stored on |path|, and optionally also attempts to
35// delete the folder itself.
[email protected]a3ef4832013-02-02 05:12:3336NET_EXPORT_PRIVATE void DeleteCache(const base::FilePath& path,
37 bool remove_folder);
[email protected]408d35f52008-08-13 18:30:2238
Yutaka Hiranobc3b4ddb2022-04-29 14:15:4439// Deletes the given directory recursively, asynchronously. `callback` will
40// called with whether the operation succeeded.
41// This is done by:
42// 1. Renaming the directory to another directory,
43// 2. Calling `callback` with the result, and
44// 3. Deleting the directory.
45// This means the caller won't know the result of 3.
46NET_EXPORT_PRIVATE void CleanupDirectory(
47 const base::FilePath& path,
48 base::OnceCallback<void(bool)> callback);
49
50// This runs 1. (see the above comments) synchronously.
51bool CleanupDirectorySync(const base::FilePath& path);
[email protected]398ad132013-04-02 15:11:0152
Bill Budge1bb18a942019-12-02 22:19:5453// Returns the preferred max cache size given the available disk space and
54// cache type.
55NET_EXPORT_PRIVATE int PreferredCacheSize(
56 int64_t available,
57 net::CacheType type = net::DISK_CACHE);
[email protected]18b5b262013-11-19 18:41:3758
59// The default cache size should not ideally be exposed, but the blockfile
60// backend uses it for reasons that include testing.
61NET_EXPORT_PRIVATE extern const int kDefaultCacheSize;
62
[email protected]408d35f52008-08-13 18:30:2263} // namespace disk_cache
64
65#endif // NET_DISK_CACHE_CACHE_UTIL_H_