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