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