OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_ |
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 | 10 |
11 namespace fileapi { | 11 namespace fileapi { |
12 | 12 |
13 class FileSystemUsageCache { | 13 class FileSystemUsageCache { |
14 public: | 14 public: |
15 // Gets the size described in the .usage file even if dirty > 0. | 15 // Gets the size described in the .usage file even if dirty > 0 or |
16 // Returns less than zero if the .usage file is not available. | 16 // is_valid == false. Returns less than zero if the .usage file is not |
17 // available. | |
17 static int64 GetUsage(const FilePath& usage_file_path); | 18 static int64 GetUsage(const FilePath& usage_file_path); |
18 | 19 |
19 // Gets the dirty count in the .usage file. | 20 // Gets the dirty count in the .usage file. |
20 // Returns less than zero if the .usage file is not available. | 21 // Returns less than zero if the .usage file is not available. |
21 static int32 GetDirty(const FilePath& usage_file_path); | 22 static int32 GetDirty(const FilePath& usage_file_path); |
22 | 23 |
23 // Increments or decrements the "dirty" entry in the .usage file. | 24 // Increments or decrements the "dirty" entry in the .usage file. |
24 // Returns false if no .usage is available. | 25 // Returns false if no .usage is available. |
25 static bool IncrementDirty(const FilePath& usage_file_path); | 26 static bool IncrementDirty(const FilePath& usage_file_path); |
26 static bool DecrementDirty(const FilePath& usage_file_path); | 27 static bool DecrementDirty(const FilePath& usage_file_path); |
27 | 28 |
29 // Notifies quota system need to recalculate their usage cache of the origin. | |
ericu
2011/08/24 03:43:50
s/need/that it needs/
s/their/the
Sorry, I know i
tzik
2011/08/29 06:54:13
Done.
| |
30 // Returns false if no .usage is available. | |
31 static bool Invalidate(const FilePath& usage_file_path); | |
32 static bool IsValid(const FilePath& usage_file_path); | |
33 | |
28 // Updates the size described in the .usage file. | 34 // Updates the size described in the .usage file. |
29 static int UpdateUsage(const FilePath& usage_file_path, int64 fs_usage); | 35 static int UpdateUsage(const FilePath& usage_file_path, int64 fs_usage); |
30 | 36 |
31 // Updates the size described in the .usage file by delta with keeping dirty | 37 // Updates the size described in the .usage file by delta with keeping dirty |
32 // even if dirty > 0. | 38 // even if dirty > 0. |
33 static int AtomicUpdateUsageByDelta( | 39 static int AtomicUpdateUsageByDelta( |
34 const FilePath& usage_file_path, int64 delta); | 40 const FilePath& usage_file_path, int64 delta); |
35 | 41 |
36 static bool Exists(const FilePath& usage_file_path); | 42 static bool Exists(const FilePath& usage_file_path); |
37 static bool Delete(const FilePath& usage_file_path); | 43 static bool Delete(const FilePath& usage_file_path); |
38 | 44 |
39 static const char kUsageFileName[]; | 45 static const char kUsageFileName[]; |
40 static const char kUsageFileHeader[]; | 46 static const char kUsageFileHeader[]; |
41 static const int kUsageFileSize; | 47 static const int kUsageFileSize; |
42 static const int kUsageFileHeaderSize; | 48 static const int kUsageFileHeaderSize; |
43 | 49 |
44 private: | 50 private: |
45 // Read the size and the "dirty" entry described in the .usage file. | 51 // Read the size, validity and the "dirty" entry described in the .usage file. |
46 // Returns less than zero if no .usage file is available. | 52 // Returns less than zero if no .usage file is available. |
47 static int64 Read(const FilePath& usage_file_path, uint32* dirty); | 53 static int64 Read(const FilePath& usage_file_path, |
54 bool* is_valid, | |
55 uint32* dirty); | |
48 | 56 |
49 static int Write(const FilePath& usage_file_path, | 57 static int Write(const FilePath& usage_file_path, |
50 uint32 dirty, int64 fs_usage); | 58 bool is_valid, |
59 uint32 dirty, | |
60 int64 fs_usage); | |
51 }; | 61 }; |
52 | 62 |
53 } // namespace fileapi | 63 } // namespace fileapi |
54 | 64 |
55 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_ | 65 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_ |
OLD | NEW |