Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: webkit/fileapi/file_system_usage_cache.h

Issue 14895013: Move webkit/fileapi/file_system_mount_point_provider.h to webkit/browser/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/platform_file.h"
14 #include "base/sequenced_task_runner.h"
15 #include "base/timer.h"
16 #include "webkit/storage/webkit_storage_export.h"
17
18 namespace fileapi {
19
20 class WEBKIT_STORAGE_EXPORT_PRIVATE FileSystemUsageCache {
21 public:
22 explicit FileSystemUsageCache(base::SequencedTaskRunner* task_runner);
23 ~FileSystemUsageCache();
24
25 // Gets the size described in the .usage file even if dirty > 0 or
26 // is_valid == false. Returns true if the .usage file is available.
27 bool GetUsage(const base::FilePath& usage_file_path, int64* usage);
28
29 // Gets the dirty count in the .usage file.
30 // Returns true if the .usage file is available.
31 bool GetDirty(const base::FilePath& usage_file_path, uint32* dirty);
32
33 // Increments or decrements the "dirty" entry in the .usage file.
34 // Returns false if no .usage is available.
35 bool IncrementDirty(const base::FilePath& usage_file_path);
36 bool DecrementDirty(const base::FilePath& usage_file_path);
37
38 // Notifies quota system that it needs to recalculate the usage cache of the
39 // origin. Returns false if no .usage is available.
40 bool Invalidate(const base::FilePath& usage_file_path);
41 bool IsValid(const base::FilePath& usage_file_path);
42
43 // Updates the size described in the .usage file.
44 bool UpdateUsage(const base::FilePath& usage_file_path, int64 fs_usage);
45
46 // Updates the size described in the .usage file by delta with keeping dirty
47 // even if dirty > 0.
48 bool AtomicUpdateUsageByDelta(const base::FilePath& usage_file_path,
49 int64 delta);
50
51 bool Exists(const base::FilePath& usage_file_path);
52 bool Delete(const base::FilePath& usage_file_path);
53
54 void CloseCacheFiles();
55
56 static const base::FilePath::CharType kUsageFileName[];
57 static const char kUsageFileHeader[];
58 static const int kUsageFileSize;
59 static const int kUsageFileHeaderSize;
60
61 private:
62 typedef std::map<base::FilePath, base::PlatformFile> CacheFiles;
63
64 // Read the size, validity and the "dirty" entry described in the .usage file.
65 // Returns less than zero if no .usage file is available.
66 bool Read(const base::FilePath& usage_file_path,
67 bool* is_valid,
68 uint32* dirty,
69 int64* usage);
70
71 bool Write(const base::FilePath& usage_file_path,
72 bool is_valid,
73 int32 dirty,
74 int64 fs_usage);
75
76 bool GetPlatformFile(const base::FilePath& file_path,
77 base::PlatformFile* file);
78
79 bool ReadBytes(const base::FilePath& file_path,
80 char* buffer,
81 int64 buffer_size);
82 bool WriteBytes(const base::FilePath& file_path,
83 const char* buffer,
84 int64 buffer_size);
85 bool FlushFile(const base::FilePath& file_path);
86 void ScheduleCloseTimer();
87
88 bool HasCacheFileHandle(const base::FilePath& file_path);
89
90 bool CalledOnValidThread();
91
92 base::OneShotTimer<FileSystemUsageCache> timer_;
93 std::map<base::FilePath, base::PlatformFile> cache_files_;
94 base::WeakPtrFactory<FileSystemUsageCache> weak_factory_;
95
96 scoped_refptr<base::SequencedTaskRunner> task_runner_;
97
98 DISALLOW_COPY_AND_ASSIGN(FileSystemUsageCache);
99 };
100
101 } // namespace fileapi
102
103 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698