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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_COPY_OPERATION_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_COPY_OPERATION_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_COPY_OPERATION_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_COPY_OPERATION_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" | 11 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" |
12 #include "chrome/browser/google_apis/gdata_errorcode.h" | 12 #include "chrome/browser/google_apis/gdata_errorcode.h" |
13 | 13 |
14 class GURL; | 14 class GURL; |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class FilePath; | 17 class FilePath; |
18 class Value; | 18 class Value; |
19 } | 19 } |
20 | 20 |
21 namespace google_apis { | 21 namespace google_apis { |
22 class ResourceEntry; | 22 class ResourceEntry; |
23 } | 23 } |
24 | 24 |
25 namespace drive { | 25 namespace drive { |
26 | 26 |
27 class DriveEntryProto; | 27 class DriveEntryProto; |
28 class DriveFileSystemInterface; | 28 class DriveFileSystemInterface; |
29 class DriveScheduler; | 29 class JobScheduler; |
30 | 30 |
31 namespace file_system { | 31 namespace file_system { |
32 | 32 |
33 class MoveOperation; | 33 class MoveOperation; |
34 class OperationObserver; | 34 class OperationObserver; |
35 | 35 |
36 // This class encapsulates the drive Copy function. It is responsible for | 36 // This class encapsulates the drive Copy function. It is responsible for |
37 // sending the request to the drive API, then updating the local state and | 37 // sending the request to the drive API, then updating the local state and |
38 // metadata to reflect the new state. | 38 // metadata to reflect the new state. |
39 class CopyOperation { | 39 class CopyOperation { |
40 public: | 40 public: |
41 CopyOperation(DriveScheduler* drive_scheduler, | 41 CopyOperation(JobScheduler* job_scheduler, |
42 DriveFileSystemInterface* drive_file_system, | 42 DriveFileSystemInterface* drive_file_system, |
43 DriveResourceMetadata* metadata, | 43 DriveResourceMetadata* metadata, |
44 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, | 44 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, |
45 OperationObserver* observer); | 45 OperationObserver* observer); |
46 virtual ~CopyOperation(); | 46 virtual ~CopyOperation(); |
47 | 47 |
48 // Performs the copy operation on the file at drive path |src_file_path| | 48 // Performs the copy operation on the file at drive path |src_file_path| |
49 // with a target of |dest_file_path|. Invokes |callback| when finished with | 49 // with a target of |dest_file_path|. Invokes |callback| when finished with |
50 // the result of the operation. |callback| must not be null. | 50 // the result of the operation. |callback| must not be null. |
51 virtual void Copy(const base::FilePath& src_file_path, | 51 virtual void Copy(const base::FilePath& src_file_path, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // handled by CopyDocumentToDirectory. Otherwise, the transfer is handled by | 190 // handled by CopyDocumentToDirectory. Otherwise, the transfer is handled by |
191 // TransferRegularFile. | 191 // TransferRegularFile. |
192 // | 192 // |
193 // Must be called from *UI* thread. |callback| is run on the calling thread. | 193 // Must be called from *UI* thread. |callback| is run on the calling thread. |
194 // |callback| must not be null. | 194 // |callback| must not be null. |
195 void TransferFileForResourceId(const base::FilePath& local_file_path, | 195 void TransferFileForResourceId(const base::FilePath& local_file_path, |
196 const base::FilePath& remote_dest_file_path, | 196 const base::FilePath& remote_dest_file_path, |
197 const FileOperationCallback& callback, | 197 const FileOperationCallback& callback, |
198 const std::string& resource_id); | 198 const std::string& resource_id); |
199 | 199 |
200 DriveScheduler* drive_scheduler_; | 200 JobScheduler* job_scheduler_; |
201 DriveFileSystemInterface* drive_file_system_; | 201 DriveFileSystemInterface* drive_file_system_; |
202 DriveResourceMetadata* metadata_; | 202 DriveResourceMetadata* metadata_; |
203 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 203 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
204 OperationObserver* observer_; | 204 OperationObserver* observer_; |
205 | 205 |
206 // Copying a hosted document is internally implemented by using a move. | 206 // Copying a hosted document is internally implemented by using a move. |
207 scoped_ptr<MoveOperation> move_operation_; | 207 scoped_ptr<MoveOperation> move_operation_; |
208 | 208 |
209 // WeakPtrFactory bound to the UI thread. | 209 // WeakPtrFactory bound to the UI thread. |
210 // Note: This should remain the last member so it'll be destroyed and | 210 // Note: This should remain the last member so it'll be destroyed and |
211 // invalidate the weak pointers before any other members are destroyed. | 211 // invalidate the weak pointers before any other members are destroyed. |
212 base::WeakPtrFactory<CopyOperation> weak_ptr_factory_; | 212 base::WeakPtrFactory<CopyOperation> weak_ptr_factory_; |
213 | 213 |
214 DISALLOW_COPY_AND_ASSIGN(CopyOperation); | 214 DISALLOW_COPY_AND_ASSIGN(CopyOperation); |
215 }; | 215 }; |
216 | 216 |
217 } // namespace file_system | 217 } // namespace file_system |
218 } // namespace drive | 218 } // namespace drive |
219 | 219 |
220 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_COPY_OPERATION_H_ | 220 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_COPY_OPERATION_H_ |
OLD | NEW |