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_LOCAL_FILE_SYSTEM_FILE_UTIL_H_ | 5 #ifndef WEBKIT_FILEAPI_NATIVE_FILE_UTIL_H_ |
6 #define WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_FILE_UTIL_H_ | 6 #define WEBKIT_FILEAPI_NATIVE_FILE_UTIL_H_ |
7 | 7 |
8 #include <vector> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/file_path.h" | 8 #include "base/file_path.h" |
12 #include "base/file_util.h" | |
13 #include "base/file_util_proxy.h" | 9 #include "base/file_util_proxy.h" |
14 #include "base/logging.h" | |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
17 #include "webkit/fileapi/file_system_file_util.h" | 11 #include "webkit/fileapi/fileapi_file_util.h" |
18 #include "webkit/fileapi/file_system_types.h" | |
19 | 12 |
20 namespace base { | 13 namespace base { |
21 struct PlatformFileInfo; | |
22 class MessageLoopProxy; | |
23 class Time; | 14 class Time; |
24 } | 15 } |
25 | 16 |
26 class GURL; | |
27 | |
28 namespace fileapi { | 17 namespace fileapi { |
29 | 18 |
30 using base::PlatformFile; | 19 using base::PlatformFile; |
31 using base::PlatformFileError; | 20 using base::PlatformFileError; |
32 | |
33 class FileSystemOperationContext; | 21 class FileSystemOperationContext; |
34 | 22 |
35 // An instance of this class is created and owned by *MountPointProvider. | 23 class NativeFileUtil : public FileUtil { |
ericu
2011/08/03 22:59:26
This needs a class comment that says what this par
Dai Mikurube (NOT FULLTIME)
2011/08/04 03:54:48
Done.
| |
36 class LocalFileSystemFileUtil : public FileSystemFileUtil { | |
37 public: | 24 public: |
38 // |underlying_file_util| is owned by the instance. It will be deleted by | 25 NativeFileUtil() {} |
39 // the owner instance. For example, it can be instanciated as follows: | 26 virtual ~NativeFileUtil() {} |
40 // FileSystemFileUtil* file_system_file_util = | |
41 // new LocalFileSystemFileUtil(new FileSystemFileUtil()); | |
42 explicit LocalFileSystemFileUtil(FileSystemFileUtil* underlying_file_util); | |
43 virtual ~LocalFileSystemFileUtil(); | |
44 | 27 |
45 virtual PlatformFileError CreateOrOpen( | 28 virtual PlatformFileError CreateOrOpen( |
46 FileSystemOperationContext* context, | 29 FileSystemOperationContext* unused, |
47 const FilePath& file_path, | 30 const FilePath& file_path, |
48 int file_flags, | 31 int file_flags, |
49 PlatformFile* file_handle, | 32 PlatformFile* file_handle, |
50 bool* created); | 33 bool* created); |
51 | 34 |
35 virtual PlatformFileError Close( | |
36 FileSystemOperationContext* unused, | |
37 PlatformFile); | |
38 | |
52 virtual PlatformFileError EnsureFileExists( | 39 virtual PlatformFileError EnsureFileExists( |
53 FileSystemOperationContext* context, | 40 FileSystemOperationContext* unused, |
54 const FilePath& file_path, bool* created); | 41 const FilePath& file_path, bool* created); |
ericu
2011/08/03 22:59:26
Please add OVERRIDE tags on all overridden methods
Dai Mikurube (NOT FULLTIME)
2011/08/04 03:54:48
Done.
| |
55 | 42 |
56 virtual PlatformFileError GetLocalFilePath( | 43 virtual PlatformFileError GetLocalFilePath( |
57 FileSystemOperationContext* context, | 44 FileSystemOperationContext* unused, |
58 const FilePath& virtual_file, | 45 const FilePath& virtual_path, |
59 FilePath* local_path); | 46 FilePath* local_path); |
60 | 47 |
61 virtual PlatformFileError GetFileInfo( | 48 virtual PlatformFileError GetFileInfo( |
62 FileSystemOperationContext* context, | 49 FileSystemOperationContext* unused, |
63 const FilePath& file, | 50 const FilePath& file_, |
64 base::PlatformFileInfo* file_info, | 51 base::PlatformFileInfo* file_info, |
65 FilePath* platform_file); | 52 FilePath* platform_path); |
66 | 53 |
67 virtual PlatformFileError ReadDirectory( | 54 virtual PlatformFileError ReadDirectory( |
68 FileSystemOperationContext* context, | 55 FileSystemOperationContext* unused, |
69 const FilePath& file_path, | 56 const FilePath& file_path, |
70 std::vector<base::FileUtilProxy::Entry>* entries); | 57 std::vector<base::FileUtilProxy::Entry>* entries); |
71 | 58 |
72 virtual PlatformFileError CreateDirectory( | 59 virtual PlatformFileError CreateDirectory( |
73 FileSystemOperationContext* context, | 60 FileSystemOperationContext* context, |
74 const FilePath& file_path, | 61 const FilePath& file_path, |
75 bool exclusive, | 62 bool exclusive, |
76 bool recursive); | 63 bool recursive); |
77 | 64 |
78 virtual PlatformFileError CopyOrMoveFile( | 65 virtual PlatformFileError CopyOrMoveFile( |
79 FileSystemOperationContext* context, | 66 FileSystemOperationContext* unused, |
80 const FilePath& src_file_path, | 67 const FilePath& src_file_path, |
81 const FilePath& dest_file_path, | 68 const FilePath& dest_file_path, |
82 bool copy); | 69 bool copy); |
83 | 70 |
84 virtual PlatformFileError CopyInForeignFile( | 71 virtual PlatformFileError CopyInForeignFile( |
85 FileSystemOperationContext* context, | 72 FileSystemOperationContext* unused, |
86 const FilePath& src_file_path, | 73 const FilePath& src_file_path, |
87 const FilePath& dest_file_path); | 74 const FilePath& dest_file_path); |
88 | 75 |
89 virtual PlatformFileError DeleteFile( | 76 virtual PlatformFileError DeleteFile( |
90 FileSystemOperationContext* context, | 77 FileSystemOperationContext* unused, |
91 const FilePath& file_path); | 78 const FilePath& file_path); |
92 | 79 |
93 virtual PlatformFileError DeleteSingleDirectory( | 80 virtual PlatformFileError DeleteSingleDirectory( |
94 FileSystemOperationContext* context, | 81 FileSystemOperationContext* unused, |
95 const FilePath& file_path); | 82 const FilePath& file_path); |
96 | 83 |
97 virtual PlatformFileError Touch( | 84 virtual PlatformFileError Touch( |
98 FileSystemOperationContext* context, | 85 FileSystemOperationContext* unused, |
99 const FilePath& file_path, | 86 const FilePath& file_path, |
100 const base::Time& last_access_time, | 87 const base::Time& last_access_time, |
101 const base::Time& last_modified_time); | 88 const base::Time& last_modified_time); |
102 | 89 |
103 virtual PlatformFileError Truncate( | 90 virtual PlatformFileError Truncate( |
104 FileSystemOperationContext* context, | 91 FileSystemOperationContext* unused, |
105 const FilePath& path, | 92 const FilePath& path, |
106 int64 length); | 93 int64 length); |
107 | 94 |
108 virtual bool PathExists( | 95 virtual bool PathExists( |
109 FileSystemOperationContext* context, | 96 FileSystemOperationContext* unused, |
110 const FilePath& file_path); | 97 const FilePath& file_path); |
111 | 98 |
112 virtual bool DirectoryExists( | 99 virtual bool DirectoryExists( |
113 FileSystemOperationContext* context, | 100 FileSystemOperationContext* unused, |
114 const FilePath& file_path); | 101 const FilePath& file_path); |
115 | 102 |
116 virtual bool IsDirectoryEmpty( | 103 virtual bool IsDirectoryEmpty( |
117 FileSystemOperationContext* context, | 104 FileSystemOperationContext* unused, |
118 const FilePath& file_path); | 105 const FilePath& file_path); |
119 | 106 |
120 virtual AbstractFileEnumerator* CreateFileEnumerator( | 107 virtual AbstractFileEnumerator* CreateFileEnumerator( |
121 FileSystemOperationContext* context, | 108 FileSystemOperationContext* unused, |
122 const FilePath& root_path); | 109 const FilePath& root_path); |
123 | 110 |
124 private: | 111 private: |
125 // Given the filesystem's root URL and a virtual path, produces a real, full | 112 DISALLOW_COPY_AND_ASSIGN(NativeFileUtil); |
126 // local path. | |
127 FilePath GetLocalPath( | |
128 FileSystemOperationContext* context, | |
129 const GURL& origin_url, | |
130 FileSystemType type, | |
131 const FilePath& virtual_path); | |
132 | |
133 scoped_ptr<FileSystemFileUtil> underlying_file_util_; | |
134 | |
135 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemFileUtil); | |
136 }; | 113 }; |
137 | 114 |
138 } // namespace fileapi | 115 } // namespace fileapi |
139 | 116 |
140 #endif // WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_FILE_UTIL_H_ | 117 #endif // WEBKIT_FILEAPI_NATIVE_FILE_UTIL_H_ |
OLD | NEW |