Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / drive / file_system / move_operation.h
blobdb6cee8f941e4ce49db085691d69a1a9dfd6374c
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.
5 #ifndef COMPONENTS_DRIVE_FILE_SYSTEM_MOVE_OPERATION_H_
6 #define COMPONENTS_DRIVE_FILE_SYSTEM_MOVE_OPERATION_H_
8 #include <set>
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread_checker.h"
15 #include "components/drive/file_errors.h"
16 #include "google_apis/drive/drive_api_error_codes.h"
18 namespace base {
19 class FilePath;
20 class SequencedTaskRunner;
21 } // namespace base
23 namespace google_apis {
24 class ResourceEntry;
25 } // namespace google_apis
27 namespace drive {
29 class FileChange;
30 class ResourceEntry;
32 namespace internal {
33 class ResourceMetadata;
34 } // namespace internal
36 namespace file_system {
38 class OperationDelegate;
40 // This class encapsulates the drive Move function. It is responsible for
41 // updating the local metadata entry.
42 class MoveOperation {
43 public:
44 MoveOperation(base::SequencedTaskRunner* blocking_task_runner,
45 OperationDelegate* delegate,
46 internal::ResourceMetadata* metadata);
47 ~MoveOperation();
49 // Performs the move operation on the file at drive path |src_file_path|
50 // with a target of |dest_file_path|.
51 // Invokes |callback| when finished with the result of the operation.
52 // |callback| must not be null.
53 void Move(const base::FilePath& src_file_path,
54 const base::FilePath& dest_file_path,
55 const FileOperationCallback& callback);
57 private:
58 // Part of Move(). Called after updating the local state.
59 void MoveAfterUpdateLocalState(const FileOperationCallback& callback,
60 const FileChange* changed_file,
61 const std::string* local_id,
62 FileError error);
64 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
65 OperationDelegate* delegate_;
66 internal::ResourceMetadata* metadata_;
68 base::ThreadChecker thread_checker_;
70 // Note: This should remain the last member so it'll be destroyed and
71 // invalidate the weak pointers before any other members are destroyed.
72 base::WeakPtrFactory<MoveOperation> weak_ptr_factory_;
73 DISALLOW_COPY_AND_ASSIGN(MoveOperation);
76 } // namespace file_system
77 } // namespace drive
79 #endif // COMPONENTS_DRIVE_FILE_SYSTEM_MOVE_OPERATION_H_