| OLD | NEW |
| 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_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_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_proxy.h" | 10 #include "base/file_util_proxy.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 typedef FileSystemOperation::GetMetadataCallback GetFileInfoCallback; | 34 typedef FileSystemOperation::GetMetadataCallback GetFileInfoCallback; |
| 35 typedef FileSystemOperation::ReadDirectoryCallback ReadDirectoryCallback; | 35 typedef FileSystemOperation::ReadDirectoryCallback ReadDirectoryCallback; |
| 36 | 36 |
| 37 typedef base::Callback< | 37 typedef base::Callback< |
| 38 void(base::PlatformFileError result, | 38 void(base::PlatformFileError result, |
| 39 const base::PlatformFileInfo& file_info, | 39 const base::PlatformFileInfo& file_info, |
| 40 const FilePath& platform_path, | 40 const FilePath& platform_path, |
| 41 FileSystemFileUtil::SnapshotFilePolicy snapshot_policy)> | 41 FileSystemFileUtil::SnapshotFilePolicy snapshot_policy)> |
| 42 SnapshotFileCallback; | 42 SnapshotFileCallback; |
| 43 | 43 |
| 44 // Deletes a file or a directory on the given context's task_runner. | 44 // Deletes a file on the given context's task_runner. |
| 45 // It is an error to delete a non-empty directory with recursive=false. | 45 static bool DeleteFile( |
| 46 static bool Delete( | |
| 47 FileSystemOperationContext* context, | 46 FileSystemOperationContext* context, |
| 48 FileSystemFileUtil* file_util, | 47 FileSystemFileUtil* file_util, |
| 49 const FileSystemURL& url, | 48 const FileSystemURL& url, |
| 50 bool recursive, | 49 const StatusCallback& callback); |
| 50 |
| 51 // Deletes a directory on the given context's task_runner. |
| 52 static bool DeleteDirectory( |
| 53 FileSystemOperationContext* context, |
| 54 FileSystemFileUtil* file_util, |
| 55 const FileSystemURL& url, |
| 51 const StatusCallback& callback); | 56 const StatusCallback& callback); |
| 52 | 57 |
| 53 // Creates or opens a file with the given flags by calling |file_util|'s | 58 // Creates or opens a file with the given flags by calling |file_util|'s |
| 54 // CreateOrOpen method on the given context's task_runner. | 59 // CreateOrOpen method on the given context's task_runner. |
| 55 static bool CreateOrOpen( | 60 static bool CreateOrOpen( |
| 56 FileSystemOperationContext* context, | 61 FileSystemOperationContext* context, |
| 57 FileSystemFileUtil* file_util, | 62 FileSystemFileUtil* file_util, |
| 58 const FileSystemURL& url, | 63 const FileSystemURL& url, |
| 59 int file_flags, | 64 int file_flags, |
| 60 const CreateOrOpenCallback& callback); | 65 const CreateOrOpenCallback& callback); |
| 61 | 66 |
| 62 // Copies a file or a directory from |src_url| to |dest_url| by calling | 67 // Copies a local file or a directory from |src_url| to |dest_url|. |
| 63 // FileSystemFileUtil's following methods on the given context's | 68 static bool CopyLocalFile( |
| 64 // task_runner. | |
| 65 // - CopyOrMoveFile() for same-filesystem operations | |
| 66 // - CopyInForeignFile() for (limited) cross-filesystem operations | |
| 67 // | |
| 68 // Error cases: | |
| 69 // If destination's parent doesn't exist. | |
| 70 // If source dir exists but destination url is an existing file. | |
| 71 // If source file exists but destination url is an existing directory. | |
| 72 // If source is a parent of destination. | |
| 73 // If source doesn't exist. | |
| 74 // If source and dest are the same url in the same filesystem. | |
| 75 static bool Copy( | |
| 76 FileSystemOperationContext* context, | 69 FileSystemOperationContext* context, |
| 77 FileSystemFileUtil* src_util, | 70 FileSystemFileUtil* file_util, |
| 78 FileSystemFileUtil* dest_util, | 71 const FileSystemURL& src_url, |
| 72 const FileSystemURL& dest_url, |
| 73 const StatusCallback& callback); |
| 74 |
| 75 // Moves a local file or a directory from |src_url| to |dest_url|. |
| 76 static bool MoveLocalFile( |
| 77 FileSystemOperationContext* context, |
| 78 FileSystemFileUtil* file_util, |
| 79 const FileSystemURL& src_url, | 79 const FileSystemURL& src_url, |
| 80 const FileSystemURL& dest_url, | 80 const FileSystemURL& dest_url, |
| 81 const StatusCallback& callback); | 81 const StatusCallback& callback); |
| 82 | 82 |
| 83 // Copies a file from local disk to the given filesystem destination. | 83 // Copies a file from local disk to the given filesystem destination. |
| 84 // Primarily used for the Syncable filesystem type (e.g. GDrive). | 84 // Primarily used for the Syncable filesystem type (e.g. GDrive). |
| 85 static bool CopyInForeignFile( | 85 static bool CopyInForeignFile( |
| 86 FileSystemOperationContext* context, | 86 FileSystemOperationContext* context, |
| 87 FileSystemFileUtil* dest_util, | 87 FileSystemFileUtil* file_util, |
| 88 const FilePath& src_local_disk_file_path, | 88 const FilePath& src_local_disk_file_path, |
| 89 const FileSystemURL& dest_url, | 89 const FileSystemURL& dest_url, |
| 90 const StatusCallback& callback); | 90 const StatusCallback& callback); |
| 91 | 91 |
| 92 // Moves a file or a directory from |src_url| to |dest_url| by calling | |
| 93 // FileSystemFileUtil's following methods on the given context's | |
| 94 // task_runner. | |
| 95 // - CopyOrMoveFile() for same-filesystem operations | |
| 96 // - CopyInForeignFile() for (limited) cross-filesystem operations | |
| 97 // | |
| 98 // This method returns an error on the same error cases with Copy. | |
| 99 static bool Move( | |
| 100 FileSystemOperationContext* context, | |
| 101 FileSystemFileUtil* src_util, | |
| 102 FileSystemFileUtil* dest_util, | |
| 103 const FileSystemURL& src_url, | |
| 104 const FileSystemURL& dest_url, | |
| 105 const StatusCallback& callback); | |
| 106 | |
| 107 // Ensures that the given |url| exist by calling |file_util|'s | 92 // Ensures that the given |url| exist by calling |file_util|'s |
| 108 // EnsureFileExists method on the given context's task_runner. | 93 // EnsureFileExists method on the given context's task_runner. |
| 109 static bool EnsureFileExists( | 94 static bool EnsureFileExists( |
| 110 FileSystemOperationContext* context, | 95 FileSystemOperationContext* context, |
| 111 FileSystemFileUtil* file_util, | 96 FileSystemFileUtil* file_util, |
| 112 const FileSystemURL& url, | 97 const FileSystemURL& url, |
| 113 const EnsureFileExistsCallback& callback); | 98 const EnsureFileExistsCallback& callback); |
| 114 | 99 |
| 115 // Creates directory at a given url by calling |file_util|'s | 100 // Creates directory at a given url by calling |file_util|'s |
| 116 // CreateDirectory method on the given context's task_runner. | 101 // CreateDirectory method on the given context's task_runner. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 int64 length, | 152 int64 length, |
| 168 const StatusCallback& callback); | 153 const StatusCallback& callback); |
| 169 | 154 |
| 170 private: | 155 private: |
| 171 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); | 156 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); |
| 172 }; | 157 }; |
| 173 | 158 |
| 174 } // namespace fileapi | 159 } // namespace fileapi |
| 175 | 160 |
| 176 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 161 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
| OLD | NEW |