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" |
33 #include "chrome/browser/chromeos/drive/file_write_watcher.h" | |
32 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 34 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
33 #include "chrome/browser/chromeos/drive/remove_stale_cache_files.h" | 35 #include "chrome/browser/chromeos/drive/remove_stale_cache_files.h" |
34 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 36 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
35 #include "chrome/browser/chromeos/drive/search_metadata.h" | 37 #include "chrome/browser/chromeos/drive/search_metadata.h" |
36 #include "chrome/browser/chromeos/drive/sync_client.h" | 38 #include "chrome/browser/chromeos/drive/sync_client.h" |
37 #include "chrome/browser/drive/drive_api_util.h" | 39 #include "chrome/browser/drive/drive_api_util.h" |
38 #include "chrome/browser/drive/drive_service_interface.h" | 40 #include "chrome/browser/drive/drive_service_interface.h" |
39 #include "chrome/browser/google_apis/drive_api_parser.h" | 41 #include "chrome/browser/google_apis/drive_api_parser.h" |
40 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
41 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 cache_, | 203 cache_, |
202 temporary_file_directory_)); | 204 temporary_file_directory_)); |
203 update_operation_.reset( | 205 update_operation_.reset( |
204 new file_system::UpdateOperation(blocking_task_runner_.get(), | 206 new file_system::UpdateOperation(blocking_task_runner_.get(), |
205 observer, | 207 observer, |
206 scheduler_, | 208 scheduler_, |
207 resource_metadata_, | 209 resource_metadata_, |
208 cache_)); | 210 cache_)); |
209 search_operation_.reset(new file_system::SearchOperation( | 211 search_operation_.reset(new file_system::SearchOperation( |
210 blocking_task_runner_.get(), scheduler_, resource_metadata_)); | 212 blocking_task_runner_.get(), scheduler_, resource_metadata_)); |
213 get_file_for_saving_operation_.reset( | |
214 new file_system::GetFileForSavingOperation(blocking_task_runner_.get(), | |
215 observer, | |
216 scheduler_, | |
217 resource_metadata_, | |
218 cache_, | |
219 temporary_file_directory_)); | |
220 | |
211 sync_client_.reset(new internal::SyncClient(blocking_task_runner_.get(), | 221 sync_client_.reset(new internal::SyncClient(blocking_task_runner_.get(), |
212 observer, | 222 observer, |
213 scheduler_, | 223 scheduler_, |
214 resource_metadata_, | 224 resource_metadata_, |
215 cache_, | 225 cache_, |
216 temporary_file_directory_)); | 226 temporary_file_directory_)); |
217 | 227 file_write_watcher_.reset(new internal::FileWriteWatcher(observer)); |
hashimoto
2013/08/07 10:31:54
What is this watcher serving for?
kinaba
2013/08/07 11:28:38
Oops. I forgot to remove this prototype impl of mi
| |
218 hide_hosted_docs_ = | 228 hide_hosted_docs_ = |
219 pref_service_->GetBoolean(prefs::kDisableDriveHostedFiles); | 229 pref_service_->GetBoolean(prefs::kDisableDriveHostedFiles); |
220 | 230 |
221 InitializePreferenceObserver(); | 231 InitializePreferenceObserver(); |
222 } | 232 } |
223 | 233 |
224 void FileSystem::ReloadAfterReset(FileError error) { | 234 void FileSystem::ReloadAfterReset(FileError error) { |
225 if (error != FILE_ERROR_OK) { | 235 if (error != FILE_ERROR_OK) { |
226 LOG(ERROR) << "Failed to reset the resource metadata: " | 236 LOG(ERROR) << "Failed to reset the resource metadata: " |
227 << FileErrorToString(error); | 237 << FileErrorToString(error); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 DCHECK(!callback.is_null()); | 494 DCHECK(!callback.is_null()); |
485 | 495 |
486 download_operation_->EnsureFileDownloadedByPath( | 496 download_operation_->EnsureFileDownloadedByPath( |
487 file_path, | 497 file_path, |
488 ClientContext(USER_INITIATED), | 498 ClientContext(USER_INITIATED), |
489 GetFileContentInitializedCallback(), | 499 GetFileContentInitializedCallback(), |
490 google_apis::GetContentCallback(), | 500 google_apis::GetContentCallback(), |
491 callback); | 501 callback); |
492 } | 502 } |
493 | 503 |
504 void FileSystem::GetFileByPathForSaving(const base::FilePath& file_path, | |
505 const GetFileCallback& callback) { | |
506 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
507 DCHECK(!callback.is_null()); | |
508 | |
509 get_file_for_saving_operation_->GetFileForSaving(file_path, callback); | |
510 } | |
511 | |
494 void FileSystem::GetFileContentByPath( | 512 void FileSystem::GetFileContentByPath( |
495 const base::FilePath& file_path, | 513 const base::FilePath& file_path, |
496 const GetFileContentInitializedCallback& initialized_callback, | 514 const GetFileContentInitializedCallback& initialized_callback, |
497 const google_apis::GetContentCallback& get_content_callback, | 515 const google_apis::GetContentCallback& get_content_callback, |
498 const FileOperationCallback& completion_callback) { | 516 const FileOperationCallback& completion_callback) { |
499 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 517 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
500 DCHECK(!initialized_callback.is_null()); | 518 DCHECK(!initialized_callback.is_null()); |
501 DCHECK(!get_content_callback.is_null()); | 519 DCHECK(!get_content_callback.is_null()); |
502 DCHECK(!completion_callback.is_null()); | 520 DCHECK(!completion_callback.is_null()); |
503 | 521 |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
939 void FileSystem::OpenFile(const base::FilePath& file_path, | 957 void FileSystem::OpenFile(const base::FilePath& file_path, |
940 OpenMode open_mode, | 958 OpenMode open_mode, |
941 const OpenFileCallback& callback) { | 959 const OpenFileCallback& callback) { |
942 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 960 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
943 DCHECK(!callback.is_null()); | 961 DCHECK(!callback.is_null()); |
944 | 962 |
945 open_file_operation_->OpenFile(file_path, open_mode, callback); | 963 open_file_operation_->OpenFile(file_path, open_mode, callback); |
946 } | 964 } |
947 | 965 |
948 } // namespace drive | 966 } // namespace drive |
OLD | NEW |