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

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

Issue 7312023: Refactoring: Change all -FileUtils non-Singleton and to own underlying FileUtils. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Reflected the comments and rebased. Created 9 years, 5 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
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 "webkit/fileapi/file_system_file_util.h" 9 #include "webkit/fileapi/file_system_file_util.h"
9 #include "webkit/fileapi/file_system_operation_context.h" 10 #include "webkit/fileapi/file_system_operation_context.h"
10 #pragma once 11 #pragma once
11 12
12 namespace fileapi { 13 namespace fileapi {
13 14
14 class QuotaFileUtil : public FileSystemFileUtil { 15 class QuotaFileUtil : public FileSystemFileUtil {
15 public: 16 public:
16 static QuotaFileUtil* GetInstance(); 17 static const int64 kNoLimit;
kinuko 2011/07/26 09:48:57 style-nit: place variables after methods
Dai Mikurube (NOT FULLTIME) 2011/07/26 10:19:11 I remember Constants (static const) are better to
17 virtual ~QuotaFileUtil() {}
18 18
19 static const int64 kNoLimit; 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:
21 // FileSystemFileUtil* file_system_file_util =
22 // new QuotaFileUtil(new FileSystemFileUtil());
23 explicit QuotaFileUtil(FileSystemFileUtil* underlying_file_util);
24 virtual ~QuotaFileUtil();
25
26 static QuotaFileUtil* CreateDefault();
kinuko 2011/07/26 09:48:57 Please add comment about what this does. The comm
Dai Mikurube (NOT FULLTIME) 2011/07/26 10:19:11 Done.
20 27
21 // TODO(dmikurube): Make this function variable by the constructor. 28 // TODO(dmikurube): Make this function variable by the constructor.
22 int64 ComputeFilePathCost(const FilePath& file_path) const; 29 int64 ComputeFilePathCost(const FilePath& file_path) const;
23 30
24 virtual base::PlatformFileError CreateOrOpen( 31 virtual base::PlatformFileError CreateOrOpen(
25 FileSystemOperationContext* fs_context, 32 FileSystemOperationContext* fs_context,
26 const FilePath& file_path, int file_flags, 33 const FilePath& file_path, int file_flags,
27 PlatformFile* file_handle, bool* created) OVERRIDE; 34 PlatformFile* file_handle, bool* created) OVERRIDE;
28 35
29 virtual base::PlatformFileError EnsureFileExists( 36 virtual base::PlatformFileError EnsureFileExists(
(...skipping 19 matching lines...) Expand all
49 56
50 virtual base::PlatformFileError DeleteSingleDirectory( 57 virtual base::PlatformFileError DeleteSingleDirectory(
51 FileSystemOperationContext* fs_context, 58 FileSystemOperationContext* fs_context,
52 const FilePath& file_path) OVERRIDE; 59 const FilePath& file_path) OVERRIDE;
53 60
54 virtual base::PlatformFileError Truncate( 61 virtual base::PlatformFileError Truncate(
55 FileSystemOperationContext* fs_context, 62 FileSystemOperationContext* fs_context,
56 const FilePath& path, 63 const FilePath& path,
57 int64 length) OVERRIDE; 64 int64 length) OVERRIDE;
58 65
59 friend struct DefaultSingletonTraits<QuotaFileUtil>; 66 private:
60 DISALLOW_COPY_AND_ASSIGN(QuotaFileUtil); 67 scoped_ptr<FileSystemFileUtil> underlying_file_util_;
61 68
62 protected:
63 QuotaFileUtil() {}
64
65 private:
66 // TODO(dmikurube): Make these constants variable by the constructor. 69 // TODO(dmikurube): Make these constants variable by the constructor.
67 // 70 //
68 // These values are based on Obfuscation DB. See crbug.com/86114 for the 71 // These values are based on Obfuscation DB. See crbug.com/86114 for the
69 // source of these numbers. These should be revisited if 72 // source of these numbers. These should be revisited if
70 // * the underlying tables change, 73 // * the underlying tables change,
71 // * indexes in levelDB change, or 74 // * indexes in levelDB change, or
72 // * another path name indexer is provided in addition to levelDB. 75 // * another path name indexer is provided in addition to levelDB.
73 // 76 //
74 // When these values are changed, the usage cache should be bumped up. 77 // When these values are changed, the usage cache should be bumped up.
75 static const int64 kFilePathCostPerChar; 78 static const int64 kFilePathCostPerChar;
76 static const int64 kFilePathCostPerFile; 79 static const int64 kFilePathCostPerFile;
77 80
78 bool CanCopyFile( 81 bool CanCopyFile(
79 FileSystemOperationContext* fs_context, 82 FileSystemOperationContext* fs_context,
80 const FilePath& src_file_path, 83 const FilePath& src_file_path,
81 const FilePath& dest_file_path, 84 const FilePath& dest_file_path,
82 int64 allowed_bytes_growth, 85 int64 allowed_bytes_growth,
83 int64* growth) const; 86 int64* growth) const;
87
88 DISALLOW_COPY_AND_ASSIGN(QuotaFileUtil);
84 }; 89 };
85 90
86 } // namespace fileapi 91 } // namespace fileapi
87 92
88 #endif // WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_ 93 #endif // WEBKIT_FILEAPI_QUOTA_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/obfuscated_file_system_file_util_unittest.cc ('k') | webkit/fileapi/quota_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698