| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/drive/file_system/drive_operations.h" | |
| 6 | |
| 7 #include "base/callback.h" | |
| 8 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h" | |
| 9 #include "chrome/browser/chromeos/drive/file_system/create_directory_operation.h
" | |
| 10 #include "chrome/browser/chromeos/drive/file_system/create_file_operation.h" | |
| 11 #include "chrome/browser/chromeos/drive/file_system/move_operation.h" | |
| 12 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" | |
| 13 #include "chrome/browser/chromeos/drive/file_system/search_operation.h" | |
| 14 #include "chrome/browser/chromeos/drive/file_system/touch_operation.h" | |
| 15 #include "chrome/browser/chromeos/drive/file_system/update_operation.h" | |
| 16 #include "content/public/browser/browser_thread.h" | |
| 17 | |
| 18 using content::BrowserThread; | |
| 19 | |
| 20 namespace drive { | |
| 21 namespace file_system { | |
| 22 | |
| 23 DriveOperations::DriveOperations() { | |
| 24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 25 } | |
| 26 | |
| 27 DriveOperations::~DriveOperations() { | |
| 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 29 } | |
| 30 | |
| 31 void DriveOperations::Init(OperationObserver* observer, | |
| 32 JobScheduler* scheduler, | |
| 33 internal::ResourceMetadata* metadata, | |
| 34 internal::FileCache* cache, | |
| 35 FileSystemInterface* file_system, | |
| 36 google_apis::DriveServiceInterface* drive_service, | |
| 37 base::SequencedTaskRunner* blocking_task_runner) { | |
| 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 39 | |
| 40 copy_operation_.reset(new file_system::CopyOperation(blocking_task_runner, | |
| 41 observer, | |
| 42 scheduler, | |
| 43 metadata, | |
| 44 cache, | |
| 45 file_system, | |
| 46 drive_service)); | |
| 47 create_directory_operation_.reset(new CreateDirectoryOperation( | |
| 48 blocking_task_runner, | |
| 49 observer, | |
| 50 scheduler, | |
| 51 metadata)); | |
| 52 create_file_operation_.reset(new CreateFileOperation(blocking_task_runner, | |
| 53 observer, | |
| 54 scheduler, | |
| 55 metadata, | |
| 56 cache)); | |
| 57 move_operation_.reset( | |
| 58 new MoveOperation(observer, scheduler, metadata)); | |
| 59 remove_operation_.reset( | |
| 60 new RemoveOperation(observer, scheduler, metadata, cache)); | |
| 61 touch_operation_.reset( | |
| 62 new TouchOperation(blocking_task_runner, observer, scheduler, metadata)); | |
| 63 update_operation_.reset( | |
| 64 new UpdateOperation(observer, scheduler, metadata, cache)); | |
| 65 search_operation_.reset( | |
| 66 new SearchOperation(blocking_task_runner, scheduler, metadata)); | |
| 67 } | |
| 68 | |
| 69 void DriveOperations::Copy(const base::FilePath& src_file_path, | |
| 70 const base::FilePath& dest_file_path, | |
| 71 const FileOperationCallback& callback) { | |
| 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 73 DCHECK(!callback.is_null()); | |
| 74 | |
| 75 copy_operation_->Copy(src_file_path, dest_file_path, callback); | |
| 76 } | |
| 77 | |
| 78 void DriveOperations::TransferFileFromRemoteToLocal( | |
| 79 const base::FilePath& remote_src_file_path, | |
| 80 const base::FilePath& local_dest_file_path, | |
| 81 const FileOperationCallback& callback) { | |
| 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 83 DCHECK(!callback.is_null()); | |
| 84 | |
| 85 copy_operation_->TransferFileFromRemoteToLocal(remote_src_file_path, | |
| 86 local_dest_file_path, | |
| 87 callback); | |
| 88 } | |
| 89 | |
| 90 void DriveOperations::TransferFileFromLocalToRemote( | |
| 91 const base::FilePath& local_src_file_path, | |
| 92 const base::FilePath& remote_dest_file_path, | |
| 93 const FileOperationCallback& callback) { | |
| 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 95 DCHECK(!callback.is_null()); | |
| 96 | |
| 97 copy_operation_->TransferFileFromLocalToRemote(local_src_file_path, | |
| 98 remote_dest_file_path, | |
| 99 callback); | |
| 100 } | |
| 101 | |
| 102 void DriveOperations::CreateDirectory(const base::FilePath& directory_path, | |
| 103 bool is_exclusive, | |
| 104 bool is_recursive, | |
| 105 const FileOperationCallback& callback) { | |
| 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 107 DCHECK(!callback.is_null()); | |
| 108 | |
| 109 create_directory_operation_->CreateDirectory( | |
| 110 directory_path, is_exclusive, is_recursive, callback); | |
| 111 } | |
| 112 | |
| 113 void DriveOperations::CreateFile(const base::FilePath& remote_file_path, | |
| 114 bool is_exclusive, | |
| 115 const FileOperationCallback& callback) { | |
| 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 117 DCHECK(!callback.is_null()); | |
| 118 | |
| 119 create_file_operation_->CreateFile(remote_file_path, is_exclusive, callback); | |
| 120 } | |
| 121 | |
| 122 void DriveOperations::Move(const base::FilePath& src_file_path, | |
| 123 const base::FilePath& dest_file_path, | |
| 124 const FileOperationCallback& callback) { | |
| 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 126 DCHECK(!callback.is_null()); | |
| 127 | |
| 128 move_operation_->Move(src_file_path, dest_file_path, callback); | |
| 129 } | |
| 130 | |
| 131 void DriveOperations::Remove(const base::FilePath& file_path, | |
| 132 bool is_recursive, | |
| 133 const FileOperationCallback& callback) { | |
| 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 135 DCHECK(!callback.is_null()); | |
| 136 | |
| 137 remove_operation_->Remove(file_path, is_recursive, callback); | |
| 138 } | |
| 139 | |
| 140 void DriveOperations::TouchFile(const base::FilePath& file_path, | |
| 141 const base::Time& last_access_time, | |
| 142 const base::Time& last_modified_time, | |
| 143 const FileOperationCallback& callback) { | |
| 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 145 DCHECK(!last_access_time.is_null()); | |
| 146 DCHECK(!last_modified_time.is_null()); | |
| 147 DCHECK(!callback.is_null()); | |
| 148 | |
| 149 touch_operation_->TouchFile( | |
| 150 file_path, last_access_time, last_modified_time, callback); | |
| 151 } | |
| 152 | |
| 153 void DriveOperations::UpdateFileByResourceId( | |
| 154 const std::string& resource_id, | |
| 155 DriveClientContext context, | |
| 156 const FileOperationCallback& callback) { | |
| 157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 158 DCHECK(!callback.is_null()); | |
| 159 | |
| 160 update_operation_->UpdateFileByResourceId(resource_id, context, callback); | |
| 161 } | |
| 162 | |
| 163 void DriveOperations::Search(const std::string& search_query, | |
| 164 const GURL& next_feed, | |
| 165 const SearchOperationCallback& callback) { | |
| 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 167 DCHECK(!callback.is_null()); | |
| 168 | |
| 169 search_operation_->Search(search_query, next_feed, callback); | |
| 170 } | |
| 171 | |
| 172 } // namespace file_system | |
| 173 } // namespace drive | |
| OLD | NEW |