| 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/gdata/gdata_file_system.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 | 685 |
| 686 GDataFileSystem::GetFileFromCacheParams::~GetFileFromCacheParams() { | 686 GDataFileSystem::GetFileFromCacheParams::~GetFileFromCacheParams() { |
| 687 } | 687 } |
| 688 | 688 |
| 689 // GDataFileSystem class implementation. | 689 // GDataFileSystem class implementation. |
| 690 | 690 |
| 691 GDataFileSystem::GDataFileSystem( | 691 GDataFileSystem::GDataFileSystem( |
| 692 Profile* profile, | 692 Profile* profile, |
| 693 GDataCache* cache, | 693 GDataCache* cache, |
| 694 DocumentsServiceInterface* documents_service, | 694 DocumentsServiceInterface* documents_service, |
| 695 GDataUploaderInterface* uploader, |
| 695 const base::SequencedWorkerPool::SequenceToken& sequence_token) | 696 const base::SequencedWorkerPool::SequenceToken& sequence_token) |
| 696 : profile_(profile), | 697 : profile_(profile), |
| 697 cache_(cache), | 698 cache_(cache), |
| 699 uploader_(uploader), |
| 698 documents_service_(documents_service), | 700 documents_service_(documents_service), |
| 699 update_timer_(true /* retain_user_task */, true /* is_repeating */), | 701 update_timer_(true /* retain_user_task */, true /* is_repeating */), |
| 700 hide_hosted_docs_(false), | 702 hide_hosted_docs_(false), |
| 701 ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 703 ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 702 ui_weak_ptr_(ui_weak_ptr_factory_.GetWeakPtr()), | 704 ui_weak_ptr_(ui_weak_ptr_factory_.GetWeakPtr()), |
| 703 sequence_token_(sequence_token) { | 705 sequence_token_(sequence_token) { |
| 704 // Should be created from the file browser extension API on UI thread. | 706 // Should be created from the file browser extension API on UI thread. |
| 705 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 707 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 706 } | 708 } |
| 707 | 709 |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 void GDataFileSystem::StartFileUploadOnUIThread( | 1122 void GDataFileSystem::StartFileUploadOnUIThread( |
| 1121 const FileOperationCallback& callback, | 1123 const FileOperationCallback& callback, |
| 1122 base::PlatformFileError* error, | 1124 base::PlatformFileError* error, |
| 1123 UploadFileInfo* upload_file_info) { | 1125 UploadFileInfo* upload_file_info) { |
| 1124 // This method needs to run on the UI thread as required by | 1126 // This method needs to run on the UI thread as required by |
| 1125 // GDataUploader::UploadFile(). | 1127 // GDataUploader::UploadFile(). |
| 1126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1127 DCHECK(error); | 1129 DCHECK(error); |
| 1128 DCHECK(upload_file_info); | 1130 DCHECK(upload_file_info); |
| 1129 | 1131 |
| 1130 GDataSystemService* service = | |
| 1131 GDataSystemServiceFactory::GetForProfile(profile_); | |
| 1132 | |
| 1133 if (*error == base::PLATFORM_FILE_OK) { | |
| 1134 if (!service) | |
| 1135 *error = base::PLATFORM_FILE_ERROR_FAILED; | |
| 1136 } | |
| 1137 | |
| 1138 if (*error != base::PLATFORM_FILE_OK) { | 1132 if (*error != base::PLATFORM_FILE_OK) { |
| 1139 if (!callback.is_null()) | 1133 if (!callback.is_null()) |
| 1140 callback.Run(*error); | 1134 callback.Run(*error); |
| 1141 | 1135 |
| 1142 return; | 1136 return; |
| 1143 } | 1137 } |
| 1144 | 1138 |
| 1145 upload_file_info->completion_callback = | 1139 upload_file_info->completion_callback = |
| 1146 base::Bind(&GDataFileSystem::OnTransferCompleted, | 1140 base::Bind(&GDataFileSystem::OnTransferCompleted, |
| 1147 ui_weak_ptr_, | 1141 ui_weak_ptr_, |
| 1148 callback); | 1142 callback); |
| 1149 | 1143 |
| 1150 service->uploader()->UploadFile(scoped_ptr<UploadFileInfo>(upload_file_info)); | 1144 uploader_->UploadFile(scoped_ptr<UploadFileInfo>(upload_file_info)); |
| 1151 } | 1145 } |
| 1152 | 1146 |
| 1153 void GDataFileSystem::OnTransferCompleted( | 1147 void GDataFileSystem::OnTransferCompleted( |
| 1154 const FileOperationCallback& callback, | 1148 const FileOperationCallback& callback, |
| 1155 base::PlatformFileError error, | 1149 base::PlatformFileError error, |
| 1156 scoped_ptr<UploadFileInfo> upload_file_info) { | 1150 scoped_ptr<UploadFileInfo> upload_file_info) { |
| 1157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1158 DCHECK(upload_file_info.get()); | 1152 DCHECK(upload_file_info.get()); |
| 1159 | 1153 |
| 1160 if (error == base::PLATFORM_FILE_OK && upload_file_info->entry.get()) { | 1154 if (error == base::PLATFORM_FILE_OK && upload_file_info->entry.get()) { |
| (...skipping 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3719 // must go through here. Removes the |file_path| from the remembered set so | 3713 // must go through here. Removes the |file_path| from the remembered set so |
| 3720 // that subsequent operations can open the file again. | 3714 // that subsequent operations can open the file again. |
| 3721 open_files_.erase(file_path); | 3715 open_files_.erase(file_path); |
| 3722 | 3716 |
| 3723 // Then invokes the user-supplied callback function. | 3717 // Then invokes the user-supplied callback function. |
| 3724 if (!callback.is_null()) | 3718 if (!callback.is_null()) |
| 3725 callback.Run(result); | 3719 callback.Run(result); |
| 3726 } | 3720 } |
| 3727 | 3721 |
| 3728 } // namespace gdata | 3722 } // namespace gdata |
| OLD | NEW |