1 // Copyright (c) 2012 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.
5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_
8 #include "base/basictypes.h"
9 #include "base/file_path.h"
10 #include "webkit/fileapi/fileapi_export.h"
14 class FILEAPI_EXPORT_PRIVATE FileSystemUsageCache
{
16 // Gets the size described in the .usage file even if dirty > 0 or
17 // is_valid == false. Returns less than zero if the .usage file is not
19 static int64
GetUsage(const FilePath
& usage_file_path
);
21 // Gets the dirty count in the .usage file.
22 // Returns less than zero if the .usage file is not available.
23 static int32
GetDirty(const FilePath
& usage_file_path
);
25 // Increments or decrements the "dirty" entry in the .usage file.
26 // Returns false if no .usage is available.
27 static bool IncrementDirty(const FilePath
& usage_file_path
);
28 static bool DecrementDirty(const FilePath
& usage_file_path
);
30 // Notifies quota system that it needs to recalculate the usage cache of the
31 // origin. Returns false if no .usage is available.
32 static bool Invalidate(const FilePath
& usage_file_path
);
33 static bool IsValid(const FilePath
& usage_file_path
);
35 // Updates the size described in the .usage file.
36 static int UpdateUsage(const FilePath
& usage_file_path
, int64 fs_usage
);
38 // Updates the size described in the .usage file by delta with keeping dirty
40 static int AtomicUpdateUsageByDelta(
41 const FilePath
& usage_file_path
, int64 delta
);
43 static bool Exists(const FilePath
& usage_file_path
);
44 static bool Delete(const FilePath
& usage_file_path
);
46 static const FilePath::CharType kUsageFileName
[];
47 static const char kUsageFileHeader
[];
48 static const int kUsageFileSize
;
49 static const int kUsageFileHeaderSize
;
52 // Read the size, validity and the "dirty" entry described in the .usage file.
53 // Returns less than zero if no .usage file is available.
54 static int64
Read(const FilePath
& usage_file_path
,
58 static int Write(const FilePath
& usage_file_path
,
64 } // namespace fileapi
66 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_