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/single_thread_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
11 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 13 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
12 #include "chrome/browser/chromeos/drive/file_system_util.h" | 14 #include "chrome/browser/chromeos/drive/file_system_util.h" |
13 #include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h" | 15 #include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h" |
14 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
15 #include "google_apis/drive/task_util.h" | 17 #include "google_apis/drive/task_util.h" |
16 #include "storage/browser/blob/shareable_file_reference.h" | 18 #include "storage/browser/blob/shareable_file_reference.h" |
17 #include "storage/browser/fileapi/file_system_operation_context.h" | 19 #include "storage/browser/fileapi/file_system_operation_context.h" |
18 #include "storage/browser/fileapi/file_system_url.h" | 20 #include "storage/browser/fileapi/file_system_url.h" |
19 | 21 |
(...skipping 24 matching lines...) Expand all Loading... |
44 // Posts fileapi_internal::RunFileSystemCallback to UI thread. | 46 // Posts fileapi_internal::RunFileSystemCallback to UI thread. |
45 // This function must be called on IO thread. | 47 // This function must be called on IO thread. |
46 // The |on_error_callback| will be called (on error case) on IO thread. | 48 // The |on_error_callback| will be called (on error case) on IO thread. |
47 void PostFileSystemCallback( | 49 void PostFileSystemCallback( |
48 const fileapi_internal::FileSystemGetter& file_system_getter, | 50 const fileapi_internal::FileSystemGetter& file_system_getter, |
49 const base::Callback<void(FileSystemInterface*)>& function, | 51 const base::Callback<void(FileSystemInterface*)>& function, |
50 const base::Closure& on_error_callback) { | 52 const base::Closure& on_error_callback) { |
51 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 53 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
52 | 54 |
53 BrowserThread::PostTask( | 55 BrowserThread::PostTask( |
54 BrowserThread::UI, | 56 BrowserThread::UI, FROM_HERE, |
55 FROM_HERE, | 57 base::Bind(&fileapi_internal::RunFileSystemCallback, file_system_getter, |
56 base::Bind(&fileapi_internal::RunFileSystemCallback, | 58 function, on_error_callback.is_null() |
57 file_system_getter, function, | 59 ? base::Closure() |
58 on_error_callback.is_null() ? | 60 : base::Bind(&google_apis::RunTaskWithTaskRunner, |
59 base::Closure() : | 61 base::ThreadTaskRunnerHandle::Get(), |
60 base::Bind(&google_apis::RunTaskWithTaskRunner, | 62 on_error_callback))); |
61 base::MessageLoopProxy::current(), | |
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_CURRENTLY_ON(BrowserThread::IO); | 70 DCHECK_CURRENTLY_ON(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. |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 base::Bind(&RunCreateSnapshotFileCallback, callback))), | 441 base::Bind(&RunCreateSnapshotFileCallback, callback))), |
442 base::Bind(callback, | 442 base::Bind(callback, |
443 base::File::FILE_ERROR_FAILED, | 443 base::File::FILE_ERROR_FAILED, |
444 base::File::Info(), | 444 base::File::Info(), |
445 base::FilePath(), | 445 base::FilePath(), |
446 scoped_refptr<storage::ShareableFileReference>())); | 446 scoped_refptr<storage::ShareableFileReference>())); |
447 } | 447 } |
448 | 448 |
449 } // namespace internal | 449 } // namespace internal |
450 } // namespace drive | 450 } // namespace drive |
OLD | NEW |