| 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 #include "base/file_util_proxy.h" | 5 #include "base/file_util_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 Bind(&GetFileInfoHelper::RunWorkForPlatformFile, | 285 Bind(&GetFileInfoHelper::RunWorkForPlatformFile, |
| 286 Unretained(helper), file), | 286 Unretained(helper), file), |
| 287 Bind(&GetFileInfoHelper::Reply, Owned(helper), callback)); | 287 Bind(&GetFileInfoHelper::Reply, Owned(helper), callback)); |
| 288 } | 288 } |
| 289 | 289 |
| 290 // static | 290 // static |
| 291 bool FileUtilProxy::Delete(TaskRunner* task_runner, | 291 bool FileUtilProxy::Delete(TaskRunner* task_runner, |
| 292 const FilePath& file_path, | 292 const FilePath& file_path, |
| 293 bool recursive, | 293 bool recursive, |
| 294 const StatusCallback& callback) { | 294 const StatusCallback& callback) { |
| 295 return RelayFileTask( | 295 return base::PostTaskAndReplyWithResult( |
| 296 task_runner, FROM_HERE, | 296 task_runner, FROM_HERE, |
| 297 Bind(&DeleteAdapter, file_path, recursive), | 297 Bind(&DeleteAdapter, file_path, recursive), |
| 298 callback); | 298 callback); |
| 299 } | 299 } |
| 300 | 300 |
| 301 // static | 301 // static |
| 302 bool FileUtilProxy::RecursiveDelete( | 302 bool FileUtilProxy::RecursiveDelete( |
| 303 TaskRunner* task_runner, | 303 TaskRunner* task_runner, |
| 304 const FilePath& file_path, | 304 const FilePath& file_path, |
| 305 const StatusCallback& callback) { | 305 const StatusCallback& callback) { |
| 306 return RelayFileTask( | 306 return base::PostTaskAndReplyWithResult( |
| 307 task_runner, FROM_HERE, | 307 task_runner, FROM_HERE, |
| 308 Bind(&DeleteAdapter, file_path, true /* recursive */), | 308 Bind(&DeleteAdapter, file_path, true /* recursive */), |
| 309 callback); | 309 callback); |
| 310 } | 310 } |
| 311 | 311 |
| 312 // static | 312 // static |
| 313 bool FileUtilProxy::Read( | 313 bool FileUtilProxy::Read( |
| 314 TaskRunner* task_runner, | 314 TaskRunner* task_runner, |
| 315 PlatformFile file, | 315 PlatformFile file, |
| 316 int64 offset, | 316 int64 offset, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 PlatformFile file, | 393 PlatformFile file, |
| 394 const StatusCallback& callback) { | 394 const StatusCallback& callback) { |
| 395 return base::PostTaskAndReplyWithResult( | 395 return base::PostTaskAndReplyWithResult( |
| 396 task_runner, | 396 task_runner, |
| 397 FROM_HERE, | 397 FROM_HERE, |
| 398 Bind(&FlushPlatformFile, file), | 398 Bind(&FlushPlatformFile, file), |
| 399 Bind(&CallWithTranslatedParameter, callback)); | 399 Bind(&CallWithTranslatedParameter, callback)); |
| 400 } | 400 } |
| 401 | 401 |
| 402 // static | 402 // static |
| 403 bool FileUtilProxy::RelayFileTask( | |
| 404 TaskRunner* task_runner, | |
| 405 const tracked_objects::Location& from_here, | |
| 406 const FileTask& file_task, | |
| 407 const StatusCallback& callback) { | |
| 408 return base::PostTaskAndReplyWithResult( | |
| 409 task_runner, from_here, file_task, callback); | |
| 410 } | |
| 411 | |
| 412 // static | |
| 413 bool FileUtilProxy::RelayCreateOrOpen( | 403 bool FileUtilProxy::RelayCreateOrOpen( |
| 414 TaskRunner* task_runner, | 404 TaskRunner* task_runner, |
| 415 const CreateOrOpenTask& open_task, | 405 const CreateOrOpenTask& open_task, |
| 416 const CloseTask& close_task, | 406 const CloseTask& close_task, |
| 417 const CreateOrOpenCallback& callback) { | 407 const CreateOrOpenCallback& callback) { |
| 418 CreateOrOpenHelper* helper = new CreateOrOpenHelper( | 408 CreateOrOpenHelper* helper = new CreateOrOpenHelper( |
| 419 task_runner, close_task); | 409 task_runner, close_task); |
| 420 return task_runner->PostTaskAndReply( | 410 return task_runner->PostTaskAndReply( |
| 421 FROM_HERE, | 411 FROM_HERE, |
| 422 Bind(&CreateOrOpenHelper::RunWork, Unretained(helper), open_task), | 412 Bind(&CreateOrOpenHelper::RunWork, Unretained(helper), open_task), |
| 423 Bind(&CreateOrOpenHelper::Reply, Owned(helper), callback)); | 413 Bind(&CreateOrOpenHelper::Reply, Owned(helper), callback)); |
| 424 } | 414 } |
| 425 | 415 |
| 426 // static | 416 // static |
| 427 bool FileUtilProxy::RelayClose( | 417 bool FileUtilProxy::RelayClose( |
| 428 TaskRunner* task_runner, | 418 TaskRunner* task_runner, |
| 429 const CloseTask& close_task, | 419 const CloseTask& close_task, |
| 430 PlatformFile file_handle, | 420 PlatformFile file_handle, |
| 431 const StatusCallback& callback) { | 421 const StatusCallback& callback) { |
| 432 return base::PostTaskAndReplyWithResult( | 422 return base::PostTaskAndReplyWithResult( |
| 433 task_runner, FROM_HERE, Bind(close_task, file_handle), callback); | 423 task_runner, FROM_HERE, Bind(close_task, file_handle), callback); |
| 434 } | 424 } |
| 435 | 425 |
| 436 } // namespace base | 426 } // namespace base |
| OLD | NEW |