| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi
le_util.h" | 5 #include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi
le_util.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 ProviderAsyncFileUtil::ProviderAsyncFileUtil() {} | 50 ProviderAsyncFileUtil::ProviderAsyncFileUtil() {} |
| 51 | 51 |
| 52 ProviderAsyncFileUtil::~ProviderAsyncFileUtil() {} | 52 ProviderAsyncFileUtil::~ProviderAsyncFileUtil() {} |
| 53 | 53 |
| 54 void ProviderAsyncFileUtil::CreateOrOpen( | 54 void ProviderAsyncFileUtil::CreateOrOpen( |
| 55 scoped_ptr<fileapi::FileSystemOperationContext> context, | 55 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 56 const fileapi::FileSystemURL& url, | 56 const fileapi::FileSystemURL& url, |
| 57 int file_flags, | 57 int file_flags, |
| 58 const CreateOrOpenCallback& callback) { | 58 const CreateOrOpenCallback& callback) { |
| 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 59 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 60 base::PlatformFile platform_file = base::kInvalidPlatformFileValue; | 60 base::PlatformFile platform_file = base::kInvalidPlatformFileValue; |
| 61 if ((file_flags & base::PLATFORM_FILE_CREATE) || | 61 if ((file_flags & base::PLATFORM_FILE_CREATE) || |
| 62 (file_flags & base::PLATFORM_FILE_OPEN_ALWAYS) || | 62 (file_flags & base::PLATFORM_FILE_OPEN_ALWAYS) || |
| 63 (file_flags & base::PLATFORM_FILE_CREATE_ALWAYS) || | 63 (file_flags & base::PLATFORM_FILE_CREATE_ALWAYS) || |
| 64 (file_flags & base::PLATFORM_FILE_OPEN_TRUNCATED)) { | 64 (file_flags & base::PLATFORM_FILE_OPEN_TRUNCATED)) { |
| 65 callback.Run(base::File::FILE_ERROR_SECURITY, | 65 callback.Run(base::File::FILE_ERROR_SECURITY, |
| 66 base::PassPlatformFile(&platform_file), | 66 base::PassPlatformFile(&platform_file), |
| 67 base::Closure()); | 67 base::Closure()); |
| 68 return; | 68 return; |
| 69 } | 69 } |
| 70 | 70 |
| 71 NOTIMPLEMENTED(); | 71 NOTIMPLEMENTED(); |
| 72 callback.Run(base::File::FILE_ERROR_NOT_FOUND, | 72 callback.Run(base::File::FILE_ERROR_NOT_FOUND, |
| 73 base::PassPlatformFile(&platform_file), | 73 base::PassPlatformFile(&platform_file), |
| 74 base::Closure()); | 74 base::Closure()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void ProviderAsyncFileUtil::EnsureFileExists( | 77 void ProviderAsyncFileUtil::EnsureFileExists( |
| 78 scoped_ptr<fileapi::FileSystemOperationContext> context, | 78 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 79 const fileapi::FileSystemURL& url, | 79 const fileapi::FileSystemURL& url, |
| 80 const EnsureFileExistsCallback& callback) { | 80 const EnsureFileExistsCallback& callback) { |
| 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 81 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 82 callback.Run(base::File::FILE_ERROR_SECURITY, false /* created */); | 82 callback.Run(base::File::FILE_ERROR_SECURITY, false /* created */); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void ProviderAsyncFileUtil::CreateDirectory( | 85 void ProviderAsyncFileUtil::CreateDirectory( |
| 86 scoped_ptr<fileapi::FileSystemOperationContext> context, | 86 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 87 const fileapi::FileSystemURL& url, | 87 const fileapi::FileSystemURL& url, |
| 88 bool exclusive, | 88 bool exclusive, |
| 89 bool recursive, | 89 bool recursive, |
| 90 const StatusCallback& callback) { | 90 const StatusCallback& callback) { |
| 91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 91 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 92 callback.Run(base::File::FILE_ERROR_SECURITY); | 92 callback.Run(base::File::FILE_ERROR_SECURITY); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void ProviderAsyncFileUtil::GetFileInfo( | 95 void ProviderAsyncFileUtil::GetFileInfo( |
| 96 scoped_ptr<fileapi::FileSystemOperationContext> context, | 96 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 97 const fileapi::FileSystemURL& url, | 97 const fileapi::FileSystemURL& url, |
| 98 const GetFileInfoCallback& callback) { | 98 const GetFileInfoCallback& callback) { |
| 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 99 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 100 BrowserThread::PostTask(BrowserThread::UI, | 100 BrowserThread::PostTask(BrowserThread::UI, |
| 101 FROM_HERE, | 101 FROM_HERE, |
| 102 base::Bind(&GetFileInfoOnUIThread, | 102 base::Bind(&GetFileInfoOnUIThread, |
| 103 base::Passed(&context), | 103 base::Passed(&context), |
| 104 url, | 104 url, |
| 105 base::Bind(&OnGetFileInfo, callback))); | 105 base::Bind(&OnGetFileInfo, callback))); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void ProviderAsyncFileUtil::ReadDirectory( | 108 void ProviderAsyncFileUtil::ReadDirectory( |
| 109 scoped_ptr<fileapi::FileSystemOperationContext> context, | 109 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 110 const fileapi::FileSystemURL& url, | 110 const fileapi::FileSystemURL& url, |
| 111 const ReadDirectoryCallback& callback) { | 111 const ReadDirectoryCallback& callback) { |
| 112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 112 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 113 NOTIMPLEMENTED(); | 113 NOTIMPLEMENTED(); |
| 114 callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), false); | 114 callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), false); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ProviderAsyncFileUtil::Touch( | 117 void ProviderAsyncFileUtil::Touch( |
| 118 scoped_ptr<fileapi::FileSystemOperationContext> context, | 118 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 119 const fileapi::FileSystemURL& url, | 119 const fileapi::FileSystemURL& url, |
| 120 const base::Time& last_access_time, | 120 const base::Time& last_access_time, |
| 121 const base::Time& last_modified_time, | 121 const base::Time& last_modified_time, |
| 122 const StatusCallback& callback) { | 122 const StatusCallback& callback) { |
| 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 123 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 124 callback.Run(base::File::FILE_ERROR_SECURITY); | 124 callback.Run(base::File::FILE_ERROR_SECURITY); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void ProviderAsyncFileUtil::Truncate( | 127 void ProviderAsyncFileUtil::Truncate( |
| 128 scoped_ptr<fileapi::FileSystemOperationContext> context, | 128 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 129 const fileapi::FileSystemURL& url, | 129 const fileapi::FileSystemURL& url, |
| 130 int64 length, | 130 int64 length, |
| 131 const StatusCallback& callback) { | 131 const StatusCallback& callback) { |
| 132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 132 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 133 callback.Run(base::File::FILE_ERROR_SECURITY); | 133 callback.Run(base::File::FILE_ERROR_SECURITY); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void ProviderAsyncFileUtil::CopyFileLocal( | 136 void ProviderAsyncFileUtil::CopyFileLocal( |
| 137 scoped_ptr<fileapi::FileSystemOperationContext> context, | 137 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 138 const fileapi::FileSystemURL& src_url, | 138 const fileapi::FileSystemURL& src_url, |
| 139 const fileapi::FileSystemURL& dest_url, | 139 const fileapi::FileSystemURL& dest_url, |
| 140 CopyOrMoveOption option, | 140 CopyOrMoveOption option, |
| 141 const CopyFileProgressCallback& progress_callback, | 141 const CopyFileProgressCallback& progress_callback, |
| 142 const StatusCallback& callback) { | 142 const StatusCallback& callback) { |
| 143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 143 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 144 callback.Run(base::File::FILE_ERROR_SECURITY); | 144 callback.Run(base::File::FILE_ERROR_SECURITY); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void ProviderAsyncFileUtil::MoveFileLocal( | 147 void ProviderAsyncFileUtil::MoveFileLocal( |
| 148 scoped_ptr<fileapi::FileSystemOperationContext> context, | 148 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 149 const fileapi::FileSystemURL& src_url, | 149 const fileapi::FileSystemURL& src_url, |
| 150 const fileapi::FileSystemURL& dest_url, | 150 const fileapi::FileSystemURL& dest_url, |
| 151 CopyOrMoveOption option, | 151 CopyOrMoveOption option, |
| 152 const StatusCallback& callback) { | 152 const StatusCallback& callback) { |
| 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 153 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 154 callback.Run(base::File::FILE_ERROR_SECURITY); | 154 callback.Run(base::File::FILE_ERROR_SECURITY); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void ProviderAsyncFileUtil::CopyInForeignFile( | 157 void ProviderAsyncFileUtil::CopyInForeignFile( |
| 158 scoped_ptr<fileapi::FileSystemOperationContext> context, | 158 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 159 const base::FilePath& src_file_path, | 159 const base::FilePath& src_file_path, |
| 160 const fileapi::FileSystemURL& dest_url, | 160 const fileapi::FileSystemURL& dest_url, |
| 161 const StatusCallback& callback) { | 161 const StatusCallback& callback) { |
| 162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 162 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 163 callback.Run(base::File::FILE_ERROR_SECURITY); | 163 callback.Run(base::File::FILE_ERROR_SECURITY); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void ProviderAsyncFileUtil::DeleteFile( | 166 void ProviderAsyncFileUtil::DeleteFile( |
| 167 scoped_ptr<fileapi::FileSystemOperationContext> context, | 167 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 168 const fileapi::FileSystemURL& url, | 168 const fileapi::FileSystemURL& url, |
| 169 const StatusCallback& callback) { | 169 const StatusCallback& callback) { |
| 170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 170 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 171 callback.Run(base::File::FILE_ERROR_SECURITY); | 171 callback.Run(base::File::FILE_ERROR_SECURITY); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ProviderAsyncFileUtil::DeleteDirectory( | 174 void ProviderAsyncFileUtil::DeleteDirectory( |
| 175 scoped_ptr<fileapi::FileSystemOperationContext> context, | 175 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 176 const fileapi::FileSystemURL& url, | 176 const fileapi::FileSystemURL& url, |
| 177 const StatusCallback& callback) { | 177 const StatusCallback& callback) { |
| 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 178 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 179 callback.Run(base::File::FILE_ERROR_SECURITY); | 179 callback.Run(base::File::FILE_ERROR_SECURITY); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void ProviderAsyncFileUtil::DeleteRecursively( | 182 void ProviderAsyncFileUtil::DeleteRecursively( |
| 183 scoped_ptr<fileapi::FileSystemOperationContext> context, | 183 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 184 const fileapi::FileSystemURL& url, | 184 const fileapi::FileSystemURL& url, |
| 185 const StatusCallback& callback) { | 185 const StatusCallback& callback) { |
| 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 186 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 187 callback.Run(base::File::FILE_ERROR_SECURITY); | 187 callback.Run(base::File::FILE_ERROR_SECURITY); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void ProviderAsyncFileUtil::CreateSnapshotFile( | 190 void ProviderAsyncFileUtil::CreateSnapshotFile( |
| 191 scoped_ptr<fileapi::FileSystemOperationContext> context, | 191 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 192 const fileapi::FileSystemURL& url, | 192 const fileapi::FileSystemURL& url, |
| 193 const CreateSnapshotFileCallback& callback) { | 193 const CreateSnapshotFileCallback& callback) { |
| 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 194 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 195 NOTIMPLEMENTED(); | 195 NOTIMPLEMENTED(); |
| 196 callback.Run(base::File::FILE_ERROR_NOT_FOUND, | 196 callback.Run(base::File::FILE_ERROR_NOT_FOUND, |
| 197 base::File::Info(), | 197 base::File::Info(), |
| 198 base::FilePath(), | 198 base::FilePath(), |
| 199 scoped_refptr<webkit_blob::ShareableFileReference>()); | 199 scoped_refptr<webkit_blob::ShareableFileReference>()); |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace internal | 202 } // namespace internal |
| 203 } // namespace file_system_provider | 203 } // namespace file_system_provider |
| 204 } // namespace chromeos | 204 } // namespace chromeos |
| OLD | NEW |