| 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 "base/file_util.h" | 7 #include "base/file_util.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_cache.h" | 9 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 10 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" | 10 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 DCHECK(entry.get()); | 71 DCHECK(entry.get()); |
| 72 if (entry->file_info().is_directory()) { | 72 if (entry->file_info().is_directory()) { |
| 73 callback.Run(FILE_ERROR_NOT_FOUND); | 73 callback.Run(FILE_ERROR_NOT_FOUND); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Extract a pointer before we call Pass() so we can use it below. | 77 // Extract a pointer before we call Pass() so we can use it below. |
| 78 ResourceEntry* entry_ptr = entry.get(); | 78 ResourceEntry* entry_ptr = entry.get(); |
| 79 cache_->GetFile(entry_ptr->resource_id(), | 79 cache_->GetFileOnUIThread( |
| 80 entry_ptr->file_specific_info().file_md5(), | 80 entry_ptr->resource_id(), |
| 81 base::Bind(&UpdateOperation::OnGetFileCompleteForUpdateFile, | 81 entry_ptr->file_specific_info().file_md5(), |
| 82 weak_ptr_factory_.GetWeakPtr(), | 82 base::Bind(&UpdateOperation::OnGetFileCompleteForUpdateFile, |
| 83 context, | 83 weak_ptr_factory_.GetWeakPtr(), |
| 84 callback, | 84 context, |
| 85 drive_file_path, | 85 callback, |
| 86 base::Passed(&entry))); | 86 drive_file_path, |
| 87 base::Passed(&entry))); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void UpdateOperation::OnGetFileCompleteForUpdateFile( | 90 void UpdateOperation::OnGetFileCompleteForUpdateFile( |
| 90 DriveClientContext context, | 91 DriveClientContext context, |
| 91 const FileOperationCallback& callback, | 92 const FileOperationCallback& callback, |
| 92 const base::FilePath& drive_file_path, | 93 const base::FilePath& drive_file_path, |
| 93 scoped_ptr<ResourceEntry> entry, | 94 scoped_ptr<ResourceEntry> entry, |
| 94 FileError error, | 95 FileError error, |
| 95 const base::FilePath& cache_file_path) { | 96 const base::FilePath& cache_file_path) { |
| 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 149 } |
| 149 | 150 |
| 150 DCHECK(entry.get()); | 151 DCHECK(entry.get()); |
| 151 DCHECK(entry->has_resource_id()); | 152 DCHECK(entry->has_resource_id()); |
| 152 DCHECK(entry->has_file_specific_info()); | 153 DCHECK(entry->has_file_specific_info()); |
| 153 DCHECK(entry->file_specific_info().has_file_md5()); | 154 DCHECK(entry->file_specific_info().has_file_md5()); |
| 154 | 155 |
| 155 observer_->OnDirectoryChangedByOperation(drive_file_path.DirName()); | 156 observer_->OnDirectoryChangedByOperation(drive_file_path.DirName()); |
| 156 | 157 |
| 157 // Clear the dirty bit if we have updated an existing file. | 158 // Clear the dirty bit if we have updated an existing file. |
| 158 cache_->ClearDirty(entry->resource_id(), | 159 cache_->ClearDirtyOnUIThread(entry->resource_id(), |
| 159 entry->file_specific_info().file_md5(), | 160 entry->file_specific_info().file_md5(), |
| 160 callback); | 161 callback); |
| 161 } | 162 } |
| 162 | 163 |
| 163 } // namespace file_system | 164 } // namespace file_system |
| 164 } // namespace drive | 165 } // namespace drive |
| OLD | NEW |