| 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/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" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 const base::Closure& on_error_callback) { | 50 const base::Closure& on_error_callback) { |
| 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 52 | 52 |
| 53 BrowserThread::PostTask( | 53 BrowserThread::PostTask( |
| 54 BrowserThread::UI, | 54 BrowserThread::UI, |
| 55 FROM_HERE, | 55 FROM_HERE, |
| 56 base::Bind(&fileapi_internal::RunFileSystemCallback, | 56 base::Bind(&fileapi_internal::RunFileSystemCallback, |
| 57 file_system_getter, function, | 57 file_system_getter, function, |
| 58 on_error_callback.is_null() ? | 58 on_error_callback.is_null() ? |
| 59 base::Closure() : | 59 base::Closure() : |
| 60 base::Bind(&google_apis::RunTaskOnThread, | 60 base::Bind(&google_apis::RunTaskWithTaskRunner, |
| 61 base::MessageLoopProxy::current(), | 61 base::MessageLoopProxy::current(), |
| 62 on_error_callback))); | 62 on_error_callback))); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Runs CreateOrOpenFile callback based on the given |error| and |file|. | 65 // Runs CreateOrOpenFile callback based on the given |error| and |file|. |
| 66 void RunCreateOrOpenFileCallback( | 66 void RunCreateOrOpenFileCallback( |
| 67 const AsyncFileUtil::CreateOrOpenCallback& callback, | 67 const AsyncFileUtil::CreateOrOpenCallback& callback, |
| 68 base::File file, | 68 base::File file, |
| 69 const base::Closure& close_callback_on_ui_thread) { | 69 const base::Closure& close_callback_on_ui_thread) { |
| 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 71 | 71 |
| 72 // It is necessary to make a closure, which runs on file closing here. | 72 // It is necessary to make a closure, which runs on file closing here. |
| 73 // It will be provided as a FileSystem::OpenFileCallback's argument later. | 73 // It will be provided as a FileSystem::OpenFileCallback's argument later. |
| 74 // (crbug.com/259184). | 74 // (crbug.com/259184). |
| 75 callback.Run( | 75 callback.Run( |
| 76 file.Pass(), | 76 file.Pass(), |
| 77 base::Bind(&google_apis::RunTaskOnThread, | 77 base::Bind(&google_apis::RunTaskWithTaskRunner, |
| 78 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 78 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 79 close_callback_on_ui_thread)); | 79 close_callback_on_ui_thread)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Runs CreateOrOpenFile when the error happens. | 82 // Runs CreateOrOpenFile when the error happens. |
| 83 void RunCreateOrOpenFileCallbackOnError( | 83 void RunCreateOrOpenFileCallbackOnError( |
| 84 const AsyncFileUtil::CreateOrOpenCallback& callback, | 84 const AsyncFileUtil::CreateOrOpenCallback& callback, |
| 85 base::File::Error error) { | 85 base::File::Error error) { |
| 86 callback.Run(base::File(error), base::Closure()); | 86 callback.Run(base::File(error), base::Closure()); |
| 87 } | 87 } |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 base::Bind(&RunCreateSnapshotFileCallback, callback))), | 442 base::Bind(&RunCreateSnapshotFileCallback, callback))), |
| 443 base::Bind(callback, | 443 base::Bind(callback, |
| 444 base::File::FILE_ERROR_FAILED, | 444 base::File::FILE_ERROR_FAILED, |
| 445 base::File::Info(), | 445 base::File::Info(), |
| 446 base::FilePath(), | 446 base::FilePath(), |
| 447 scoped_refptr<webkit_blob::ShareableFileReference>())); | 447 scoped_refptr<webkit_blob::ShareableFileReference>())); |
| 448 } | 448 } |
| 449 | 449 |
| 450 } // namespace internal | 450 } // namespace internal |
| 451 } // namespace drive | 451 } // namespace drive |
| OLD | NEW |