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" | |
10 #include "webkit/fileapi/file_system_operation_context.h" | 9 #include "webkit/fileapi/file_system_operation_context.h" |
| 10 #include "webkit/fileapi/fileapi_file_util.h" |
11 #pragma once | 11 #pragma once |
12 | 12 |
13 namespace fileapi { | 13 namespace fileapi { |
14 | 14 |
15 class QuotaFileUtil : public FileSystemFileUtil { | 15 class QuotaFileUtil : public FileApiFileUtil { |
16 public: | 16 public: |
17 static const int64 kNoLimit; | 17 static const int64 kNoLimit; |
18 | 18 |
19 // |underlying_file_util| is owned by the instance. It will be deleted by | 19 // |underlying_file_util| is owned by the instance. It will be deleted by |
20 // the owner instance. For example, it can be instanciated as follows: | 20 // the owner instance. For example, it can be instanciated as follows: |
21 // FileSystemFileUtil* file_util = new QuotaFileUtil(new SomeFileUtil()); | 21 // FileApiFileUtil* file_util = new QuotaFileUtil(new SomeFileUtil()); |
22 // | 22 // |
23 // To instanciate an object whose underlying file_util is FileSystemFileUtil, | 23 // To instanciate an object whose underlying file_util is FileApiFileUtil, |
24 // QuotaFileUtil::CreateDefault() can be used. | 24 // QuotaFileUtil::CreateDefault() can be used. |
25 explicit QuotaFileUtil(FileSystemFileUtil* underlying_file_util); | 25 explicit QuotaFileUtil(FileApiFileUtil* 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 FileUtil instance. |
29 // instance. | |
30 static QuotaFileUtil* CreateDefault(); | 29 static QuotaFileUtil* CreateDefault(); |
31 | 30 |
32 // TODO(dmikurube): Make this function variable by the constructor. | 31 // TODO(dmikurube): Make this function variable by the constructor. |
33 int64 ComputeFilePathCost(const FilePath& file_path) const; | 32 int64 ComputeFilePathCost(const FilePath& file_path) const; |
34 | 33 |
35 virtual base::PlatformFileError CreateOrOpen( | 34 virtual base::PlatformFileError CreateOrOpen( |
36 FileSystemOperationContext* fs_context, | 35 FileSystemOperationContext* fs_context, |
37 const FilePath& file_path, int file_flags, | 36 const FilePath& file_path, int file_flags, |
38 PlatformFile* file_handle, bool* created) OVERRIDE; | 37 PlatformFile* file_handle, bool* created) OVERRIDE; |
39 | 38 |
(...skipping 21 matching lines...) Expand all Loading... |
61 virtual base::PlatformFileError DeleteSingleDirectory( | 60 virtual base::PlatformFileError DeleteSingleDirectory( |
62 FileSystemOperationContext* fs_context, | 61 FileSystemOperationContext* fs_context, |
63 const FilePath& file_path) OVERRIDE; | 62 const FilePath& file_path) OVERRIDE; |
64 | 63 |
65 virtual base::PlatformFileError Truncate( | 64 virtual base::PlatformFileError Truncate( |
66 FileSystemOperationContext* fs_context, | 65 FileSystemOperationContext* fs_context, |
67 const FilePath& path, | 66 const FilePath& path, |
68 int64 length) OVERRIDE; | 67 int64 length) OVERRIDE; |
69 | 68 |
70 private: | 69 private: |
71 scoped_ptr<FileSystemFileUtil> underlying_file_util_; | |
72 | |
73 // TODO(dmikurube): Make these constants variable by the constructor. | 70 // TODO(dmikurube): Make these constants variable by the constructor. |
74 // | 71 // |
75 // These values are based on Obfuscation DB. See crbug.com/86114 for the | 72 // These values are based on Obfuscation DB. See crbug.com/86114 for the |
76 // source of these numbers. These should be revisited if | 73 // source of these numbers. These should be revisited if |
77 // * the underlying tables change, | 74 // * the underlying tables change, |
78 // * indexes in levelDB change, or | 75 // * indexes in levelDB change, or |
79 // * another path name indexer is provided in addition to levelDB. | 76 // * another path name indexer is provided in addition to levelDB. |
80 // | 77 // |
81 // When these values are changed, the usage cache should be bumped up. | 78 // When these values are changed, the usage cache should be bumped up. |
82 static const int64 kFilePathCostPerChar; | 79 static const int64 kFilePathCostPerChar; |
83 static const int64 kFilePathCostPerFile; | 80 static const int64 kFilePathCostPerFile; |
84 | 81 |
85 bool CanCopyFile( | 82 bool CanCopyFile( |
86 FileSystemOperationContext* fs_context, | 83 FileSystemOperationContext* fs_context, |
87 const FilePath& src_file_path, | 84 const FilePath& src_file_path, |
88 const FilePath& dest_file_path, | 85 const FilePath& dest_file_path, |
89 int64 allowed_bytes_growth, | 86 int64 allowed_bytes_growth, |
90 int64* growth) const; | 87 int64* growth) const; |
91 | 88 |
92 DISALLOW_COPY_AND_ASSIGN(QuotaFileUtil); | 89 DISALLOW_COPY_AND_ASSIGN(QuotaFileUtil); |
93 }; | 90 }; |
94 | 91 |
95 } // namespace fileapi | 92 } // namespace fileapi |
96 | 93 |
97 #endif // WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_ | 94 #endif // WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_ |
OLD | NEW |