Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: chrome/browser/chromeos/drive/file_system/move_operation.cc

Issue 14493009: drive: Rename DriveScheduler to JobScheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indent Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/move_operation.h" 5 #include "chrome/browser/chromeos/drive/file_system/move_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/drive_cache.h" 8 #include "chrome/browser/chromeos/drive/drive_cache.h"
9 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" 9 #include "chrome/browser/chromeos/drive/drive_file_system_util.h"
10 #include "chrome/browser/chromeos/drive/drive_scheduler.h"
11 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" 10 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h"
11 #include "chrome/browser/chromeos/drive/job_scheduler.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 13
14 using content::BrowserThread; 14 using content::BrowserThread;
15 15
16 namespace drive { 16 namespace drive {
17 namespace file_system { 17 namespace file_system {
18 18
19 MoveOperation::MoveOperation(DriveScheduler* drive_scheduler, 19 MoveOperation::MoveOperation(JobScheduler* job_scheduler,
20 DriveResourceMetadata* metadata, 20 DriveResourceMetadata* metadata,
21 OperationObserver* observer) 21 OperationObserver* observer)
22 : drive_scheduler_(drive_scheduler), 22 : job_scheduler_(job_scheduler),
23 metadata_(metadata), 23 metadata_(metadata),
24 observer_(observer), 24 observer_(observer),
25 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 25 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
27 } 27 }
28 28
29 MoveOperation::~MoveOperation() { 29 MoveOperation::~MoveOperation() {
30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
31 } 31 }
32 32
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return; 146 return;
147 } 147 }
148 148
149 // Drop the .g<something> extension from |new_name| if the file being 149 // Drop the .g<something> extension from |new_name| if the file being
150 // renamed is a hosted document and |new_name| has the same .g<something> 150 // renamed is a hosted document and |new_name| has the same .g<something>
151 // extension as the file. 151 // extension as the file.
152 const base::FilePath& new_name_arg( 152 const base::FilePath& new_name_arg(
153 new_name_has_hosted_extension ? new_name.RemoveExtension() : new_name); 153 new_name_has_hosted_extension ? new_name.RemoveExtension() : new_name);
154 154
155 // Rename on the server. 155 // Rename on the server.
156 drive_scheduler_->RenameResource(src_id, 156 job_scheduler_->RenameResource(src_id,
157 new_name_arg.AsUTF8Unsafe(), 157 new_name_arg.AsUTF8Unsafe(),
158 base::Bind(&MoveOperation::RenameLocally, 158 base::Bind(&MoveOperation::RenameLocally,
159 weak_ptr_factory_.GetWeakPtr(), 159 weak_ptr_factory_.GetWeakPtr(),
160 src_path, 160 src_path,
161 new_name_arg, 161 new_name_arg,
162 callback)); 162 callback));
163 } 163 }
164 164
165 void MoveOperation::RenameLocally(const base::FilePath& src_path, 165 void MoveOperation::RenameLocally(const base::FilePath& src_path,
166 const base::FilePath& new_name, 166 const base::FilePath& new_name,
167 const FileMoveCallback& callback, 167 const FileMoveCallback& callback,
168 google_apis::GDataErrorCode status) { 168 google_apis::GDataErrorCode status) {
169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
170 170
171 const FileError error = util::GDataToFileError(status); 171 const FileError error = util::GDataToFileError(status);
172 if (error != FILE_ERROR_OK) { 172 if (error != FILE_ERROR_OK) {
173 callback.Run(error, base::FilePath()); 173 callback.Run(error, base::FilePath());
174 return; 174 return;
175 } 175 }
176 metadata_->RenameEntry(src_path, new_name.AsUTF8Unsafe(), callback); 176 metadata_->RenameEntry(src_path, new_name.AsUTF8Unsafe(), callback);
177 } 177 }
178 178
179 179
180 void MoveOperation::AddToDirectory(const std::string& src_id, 180 void MoveOperation::AddToDirectory(const std::string& src_id,
181 const std::string& dest_dir_id, 181 const std::string& dest_dir_id,
182 const base::FilePath& src_path, 182 const base::FilePath& src_path,
183 const base::FilePath& dest_dir_path, 183 const base::FilePath& dest_dir_path,
184 const FileMoveCallback& callback) { 184 const FileMoveCallback& callback) {
185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
186 186
187 drive_scheduler_->AddResourceToDirectory( 187 job_scheduler_->AddResourceToDirectory(
188 dest_dir_id, src_id, 188 dest_dir_id, src_id,
189 base::Bind(&MoveOperation::AddToDirectoryLocally, 189 base::Bind(&MoveOperation::AddToDirectoryLocally,
190 weak_ptr_factory_.GetWeakPtr(), 190 weak_ptr_factory_.GetWeakPtr(),
191 src_path, 191 src_path,
192 dest_dir_path, 192 dest_dir_path,
193 callback)); 193 callback));
194 } 194 }
195 195
196 void MoveOperation::AddToDirectoryLocally(const base::FilePath& src_path, 196 void MoveOperation::AddToDirectoryLocally(const base::FilePath& src_path,
197 const base::FilePath& dest_dir_path, 197 const base::FilePath& dest_dir_path,
198 const FileMoveCallback& callback, 198 const FileMoveCallback& callback,
199 google_apis::GDataErrorCode status) { 199 google_apis::GDataErrorCode status) {
200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
201 201
202 const FileError error = util::GDataToFileError(status); 202 const FileError error = util::GDataToFileError(status);
203 if (error != FILE_ERROR_OK) { 203 if (error != FILE_ERROR_OK) {
204 callback.Run(error, base::FilePath()); 204 callback.Run(error, base::FilePath());
205 return; 205 return;
206 } 206 }
207 metadata_->MoveEntryToDirectory(src_path, dest_dir_path, callback); 207 metadata_->MoveEntryToDirectory(src_path, dest_dir_path, callback);
208 } 208 }
209 209
210 void MoveOperation::RemoveFromDirectory( 210 void MoveOperation::RemoveFromDirectory(
211 const std::string& resource_id, 211 const std::string& resource_id,
212 const std::string& directory_resource_id, 212 const std::string& directory_resource_id,
213 const FileOperationCallback& callback) { 213 const FileOperationCallback& callback) {
214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
215 215
216 drive_scheduler_->RemoveResourceFromDirectory( 216 job_scheduler_->RemoveResourceFromDirectory(
217 directory_resource_id, 217 directory_resource_id,
218 resource_id, 218 resource_id,
219 base::Bind(&MoveOperation::RemoveFromDirectoryCompleted, 219 base::Bind(&MoveOperation::RemoveFromDirectoryCompleted,
220 weak_ptr_factory_.GetWeakPtr(), 220 weak_ptr_factory_.GetWeakPtr(),
221 callback)); 221 callback));
222 } 222 }
223 223
224 void MoveOperation::RemoveFromDirectoryCompleted( 224 void MoveOperation::RemoveFromDirectoryCompleted(
225 const FileOperationCallback& callback, 225 const FileOperationCallback& callback,
226 google_apis::GDataErrorCode status) { 226 google_apis::GDataErrorCode status) {
227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
228 callback.Run(util::GDataToFileError(status)); 228 callback.Run(util::GDataToFileError(status));
229 } 229 }
230 230
231 } // namespace file_system 231 } // namespace file_system
232 } // namespace drive 232 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698