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

Side by Side Diff: chrome/browser/chromeos/drive/fileapi/async_file_util.cc

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 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/drive/fileapi/async_file_util.h" 5 #include "chrome/browser/chromeos/drive/fileapi/async_file_util.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
11 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 11 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
12 #include "chrome/browser/chromeos/drive/file_system_util.h" 12 #include "chrome/browser/chromeos/drive/file_system_util.h"
13 #include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h" 13 #include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "google_apis/drive/task_util.h" 15 #include "google_apis/drive/task_util.h"
16 #include "webkit/browser/fileapi/file_system_operation_context.h" 16 #include "storage/browser/fileapi/file_system_operation_context.h"
17 #include "webkit/browser/fileapi/file_system_url.h" 17 #include "storage/browser/fileapi/file_system_url.h"
18 #include "webkit/common/blob/shareable_file_reference.h" 18 #include "storage/common/blob/shareable_file_reference.h"
19 19
20 using content::BrowserThread; 20 using content::BrowserThread;
21 21
22 namespace google_apis { 22 namespace google_apis {
23 namespace internal { 23 namespace internal {
24 24
25 // Partial specialization of helper template from google_apis/drive/task_util.h 25 // Partial specialization of helper template from google_apis/drive/task_util.h
26 // to enable google_apis::CreateRelayCallback to work with CreateOrOpenCallback. 26 // to enable google_apis::CreateRelayCallback to work with CreateOrOpenCallback.
27 template<typename T2> 27 template<typename T2>
28 struct ComposedCallback<void(base::File, T2)> { 28 struct ComposedCallback<void(base::File, T2)> {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 callback.Run(error, created); 102 callback.Run(error, created);
103 } 103 }
104 104
105 // Runs |callback| with the arguments based on the given arguments. 105 // Runs |callback| with the arguments based on the given arguments.
106 void RunCreateSnapshotFileCallback( 106 void RunCreateSnapshotFileCallback(
107 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 107 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
108 base::File::Error error, 108 base::File::Error error,
109 const base::File::Info& file_info, 109 const base::File::Info& file_info,
110 const base::FilePath& local_path, 110 const base::FilePath& local_path,
111 webkit_blob::ScopedFile::ScopeOutPolicy scope_out_policy) { 111 storage::ScopedFile::ScopeOutPolicy scope_out_policy) {
112 // ShareableFileReference is thread *unsafe* class. So it is necessary to 112 // ShareableFileReference is thread *unsafe* class. So it is necessary to
113 // create the instance (by invoking GetOrCreate) on IO thread, though 113 // create the instance (by invoking GetOrCreate) on IO thread, though
114 // most drive file system related operations run on UI thread. 114 // most drive file system related operations run on UI thread.
115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
116 116
117 scoped_refptr<webkit_blob::ShareableFileReference> file_reference = 117 scoped_refptr<storage::ShareableFileReference> file_reference =
118 webkit_blob::ShareableFileReference::GetOrCreate(webkit_blob::ScopedFile( 118 storage::ShareableFileReference::GetOrCreate(storage::ScopedFile(
119 local_path, 119 local_path, scope_out_policy, BrowserThread::GetBlockingPool()));
120 scope_out_policy,
121 BrowserThread::GetBlockingPool()));
122 callback.Run(error, file_info, local_path, file_reference); 120 callback.Run(error, file_info, local_path, file_reference);
123 } 121 }
124 122
125 } // namespace 123 } // namespace
126 124
127 AsyncFileUtil::AsyncFileUtil() { 125 AsyncFileUtil::AsyncFileUtil() {
128 } 126 }
129 127
130 AsyncFileUtil::~AsyncFileUtil() { 128 AsyncFileUtil::~AsyncFileUtil() {
131 } 129 }
132 130
133 void AsyncFileUtil::CreateOrOpen( 131 void AsyncFileUtil::CreateOrOpen(
134 scoped_ptr<fileapi::FileSystemOperationContext> context, 132 scoped_ptr<storage::FileSystemOperationContext> context,
135 const fileapi::FileSystemURL& url, 133 const storage::FileSystemURL& url,
136 int file_flags, 134 int file_flags,
137 const CreateOrOpenCallback& callback) { 135 const CreateOrOpenCallback& callback) {
138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
139 137
140 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 138 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
141 if (file_path.empty()) { 139 if (file_path.empty()) {
142 callback.Run(base::File(base::File::FILE_ERROR_NOT_FOUND), base::Closure()); 140 callback.Run(base::File(base::File::FILE_ERROR_NOT_FOUND), base::Closure());
143 return; 141 return;
144 } 142 }
145 143
146 const fileapi_internal::FileSystemGetter getter = 144 const fileapi_internal::FileSystemGetter getter =
147 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url); 145 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url);
148 PostFileSystemCallback( 146 PostFileSystemCallback(
149 getter, 147 getter,
150 base::Bind(&fileapi_internal::OpenFile, 148 base::Bind(&fileapi_internal::OpenFile,
151 file_path, file_flags, 149 file_path, file_flags,
152 google_apis::CreateRelayCallback( 150 google_apis::CreateRelayCallback(
153 base::Bind(&RunCreateOrOpenFileCallback, callback))), 151 base::Bind(&RunCreateOrOpenFileCallback, callback))),
154 base::Bind(&RunCreateOrOpenFileCallbackOnError, 152 base::Bind(&RunCreateOrOpenFileCallbackOnError,
155 callback, base::File::FILE_ERROR_FAILED)); 153 callback, base::File::FILE_ERROR_FAILED));
156 } 154 }
157 155
158 void AsyncFileUtil::EnsureFileExists( 156 void AsyncFileUtil::EnsureFileExists(
159 scoped_ptr<fileapi::FileSystemOperationContext> context, 157 scoped_ptr<storage::FileSystemOperationContext> context,
160 const fileapi::FileSystemURL& url, 158 const storage::FileSystemURL& url,
161 const EnsureFileExistsCallback& callback) { 159 const EnsureFileExistsCallback& callback) {
162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
163 161
164 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 162 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
165 if (file_path.empty()) { 163 if (file_path.empty()) {
166 callback.Run(base::File::FILE_ERROR_NOT_FOUND, false); 164 callback.Run(base::File::FILE_ERROR_NOT_FOUND, false);
167 return; 165 return;
168 } 166 }
169 167
170 PostFileSystemCallback( 168 PostFileSystemCallback(
171 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), 169 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
172 base::Bind(&fileapi_internal::CreateFile, 170 base::Bind(&fileapi_internal::CreateFile,
173 file_path, true /* is_exlusive */, 171 file_path, true /* is_exlusive */,
174 google_apis::CreateRelayCallback( 172 google_apis::CreateRelayCallback(
175 base::Bind(&RunEnsureFileExistsCallback, callback))), 173 base::Bind(&RunEnsureFileExistsCallback, callback))),
176 base::Bind(callback, base::File::FILE_ERROR_FAILED, false)); 174 base::Bind(callback, base::File::FILE_ERROR_FAILED, false));
177 } 175 }
178 176
179 void AsyncFileUtil::CreateDirectory( 177 void AsyncFileUtil::CreateDirectory(
180 scoped_ptr<fileapi::FileSystemOperationContext> context, 178 scoped_ptr<storage::FileSystemOperationContext> context,
181 const fileapi::FileSystemURL& url, 179 const storage::FileSystemURL& url,
182 bool exclusive, 180 bool exclusive,
183 bool recursive, 181 bool recursive,
184 const StatusCallback& callback) { 182 const StatusCallback& callback) {
185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
186 184
187 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 185 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
188 if (file_path.empty()) { 186 if (file_path.empty()) {
189 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 187 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
190 return; 188 return;
191 } 189 }
192 190
193 PostFileSystemCallback( 191 PostFileSystemCallback(
194 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), 192 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
195 base::Bind(&fileapi_internal::CreateDirectory, 193 base::Bind(&fileapi_internal::CreateDirectory,
196 file_path, exclusive, recursive, 194 file_path, exclusive, recursive,
197 google_apis::CreateRelayCallback(callback)), 195 google_apis::CreateRelayCallback(callback)),
198 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 196 base::Bind(callback, base::File::FILE_ERROR_FAILED));
199 } 197 }
200 198
201 void AsyncFileUtil::GetFileInfo( 199 void AsyncFileUtil::GetFileInfo(
202 scoped_ptr<fileapi::FileSystemOperationContext> context, 200 scoped_ptr<storage::FileSystemOperationContext> context,
203 const fileapi::FileSystemURL& url, 201 const storage::FileSystemURL& url,
204 const GetFileInfoCallback& callback) { 202 const GetFileInfoCallback& callback) {
205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
206 204
207 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 205 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
208 if (file_path.empty()) { 206 if (file_path.empty()) {
209 callback.Run(base::File::FILE_ERROR_NOT_FOUND, base::File::Info()); 207 callback.Run(base::File::FILE_ERROR_NOT_FOUND, base::File::Info());
210 return; 208 return;
211 } 209 }
212 210
213 PostFileSystemCallback( 211 PostFileSystemCallback(
214 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), 212 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
215 base::Bind(&fileapi_internal::GetFileInfo, 213 base::Bind(&fileapi_internal::GetFileInfo,
216 file_path, google_apis::CreateRelayCallback(callback)), 214 file_path, google_apis::CreateRelayCallback(callback)),
217 base::Bind(callback, base::File::FILE_ERROR_FAILED, 215 base::Bind(callback, base::File::FILE_ERROR_FAILED,
218 base::File::Info())); 216 base::File::Info()));
219 } 217 }
220 218
221 void AsyncFileUtil::ReadDirectory( 219 void AsyncFileUtil::ReadDirectory(
222 scoped_ptr<fileapi::FileSystemOperationContext> context, 220 scoped_ptr<storage::FileSystemOperationContext> context,
223 const fileapi::FileSystemURL& url, 221 const storage::FileSystemURL& url,
224 const ReadDirectoryCallback& callback) { 222 const ReadDirectoryCallback& callback) {
225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
226 224
227 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 225 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
228 if (file_path.empty()) { 226 if (file_path.empty()) {
229 callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), false); 227 callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), false);
230 return; 228 return;
231 } 229 }
232 230
233 PostFileSystemCallback( 231 PostFileSystemCallback(
234 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), 232 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
235 base::Bind(&fileapi_internal::ReadDirectory, 233 base::Bind(&fileapi_internal::ReadDirectory,
236 file_path, google_apis::CreateRelayCallback(callback)), 234 file_path, google_apis::CreateRelayCallback(callback)),
237 base::Bind(callback, base::File::FILE_ERROR_FAILED, 235 base::Bind(callback, base::File::FILE_ERROR_FAILED,
238 EntryList(), false)); 236 EntryList(), false));
239 } 237 }
240 238
241 void AsyncFileUtil::Touch( 239 void AsyncFileUtil::Touch(
242 scoped_ptr<fileapi::FileSystemOperationContext> context, 240 scoped_ptr<storage::FileSystemOperationContext> context,
243 const fileapi::FileSystemURL& url, 241 const storage::FileSystemURL& url,
244 const base::Time& last_access_time, 242 const base::Time& last_access_time,
245 const base::Time& last_modified_time, 243 const base::Time& last_modified_time,
246 const StatusCallback& callback) { 244 const StatusCallback& callback) {
247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
248 246
249 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 247 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
250 if (file_path.empty()) { 248 if (file_path.empty()) {
251 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 249 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
252 return; 250 return;
253 } 251 }
254 252
255 PostFileSystemCallback( 253 PostFileSystemCallback(
256 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), 254 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
257 base::Bind(&fileapi_internal::TouchFile, 255 base::Bind(&fileapi_internal::TouchFile,
258 file_path, last_access_time, last_modified_time, 256 file_path, last_access_time, last_modified_time,
259 google_apis::CreateRelayCallback(callback)), 257 google_apis::CreateRelayCallback(callback)),
260 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 258 base::Bind(callback, base::File::FILE_ERROR_FAILED));
261 } 259 }
262 260
263 void AsyncFileUtil::Truncate( 261 void AsyncFileUtil::Truncate(
264 scoped_ptr<fileapi::FileSystemOperationContext> context, 262 scoped_ptr<storage::FileSystemOperationContext> context,
265 const fileapi::FileSystemURL& url, 263 const storage::FileSystemURL& url,
266 int64 length, 264 int64 length,
267 const StatusCallback& callback) { 265 const StatusCallback& callback) {
268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
269 267
270 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 268 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
271 if (file_path.empty()) { 269 if (file_path.empty()) {
272 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 270 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
273 return; 271 return;
274 } 272 }
275 273
276 PostFileSystemCallback( 274 PostFileSystemCallback(
277 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), 275 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
278 base::Bind(&fileapi_internal::Truncate, 276 base::Bind(&fileapi_internal::Truncate,
279 file_path, length, google_apis::CreateRelayCallback(callback)), 277 file_path, length, google_apis::CreateRelayCallback(callback)),
280 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 278 base::Bind(callback, base::File::FILE_ERROR_FAILED));
281 } 279 }
282 280
283 void AsyncFileUtil::CopyFileLocal( 281 void AsyncFileUtil::CopyFileLocal(
284 scoped_ptr<fileapi::FileSystemOperationContext> context, 282 scoped_ptr<storage::FileSystemOperationContext> context,
285 const fileapi::FileSystemURL& src_url, 283 const storage::FileSystemURL& src_url,
286 const fileapi::FileSystemURL& dest_url, 284 const storage::FileSystemURL& dest_url,
287 CopyOrMoveOption option, 285 CopyOrMoveOption option,
288 const CopyFileProgressCallback& progress_callback, 286 const CopyFileProgressCallback& progress_callback,
289 const StatusCallback& callback) { 287 const StatusCallback& callback) {
290 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 288 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
291 289
292 base::FilePath src_path = util::ExtractDrivePathFromFileSystemUrl(src_url); 290 base::FilePath src_path = util::ExtractDrivePathFromFileSystemUrl(src_url);
293 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url); 291 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url);
294 if (src_path.empty() || dest_path.empty()) { 292 if (src_path.empty() || dest_path.empty()) {
295 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 293 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
296 return; 294 return;
297 } 295 }
298 296
299 // TODO(kinaba): crbug.com/339794. 297 // TODO(kinaba): crbug.com/339794.
300 // Assumption here is that |src_url| and |dest_url| are always from the same 298 // Assumption here is that |src_url| and |dest_url| are always from the same
301 // profile. This indeed holds as long as we mount different profiles onto 299 // profile. This indeed holds as long as we mount different profiles onto
302 // different mount point. Hence, using GetFileSystemFromUrl(dest_url) is safe. 300 // different mount point. Hence, using GetFileSystemFromUrl(dest_url) is safe.
303 // This will change after we introduce cross-profile sharing etc., and we 301 // This will change after we introduce cross-profile sharing etc., and we
304 // need to deal with files from different profiles here. 302 // need to deal with files from different profiles here.
305 PostFileSystemCallback( 303 PostFileSystemCallback(
306 base::Bind(&fileapi_internal::GetFileSystemFromUrl, dest_url), 304 base::Bind(&fileapi_internal::GetFileSystemFromUrl, dest_url),
307 base::Bind( 305 base::Bind(
308 &fileapi_internal::Copy, 306 &fileapi_internal::Copy,
309 src_path, dest_path, 307 src_path,
310 option == fileapi::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED, 308 dest_path,
309 option == storage::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED,
311 google_apis::CreateRelayCallback(callback)), 310 google_apis::CreateRelayCallback(callback)),
312 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 311 base::Bind(callback, base::File::FILE_ERROR_FAILED));
313 } 312 }
314 313
315 void AsyncFileUtil::MoveFileLocal( 314 void AsyncFileUtil::MoveFileLocal(
316 scoped_ptr<fileapi::FileSystemOperationContext> context, 315 scoped_ptr<storage::FileSystemOperationContext> context,
317 const fileapi::FileSystemURL& src_url, 316 const storage::FileSystemURL& src_url,
318 const fileapi::FileSystemURL& dest_url, 317 const storage::FileSystemURL& dest_url,
319 CopyOrMoveOption option, 318 CopyOrMoveOption option,
320 const StatusCallback& callback) { 319 const StatusCallback& callback) {
321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
322 321
323 base::FilePath src_path = util::ExtractDrivePathFromFileSystemUrl(src_url); 322 base::FilePath src_path = util::ExtractDrivePathFromFileSystemUrl(src_url);
324 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url); 323 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url);
325 if (src_path.empty() || dest_path.empty()) { 324 if (src_path.empty() || dest_path.empty()) {
326 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 325 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
327 return; 326 return;
328 } 327 }
329 328
330 // TODO(kinaba): see the comment in CopyFileLocal(). |src_url| and |dest_url| 329 // TODO(kinaba): see the comment in CopyFileLocal(). |src_url| and |dest_url|
331 // always return the same FileSystem by GetFileSystemFromUrl, but we need to 330 // always return the same FileSystem by GetFileSystemFromUrl, but we need to
332 // change it in order to support cross-profile file sharing etc. 331 // change it in order to support cross-profile file sharing etc.
333 PostFileSystemCallback( 332 PostFileSystemCallback(
334 base::Bind(&fileapi_internal::GetFileSystemFromUrl, dest_url), 333 base::Bind(&fileapi_internal::GetFileSystemFromUrl, dest_url),
335 base::Bind(&fileapi_internal::Move, 334 base::Bind(&fileapi_internal::Move,
336 src_path, dest_path, 335 src_path, dest_path,
337 google_apis::CreateRelayCallback(callback)), 336 google_apis::CreateRelayCallback(callback)),
338 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 337 base::Bind(callback, base::File::FILE_ERROR_FAILED));
339 } 338 }
340 339
341 void AsyncFileUtil::CopyInForeignFile( 340 void AsyncFileUtil::CopyInForeignFile(
342 scoped_ptr<fileapi::FileSystemOperationContext> context, 341 scoped_ptr<storage::FileSystemOperationContext> context,
343 const base::FilePath& src_file_path, 342 const base::FilePath& src_file_path,
344 const fileapi::FileSystemURL& dest_url, 343 const storage::FileSystemURL& dest_url,
345 const StatusCallback& callback) { 344 const StatusCallback& callback) {
346 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 345 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
347 346
348 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url); 347 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url);
349 if (dest_path.empty()) { 348 if (dest_path.empty()) {
350 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 349 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
351 return; 350 return;
352 } 351 }
353 352
354 PostFileSystemCallback( 353 PostFileSystemCallback(
355 base::Bind(&fileapi_internal::GetFileSystemFromUrl, dest_url), 354 base::Bind(&fileapi_internal::GetFileSystemFromUrl, dest_url),
356 base::Bind(&fileapi_internal::CopyInForeignFile, 355 base::Bind(&fileapi_internal::CopyInForeignFile,
357 src_file_path, dest_path, 356 src_file_path, dest_path,
358 google_apis::CreateRelayCallback(callback)), 357 google_apis::CreateRelayCallback(callback)),
359 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 358 base::Bind(callback, base::File::FILE_ERROR_FAILED));
360 } 359 }
361 360
362 void AsyncFileUtil::DeleteFile( 361 void AsyncFileUtil::DeleteFile(
363 scoped_ptr<fileapi::FileSystemOperationContext> context, 362 scoped_ptr<storage::FileSystemOperationContext> context,
364 const fileapi::FileSystemURL& url, 363 const storage::FileSystemURL& url,
365 const StatusCallback& callback) { 364 const StatusCallback& callback) {
366 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
367 366
368 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 367 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
369 if (file_path.empty()) { 368 if (file_path.empty()) {
370 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 369 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
371 return; 370 return;
372 } 371 }
373 372
374 PostFileSystemCallback( 373 PostFileSystemCallback(
375 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), 374 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
376 base::Bind(&fileapi_internal::Remove, 375 base::Bind(&fileapi_internal::Remove,
377 file_path, false /* not recursive */, 376 file_path, false /* not recursive */,
378 google_apis::CreateRelayCallback(callback)), 377 google_apis::CreateRelayCallback(callback)),
379 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 378 base::Bind(callback, base::File::FILE_ERROR_FAILED));
380 } 379 }
381 380
382 void AsyncFileUtil::DeleteDirectory( 381 void AsyncFileUtil::DeleteDirectory(
383 scoped_ptr<fileapi::FileSystemOperationContext> context, 382 scoped_ptr<storage::FileSystemOperationContext> context,
384 const fileapi::FileSystemURL& url, 383 const storage::FileSystemURL& url,
385 const StatusCallback& callback) { 384 const StatusCallback& callback) {
386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
387 386
388 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 387 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
389 if (file_path.empty()) { 388 if (file_path.empty()) {
390 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 389 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
391 return; 390 return;
392 } 391 }
393 392
394 PostFileSystemCallback( 393 PostFileSystemCallback(
395 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), 394 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
396 base::Bind(&fileapi_internal::Remove, 395 base::Bind(&fileapi_internal::Remove,
397 file_path, false /* not recursive */, 396 file_path, false /* not recursive */,
398 google_apis::CreateRelayCallback(callback)), 397 google_apis::CreateRelayCallback(callback)),
399 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 398 base::Bind(callback, base::File::FILE_ERROR_FAILED));
400 } 399 }
401 400
402 void AsyncFileUtil::DeleteRecursively( 401 void AsyncFileUtil::DeleteRecursively(
403 scoped_ptr<fileapi::FileSystemOperationContext> context, 402 scoped_ptr<storage::FileSystemOperationContext> context,
404 const fileapi::FileSystemURL& url, 403 const storage::FileSystemURL& url,
405 const StatusCallback& callback) { 404 const StatusCallback& callback) {
406 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 405 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
407 406
408 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 407 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
409 if (file_path.empty()) { 408 if (file_path.empty()) {
410 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 409 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
411 return; 410 return;
412 } 411 }
413 412
414 PostFileSystemCallback( 413 PostFileSystemCallback(
415 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), 414 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
416 base::Bind(&fileapi_internal::Remove, 415 base::Bind(&fileapi_internal::Remove,
417 file_path, true /* recursive */, 416 file_path, true /* recursive */,
418 google_apis::CreateRelayCallback(callback)), 417 google_apis::CreateRelayCallback(callback)),
419 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 418 base::Bind(callback, base::File::FILE_ERROR_FAILED));
420 } 419 }
421 420
422 void AsyncFileUtil::CreateSnapshotFile( 421 void AsyncFileUtil::CreateSnapshotFile(
423 scoped_ptr<fileapi::FileSystemOperationContext> context, 422 scoped_ptr<storage::FileSystemOperationContext> context,
424 const fileapi::FileSystemURL& url, 423 const storage::FileSystemURL& url,
425 const CreateSnapshotFileCallback& callback) { 424 const CreateSnapshotFileCallback& callback) {
426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 425 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
427 426
428 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 427 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
429 if (file_path.empty()) { 428 if (file_path.empty()) {
430 callback.Run(base::File::FILE_ERROR_NOT_FOUND, 429 callback.Run(base::File::FILE_ERROR_NOT_FOUND,
431 base::File::Info(), 430 base::File::Info(),
432 base::FilePath(), 431 base::FilePath(),
433 scoped_refptr<webkit_blob::ShareableFileReference>()); 432 scoped_refptr<storage::ShareableFileReference>());
434 return; 433 return;
435 } 434 }
436 435
437 PostFileSystemCallback( 436 PostFileSystemCallback(
438 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url), 437 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
439 base::Bind(&fileapi_internal::CreateSnapshotFile, 438 base::Bind(&fileapi_internal::CreateSnapshotFile,
440 file_path, 439 file_path,
441 google_apis::CreateRelayCallback( 440 google_apis::CreateRelayCallback(
442 base::Bind(&RunCreateSnapshotFileCallback, callback))), 441 base::Bind(&RunCreateSnapshotFileCallback, callback))),
443 base::Bind(callback, 442 base::Bind(callback,
444 base::File::FILE_ERROR_FAILED, 443 base::File::FILE_ERROR_FAILED,
445 base::File::Info(), 444 base::File::Info(),
446 base::FilePath(), 445 base::FilePath(),
447 scoped_refptr<webkit_blob::ShareableFileReference>())); 446 scoped_refptr<storage::ShareableFileReference>()));
448 } 447 }
449 448
450 } // namespace internal 449 } // namespace internal
451 } // namespace drive 450 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698