Chromium Code Reviews| 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_FILE_SYSTEM_FILE_UTIL_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/file_util_proxy.h" | 11 #include "base/file_util_proxy.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
| 15 #include "base/tracked_objects.h" | 15 #include "base/tracked_objects.h" |
| 16 #include "webkit/fileapi/file_system_types.h" | |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 struct PlatformFileInfo; | 19 struct PlatformFileInfo; |
| 19 class MessageLoopProxy; | 20 class MessageLoopProxy; |
| 20 class Time; | 21 class Time; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace fileapi { | 24 namespace fileapi { |
| 24 | 25 |
| 25 using base::PlatformFile; | 26 using base::PlatformFile; |
| 26 using base::PlatformFileError; | 27 using base::PlatformFileError; |
| 27 | |
| 28 class FileSystemOperationContext; | 28 class FileSystemOperationContext; |
| 29 | 29 |
| 30 // A large part of this implementation is taken from base::FileUtilProxy. | 30 // A large part of this implementation is taken from base::FileUtilProxy. |
| 31 // TODO(dmikurube, kinuko): Clean up base::FileUtilProxy to factor out common | 31 // TODO(dmikurube, kinuko): Clean up base::FileUtilProxy to factor out common |
| 32 // routines. It includes dropping FileAPI-specific routines from FileUtilProxy. | 32 // routines. It includes dropping FileAPI-specific routines from FileUtilProxy. |
| 33 class FileSystemFileUtil { | 33 class FileSystemFileUtil { |
| 34 public: | 34 public: |
| 35 static FileSystemFileUtil* GetInstance(); | 35 static FileSystemFileUtil* GetInstance(); |
| 36 | 36 |
| 37 // Creates or opens a file with the given flags. It is invalid to pass NULL | 37 // Creates or opens a file with the given flags. It is invalid to pass NULL |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 57 // |created| of the callback argument is set true and |error code| | 57 // |created| of the callback argument is set true and |error code| |
| 58 // is set PLATFORM_FILE_OK. | 58 // is set PLATFORM_FILE_OK. |
| 59 // If the file already exists, |created| is set false and |error code| | 59 // If the file already exists, |created| is set false and |error code| |
| 60 // is set PLATFORM_FILE_OK. | 60 // is set PLATFORM_FILE_OK. |
| 61 // If the file hasn't existed but it couldn't be created for some other | 61 // If the file hasn't existed but it couldn't be created for some other |
| 62 // reasons, |created| is set false and |error code| indicates the error. | 62 // reasons, |created| is set false and |error code| indicates the error. |
| 63 virtual PlatformFileError EnsureFileExists( | 63 virtual PlatformFileError EnsureFileExists( |
| 64 FileSystemOperationContext* context, | 64 FileSystemOperationContext* context, |
| 65 const FilePath& file_path, bool* created); | 65 const FilePath& file_path, bool* created); |
| 66 | 66 |
| 67 // Maps |virtual_file| given |context| into |local_path| which represents | |
| 68 // phyisical file location on the host OS. | |
|
ericu
2011/04/19 20:30:49
Add comment that this may not always make sense fo
zel
2011/04/19 23:14:00
Done.
| |
| 69 virtual PlatformFileError GetLocalFilePath( | |
| 70 FileSystemOperationContext* context, | |
| 71 const FilePath& virtual_file, | |
|
ericu
2011/04/19 20:30:49
s/virtual_file/virtual_path/
zel
2011/04/19 23:14:00
Done.
| |
| 72 FilePath* local_path); | |
| 73 | |
| 67 // Retrieves the information about a file. It is invalid to pass NULL for the | 74 // Retrieves the information about a file. It is invalid to pass NULL for the |
| 68 // callback. | 75 // callback. |
| 69 virtual PlatformFileError GetFileInfo( | 76 virtual PlatformFileError GetFileInfo( |
| 70 FileSystemOperationContext* context, | 77 FileSystemOperationContext* context, |
| 71 const FilePath& file_, | 78 const FilePath& file_, |
| 72 base::PlatformFileInfo* file_info, | 79 base::PlatformFileInfo* file_info, |
| 73 FilePath* platform_path); | 80 FilePath* platform_path); |
| 74 | 81 |
| 75 virtual PlatformFileError ReadDirectory( | 82 virtual PlatformFileError ReadDirectory( |
| 76 FileSystemOperationContext* context, | 83 FileSystemOperationContext* context, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 virtual AbstractFileEnumerator* CreateFileEnumerator( | 197 virtual AbstractFileEnumerator* CreateFileEnumerator( |
| 191 const FilePath& root_path); | 198 const FilePath& root_path); |
| 192 | 199 |
| 193 friend struct DefaultSingletonTraits<FileSystemFileUtil>; | 200 friend struct DefaultSingletonTraits<FileSystemFileUtil>; |
| 194 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil); | 201 DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil); |
| 195 }; | 202 }; |
| 196 | 203 |
| 197 } // namespace fileapi | 204 } // namespace fileapi |
| 198 | 205 |
| 199 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ | 206 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_ |
| OLD | NEW |