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_QUOTA_FILE_UTIL_H_ | 5 #ifndef WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_ |
6 #define WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_ | 6 #define WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "webkit/fileapi/file_system_file_util.h" | 9 #include "webkit/fileapi/file_system_file_util.h" |
10 #include "webkit/fileapi/file_system_operation_context.h" | 10 #include "webkit/fileapi/file_system_operation_context.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // | 22 // |
23 // To instanciate an object whose underlying file_util is FileSystemFileUtil, | 23 // To instanciate an object whose underlying file_util is FileSystemFileUtil, |
24 // QuotaFileUtil::CreateDefault() can be used. | 24 // QuotaFileUtil::CreateDefault() can be used. |
25 explicit QuotaFileUtil(FileSystemFileUtil* underlying_file_util); | 25 explicit QuotaFileUtil(FileSystemFileUtil* underlying_file_util); |
26 virtual ~QuotaFileUtil(); | 26 virtual ~QuotaFileUtil(); |
27 | 27 |
28 // Creates a QuotaFileUtil instance with an underlying FileSystemFileUtil | 28 // Creates a QuotaFileUtil instance with an underlying FileSystemFileUtil |
29 // instance. | 29 // instance. |
30 static QuotaFileUtil* CreateDefault(); | 30 static QuotaFileUtil* CreateDefault(); |
31 | 31 |
32 // TODO(dmikurube): Make this function variable by the constructor. | |
33 int64 ComputeFilePathCost(const FilePath& file_path) const; | |
34 | |
35 virtual base::PlatformFileError CreateOrOpen( | |
36 FileSystemOperationContext* fs_context, | |
37 const FilePath& file_path, int file_flags, | |
38 PlatformFile* file_handle, bool* created) OVERRIDE; | |
39 | |
40 virtual base::PlatformFileError EnsureFileExists( | |
41 FileSystemOperationContext* fs_context, | |
42 const FilePath& file_path, | |
43 bool* created) OVERRIDE; | |
44 | |
45 virtual base::PlatformFileError CreateDirectory( | |
46 FileSystemOperationContext* fs_context, | |
47 const FilePath& file_path, | |
48 bool exclusive, | |
49 bool recursive) OVERRIDE; | |
50 | |
51 virtual base::PlatformFileError CopyOrMoveFile( | 32 virtual base::PlatformFileError CopyOrMoveFile( |
52 FileSystemOperationContext* fs_context, | 33 FileSystemOperationContext* fs_context, |
53 const FilePath& src_file_path, | 34 const FilePath& src_file_path, |
54 const FilePath& dest_file_path, | 35 const FilePath& dest_file_path, |
55 bool copy) OVERRIDE; | 36 bool copy) OVERRIDE; |
56 | 37 |
57 virtual base::PlatformFileError DeleteFile( | 38 virtual base::PlatformFileError DeleteFile( |
58 FileSystemOperationContext* fs_context, | 39 FileSystemOperationContext* fs_context, |
59 const FilePath& file_path) OVERRIDE; | 40 const FilePath& file_path) OVERRIDE; |
60 | 41 |
61 virtual base::PlatformFileError DeleteSingleDirectory( | |
62 FileSystemOperationContext* fs_context, | |
63 const FilePath& file_path) OVERRIDE; | |
64 | |
65 virtual base::PlatformFileError Truncate( | 42 virtual base::PlatformFileError Truncate( |
66 FileSystemOperationContext* fs_context, | 43 FileSystemOperationContext* fs_context, |
67 const FilePath& path, | 44 const FilePath& path, |
68 int64 length) OVERRIDE; | 45 int64 length) OVERRIDE; |
69 | 46 |
70 private: | 47 private: |
71 scoped_ptr<FileSystemFileUtil> underlying_file_util_; | 48 scoped_ptr<FileSystemFileUtil> underlying_file_util_; |
72 | 49 |
73 // TODO(dmikurube): Make these constants variable by the constructor. | |
74 // | |
75 // These values are based on Obfuscation DB. See crbug.com/86114 for the | |
76 // source of these numbers. These should be revisited if | |
77 // * the underlying tables change, | |
78 // * indexes in levelDB change, or | |
79 // * another path name indexer is provided in addition to levelDB. | |
80 // | |
81 // When these values are changed, the usage cache should be bumped up. | |
82 static const int64 kFilePathCostPerChar; | |
83 static const int64 kFilePathCostPerFile; | |
84 | |
85 bool CanCopyFile( | |
86 FileSystemOperationContext* fs_context, | |
87 const FilePath& src_file_path, | |
88 const FilePath& dest_file_path, | |
89 int64 allowed_bytes_growth, | |
90 int64* growth) const; | |
91 | |
92 DISALLOW_COPY_AND_ASSIGN(QuotaFileUtil); | 50 DISALLOW_COPY_AND_ASSIGN(QuotaFileUtil); |
93 }; | 51 }; |
94 | 52 |
95 } // namespace fileapi | 53 } // namespace fileapi |
96 | 54 |
97 #endif // WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_ | 55 #endif // WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_ |
OLD | NEW |