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/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.h" | 9 #include "chrome/browser/chromeos/drive/drive_file_system.h" |
10 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | 10 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
11 #include "chrome/browser/chromeos/drive/drive_files.h" | 11 #include "chrome/browser/chromeos/drive/drive_files.h" |
12 #include "chrome/browser/chromeos/drive/drive_service_interface.h" | 12 #include "chrome/browser/chromeos/drive/drive_service_interface.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 | 14 |
15 using content::BrowserThread; | 15 using content::BrowserThread; |
16 | 16 |
17 namespace gdata { | 17 namespace drive { |
18 namespace file_system { | 18 namespace file_system { |
19 | 19 |
20 MoveOperation::MoveOperation(DriveServiceInterface* drive_service, | 20 MoveOperation::MoveOperation(DriveServiceInterface* drive_service, |
21 DriveFileSystem* file_system, | 21 DriveFileSystem* file_system, |
22 DriveCache* cache) | 22 DriveCache* cache) |
23 : drive_service_(drive_service), | 23 : drive_service_(drive_service), |
24 file_system_(file_system), | 24 file_system_(file_system), |
25 cache_(cache), | 25 cache_(cache), |
26 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 26 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
27 } | 27 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 weak_ptr_factory_.GetWeakPtr(), | 171 weak_ptr_factory_.GetWeakPtr(), |
172 file_path, | 172 file_path, |
173 file_name, | 173 file_name, |
174 callback)); | 174 callback)); |
175 } | 175 } |
176 | 176 |
177 void MoveOperation::RenameEntryLocally( | 177 void MoveOperation::RenameEntryLocally( |
178 const FilePath& file_path, | 178 const FilePath& file_path, |
179 const FilePath::StringType& new_name, | 179 const FilePath::StringType& new_name, |
180 const FileMoveCallback& callback, | 180 const FileMoveCallback& callback, |
181 GDataErrorCode status, | 181 gdata::GDataErrorCode status, |
182 const GURL& /* document_url */) { | 182 const GURL& /* document_url */) { |
183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
184 DCHECK(!callback.is_null()); | 184 DCHECK(!callback.is_null()); |
185 | 185 |
186 const DriveFileError error = util::GDataToDriveFileError(status); | 186 const DriveFileError error = util::GDataToDriveFileError(status); |
187 if (error != DRIVE_FILE_OK) { | 187 if (error != DRIVE_FILE_OK) { |
188 callback.Run(error, FilePath()); | 188 callback.Run(error, FilePath()); |
189 return; | 189 return; |
190 } | 190 } |
191 | 191 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 weak_ptr_factory_.GetWeakPtr(), | 323 weak_ptr_factory_.GetWeakPtr(), |
324 callback))); | 324 callback))); |
325 } | 325 } |
326 | 326 |
327 // TODO(zork): Share with CopyOperation. | 327 // TODO(zork): Share with CopyOperation. |
328 // See: crbug.com/150050 | 328 // See: crbug.com/150050 |
329 void MoveOperation::MoveEntryToDirectory( | 329 void MoveOperation::MoveEntryToDirectory( |
330 const FilePath& file_path, | 330 const FilePath& file_path, |
331 const FilePath& directory_path, | 331 const FilePath& directory_path, |
332 const FileMoveCallback& callback, | 332 const FileMoveCallback& callback, |
333 GDataErrorCode status, | 333 gdata::GDataErrorCode status, |
334 const GURL& /* document_url */) { | 334 const GURL& /* document_url */) { |
335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
336 DCHECK(!callback.is_null()); | 336 DCHECK(!callback.is_null()); |
337 | 337 |
338 const DriveFileError error = util::GDataToDriveFileError(status); | 338 const DriveFileError error = util::GDataToDriveFileError(status); |
339 if (error != DRIVE_FILE_OK) { | 339 if (error != DRIVE_FILE_OK) { |
340 callback.Run(error, FilePath()); | 340 callback.Run(error, FilePath()); |
341 return; | 341 return; |
342 } | 342 } |
343 | 343 |
(...skipping 23 matching lines...) Expand all Loading... |
367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
368 DCHECK(!callback.is_null()); | 368 DCHECK(!callback.is_null()); |
369 | 369 |
370 if (error == DRIVE_FILE_OK) | 370 if (error == DRIVE_FILE_OK) |
371 file_system_->OnDirectoryChanged(moved_file_path.DirName()); | 371 file_system_->OnDirectoryChanged(moved_file_path.DirName()); |
372 | 372 |
373 callback.Run(error, moved_file_path); | 373 callback.Run(error, moved_file_path); |
374 } | 374 } |
375 | 375 |
376 } // namespace file_system | 376 } // namespace file_system |
377 } // namespace gdata | 377 } // namespace drive |
OLD | NEW |