| 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/update_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/update_operation.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/drive/drive.pb.h" | 7 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 8 #include "chrome/browser/chromeos/drive/file_cache.h" | 8 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 9 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" | 9 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" |
| 10 #include "chrome/browser/chromeos/drive/file_system_util.h" | 10 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 weak_ptr_factory_(this) { | 29 weak_ptr_factory_(this) { |
| 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 UpdateOperation::~UpdateOperation() { | 33 UpdateOperation::~UpdateOperation() { |
| 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void UpdateOperation::UpdateFileByResourceId( | 37 void UpdateOperation::UpdateFileByResourceId( |
| 38 const std::string& resource_id, | 38 const std::string& resource_id, |
| 39 DriveClientContext context, | 39 ClientContext context, |
| 40 const FileOperationCallback& callback) { | 40 const FileOperationCallback& callback) { |
| 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 42 DCHECK(!callback.is_null()); | 42 DCHECK(!callback.is_null()); |
| 43 | 43 |
| 44 metadata_->GetResourceEntryByIdOnUIThread( | 44 metadata_->GetResourceEntryByIdOnUIThread( |
| 45 resource_id, | 45 resource_id, |
| 46 base::Bind(&UpdateOperation::UpdateFileAfterGetEntryInfo, | 46 base::Bind(&UpdateOperation::UpdateFileAfterGetEntryInfo, |
| 47 weak_ptr_factory_.GetWeakPtr(), | 47 weak_ptr_factory_.GetWeakPtr(), |
| 48 context, | 48 context, |
| 49 callback)); | 49 callback)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void UpdateOperation::UpdateFileAfterGetEntryInfo( | 52 void UpdateOperation::UpdateFileAfterGetEntryInfo( |
| 53 DriveClientContext context, | 53 ClientContext context, |
| 54 const FileOperationCallback& callback, | 54 const FileOperationCallback& callback, |
| 55 FileError error, | 55 FileError error, |
| 56 const base::FilePath& drive_file_path, | 56 const base::FilePath& drive_file_path, |
| 57 scoped_ptr<ResourceEntry> entry) { | 57 scoped_ptr<ResourceEntry> entry) { |
| 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 59 DCHECK(!callback.is_null()); | 59 DCHECK(!callback.is_null()); |
| 60 | 60 |
| 61 if (error != FILE_ERROR_OK) { | 61 if (error != FILE_ERROR_OK) { |
| 62 callback.Run(error); | 62 callback.Run(error); |
| 63 return; | 63 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 76 entry_ptr->file_specific_info().file_md5(), | 76 entry_ptr->file_specific_info().file_md5(), |
| 77 base::Bind(&UpdateOperation::UpdateFileAfterGetFile, | 77 base::Bind(&UpdateOperation::UpdateFileAfterGetFile, |
| 78 weak_ptr_factory_.GetWeakPtr(), | 78 weak_ptr_factory_.GetWeakPtr(), |
| 79 context, | 79 context, |
| 80 callback, | 80 callback, |
| 81 drive_file_path, | 81 drive_file_path, |
| 82 base::Passed(&entry))); | 82 base::Passed(&entry))); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void UpdateOperation::UpdateFileAfterGetFile( | 85 void UpdateOperation::UpdateFileAfterGetFile( |
| 86 DriveClientContext context, | 86 ClientContext context, |
| 87 const FileOperationCallback& callback, | 87 const FileOperationCallback& callback, |
| 88 const base::FilePath& drive_file_path, | 88 const base::FilePath& drive_file_path, |
| 89 scoped_ptr<ResourceEntry> entry, | 89 scoped_ptr<ResourceEntry> entry, |
| 90 FileError error, | 90 FileError error, |
| 91 const base::FilePath& cache_file_path) { | 91 const base::FilePath& cache_file_path) { |
| 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 93 DCHECK(!callback.is_null()); | 93 DCHECK(!callback.is_null()); |
| 94 | 94 |
| 95 if (error != FILE_ERROR_OK) { | 95 if (error != FILE_ERROR_OK) { |
| 96 callback.Run(error); | 96 callback.Run(error); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 observer_->OnDirectoryChangedByOperation(drive_file_path.DirName()); | 149 observer_->OnDirectoryChangedByOperation(drive_file_path.DirName()); |
| 150 | 150 |
| 151 // Clear the dirty bit if we have updated an existing file. | 151 // Clear the dirty bit if we have updated an existing file. |
| 152 cache_->ClearDirtyOnUIThread(entry->resource_id(), | 152 cache_->ClearDirtyOnUIThread(entry->resource_id(), |
| 153 entry->file_specific_info().file_md5(), | 153 entry->file_specific_info().file_md5(), |
| 154 callback); | 154 callback); |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace file_system | 157 } // namespace file_system |
| 158 } // namespace drive | 158 } // namespace drive |
| OLD | NEW |