| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sync/entry_revert_performer.h" | 5 #include "chrome/browser/chromeos/drive/sync/entry_revert_performer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/drive/change_list_processor.h" | 7 #include "chrome/browser/chromeos/drive/change_list_processor.h" |
| 8 #include "chrome/browser/chromeos/drive/drive.pb.h" | 8 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 9 #include "chrome/browser/chromeos/drive/file_change.h" | 9 #include "chrome/browser/chromeos/drive/file_change.h" |
| 10 #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" | 10 #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" |
| 11 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 11 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
| 12 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 12 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
| 13 #include "chrome/browser/chromeos/drive/resource_metadata.h" | 13 #include "chrome/browser/chromeos/drive/resource_metadata.h" |
| 14 #include "chrome/browser/drive/drive_api_util.h" | 14 #include "chrome/browser/drive/drive_api_util.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "google_apis/drive/drive_api_parser.h" | 16 #include "google_apis/drive/drive_api_parser.h" |
| 17 | 17 |
| 18 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 | 19 |
| 20 namespace drive { | 20 namespace drive { |
| 21 namespace internal { | 21 namespace internal { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 FileError FinishRevert(ResourceMetadata* metadata, | 24 FileError FinishRevert(ResourceMetadata* metadata, |
| 25 const std::string& local_id, | 25 const std::string& local_id, |
| 26 google_apis::GDataErrorCode status, | 26 google_apis::DriveApiErrorCode status, |
| 27 scoped_ptr<google_apis::FileResource> file_resource, | 27 scoped_ptr<google_apis::FileResource> file_resource, |
| 28 FileChange* changed_files) { | 28 FileChange* changed_files) { |
| 29 ResourceEntry entry; | 29 ResourceEntry entry; |
| 30 std::string parent_resource_id; | 30 std::string parent_resource_id; |
| 31 FileError error = GDataToFileError(status); | 31 FileError error = GDataToFileError(status); |
| 32 switch (error) { | 32 switch (error) { |
| 33 case FILE_ERROR_OK: | 33 case FILE_ERROR_OK: |
| 34 if (!ConvertFileResourceToResourceEntry(*file_resource, &entry, | 34 if (!ConvertFileResourceToResourceEntry(*file_resource, &entry, |
| 35 &parent_resource_id)) | 35 &parent_resource_id)) |
| 36 return FILE_ERROR_NOT_A_FILE; | 36 return FILE_ERROR_NOT_A_FILE; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 scheduler_->GetFileResource( | 137 scheduler_->GetFileResource( |
| 138 entry->resource_id(), | 138 entry->resource_id(), |
| 139 context, | 139 context, |
| 140 base::Bind(&EntryRevertPerformer::RevertEntryAfterGetFileResource, | 140 base::Bind(&EntryRevertPerformer::RevertEntryAfterGetFileResource, |
| 141 weak_ptr_factory_.GetWeakPtr(), callback, entry->local_id())); | 141 weak_ptr_factory_.GetWeakPtr(), callback, entry->local_id())); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void EntryRevertPerformer::RevertEntryAfterGetFileResource( | 144 void EntryRevertPerformer::RevertEntryAfterGetFileResource( |
| 145 const FileOperationCallback& callback, | 145 const FileOperationCallback& callback, |
| 146 const std::string& local_id, | 146 const std::string& local_id, |
| 147 google_apis::GDataErrorCode status, | 147 google_apis::DriveApiErrorCode status, |
| 148 scoped_ptr<google_apis::FileResource> entry) { | 148 scoped_ptr<google_apis::FileResource> entry) { |
| 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 150 DCHECK(!callback.is_null()); | 150 DCHECK(!callback.is_null()); |
| 151 | 151 |
| 152 FileChange* changed_files = new FileChange; | 152 FileChange* changed_files = new FileChange; |
| 153 base::PostTaskAndReplyWithResult( | 153 base::PostTaskAndReplyWithResult( |
| 154 blocking_task_runner_.get(), | 154 blocking_task_runner_.get(), |
| 155 FROM_HERE, | 155 FROM_HERE, |
| 156 base::Bind(&FinishRevert, | 156 base::Bind(&FinishRevert, |
| 157 metadata_, | 157 metadata_, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 173 DCHECK(!callback.is_null()); | 173 DCHECK(!callback.is_null()); |
| 174 | 174 |
| 175 delegate_->OnFileChangedByOperation(*changed_files); | 175 delegate_->OnFileChangedByOperation(*changed_files); |
| 176 | 176 |
| 177 callback.Run(error); | 177 callback.Run(error); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace internal | 180 } // namespace internal |
| 181 } // namespace drive | 181 } // namespace drive |
| OLD | NEW |