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

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

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_MOVE_OPERATION_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_MOVE_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_MOVE_OPERATION_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_MOVE_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;
15
16 namespace base {
14 class FilePath; 17 class FilePath;
15 class GURL; 18 }
16 19
17 namespace drive { 20 namespace drive {
18 21
19 class DriveCache; 22 class DriveCache;
20 class DriveEntryProto; 23 class DriveEntryProto;
21 class DriveResourceMetadata; 24 class DriveResourceMetadata;
22 class DriveScheduler; 25 class DriveScheduler;
23 26
24 namespace file_system { 27 namespace file_system {
25 28
26 class OperationObserver; 29 class OperationObserver;
27 30
28 // This class encapsulates the drive Move function. It is responsible for 31 // This class encapsulates the drive Move function. It is responsible for
29 // sending the request to the drive API, then updating the local state and 32 // sending the request to the drive API, then updating the local state and
30 // metadata to reflect the new state. 33 // metadata to reflect the new state.
31 class MoveOperation { 34 class MoveOperation {
32 public: 35 public:
33 MoveOperation(DriveScheduler* drive_scheduler, 36 MoveOperation(DriveScheduler* drive_scheduler,
34 DriveResourceMetadata* metadata, 37 DriveResourceMetadata* metadata,
35 OperationObserver* observer); 38 OperationObserver* observer);
36 virtual ~MoveOperation(); 39 virtual ~MoveOperation();
37 40
38 // Performs the move operation on the file at drive path |src_file_path| 41 // Performs the move operation on the file at drive path |src_file_path|
39 // with a target of |dest_file_path|. Invokes |callback| when finished with 42 // with a target of |dest_file_path|. Invokes |callback| when finished with
40 // the result of the operation. |callback| must not be null. 43 // the result of the operation. |callback| must not be null.
41 virtual void Move(const FilePath& src_file_path, 44 virtual void Move(const base::FilePath& src_file_path,
42 const FilePath& dest_file_path, 45 const base::FilePath& dest_file_path,
43 const FileOperationCallback& callback); 46 const FileOperationCallback& callback);
44 private: 47 private:
45 // Part of Move(). Called after GetEntryInfoPairByPaths() is 48 // Part of Move(). Called after GetEntryInfoPairByPaths() is
46 // complete. |callback| must not be null. 49 // complete. |callback| must not be null.
47 void MoveAfterGetEntryInfoPair( 50 void MoveAfterGetEntryInfoPair(
48 const FilePath& dest_file_path, 51 const base::FilePath& dest_file_path,
49 const FileOperationCallback& callback, 52 const FileOperationCallback& callback,
50 scoped_ptr<EntryInfoPairResult> result); 53 scoped_ptr<EntryInfoPairResult> result);
51 54
52 // A pass-through callback used for bridging from 55 // A pass-through callback used for bridging from
53 // FileMoveCallback to FileOperationCallback. 56 // FileMoveCallback to FileOperationCallback.
54 void OnFilePathUpdated(const FileOperationCallback& cllback, 57 void OnFilePathUpdated(const FileOperationCallback& cllback,
55 DriveFileError error, 58 DriveFileError error,
56 const FilePath& file_path); 59 const base::FilePath& file_path);
57 60
58 // Renames a file or directory at |file_path| to |new_name| in the same 61 // Renames a file or directory at |file_path| to |new_name| in the same
59 // directory. |callback| will receive the new file path if the operation is 62 // directory. |callback| will receive the new file path if the operation is
60 // successful. If the new name already exists in the same directory, the file 63 // successful. If the new name already exists in the same directory, the file
61 // name is uniquified by adding a parenthesized serial number like 64 // name is uniquified by adding a parenthesized serial number like
62 // "foo (2).txt" 65 // "foo (2).txt"
63 // 66 //
64 // Can be called from UI thread. |callback| is run on the calling thread. 67 // Can be called from UI thread. |callback| is run on the calling thread.
65 // |callback| must not be null. 68 // |callback| must not be null.
66 void Rename(const FilePath& file_path, 69 void Rename(const base::FilePath& file_path,
67 const FilePath::StringType& new_name, 70 const base::FilePath::StringType& new_name,
68 const FileMoveCallback& callback); 71 const FileMoveCallback& callback);
69 72
70 // Part of Rename(). Called after GetEntryInfoByPath() is complete. 73 // Part of Rename(). Called after GetEntryInfoByPath() is complete.
71 // |callback| must not be null. 74 // |callback| must not be null.
72 void RenameAfterGetEntryInfo(const FilePath& file_path, 75 void RenameAfterGetEntryInfo(const base::FilePath& file_path,
73 const FilePath::StringType& new_name, 76 const base::FilePath::StringType& new_name,
74 const FileMoveCallback& callback, 77 const FileMoveCallback& callback,
75 DriveFileError error, 78 DriveFileError error,
76 scoped_ptr<DriveEntryProto> entry_proto); 79 scoped_ptr<DriveEntryProto> entry_proto);
77 80
78 // Callback for handling resource rename attempt. Renames a file or 81 // Callback for handling resource rename attempt. Renames a file or
79 // directory at |file_path| on the client side. 82 // directory at |file_path| on the client side.
80 // |callback| must not be null. 83 // |callback| must not be null.
81 void RenameEntryLocally(const FilePath& file_path, 84 void RenameEntryLocally(const base::FilePath& file_path,
82 const FilePath::StringType& new_name, 85 const base::FilePath::StringType& new_name,
83 const FileMoveCallback& callback, 86 const FileMoveCallback& callback,
84 google_apis::GDataErrorCode status); 87 google_apis::GDataErrorCode status);
85 88
86 // Removes a file or directory at |file_path| from the current directory. 89 // Removes a file or directory at |file_path| from the current directory.
87 // It moves the entry to a dangle, no-parent state on the server side. 90 // It moves the entry to a dangle, no-parent state on the server side.
88 // 91 //
89 // Can be called from UI thread. |callback| is run on the calling thread. 92 // Can be called from UI thread. |callback| is run on the calling thread.
90 // |callback| must not be null. 93 // |callback| must not be null.
91 void RemoveEntryFromDirectory(const FileMoveCallback& callback, 94 void RemoveEntryFromDirectory(const FileMoveCallback& callback,
92 DriveFileError error, 95 DriveFileError error,
93 const FilePath& file_path); 96 const base::FilePath& file_path);
94 97
95 // Part of RemoveEntryFromDirectory(). Called after 98 // Part of RemoveEntryFromDirectory(). Called after
96 // GetEntryInfoPairByPaths() is complete. |callback| must not be null. 99 // GetEntryInfoPairByPaths() is complete. |callback| must not be null.
97 void RemoveEntryFromDirectoryAfterEntryInfoPair( 100 void RemoveEntryFromDirectoryAfterEntryInfoPair(
98 const FileMoveCallback& callback, 101 const FileMoveCallback& callback,
99 scoped_ptr<EntryInfoPairResult> result); 102 scoped_ptr<EntryInfoPairResult> result);
100 103
101 // Moves a file or directory at |file_path| to another directory at 104 // Moves a file or directory at |file_path| to another directory at
102 // |dir_path|. 105 // |dir_path|.
103 // 106 //
104 // Can be called from UI thread. |callback| is run on the calling thread. 107 // Can be called from UI thread. |callback| is run on the calling thread.
105 // |callback| must not be null. 108 // |callback| must not be null.
106 void AddEntryToDirectory(const FilePath& directory_path, 109 void AddEntryToDirectory(const base::FilePath& directory_path,
107 const FileOperationCallback& callback, 110 const FileOperationCallback& callback,
108 DriveFileError error, 111 DriveFileError error,
109 const FilePath& file_path); 112 const base::FilePath& file_path);
110 113
111 // Part of AddEntryToDirectory(). Called after 114 // Part of AddEntryToDirectory(). Called after
112 // GetEntryInfoPairByPaths() is complete. |callback| must not be null. 115 // GetEntryInfoPairByPaths() is complete. |callback| must not be null.
113 void AddEntryToDirectoryAfterGetEntryInfoPair( 116 void AddEntryToDirectoryAfterGetEntryInfoPair(
114 const FileOperationCallback& callback, 117 const FileOperationCallback& callback,
115 scoped_ptr<EntryInfoPairResult> result); 118 scoped_ptr<EntryInfoPairResult> result);
116 119
117 // Moves entry specified by |file_path| to the directory specified by 120 // Moves entry specified by |file_path| to the directory specified by
118 // |dir_path| and calls |callback| asynchronously. 121 // |dir_path| and calls |callback| asynchronously.
119 // |callback| must not be null. 122 // |callback| must not be null.
120 void MoveEntryToDirectory(const FilePath& file_path, 123 void MoveEntryToDirectory(const base::FilePath& file_path,
121 const FilePath& directory_path, 124 const base::FilePath& directory_path,
122 const FileMoveCallback& callback, 125 const FileMoveCallback& callback,
123 google_apis::GDataErrorCode status); 126 google_apis::GDataErrorCode status);
124 127
125 // Callback when an entry is moved to another directory on the client side. 128 // Callback when an entry is moved to another directory on the client side.
126 // Notifies the directory change and runs |callback|. 129 // Notifies the directory change and runs |callback|.
127 // |callback| must not be null. 130 // |callback| must not be null.
128 void NotifyAndRunFileOperationCallback( 131 void NotifyAndRunFileOperationCallback(
129 const FileOperationCallback& callback, 132 const FileOperationCallback& callback,
130 DriveFileError error, 133 DriveFileError error,
131 const FilePath& moved_file_path); 134 const base::FilePath& moved_file_path);
132 135
133 // Callback when an entry is moved to another directory on the client side. 136 // Callback when an entry is moved to another directory on the client side.
134 // Notifies the directory change and runs |callback|. 137 // Notifies the directory change and runs |callback|.
135 // |callback| must not be null. 138 // |callback| must not be null.
136 void NotifyAndRunFileMoveCallback( 139 void NotifyAndRunFileMoveCallback(
137 const FileMoveCallback& callback, 140 const FileMoveCallback& callback,
138 DriveFileError error, 141 DriveFileError error,
139 const FilePath& moved_file_path); 142 const base::FilePath& moved_file_path);
140 143
141 DriveScheduler* drive_scheduler_; 144 DriveScheduler* drive_scheduler_;
142 DriveResourceMetadata* metadata_; 145 DriveResourceMetadata* metadata_;
143 OperationObserver* observer_; 146 OperationObserver* observer_;
144 147
145 // WeakPtrFactory bound to the UI thread. 148 // WeakPtrFactory bound to the UI thread.
146 // Note: This should remain the last member so it'll be destroyed and 149 // Note: This should remain the last member so it'll be destroyed and
147 // invalidate the weak pointers before any other members are destroyed. 150 // invalidate the weak pointers before any other members are destroyed.
148 base::WeakPtrFactory<MoveOperation> weak_ptr_factory_; 151 base::WeakPtrFactory<MoveOperation> weak_ptr_factory_;
149 152
150 DISALLOW_COPY_AND_ASSIGN(MoveOperation); 153 DISALLOW_COPY_AND_ASSIGN(MoveOperation);
151 }; 154 };
152 155
153 } // namespace file_system 156 } // namespace file_system
154 } // namespace drive 157 } // namespace drive
155 158
156 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_MOVE_OPERATION_H_ 159 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_MOVE_OPERATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698