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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 const std::string& resource_id, | 91 const std::string& resource_id, |
92 const ClientContext& context, | 92 const ClientContext& context, |
93 const FileOperationCallback& callback) { | 93 const FileOperationCallback& callback) { |
94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
95 DCHECK(!callback.is_null()); | 95 DCHECK(!callback.is_null()); |
96 | 96 |
97 ResourceEntry* entry = new ResourceEntry; | 97 ResourceEntry* entry = new ResourceEntry; |
98 base::FilePath* drive_file_path = new base::FilePath; | 98 base::FilePath* drive_file_path = new base::FilePath; |
99 base::FilePath* cache_file_path = new base::FilePath; | 99 base::FilePath* cache_file_path = new base::FilePath; |
100 base::PostTaskAndReplyWithResult( | 100 base::PostTaskAndReplyWithResult( |
101 blocking_task_runner_, | 101 blocking_task_runner_.get(), |
102 FROM_HERE, | 102 FROM_HERE, |
103 base::Bind(&GetFileLocalState, | 103 base::Bind(&GetFileLocalState, |
104 metadata_, | 104 metadata_, |
105 cache_, | 105 cache_, |
106 resource_id, | 106 resource_id, |
107 entry, | 107 entry, |
108 drive_file_path, | 108 drive_file_path, |
109 cache_file_path), | 109 cache_file_path), |
110 base::Bind(&UpdateOperation::UpdateFileAfterGetLocalState, | 110 base::Bind(&UpdateOperation::UpdateFileAfterGetLocalState, |
111 weak_ptr_factory_.GetWeakPtr(), | 111 weak_ptr_factory_.GetWeakPtr(), |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 DCHECK(!callback.is_null()); | 151 DCHECK(!callback.is_null()); |
152 | 152 |
153 FileError drive_error = util::GDataToFileError(error); | 153 FileError drive_error = util::GDataToFileError(error); |
154 if (drive_error != FILE_ERROR_OK) { | 154 if (drive_error != FILE_ERROR_OK) { |
155 callback.Run(drive_error); | 155 callback.Run(drive_error); |
156 return; | 156 return; |
157 } | 157 } |
158 | 158 |
159 base::FilePath* drive_file_path = new base::FilePath; | 159 base::FilePath* drive_file_path = new base::FilePath; |
160 base::PostTaskAndReplyWithResult( | 160 base::PostTaskAndReplyWithResult( |
161 blocking_task_runner_, | 161 blocking_task_runner_.get(), |
162 FROM_HERE, | 162 FROM_HERE, |
163 base::Bind(&UpdateFileLocalState, | 163 base::Bind(&UpdateFileLocalState, |
164 metadata_, | 164 metadata_, |
165 cache_, | 165 cache_, |
166 base::Passed(&resource_entry), | 166 base::Passed(&resource_entry), |
167 drive_file_path), | 167 drive_file_path), |
168 base::Bind(&UpdateOperation::UpdateFileAfterUpdateLocalState, | 168 base::Bind(&UpdateOperation::UpdateFileAfterUpdateLocalState, |
169 weak_ptr_factory_.GetWeakPtr(), | 169 weak_ptr_factory_.GetWeakPtr(), |
170 callback, | 170 callback, |
171 base::Owned(drive_file_path))); | 171 base::Owned(drive_file_path))); |
172 } | 172 } |
173 | 173 |
174 void UpdateOperation::UpdateFileAfterUpdateLocalState( | 174 void UpdateOperation::UpdateFileAfterUpdateLocalState( |
175 const FileOperationCallback& callback, | 175 const FileOperationCallback& callback, |
176 const base::FilePath* drive_file_path, | 176 const base::FilePath* drive_file_path, |
177 FileError error) { | 177 FileError error) { |
178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
179 DCHECK(!callback.is_null()); | 179 DCHECK(!callback.is_null()); |
180 | 180 |
181 if (error != FILE_ERROR_OK) { | 181 if (error != FILE_ERROR_OK) { |
182 callback.Run(error); | 182 callback.Run(error); |
183 return; | 183 return; |
184 } | 184 } |
185 observer_->OnDirectoryChangedByOperation(drive_file_path->DirName()); | 185 observer_->OnDirectoryChangedByOperation(drive_file_path->DirName()); |
186 callback.Run(FILE_ERROR_OK); | 186 callback.Run(FILE_ERROR_OK); |
187 } | 187 } |
188 | 188 |
189 } // namespace file_system | 189 } // namespace file_system |
190 } // namespace drive | 190 } // namespace drive |
OLD | NEW |