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

Side by Side Diff: storage/browser/fileapi/file_system_file_util.h

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BROWSER_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ 5 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_
6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_
7 7
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "webkit/browser/fileapi/file_system_operation.h" 11 #include "storage/browser/fileapi/file_system_operation.h"
12 #include "webkit/browser/webkit_storage_browser_export.h" 12 #include "storage/common/storage_export.h"
13 #include "webkit/common/blob/scoped_file.h" 13 #include "storage/common/blob/scoped_file.h"
14 14
15 namespace base { 15 namespace base {
16 class Time; 16 class Time;
17 } 17 }
18 18
19 namespace fileapi { 19 namespace storage {
20 20
21 class FileSystemOperationContext; 21 class FileSystemOperationContext;
22 class FileSystemURL; 22 class FileSystemURL;
23 23
24 // A file utility interface that provides basic file utility methods for 24 // A file utility interface that provides basic file utility methods for
25 // FileSystem API. 25 // FileSystem API.
26 // 26 //
27 // Layering structure of the FileSystemFileUtil was split out. 27 // Layering structure of the FileSystemFileUtil was split out.
28 // See http://crbug.com/128136 if you need it. 28 // See http://crbug.com/128136 if you need it.
29 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemFileUtil { 29 class STORAGE_EXPORT FileSystemFileUtil {
30 public: 30 public:
31 typedef FileSystemOperation::CopyOrMoveOption CopyOrMoveOption; 31 typedef FileSystemOperation::CopyOrMoveOption CopyOrMoveOption;
32 32
33 // It will be implemented by each subclass such as FileSystemFileEnumerator. 33 // It will be implemented by each subclass such as FileSystemFileEnumerator.
34 class WEBKIT_STORAGE_BROWSER_EXPORT AbstractFileEnumerator { 34 class STORAGE_EXPORT AbstractFileEnumerator {
35 public: 35 public:
36 virtual ~AbstractFileEnumerator() {} 36 virtual ~AbstractFileEnumerator() {}
37 37
38 // Returns an empty string if there are no more results. 38 // Returns an empty string if there are no more results.
39 virtual base::FilePath Next() = 0; 39 virtual base::FilePath Next() = 0;
40 40
41 // These methods return metadata for the file most recently returned by 41 // These methods return metadata for the file most recently returned by
42 // Next(). If Next() has never been called, or if Next() most recently 42 // Next(). If Next() has never been called, or if Next() most recently
43 // returned an empty string, then return the default values of 0, 43 // returned an empty string, then return the default values of 0,
44 // "null time", and false, respectively. 44 // "null time", and false, respectively.
45 virtual int64 Size() = 0; 45 virtual int64 Size() = 0;
46 virtual base::Time LastModifiedTime() = 0; 46 virtual base::Time LastModifiedTime() = 0;
47 virtual bool IsDirectory() = 0; 47 virtual bool IsDirectory() = 0;
48 }; 48 };
49 49
50 class WEBKIT_STORAGE_BROWSER_EXPORT EmptyFileEnumerator 50 class STORAGE_EXPORT EmptyFileEnumerator : public AbstractFileEnumerator {
51 : public AbstractFileEnumerator {
52 virtual base::FilePath Next() OVERRIDE; 51 virtual base::FilePath Next() OVERRIDE;
53 virtual int64 Size() OVERRIDE; 52 virtual int64 Size() OVERRIDE;
54 virtual base::Time LastModifiedTime() OVERRIDE; 53 virtual base::Time LastModifiedTime() OVERRIDE;
55 virtual bool IsDirectory() OVERRIDE; 54 virtual bool IsDirectory() OVERRIDE;
56 }; 55 };
57 56
58 virtual ~FileSystemFileUtil() {} 57 virtual ~FileSystemFileUtil() {}
59 58
60 // Creates or opens a file with the given flags. 59 // Creates or opens a file with the given flags.
61 // See header comments for AsyncFileUtil::CreateOrOpen() for more details. 60 // See header comments for AsyncFileUtil::CreateOrOpen() for more details.
62 // This is used only by Pepper/NaCl File API. 61 // This is used only by Pepper/NaCl File API.
63 virtual base::File CreateOrOpen( 62 virtual base::File CreateOrOpen(FileSystemOperationContext* context,
64 FileSystemOperationContext* context, 63 const FileSystemURL& url,
65 const FileSystemURL& url, 64 int file_flags) = 0;
66 int file_flags) = 0;
67 65
68 // Ensures that the given |url| exist. This creates a empty new file 66 // Ensures that the given |url| exist. This creates a empty new file
69 // at |url| if the |url| does not exist. 67 // at |url| if the |url| does not exist.
70 // See header comments for AsyncFileUtil::EnsureFileExists() for more details. 68 // See header comments for AsyncFileUtil::EnsureFileExists() for more details.
71 virtual base::File::Error EnsureFileExists( 69 virtual base::File::Error EnsureFileExists(
72 FileSystemOperationContext* context, 70 FileSystemOperationContext* context,
73 const FileSystemURL& url, bool* created) = 0; 71 const FileSystemURL& url,
72 bool* created) = 0;
74 73
75 // Creates directory at given url. 74 // Creates directory at given url.
76 // See header comments for AsyncFileUtil::CreateDirectory() for more details. 75 // See header comments for AsyncFileUtil::CreateDirectory() for more details.
77 virtual base::File::Error CreateDirectory( 76 virtual base::File::Error CreateDirectory(FileSystemOperationContext* context,
78 FileSystemOperationContext* context, 77 const FileSystemURL& url,
79 const FileSystemURL& url, 78 bool exclusive,
80 bool exclusive, 79 bool recursive) = 0;
81 bool recursive) = 0;
82 80
83 // Retrieves the information about a file. 81 // Retrieves the information about a file.
84 // See header comments for AsyncFileUtil::GetFileInfo() for more details. 82 // See header comments for AsyncFileUtil::GetFileInfo() for more details.
85 virtual base::File::Error GetFileInfo( 83 virtual base::File::Error GetFileInfo(FileSystemOperationContext* context,
86 FileSystemOperationContext* context, 84 const FileSystemURL& url,
87 const FileSystemURL& url, 85 base::File::Info* file_info,
88 base::File::Info* file_info, 86 base::FilePath* platform_path) = 0;
89 base::FilePath* platform_path) = 0;
90 87
91 // Returns a pointer to a new instance of AbstractFileEnumerator which is 88 // Returns a pointer to a new instance of AbstractFileEnumerator which is
92 // implemented for each FileSystemFileUtil subclass. The instance needs to be 89 // implemented for each FileSystemFileUtil subclass. The instance needs to be
93 // freed by the caller, and its lifetime should not extend past when the 90 // freed by the caller, and its lifetime should not extend past when the
94 // current call returns to the main FILE message loop. 91 // current call returns to the main FILE message loop.
95 // 92 //
96 // The supplied context must remain valid at least lifetime of the enumerator 93 // The supplied context must remain valid at least lifetime of the enumerator
97 // instance. 94 // instance.
98 virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator( 95 virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator(
99 FileSystemOperationContext* context, 96 FileSystemOperationContext* context,
100 const FileSystemURL& root_url) = 0; 97 const FileSystemURL& root_url) = 0;
101 98
102 // Maps |file_system_url| given |context| into |local_file_path| 99 // Maps |file_system_url| given |context| into |local_file_path|
103 // which represents physical file location on the host OS. 100 // which represents physical file location on the host OS.
104 // This may not always make sense for all subclasses. 101 // This may not always make sense for all subclasses.
105 virtual base::File::Error GetLocalFilePath( 102 virtual base::File::Error GetLocalFilePath(
106 FileSystemOperationContext* context, 103 FileSystemOperationContext* context,
107 const FileSystemURL& file_system_url, 104 const FileSystemURL& file_system_url,
108 base::FilePath* local_file_path) = 0; 105 base::FilePath* local_file_path) = 0;
109 106
110 // Updates the file metadata information. 107 // Updates the file metadata information.
111 // See header comments for AsyncFileUtil::Touch() for more details. 108 // See header comments for AsyncFileUtil::Touch() for more details.
112 virtual base::File::Error Touch( 109 virtual base::File::Error Touch(FileSystemOperationContext* context,
113 FileSystemOperationContext* context, 110 const FileSystemURL& url,
114 const FileSystemURL& url, 111 const base::Time& last_access_time,
115 const base::Time& last_access_time, 112 const base::Time& last_modified_time) = 0;
116 const base::Time& last_modified_time) = 0;
117 113
118 // Truncates a file to the given length. 114 // Truncates a file to the given length.
119 // See header comments for AsyncFileUtil::Truncate() for more details. 115 // See header comments for AsyncFileUtil::Truncate() for more details.
120 virtual base::File::Error Truncate( 116 virtual base::File::Error Truncate(FileSystemOperationContext* context,
121 FileSystemOperationContext* context, 117 const FileSystemURL& url,
122 const FileSystemURL& url, 118 int64 length) = 0;
123 int64 length) = 0;
124 119
125 // Copies or moves a single file from |src_url| to |dest_url|. 120 // Copies or moves a single file from |src_url| to |dest_url|.
126 // The filesystem type of |src_url| and |dest_url| MUST be same. 121 // The filesystem type of |src_url| and |dest_url| MUST be same.
127 // For |option|, please see file_system_operation.h 122 // For |option|, please see file_system_operation.h
128 // 123 //
129 // This returns: 124 // This returns:
130 // - File::FILE_ERROR_NOT_FOUND if |src_url| 125 // - File::FILE_ERROR_NOT_FOUND if |src_url|
131 // or the parent directory of |dest_url| does not exist. 126 // or the parent directory of |dest_url| does not exist.
132 // - File::FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file. 127 // - File::FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
133 // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and 128 // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
134 // is not a file. 129 // is not a file.
135 // - File::FILE_ERROR_FAILED if |dest_url| does not exist and 130 // - File::FILE_ERROR_FAILED if |dest_url| does not exist and
136 // its parent path is a file. 131 // its parent path is a file.
137 // 132 //
138 virtual base::File::Error CopyOrMoveFile( 133 virtual base::File::Error CopyOrMoveFile(FileSystemOperationContext* context,
139 FileSystemOperationContext* context, 134 const FileSystemURL& src_url,
140 const FileSystemURL& src_url, 135 const FileSystemURL& dest_url,
141 const FileSystemURL& dest_url, 136 CopyOrMoveOption option,
142 CopyOrMoveOption option, 137 bool copy) = 0;
143 bool copy) = 0;
144 138
145 // Copies in a single file from a different filesystem. 139 // Copies in a single file from a different filesystem.
146 // See header comments for AsyncFileUtil::CopyInForeignFile() for 140 // See header comments for AsyncFileUtil::CopyInForeignFile() for
147 // more details. 141 // more details.
148 virtual base::File::Error CopyInForeignFile( 142 virtual base::File::Error CopyInForeignFile(
149 FileSystemOperationContext* context, 143 FileSystemOperationContext* context,
150 const base::FilePath& src_file_path, 144 const base::FilePath& src_file_path,
151 const FileSystemURL& dest_url) = 0; 145 const FileSystemURL& dest_url) = 0;
152 146
153 // Deletes a single file. 147 // Deletes a single file.
154 // See header comments for AsyncFileUtil::DeleteFile() for more details. 148 // See header comments for AsyncFileUtil::DeleteFile() for more details.
155 virtual base::File::Error DeleteFile( 149 virtual base::File::Error DeleteFile(FileSystemOperationContext* context,
156 FileSystemOperationContext* context, 150 const FileSystemURL& url) = 0;
157 const FileSystemURL& url) = 0;
158 151
159 // Deletes a single empty directory. 152 // Deletes a single empty directory.
160 // See header comments for AsyncFileUtil::DeleteDirectory() for more details. 153 // See header comments for AsyncFileUtil::DeleteDirectory() for more details.
161 virtual base::File::Error DeleteDirectory( 154 virtual base::File::Error DeleteDirectory(FileSystemOperationContext* context,
162 FileSystemOperationContext* context, 155 const FileSystemURL& url) = 0;
163 const FileSystemURL& url) = 0;
164 156
165 // Creates a local snapshot file for a given |url| and returns the 157 // Creates a local snapshot file for a given |url| and returns the
166 // metadata and platform path of the snapshot file via |callback|. 158 // metadata and platform path of the snapshot file via |callback|.
167 // 159 //
168 // See header comments for AsyncFileUtil::CreateSnapshotFile() for 160 // See header comments for AsyncFileUtil::CreateSnapshotFile() for
169 // more details. 161 // more details.
170 virtual webkit_blob::ScopedFile CreateSnapshotFile( 162 virtual storage::ScopedFile CreateSnapshotFile(
171 FileSystemOperationContext* context, 163 FileSystemOperationContext* context,
172 const FileSystemURL& url, 164 const FileSystemURL& url,
173 base::File::Error* error, 165 base::File::Error* error,
174 base::File::Info* file_info, 166 base::File::Info* file_info,
175 base::FilePath* platform_path) = 0; 167 base::FilePath* platform_path) = 0;
176 168
177 protected: 169 protected:
178 FileSystemFileUtil() {} 170 FileSystemFileUtil() {}
179 171
180 private: 172 private:
181 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil); 173 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil);
182 }; 174 };
183 175
184 } // namespace fileapi 176 } // namespace storage
185 177
186 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ 178 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « storage/browser/fileapi/file_system_file_stream_reader.cc ('k') | storage/browser/fileapi/file_system_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698