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 "chrome/browser/chromeos/drive/file_system.h" | 5 #include "chrome/browser/chromeos/drive/file_system.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
11 #include "base/prefs/pref_change_registrar.h" | 11 #include "base/prefs/pref_change_registrar.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/threading/sequenced_worker_pool.h" | 14 #include "base/threading/sequenced_worker_pool.h" |
15 #include "chrome/browser/chromeos/drive/change_list_loader.h" | 15 #include "chrome/browser/chromeos/drive/change_list_loader.h" |
16 #include "chrome/browser/chromeos/drive/change_list_processor.h" | 16 #include "chrome/browser/chromeos/drive/change_list_processor.h" |
17 #include "chrome/browser/chromeos/drive/drive.pb.h" | 17 #include "chrome/browser/chromeos/drive/drive.pb.h" |
18 #include "chrome/browser/chromeos/drive/file_cache.h" | 18 #include "chrome/browser/chromeos/drive/file_cache.h" |
19 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h" | 19 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h" |
20 #include "chrome/browser/chromeos/drive/file_system/create_directory_operation.h
" | 20 #include "chrome/browser/chromeos/drive/file_system/create_directory_operation.h
" |
21 #include "chrome/browser/chromeos/drive/file_system/create_file_operation.h" | 21 #include "chrome/browser/chromeos/drive/file_system/create_file_operation.h" |
22 #include "chrome/browser/chromeos/drive/file_system/download_operation.h" | 22 #include "chrome/browser/chromeos/drive/file_system/download_operation.h" |
| 23 #include "chrome/browser/chromeos/drive/file_system/get_file_for_saving_operatio
n.h" |
23 #include "chrome/browser/chromeos/drive/file_system/move_operation.h" | 24 #include "chrome/browser/chromeos/drive/file_system/move_operation.h" |
24 #include "chrome/browser/chromeos/drive/file_system/open_file_operation.h" | 25 #include "chrome/browser/chromeos/drive/file_system/open_file_operation.h" |
25 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" | 26 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" |
26 #include "chrome/browser/chromeos/drive/file_system/search_operation.h" | 27 #include "chrome/browser/chromeos/drive/file_system/search_operation.h" |
27 #include "chrome/browser/chromeos/drive/file_system/touch_operation.h" | 28 #include "chrome/browser/chromeos/drive/file_system/touch_operation.h" |
28 #include "chrome/browser/chromeos/drive/file_system/truncate_operation.h" | 29 #include "chrome/browser/chromeos/drive/file_system/truncate_operation.h" |
29 #include "chrome/browser/chromeos/drive/file_system/update_operation.h" | 30 #include "chrome/browser/chromeos/drive/file_system/update_operation.h" |
30 #include "chrome/browser/chromeos/drive/file_system_observer.h" | 31 #include "chrome/browser/chromeos/drive/file_system_observer.h" |
31 #include "chrome/browser/chromeos/drive/file_system_util.h" | 32 #include "chrome/browser/chromeos/drive/file_system_util.h" |
32 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 33 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 cache_, | 202 cache_, |
202 temporary_file_directory_)); | 203 temporary_file_directory_)); |
203 update_operation_.reset( | 204 update_operation_.reset( |
204 new file_system::UpdateOperation(blocking_task_runner_.get(), | 205 new file_system::UpdateOperation(blocking_task_runner_.get(), |
205 observer, | 206 observer, |
206 scheduler_, | 207 scheduler_, |
207 resource_metadata_, | 208 resource_metadata_, |
208 cache_)); | 209 cache_)); |
209 search_operation_.reset(new file_system::SearchOperation( | 210 search_operation_.reset(new file_system::SearchOperation( |
210 blocking_task_runner_.get(), scheduler_, resource_metadata_)); | 211 blocking_task_runner_.get(), scheduler_, resource_metadata_)); |
| 212 get_file_for_saving_operation_.reset( |
| 213 new file_system::GetFileForSavingOperation(blocking_task_runner_.get(), |
| 214 observer, |
| 215 scheduler_, |
| 216 resource_metadata_, |
| 217 cache_, |
| 218 temporary_file_directory_)); |
| 219 |
211 sync_client_.reset(new internal::SyncClient(blocking_task_runner_.get(), | 220 sync_client_.reset(new internal::SyncClient(blocking_task_runner_.get(), |
212 observer, | 221 observer, |
213 scheduler_, | 222 scheduler_, |
214 resource_metadata_, | 223 resource_metadata_, |
215 cache_, | 224 cache_, |
216 temporary_file_directory_)); | 225 temporary_file_directory_)); |
217 | |
218 hide_hosted_docs_ = | 226 hide_hosted_docs_ = |
219 pref_service_->GetBoolean(prefs::kDisableDriveHostedFiles); | 227 pref_service_->GetBoolean(prefs::kDisableDriveHostedFiles); |
220 | 228 |
221 InitializePreferenceObserver(); | 229 InitializePreferenceObserver(); |
222 } | 230 } |
223 | 231 |
224 void FileSystem::ReloadAfterReset(FileError error) { | 232 void FileSystem::ReloadAfterReset(FileError error) { |
225 if (error != FILE_ERROR_OK) { | 233 if (error != FILE_ERROR_OK) { |
226 LOG(ERROR) << "Failed to reset the resource metadata: " | 234 LOG(ERROR) << "Failed to reset the resource metadata: " |
227 << FileErrorToString(error); | 235 << FileErrorToString(error); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 DCHECK(!callback.is_null()); | 492 DCHECK(!callback.is_null()); |
485 | 493 |
486 download_operation_->EnsureFileDownloadedByPath( | 494 download_operation_->EnsureFileDownloadedByPath( |
487 file_path, | 495 file_path, |
488 ClientContext(USER_INITIATED), | 496 ClientContext(USER_INITIATED), |
489 GetFileContentInitializedCallback(), | 497 GetFileContentInitializedCallback(), |
490 google_apis::GetContentCallback(), | 498 google_apis::GetContentCallback(), |
491 callback); | 499 callback); |
492 } | 500 } |
493 | 501 |
| 502 void FileSystem::GetFileByPathForSaving(const base::FilePath& file_path, |
| 503 const GetFileCallback& callback) { |
| 504 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 505 DCHECK(!callback.is_null()); |
| 506 |
| 507 get_file_for_saving_operation_->GetFileForSaving(file_path, callback); |
| 508 } |
| 509 |
494 void FileSystem::GetFileContentByPath( | 510 void FileSystem::GetFileContentByPath( |
495 const base::FilePath& file_path, | 511 const base::FilePath& file_path, |
496 const GetFileContentInitializedCallback& initialized_callback, | 512 const GetFileContentInitializedCallback& initialized_callback, |
497 const google_apis::GetContentCallback& get_content_callback, | 513 const google_apis::GetContentCallback& get_content_callback, |
498 const FileOperationCallback& completion_callback) { | 514 const FileOperationCallback& completion_callback) { |
499 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 515 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
500 DCHECK(!initialized_callback.is_null()); | 516 DCHECK(!initialized_callback.is_null()); |
501 DCHECK(!get_content_callback.is_null()); | 517 DCHECK(!get_content_callback.is_null()); |
502 DCHECK(!completion_callback.is_null()); | 518 DCHECK(!completion_callback.is_null()); |
503 | 519 |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 void FileSystem::OpenFile(const base::FilePath& file_path, | 955 void FileSystem::OpenFile(const base::FilePath& file_path, |
940 OpenMode open_mode, | 956 OpenMode open_mode, |
941 const OpenFileCallback& callback) { | 957 const OpenFileCallback& callback) { |
942 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 958 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
943 DCHECK(!callback.is_null()); | 959 DCHECK(!callback.is_null()); |
944 | 960 |
945 open_file_operation_->OpenFile(file_path, open_mode, callback); | 961 open_file_operation_->OpenFile(file_path, open_mode, callback); |
946 } | 962 } |
947 | 963 |
948 } // namespace drive | 964 } // namespace drive |
OLD | NEW |