Experimental push messaging api reference docs.
[chromium-blink-merge.git] / webkit / fileapi / file_system_usage_cache.h
blob4a8825456680dcbe8e55616ed8a97b6744da83e5
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"
12 namespace fileapi {
14 class FILEAPI_EXPORT_PRIVATE FileSystemUsageCache {
15 public:
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
18 // available.
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
39 // even if dirty > 0.
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;
51 private:
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,
55 bool* is_valid,
56 uint32* dirty);
58 static int Write(const FilePath& usage_file_path,
59 bool is_valid,
60 uint32 dirty,
61 int64 fs_usage);
64 } // namespace fileapi
66 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_