| 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_GDATA_GDATA_FILE_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
| 17 #include "base/timer.h" | 17 #include "base/timer.h" |
| 18 #include "chrome/browser/api/prefs/pref_change_registrar.h" | 18 #include "chrome/browser/api/prefs/pref_change_registrar.h" |
| 19 #include "chrome/browser/chromeos/gdata/drive_cache.h" | 19 #include "chrome/browser/chromeos/gdata/drive_cache.h" |
| 20 #include "chrome/browser/chromeos/gdata/drive_errorcode.h" |
| 20 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" | 21 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" |
| 21 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | |
| 22 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" | 22 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" |
| 23 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h" | 23 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h" |
| 24 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h" | 24 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h" |
| 25 #include "content/public/browser/notification_observer.h" | 25 #include "content/public/browser/notification_observer.h" |
| 26 | 26 |
| 27 namespace base { | 27 namespace base { |
| 28 class SequencedTaskRunner; | 28 class SequencedTaskRunner; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace gdata { | 31 namespace gdata { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // Used to propagate events from GDataWapiFeedLoader. | 136 // Used to propagate events from GDataWapiFeedLoader. |
| 137 virtual void OnDirectoryChanged(const FilePath& directory_path) OVERRIDE; | 137 virtual void OnDirectoryChanged(const FilePath& directory_path) OVERRIDE; |
| 138 virtual void OnDocumentFeedFetched(int num_accumulated_entries) OVERRIDE; | 138 virtual void OnDocumentFeedFetched(int num_accumulated_entries) OVERRIDE; |
| 139 virtual void OnFeedFromServerLoaded() OVERRIDE; | 139 virtual void OnFeedFromServerLoaded() OVERRIDE; |
| 140 | 140 |
| 141 // Used in tests to load the root feed from the cache. | 141 // Used in tests to load the root feed from the cache. |
| 142 void LoadRootFeedFromCacheForTesting(); | 142 void LoadRootFeedFromCacheForTesting(); |
| 143 | 143 |
| 144 // Used in tests to update the file system from |feed_list|. | 144 // Used in tests to update the file system from |feed_list|. |
| 145 // See also the comment at GDataWapiFeedLoader::UpdateFromFeed(). | 145 // See also the comment at GDataWapiFeedLoader::UpdateFromFeed(). |
| 146 GDataFileError UpdateFromFeedForTesting( | 146 DriveFileError UpdateFromFeedForTesting( |
| 147 const std::vector<DocumentFeed*>& feed_list, | 147 const std::vector<DocumentFeed*>& feed_list, |
| 148 int64 start_changestamp, | 148 int64 start_changestamp, |
| 149 int64 root_feed_changestamp); | 149 int64 root_feed_changestamp); |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 friend class GDataFileSystemTest; | 152 friend class GDataFileSystemTest; |
| 153 FRIEND_TEST_ALL_PREFIXES(GDataFileSystemTest, | 153 FRIEND_TEST_ALL_PREFIXES(GDataFileSystemTest, |
| 154 FindFirstMissingParentDirectory); | 154 FindFirstMissingParentDirectory); |
| 155 | 155 |
| 156 // Defines possible search results of FindFirstMissingParentDirectory(). | 156 // Defines possible search results of FindFirstMissingParentDirectory(). |
| (...skipping 24 matching lines...) Expand all Loading... |
| 181 // Struct used for AddUploadedFile. | 181 // Struct used for AddUploadedFile. |
| 182 struct AddUploadedFileParams; | 182 struct AddUploadedFileParams; |
| 183 | 183 |
| 184 // Callback passed to |LoadFeedFromServer| from |Search| method. | 184 // Callback passed to |LoadFeedFromServer| from |Search| method. |
| 185 // |callback| is that should be run with data received from | 185 // |callback| is that should be run with data received from |
| 186 // |LoadFeedFromServer|. | 186 // |LoadFeedFromServer|. |
| 187 // |params| params used for getting document feed for content search. | 187 // |params| params used for getting document feed for content search. |
| 188 // |error| error code returned by |LoadFeedFromServer|. | 188 // |error| error code returned by |LoadFeedFromServer|. |
| 189 void OnSearch(const SearchCallback& callback, | 189 void OnSearch(const SearchCallback& callback, |
| 190 GetDocumentsParams* params, | 190 GetDocumentsParams* params, |
| 191 GDataFileError error); | 191 DriveFileError error); |
| 192 | 192 |
| 193 // Part of TransferFileFromLocalToRemote(). Called after | 193 // Part of TransferFileFromLocalToRemote(). Called after |
| 194 // GetEntryInfoByPath() is complete. | 194 // GetEntryInfoByPath() is complete. |
| 195 void TransferFileFromLocalToRemoteAfterGetEntryInfo( | 195 void TransferFileFromLocalToRemoteAfterGetEntryInfo( |
| 196 const FilePath& local_src_file_path, | 196 const FilePath& local_src_file_path, |
| 197 const FilePath& remote_dest_file_path, | 197 const FilePath& remote_dest_file_path, |
| 198 const FileOperationCallback& callback, | 198 const FileOperationCallback& callback, |
| 199 GDataFileError error, | 199 DriveFileError error, |
| 200 scoped_ptr<DriveEntryProto> entry_proto); | 200 scoped_ptr<DriveEntryProto> entry_proto); |
| 201 | 201 |
| 202 // Initiates transfer of |local_file_path| with |resource_id| to | 202 // Initiates transfer of |local_file_path| with |resource_id| to |
| 203 // |remote_dest_file_path|. |local_file_path| must be a file from the local | 203 // |remote_dest_file_path|. |local_file_path| must be a file from the local |
| 204 // file system, |remote_dest_file_path| is the virtual destination path within | 204 // file system, |remote_dest_file_path| is the virtual destination path within |
| 205 // gdata file system. If |resource_id| is a non-empty string, the transfer is | 205 // gdata file system. If |resource_id| is a non-empty string, the transfer is |
| 206 // handled by CopyDocumentToDirectory. Otherwise, the transfer is handled by | 206 // handled by CopyDocumentToDirectory. Otherwise, the transfer is handled by |
| 207 // TransferRegularFile. | 207 // TransferRegularFile. |
| 208 // | 208 // |
| 209 // Must be called from *UI* thread. |callback| is run on the calling thread. | 209 // Must be called from *UI* thread. |callback| is run on the calling thread. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 226 // Invoked during the process of CreateFile. | 226 // Invoked during the process of CreateFile. |
| 227 // First, FindEntryByPathAsyncOnUIThread is called and the result is returned | 227 // First, FindEntryByPathAsyncOnUIThread is called and the result is returned |
| 228 // to OnGetEntryInfoForCreateFile. By using the information, CreateFile deals | 228 // to OnGetEntryInfoForCreateFile. By using the information, CreateFile deals |
| 229 // with the cases when an entry already existed at the path. If there was no | 229 // with the cases when an entry already existed at the path. If there was no |
| 230 // entry, a new empty file is uploaded, and when it finishes | 230 // entry, a new empty file is uploaded, and when it finishes |
| 231 // DidUploadForCreateBrandNewFile does the final clean up. | 231 // DidUploadForCreateBrandNewFile does the final clean up. |
| 232 // |callback| must not be null. | 232 // |callback| must not be null. |
| 233 void OnGetEntryInfoForCreateFile(const FilePath& file_path, | 233 void OnGetEntryInfoForCreateFile(const FilePath& file_path, |
| 234 bool is_exclusive, | 234 bool is_exclusive, |
| 235 const FileOperationCallback& callback, | 235 const FileOperationCallback& callback, |
| 236 GDataFileError result, | 236 DriveFileError result, |
| 237 scoped_ptr<DriveEntryProto> entry_proto); | 237 scoped_ptr<DriveEntryProto> entry_proto); |
| 238 void DoUploadForCreateBrandNewFile(const FilePath& remote_path, | 238 void DoUploadForCreateBrandNewFile(const FilePath& remote_path, |
| 239 FilePath* local_path, | 239 FilePath* local_path, |
| 240 const FileOperationCallback& callback); | 240 const FileOperationCallback& callback); |
| 241 void DidUploadForCreateBrandNewFile(const FilePath& local_path, | 241 void DidUploadForCreateBrandNewFile(const FilePath& local_path, |
| 242 const FileOperationCallback& callback, | 242 const FileOperationCallback& callback, |
| 243 GDataFileError result); | 243 DriveFileError result); |
| 244 | 244 |
| 245 // Invoked upon completion of GetEntryInfoByPath initiated by | 245 // Invoked upon completion of GetEntryInfoByPath initiated by |
| 246 // GetFileByPath. It then continues to invoke GetResolvedFileByPath. | 246 // GetFileByPath. It then continues to invoke GetResolvedFileByPath. |
| 247 void OnGetEntryInfoCompleteForGetFileByPath( | 247 void OnGetEntryInfoCompleteForGetFileByPath( |
| 248 const FilePath& file_path, | 248 const FilePath& file_path, |
| 249 const GetFileCallback& get_file_callback, | 249 const GetFileCallback& get_file_callback, |
| 250 const GetContentCallback& get_content_callback, | 250 const GetContentCallback& get_content_callback, |
| 251 GDataFileError error, | 251 DriveFileError error, |
| 252 scoped_ptr<DriveEntryProto> file_info); | 252 scoped_ptr<DriveEntryProto> file_info); |
| 253 | 253 |
| 254 // Invoked upon completion of GetEntryInfoByPath initiated by OpenFile. | 254 // Invoked upon completion of GetEntryInfoByPath initiated by OpenFile. |
| 255 // It then continues to invoke GetResolvedFileByPath and proceeds to | 255 // It then continues to invoke GetResolvedFileByPath and proceeds to |
| 256 // OnGetFileCompleteForOpenFile. | 256 // OnGetFileCompleteForOpenFile. |
| 257 void OnGetEntryInfoCompleteForOpenFile( | 257 void OnGetEntryInfoCompleteForOpenFile( |
| 258 const FilePath& file_path, | 258 const FilePath& file_path, |
| 259 const OpenFileCallback& callback, | 259 const OpenFileCallback& callback, |
| 260 GDataFileError error, | 260 DriveFileError error, |
| 261 scoped_ptr<DriveEntryProto> file_info); | 261 scoped_ptr<DriveEntryProto> file_info); |
| 262 | 262 |
| 263 // Invoked at the last step of OpenFile. It removes |file_path| from the | 263 // Invoked at the last step of OpenFile. It removes |file_path| from the |
| 264 // current set of opened files if |result| is an error, and then invokes the | 264 // current set of opened files if |result| is an error, and then invokes the |
| 265 // |callback| function. | 265 // |callback| function. |
| 266 void OnOpenFileFinished(const FilePath& file_path, | 266 void OnOpenFileFinished(const FilePath& file_path, |
| 267 const OpenFileCallback& callback, | 267 const OpenFileCallback& callback, |
| 268 GDataFileError result, | 268 DriveFileError result, |
| 269 const FilePath& cache_file_path); | 269 const FilePath& cache_file_path); |
| 270 | 270 |
| 271 // Invoked during the process of CloseFile. What is done here is as follows: | 271 // Invoked during the process of CloseFile. What is done here is as follows: |
| 272 // 1) Gets resource_id and md5 of the entry at |file_path|. | 272 // 1) Gets resource_id and md5 of the entry at |file_path|. |
| 273 // 2) Commits the modification to the cache system. | 273 // 2) Commits the modification to the cache system. |
| 274 // 3) Removes the |file_path| from the remembered set of opened files. | 274 // 3) Removes the |file_path| from the remembered set of opened files. |
| 275 // 4) Invokes the user-supplied |callback|. | 275 // 4) Invokes the user-supplied |callback|. |
| 276 // |callback| must not be null. | 276 // |callback| must not be null. |
| 277 void CloseFileOnUIThreadAfterGetEntryInfo( | 277 void CloseFileOnUIThreadAfterGetEntryInfo( |
| 278 const FilePath& file_path, | 278 const FilePath& file_path, |
| 279 const FileOperationCallback& callback, | 279 const FileOperationCallback& callback, |
| 280 GDataFileError error, | 280 DriveFileError error, |
| 281 scoped_ptr<DriveEntryProto> entry_proto); | 281 scoped_ptr<DriveEntryProto> entry_proto); |
| 282 void CloseFileOnUIThreadAfterCommitDirtyInCache( | 282 void CloseFileOnUIThreadAfterCommitDirtyInCache( |
| 283 const FileOperationCallback& callback, | 283 const FileOperationCallback& callback, |
| 284 GDataFileError error, | 284 DriveFileError error, |
| 285 const std::string& resource_id, | 285 const std::string& resource_id, |
| 286 const std::string& md5); | 286 const std::string& md5); |
| 287 void CloseFileOnUIThreadFinalize(const FilePath& file_path, | 287 void CloseFileOnUIThreadFinalize(const FilePath& file_path, |
| 288 const FileOperationCallback& callback, | 288 const FileOperationCallback& callback, |
| 289 GDataFileError result); | 289 DriveFileError result); |
| 290 | 290 |
| 291 // Invoked upon completion of GetFileByPath initiated by Copy. If | 291 // Invoked upon completion of GetFileByPath initiated by Copy. If |
| 292 // GetFileByPath reports no error, calls TransferRegularFile to transfer | 292 // GetFileByPath reports no error, calls TransferRegularFile to transfer |
| 293 // |local_file_path| to |remote_dest_file_path|. | 293 // |local_file_path| to |remote_dest_file_path|. |
| 294 // | 294 // |
| 295 // Can be called from UI thread. |callback| is run on the calling thread. | 295 // Can be called from UI thread. |callback| is run on the calling thread. |
| 296 void OnGetFileCompleteForCopy(const FilePath& remote_dest_file_path, | 296 void OnGetFileCompleteForCopy(const FilePath& remote_dest_file_path, |
| 297 const FileOperationCallback& callback, | 297 const FileOperationCallback& callback, |
| 298 GDataFileError error, | 298 DriveFileError error, |
| 299 const FilePath& local_file_path, | 299 const FilePath& local_file_path, |
| 300 const std::string& unused_mime_type, | 300 const std::string& unused_mime_type, |
| 301 DriveFileType file_type); | 301 DriveFileType file_type); |
| 302 | 302 |
| 303 // Invoked upon completion of GetFileByPath initiated by | 303 // Invoked upon completion of GetFileByPath initiated by |
| 304 // TransferFileFromRemoteToLocal. If GetFileByPath reports no error, calls | 304 // TransferFileFromRemoteToLocal. If GetFileByPath reports no error, calls |
| 305 // CopyLocalFileOnBlockingPool to copy |local_file_path| to | 305 // CopyLocalFileOnBlockingPool to copy |local_file_path| to |
| 306 // |local_dest_file_path|. | 306 // |local_dest_file_path|. |
| 307 // | 307 // |
| 308 // Can be called from UI thread. |callback| is run on the calling thread. | 308 // Can be called from UI thread. |callback| is run on the calling thread. |
| 309 // |callback| must not be null. | 309 // |callback| must not be null. |
| 310 void OnGetFileCompleteForTransferFile(const FilePath& local_dest_file_path, | 310 void OnGetFileCompleteForTransferFile(const FilePath& local_dest_file_path, |
| 311 const FileOperationCallback& callback, | 311 const FileOperationCallback& callback, |
| 312 GDataFileError error, | 312 DriveFileError error, |
| 313 const FilePath& local_file_path, | 313 const FilePath& local_file_path, |
| 314 const std::string& unused_mime_type, | 314 const std::string& unused_mime_type, |
| 315 DriveFileType file_type); | 315 DriveFileType file_type); |
| 316 | 316 |
| 317 // Invoked upon completion of GetFileByPath initiated by OpenFile. If | 317 // Invoked upon completion of GetFileByPath initiated by OpenFile. If |
| 318 // GetFileByPath is successful, calls MarkDirtyInCache to mark the cache | 318 // GetFileByPath is successful, calls MarkDirtyInCache to mark the cache |
| 319 // file as dirty for the file identified by |file_info.resource_id| and | 319 // file as dirty for the file identified by |file_info.resource_id| and |
| 320 // |file_info.md5|. | 320 // |file_info.md5|. |
| 321 // | 321 // |
| 322 // Can be called from UI thread. |callback| is run on the calling thread. | 322 // Can be called from UI thread. |callback| is run on the calling thread. |
| 323 void OnGetFileCompleteForOpenFile( | 323 void OnGetFileCompleteForOpenFile( |
| 324 const OpenFileCallback& callback, | 324 const OpenFileCallback& callback, |
| 325 const GetFileCompleteForOpenParams& file_info, | 325 const GetFileCompleteForOpenParams& file_info, |
| 326 GDataFileError error, | 326 DriveFileError error, |
| 327 const FilePath& file_path, | 327 const FilePath& file_path, |
| 328 const std::string& mime_type, | 328 const std::string& mime_type, |
| 329 DriveFileType file_type); | 329 DriveFileType file_type); |
| 330 | 330 |
| 331 // Copies a document with |resource_id| to the directory at |dir_path| | 331 // Copies a document with |resource_id| to the directory at |dir_path| |
| 332 // and names the copied document as |new_name|. | 332 // and names the copied document as |new_name|. |
| 333 // | 333 // |
| 334 // Can be called from UI thread. |callback| is run on the calling thread. | 334 // Can be called from UI thread. |callback| is run on the calling thread. |
| 335 // |callback| must not be null. | 335 // |callback| must not be null. |
| 336 void CopyDocumentToDirectory(const FilePath& dir_path, | 336 void CopyDocumentToDirectory(const FilePath& dir_path, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 347 // Can be called from UI thread. |callback| is run on the calling thread. | 347 // Can be called from UI thread. |callback| is run on the calling thread. |
| 348 // |callback| must not be null. | 348 // |callback| must not be null. |
| 349 void Rename(const FilePath& file_path, | 349 void Rename(const FilePath& file_path, |
| 350 const FilePath::StringType& new_name, | 350 const FilePath::StringType& new_name, |
| 351 const FileMoveCallback& callback); | 351 const FileMoveCallback& callback); |
| 352 | 352 |
| 353 // Part of Rename(). Called after GetEntryInfoByPath() is complete. | 353 // Part of Rename(). Called after GetEntryInfoByPath() is complete. |
| 354 void RenameAfterGetEntryInfo(const FilePath& file_path, | 354 void RenameAfterGetEntryInfo(const FilePath& file_path, |
| 355 const FilePath::StringType& new_name, | 355 const FilePath::StringType& new_name, |
| 356 const FileMoveCallback& callback, | 356 const FileMoveCallback& callback, |
| 357 GDataFileError error, | 357 DriveFileError error, |
| 358 scoped_ptr<DriveEntryProto> entry_proto); | 358 scoped_ptr<DriveEntryProto> entry_proto); |
| 359 | 359 |
| 360 // Moves a file or directory at |file_path| in the root directory to | 360 // Moves a file or directory at |file_path| in the root directory to |
| 361 // another directory at |dir_path|. This function does nothing if | 361 // another directory at |dir_path|. This function does nothing if |
| 362 // |dir_path| points to the root directory. | 362 // |dir_path| points to the root directory. |
| 363 // | 363 // |
| 364 // Can be called from UI thread. |callback| is run on the calling thread. | 364 // Can be called from UI thread. |callback| is run on the calling thread. |
| 365 // |callback| must not be null. | 365 // |callback| must not be null. |
| 366 void MoveEntryFromRootDirectory(const FilePath& dir_path, | 366 void MoveEntryFromRootDirectory(const FilePath& dir_path, |
| 367 const FileOperationCallback& callback, | 367 const FileOperationCallback& callback, |
| 368 GDataFileError error, | 368 DriveFileError error, |
| 369 const FilePath& file_path); | 369 const FilePath& file_path); |
| 370 | 370 |
| 371 // Part of MoveEntryFromRootDirectory(). Called after | 371 // Part of MoveEntryFromRootDirectory(). Called after |
| 372 // GetEntryInfoPairByPaths() is complete. |callback| must not be null. | 372 // GetEntryInfoPairByPaths() is complete. |callback| must not be null. |
| 373 void MoveEntryFromRootDirectoryAfterGetEntryInfoPair( | 373 void MoveEntryFromRootDirectoryAfterGetEntryInfoPair( |
| 374 const FileOperationCallback& callback, | 374 const FileOperationCallback& callback, |
| 375 scoped_ptr<EntryInfoPairResult> result); | 375 scoped_ptr<EntryInfoPairResult> result); |
| 376 | 376 |
| 377 // Part of RemoveEntryFromNonRootDirectory(). Called after | 377 // Part of RemoveEntryFromNonRootDirectory(). Called after |
| 378 // GetEntryInfoPairByPaths() is complete. |callback| must not be null. | 378 // GetEntryInfoPairByPaths() is complete. |callback| must not be null. |
| 379 void RemoveEntryFromNonRootDirectoryAfterEntryInfoPair( | 379 void RemoveEntryFromNonRootDirectoryAfterEntryInfoPair( |
| 380 const FileMoveCallback& callback, | 380 const FileMoveCallback& callback, |
| 381 scoped_ptr<EntryInfoPairResult> result); | 381 scoped_ptr<EntryInfoPairResult> result); |
| 382 | 382 |
| 383 // Removes a file or directory at |file_path| from the current directory if | 383 // Removes a file or directory at |file_path| from the current directory if |
| 384 // it's not in the root directory. This essentially moves an entry to the | 384 // it's not in the root directory. This essentially moves an entry to the |
| 385 // root directory on the server side. | 385 // root directory on the server side. |
| 386 // | 386 // |
| 387 // Can be called from UI thread. |callback| is run on the calling thread. | 387 // Can be called from UI thread. |callback| is run on the calling thread. |
| 388 // |callback| must not be null. | 388 // |callback| must not be null. |
| 389 void RemoveEntryFromNonRootDirectory(const FileMoveCallback& callback, | 389 void RemoveEntryFromNonRootDirectory(const FileMoveCallback& callback, |
| 390 GDataFileError error, | 390 DriveFileError error, |
| 391 const FilePath& file_path); | 391 const FilePath& file_path); |
| 392 | 392 |
| 393 // Removes file under |file_path| on the client side. | 393 // Removes file under |file_path| on the client side. |
| 394 // |resource_id| contains the resource id of the removed file if it was a | 394 // |resource_id| contains the resource id of the removed file if it was a |
| 395 // file. | 395 // file. |
| 396 // Return PLATFORM_FILE_OK if successful. | 396 // Return PLATFORM_FILE_OK if successful. |
| 397 GDataFileError RemoveEntryLocally(const FilePath& file_path, | 397 DriveFileError RemoveEntryLocally(const FilePath& file_path, |
| 398 std::string* resource_id); | 398 std::string* resource_id); |
| 399 | 399 |
| 400 // A pass-through callback used for bridging from | 400 // A pass-through callback used for bridging from |
| 401 // FileMoveCallback to FileOperationCallback. | 401 // FileMoveCallback to FileOperationCallback. |
| 402 void OnFilePathUpdated(const FileOperationCallback& cllback, | 402 void OnFilePathUpdated(const FileOperationCallback& cllback, |
| 403 GDataFileError error, | 403 DriveFileError error, |
| 404 const FilePath& file_path); | 404 const FilePath& file_path); |
| 405 | 405 |
| 406 // Invoked upon completion of MarkDirtyInCache initiated by OpenFile. Invokes | 406 // Invoked upon completion of MarkDirtyInCache initiated by OpenFile. Invokes |
| 407 // |callback| with |cache_file_path|, which is the path of the cache file | 407 // |callback| with |cache_file_path|, which is the path of the cache file |
| 408 // ready for modification. | 408 // ready for modification. |
| 409 // | 409 // |
| 410 // Must be called on UI thread. | 410 // Must be called on UI thread. |
| 411 void OnMarkDirtyInCacheCompleteForOpenFile(const OpenFileCallback& callback, | 411 void OnMarkDirtyInCacheCompleteForOpenFile(const OpenFileCallback& callback, |
| 412 GDataFileError error, | 412 DriveFileError error, |
| 413 const std::string& resource_id, | 413 const std::string& resource_id, |
| 414 const std::string& md5, | 414 const std::string& md5, |
| 415 const FilePath& cache_file_path); | 415 const FilePath& cache_file_path); |
| 416 | 416 |
| 417 // Callback for handling document copy attempt. | 417 // Callback for handling document copy attempt. |
| 418 // |callback| must not be null. | 418 // |callback| must not be null. |
| 419 void OnCopyDocumentCompleted(const FilePath& dir_path, | 419 void OnCopyDocumentCompleted(const FilePath& dir_path, |
| 420 const FileOperationCallback& callback, | 420 const FileOperationCallback& callback, |
| 421 GDataErrorCode status, | 421 DriveErrorCode status, |
| 422 scoped_ptr<base::Value> data); | 422 scoped_ptr<base::Value> data); |
| 423 | 423 |
| 424 // Callback for handling an attempt to move a file or directory from the | 424 // Callback for handling an attempt to move a file or directory from the |
| 425 // root directory to another directory on the server side. This function | 425 // root directory to another directory on the server side. This function |
| 426 // moves |entry| to the root directory on the client side with | 426 // moves |entry| to the root directory on the client side with |
| 427 // DriveResourceMetadata::MoveEntryToDirectory(). | 427 // DriveResourceMetadata::MoveEntryToDirectory(). |
| 428 // | 428 // |
| 429 // |callback| must not be null. | 429 // |callback| must not be null. |
| 430 void OnMoveEntryFromRootDirectoryCompleted( | 430 void OnMoveEntryFromRootDirectoryCompleted( |
| 431 const FileOperationCallback& callback, | 431 const FileOperationCallback& callback, |
| 432 const FilePath& file_path, | 432 const FilePath& file_path, |
| 433 const FilePath& dir_path, | 433 const FilePath& dir_path, |
| 434 GDataErrorCode status, | 434 DriveErrorCode status, |
| 435 const GURL& document_url); | 435 const GURL& document_url); |
| 436 | 436 |
| 437 // Callback for handling account metadata fetch. | 437 // Callback for handling account metadata fetch. |
| 438 void OnGetAvailableSpace(const GetAvailableSpaceCallback& callback, | 438 void OnGetAvailableSpace(const GetAvailableSpaceCallback& callback, |
| 439 GDataErrorCode status, | 439 DriveErrorCode status, |
| 440 scoped_ptr<base::Value> data); | 440 scoped_ptr<base::Value> data); |
| 441 | 441 |
| 442 // Callback for handling Drive V2 about resource fetch. | 442 // Callback for handling Drive V2 about resource fetch. |
| 443 void OnGetAboutResource(const GetAvailableSpaceCallback& callback, | 443 void OnGetAboutResource(const GetAvailableSpaceCallback& callback, |
| 444 GDataErrorCode status, | 444 DriveErrorCode status, |
| 445 scoped_ptr<base::Value> data); | 445 scoped_ptr<base::Value> data); |
| 446 | 446 |
| 447 // Callback for handling document remove attempt. | 447 // Callback for handling document remove attempt. |
| 448 void OnRemovedDocument(const FileOperationCallback& callback, | 448 void OnRemovedDocument(const FileOperationCallback& callback, |
| 449 const FilePath& file_path, | 449 const FilePath& file_path, |
| 450 GDataErrorCode status, | 450 DriveErrorCode status, |
| 451 const GURL& document_url); | 451 const GURL& document_url); |
| 452 | 452 |
| 453 // Callback for handling directory create requests. | 453 // Callback for handling directory create requests. |
| 454 void OnCreateDirectoryCompleted(const CreateDirectoryParams& params, | 454 void OnCreateDirectoryCompleted(const CreateDirectoryParams& params, |
| 455 GDataErrorCode status, | 455 DriveErrorCode status, |
| 456 scoped_ptr<base::Value> created_entry); | 456 scoped_ptr<base::Value> created_entry); |
| 457 | 457 |
| 458 // Callback for handling file downloading requests. | 458 // Callback for handling file downloading requests. |
| 459 void OnFileDownloaded(const GetFileFromCacheParams& params, | 459 void OnFileDownloaded(const GetFileFromCacheParams& params, |
| 460 GDataErrorCode status, | 460 DriveErrorCode status, |
| 461 const GURL& content_url, | 461 const GURL& content_url, |
| 462 const FilePath& downloaded_file_path); | 462 const FilePath& downloaded_file_path); |
| 463 | 463 |
| 464 // Unpins file if cache entry is pinned. | 464 // Unpins file if cache entry is pinned. |
| 465 void UnpinIfPinned(const std::string& resource_id, | 465 void UnpinIfPinned(const std::string& resource_id, |
| 466 const std::string& md5, | 466 const std::string& md5, |
| 467 bool success, | 467 bool success, |
| 468 const DriveCacheEntry& cache_entry); | 468 const DriveCacheEntry& cache_entry); |
| 469 | 469 |
| 470 // Similar to OnFileDownloaded() but takes |has_enough_space| so we report | 470 // Similar to OnFileDownloaded() but takes |has_enough_space| so we report |
| 471 // an error in case we don't have enough disk space. | 471 // an error in case we don't have enough disk space. |
| 472 void OnFileDownloadedAndSpaceChecked(const GetFileFromCacheParams& params, | 472 void OnFileDownloadedAndSpaceChecked(const GetFileFromCacheParams& params, |
| 473 GDataErrorCode status, | 473 DriveErrorCode status, |
| 474 const GURL& content_url, | 474 const GURL& content_url, |
| 475 const FilePath& downloaded_file_path, | 475 const FilePath& downloaded_file_path, |
| 476 bool* has_enough_space); | 476 bool* has_enough_space); |
| 477 | 477 |
| 478 // Callback for handling internal StoreToCache() calls after downloading | 478 // Callback for handling internal StoreToCache() calls after downloading |
| 479 // file content. | 479 // file content. |
| 480 void OnDownloadStoredToCache(GDataFileError error, | 480 void OnDownloadStoredToCache(DriveFileError error, |
| 481 const std::string& resource_id, | 481 const std::string& resource_id, |
| 482 const std::string& md5); | 482 const std::string& md5); |
| 483 | 483 |
| 484 // Callback for handling resource rename attempt. Renames a file or | 484 // Callback for handling resource rename attempt. Renames a file or |
| 485 // directory at |file_path| on the client side. | 485 // directory at |file_path| on the client side. |
| 486 // |callback| must not be null. | 486 // |callback| must not be null. |
| 487 void RenameEntryLocally(const FilePath& file_path, | 487 void RenameEntryLocally(const FilePath& file_path, |
| 488 const FilePath::StringType& new_name, | 488 const FilePath::StringType& new_name, |
| 489 const FileMoveCallback& callback, | 489 const FileMoveCallback& callback, |
| 490 GDataErrorCode status, | 490 DriveErrorCode status, |
| 491 const GURL& document_url); | 491 const GURL& document_url); |
| 492 | 492 |
| 493 // Callback for handling an attempt to remove a file or directory from | 493 // Callback for handling an attempt to remove a file or directory from |
| 494 // another directory. Moves a file or directory at |file_path| to root on | 494 // another directory. Moves a file or directory at |file_path| to root on |
| 495 // the client side. | 495 // the client side. |
| 496 // |callback| must not be null. | 496 // |callback| must not be null. |
| 497 void MoveEntryToRootDirectoryLocally(const FileMoveCallback& callback, | 497 void MoveEntryToRootDirectoryLocally(const FileMoveCallback& callback, |
| 498 const FilePath& file_path, | 498 const FilePath& file_path, |
| 499 const FilePath& dir_path, | 499 const FilePath& dir_path, |
| 500 GDataErrorCode status, | 500 DriveErrorCode status, |
| 501 const GURL& document_url); | 501 const GURL& document_url); |
| 502 | 502 |
| 503 // Removes a file or directory under |file_path| on the client side and the | 503 // Removes a file or directory under |file_path| on the client side and the |
| 504 // corresponding file from cache if it exists. Returns PLATFORM_FILE_OK if | 504 // corresponding file from cache if it exists. Returns PLATFORM_FILE_OK if |
| 505 // successful. | 505 // successful. |
| 506 GDataFileError RemoveEntryAndCacheLocally(const FilePath& file_path); | 506 DriveFileError RemoveEntryAndCacheLocally(const FilePath& file_path); |
| 507 | 507 |
| 508 // Callback when an entry is moved to another directory on the client side. | 508 // Callback when an entry is moved to another directory on the client side. |
| 509 // Notifies the directory change and runs |callback|. | 509 // Notifies the directory change and runs |callback|. |
| 510 // |callback| may be null. | 510 // |callback| may be null. |
| 511 void NotifyAndRunFileMoveCallback( | 511 void NotifyAndRunFileMoveCallback( |
| 512 const FileMoveCallback& callback, | 512 const FileMoveCallback& callback, |
| 513 GDataFileError error, | 513 DriveFileError error, |
| 514 const FilePath& moved_file_path); | 514 const FilePath& moved_file_path); |
| 515 | 515 |
| 516 // Callback when an entry is moved to another directory on the client side. | 516 // Callback when an entry is moved to another directory on the client side. |
| 517 // Notifies the directory change and runs |callback|. | 517 // Notifies the directory change and runs |callback|. |
| 518 // |callback| must not be null. | 518 // |callback| must not be null. |
| 519 void NotifyAndRunFileOperationCallback( | 519 void NotifyAndRunFileOperationCallback( |
| 520 const FileOperationCallback& callback, | 520 const FileOperationCallback& callback, |
| 521 GDataFileError error, | 521 DriveFileError error, |
| 522 const FilePath& moved_file_path); | 522 const FilePath& moved_file_path); |
| 523 | 523 |
| 524 // FileMoveCallback for directory changes. | 524 // FileMoveCallback for directory changes. |
| 525 void OnDirectoryChangeFileMoveCallback( | 525 void OnDirectoryChangeFileMoveCallback( |
| 526 GDataFileError error, | 526 DriveFileError error, |
| 527 const FilePath& directory_path); | 527 const FilePath& directory_path); |
| 528 | 528 |
| 529 // Callback for GetEntryByResourceIdAsync. | 529 // Callback for GetEntryByResourceIdAsync. |
| 530 // Removes stale entry upon upload of file. | 530 // Removes stale entry upon upload of file. |
| 531 void RemoveStaleEntryOnUpload(const std::string& resource_id, | 531 void RemoveStaleEntryOnUpload(const std::string& resource_id, |
| 532 DriveDirectory* parent_dir, | 532 DriveDirectory* parent_dir, |
| 533 const FileMoveCallback& callback, | 533 const FileMoveCallback& callback, |
| 534 DriveEntry* existing_entry); | 534 DriveEntry* existing_entry); |
| 535 | 535 |
| 536 // Continues to add an uploaded file after existing entry has been deleted. | 536 // Continues to add an uploaded file after existing entry has been deleted. |
| 537 void ContinueAddUploadedFile(AddUploadedFileParams* params, | 537 void ContinueAddUploadedFile(AddUploadedFileParams* params, |
| 538 GDataFileError error, | 538 DriveFileError error, |
| 539 const FilePath& file_path); | 539 const FilePath& file_path); |
| 540 | 540 |
| 541 // Adds the uploaded file to the cache. | 541 // Adds the uploaded file to the cache. |
| 542 void AddUploadedFileToCache(AddUploadedFileParams* params, | 542 void AddUploadedFileToCache(AddUploadedFileParams* params, |
| 543 GDataFileError error, | 543 DriveFileError error, |
| 544 const FilePath& file_path); | 544 const FilePath& file_path); |
| 545 | 545 |
| 546 // Converts |entry_value| into GFileDocument instance and adds it | 546 // Converts |entry_value| into GFileDocument instance and adds it |
| 547 // to virtual file system at |directory_path|. | 547 // to virtual file system at |directory_path|. |
| 548 GDataFileError AddNewDirectory(const FilePath& directory_path, | 548 DriveFileError AddNewDirectory(const FilePath& directory_path, |
| 549 base::Value* entry_value); | 549 base::Value* entry_value); |
| 550 | 550 |
| 551 // Given non-existing |directory_path|, finds the first missing parent | 551 // Given non-existing |directory_path|, finds the first missing parent |
| 552 // directory of |directory_path|. | 552 // directory of |directory_path|. |
| 553 FindMissingDirectoryResult FindFirstMissingParentDirectory( | 553 FindMissingDirectoryResult FindFirstMissingParentDirectory( |
| 554 const FilePath& directory_path, | 554 const FilePath& directory_path, |
| 555 GURL* last_dir_content_url, | 555 GURL* last_dir_content_url, |
| 556 FilePath* first_missing_parent_path); | 556 FilePath* first_missing_parent_path); |
| 557 | 557 |
| 558 // Callback for handling results of ReloadFeedFromServerIfNeeded() initiated | 558 // Callback for handling results of ReloadFeedFromServerIfNeeded() initiated |
| 559 // from CheckForUpdates(). This callback checks whether feed is successfully | 559 // from CheckForUpdates(). This callback checks whether feed is successfully |
| 560 // reloaded, and in case of failure, restores the content origin of the root | 560 // reloaded, and in case of failure, restores the content origin of the root |
| 561 // directory. | 561 // directory. |
| 562 void OnUpdateChecked(ContentOrigin initial_origin, | 562 void OnUpdateChecked(ContentOrigin initial_origin, |
| 563 GDataFileError error); | 563 DriveFileError error); |
| 564 | 564 |
| 565 // Notifies that the initial load is finished and runs |callback|. | 565 // Notifies that the initial load is finished and runs |callback|. |
| 566 // |callback| must not be null. | 566 // |callback| must not be null. |
| 567 void NotifyInitialLoadFinishedAndRun(const FileOperationCallback& callback, | 567 void NotifyInitialLoadFinishedAndRun(const FileOperationCallback& callback, |
| 568 GDataFileError error); | 568 DriveFileError error); |
| 569 | 569 |
| 570 // Helper function that completes bookkeeping tasks related to | 570 // Helper function that completes bookkeeping tasks related to |
| 571 // completed file transfer. | 571 // completed file transfer. |
| 572 void OnTransferCompleted(const FileOperationCallback& callback, | 572 void OnTransferCompleted(const FileOperationCallback& callback, |
| 573 GDataFileError error, | 573 DriveFileError error, |
| 574 scoped_ptr<UploadFileInfo> upload_file_info); | 574 scoped_ptr<UploadFileInfo> upload_file_info); |
| 575 | 575 |
| 576 // Kicks off file upload once it receives |file_size| and |content_type|. | 576 // Kicks off file upload once it receives |file_size| and |content_type|. |
| 577 void StartFileUploadOnUIThread(const StartFileUploadParams& params, | 577 void StartFileUploadOnUIThread(const StartFileUploadParams& params, |
| 578 GDataFileError* error, | 578 DriveFileError* error, |
| 579 int64* file_size, | 579 int64* file_size, |
| 580 std::string* content_type); | 580 std::string* content_type); |
| 581 | 581 |
| 582 // Part of StartFileUploadOnUIThread(). Called after GetEntryInfoByPath() | 582 // Part of StartFileUploadOnUIThread(). Called after GetEntryInfoByPath() |
| 583 // is complete. | 583 // is complete. |
| 584 void StartFileUploadOnUIThreadAfterGetEntryInfo( | 584 void StartFileUploadOnUIThreadAfterGetEntryInfo( |
| 585 const StartFileUploadParams& params, | 585 const StartFileUploadParams& params, |
| 586 int64 file_size, | 586 int64 file_size, |
| 587 std::string content_type, | 587 std::string content_type, |
| 588 GDataFileError error, | 588 DriveFileError error, |
| 589 scoped_ptr<DriveEntryProto> entry_proto); | 589 scoped_ptr<DriveEntryProto> entry_proto); |
| 590 | 590 |
| 591 // Cache intermediate callbacks, that run on calling thread, for above cache | 591 // Cache intermediate callbacks, that run on calling thread, for above cache |
| 592 // tasks that were run on blocking pool. | 592 // tasks that were run on blocking pool. |
| 593 | 593 |
| 594 // Helper function for internally handling responses from | 594 // Helper function for internally handling responses from |
| 595 // GetFileFromCacheByResourceIdAndMd5() calls during processing of | 595 // GetFileFromCacheByResourceIdAndMd5() calls during processing of |
| 596 // GetFileByPath() request. | 596 // GetFileByPath() request. |
| 597 void OnGetFileFromCache(const GetFileFromCacheParams& params, | 597 void OnGetFileFromCache(const GetFileFromCacheParams& params, |
| 598 GDataFileError error, | 598 DriveFileError error, |
| 599 const std::string& resource_id, | 599 const std::string& resource_id, |
| 600 const std::string& md5, | 600 const std::string& md5, |
| 601 const FilePath& cache_file_path); | 601 const FilePath& cache_file_path); |
| 602 | 602 |
| 603 // Callback for |drive_service_->GetDocumentEntry|. | 603 // Callback for |drive_service_->GetDocumentEntry|. |
| 604 // It is called before file download. If GetDocumentEntry was successful, | 604 // It is called before file download. If GetDocumentEntry was successful, |
| 605 // file download procedure is started for the file. The file is downloaded | 605 // file download procedure is started for the file. The file is downloaded |
| 606 // from the content url extracted from the fetched metadata to | 606 // from the content url extracted from the fetched metadata to |
| 607 // |cache_file_path|. Also, available space checks are done using file size | 607 // |cache_file_path|. Also, available space checks are done using file size |
| 608 // from the fetched metadata. | 608 // from the fetched metadata. |
| 609 void OnGetDocumentEntry(const FilePath& cache_file_path, | 609 void OnGetDocumentEntry(const FilePath& cache_file_path, |
| 610 const GetFileFromCacheParams& params, | 610 const GetFileFromCacheParams& params, |
| 611 GDataErrorCode status, | 611 DriveErrorCode status, |
| 612 scoped_ptr<base::Value> data); | 612 scoped_ptr<base::Value> data); |
| 613 | 613 |
| 614 // Starts downloading a file if we have enough disk space indicated by | 614 // Starts downloading a file if we have enough disk space indicated by |
| 615 // |has_enough_space|. | 615 // |has_enough_space|. |
| 616 void StartDownloadFileIfEnoughSpace(const GetFileFromCacheParams& params, | 616 void StartDownloadFileIfEnoughSpace(const GetFileFromCacheParams& params, |
| 617 const GURL& content_url, | 617 const GURL& content_url, |
| 618 const FilePath& cache_file_path, | 618 const FilePath& cache_file_path, |
| 619 bool* has_enough_space); | 619 bool* has_enough_space); |
| 620 | 620 |
| 621 // Changes state of hosted documents visibility, triggers directory refresh. | 621 // Changes state of hosted documents visibility, triggers directory refresh. |
| 622 void SetHideHostedDocuments(bool hide); | 622 void SetHideHostedDocuments(bool hide); |
| 623 | 623 |
| 624 // Initializes preference change observer. | 624 // Initializes preference change observer. |
| 625 void InitializePreferenceObserver(); | 625 void InitializePreferenceObserver(); |
| 626 | 626 |
| 627 // Part of GetEntryInfoByPathOnUIThread() | 627 // Part of GetEntryInfoByPathOnUIThread() |
| 628 // 1) Called when the feed is loaded. | 628 // 1) Called when the feed is loaded. |
| 629 // 2) Called when an entry is found. | 629 // 2) Called when an entry is found. |
| 630 // |callback| must not be null. | 630 // |callback| must not be null. |
| 631 void GetEntryInfoByPathOnUIThreadAfterLoad( | 631 void GetEntryInfoByPathOnUIThreadAfterLoad( |
| 632 const FilePath& file_path, | 632 const FilePath& file_path, |
| 633 const GetEntryInfoCallback& callback, | 633 const GetEntryInfoCallback& callback, |
| 634 GDataFileError error); | 634 DriveFileError error); |
| 635 void GetEntryInfoByPathOnUIThreadAfterGetEntry( | 635 void GetEntryInfoByPathOnUIThreadAfterGetEntry( |
| 636 const GetEntryInfoCallback& callback, | 636 const GetEntryInfoCallback& callback, |
| 637 GDataFileError error, | 637 DriveFileError error, |
| 638 scoped_ptr<DriveEntryProto> entry_proto); | 638 scoped_ptr<DriveEntryProto> entry_proto); |
| 639 | 639 |
| 640 // Part of ReadDirectoryByPathOnUIThread() | 640 // Part of ReadDirectoryByPathOnUIThread() |
| 641 // 1) Called when the feed is loaded. | 641 // 1) Called when the feed is loaded. |
| 642 // 2) Called when an entry is found. | 642 // 2) Called when an entry is found. |
| 643 // |callback| must not be null. | 643 // |callback| must not be null. |
| 644 void ReadDirectoryByPathOnUIThreadAfterLoad( | 644 void ReadDirectoryByPathOnUIThreadAfterLoad( |
| 645 const FilePath& file_path, | 645 const FilePath& file_path, |
| 646 const ReadDirectoryWithSettingCallback& callback, | 646 const ReadDirectoryWithSettingCallback& callback, |
| 647 GDataFileError error); | 647 DriveFileError error); |
| 648 void ReadDirectoryByPathOnUIThreadAfterRead( | 648 void ReadDirectoryByPathOnUIThreadAfterRead( |
| 649 const ReadDirectoryWithSettingCallback& callback, | 649 const ReadDirectoryWithSettingCallback& callback, |
| 650 GDataFileError error, | 650 DriveFileError error, |
| 651 scoped_ptr<DriveEntryProtoVector> entries); | 651 scoped_ptr<DriveEntryProtoVector> entries); |
| 652 | 652 |
| 653 // Loads the feed from the cache or the server if not yet loaded. Runs | 653 // Loads the feed from the cache or the server if not yet loaded. Runs |
| 654 // |callback| upon the completion with the error code. | 654 // |callback| upon the completion with the error code. |
| 655 // |callback| must not be null. | 655 // |callback| must not be null. |
| 656 void LoadFeedIfNeeded(const FileOperationCallback& callback); | 656 void LoadFeedIfNeeded(const FileOperationCallback& callback); |
| 657 | 657 |
| 658 // Gets |file_path| from the file system after the file info is already | 658 // Gets |file_path| from the file system after the file info is already |
| 659 // resolved with GetEntryInfoByPath(). This function is called by | 659 // resolved with GetEntryInfoByPath(). This function is called by |
| 660 // OnGetEntryInfoCompleteForGetFileByPath and | 660 // OnGetEntryInfoCompleteForGetFileByPath and |
| 661 // OnGetEntryInfoCompleteForOpenFile. | 661 // OnGetEntryInfoCompleteForOpenFile. |
| 662 void GetResolvedFileByPath( | 662 void GetResolvedFileByPath( |
| 663 const FilePath& file_path, | 663 const FilePath& file_path, |
| 664 const GetFileCallback& get_file_callback, | 664 const GetFileCallback& get_file_callback, |
| 665 const GetContentCallback& get_content_callback, | 665 const GetContentCallback& get_content_callback, |
| 666 GDataFileError error, | 666 DriveFileError error, |
| 667 const DriveEntryProto* entry_proto); | 667 const DriveEntryProto* entry_proto); |
| 668 | 668 |
| 669 // Part of UpdateFileByResourceId(). Called when | 669 // Part of UpdateFileByResourceId(). Called when |
| 670 // DriveDirectory::GetEntryInfoByResourceId() is complete. | 670 // DriveDirectory::GetEntryInfoByResourceId() is complete. |
| 671 // |callback| must not be null. | 671 // |callback| must not be null. |
| 672 void UpdateFileByEntryInfo( | 672 void UpdateFileByEntryInfo( |
| 673 const FileOperationCallback& callback, | 673 const FileOperationCallback& callback, |
| 674 GDataFileError error, | 674 DriveFileError error, |
| 675 const FilePath& /* drive_file_path */, | 675 const FilePath& /* drive_file_path */, |
| 676 scoped_ptr<DriveEntryProto> entry_proto); | 676 scoped_ptr<DriveEntryProto> entry_proto); |
| 677 | 677 |
| 678 // Part of UpdateFileByResourceId(). | 678 // Part of UpdateFileByResourceId(). |
| 679 // Called when DriveCache::GetFileOnUIThread() is completed for | 679 // Called when DriveCache::GetFileOnUIThread() is completed for |
| 680 // UpdateFileByResourceId(). | 680 // UpdateFileByResourceId(). |
| 681 // |callback| must not be null. | 681 // |callback| must not be null. |
| 682 void OnGetFileCompleteForUpdateFile(const FileOperationCallback& callback, | 682 void OnGetFileCompleteForUpdateFile(const FileOperationCallback& callback, |
| 683 GDataFileError error, | 683 DriveFileError error, |
| 684 const std::string& resource_id, | 684 const std::string& resource_id, |
| 685 const std::string& md5, | 685 const std::string& md5, |
| 686 const FilePath& cache_file_path); | 686 const FilePath& cache_file_path); |
| 687 | 687 |
| 688 // Part of UpdateFileByResourceId(). | 688 // Part of UpdateFileByResourceId(). |
| 689 // Callback for getting the size of the cache file in the blocking pool. | 689 // Callback for getting the size of the cache file in the blocking pool. |
| 690 // |callback| must not be null. | 690 // |callback| must not be null. |
| 691 void OnGetFileSizeCompleteForUpdateFile(const FileOperationCallback& callback, | 691 void OnGetFileSizeCompleteForUpdateFile(const FileOperationCallback& callback, |
| 692 const std::string& resource_id, | 692 const std::string& resource_id, |
| 693 const FilePath& cache_file_path, | 693 const FilePath& cache_file_path, |
| 694 GDataFileError* error, | 694 DriveFileError* error, |
| 695 int64* file_size); | 695 int64* file_size); |
| 696 | 696 |
| 697 // Part of UpdateFileByResourceId(). | 697 // Part of UpdateFileByResourceId(). |
| 698 // Callback for GDataRootDirectory::GetEntryByResourceIdAsync. | 698 // Callback for GDataRootDirectory::GetEntryByResourceIdAsync. |
| 699 // |callback| must not be null. | 699 // |callback| must not be null. |
| 700 void OnGetFileCompleteForUpdateFileByEntry( | 700 void OnGetFileCompleteForUpdateFileByEntry( |
| 701 const FileOperationCallback& callback, | 701 const FileOperationCallback& callback, |
| 702 int64 file_size, | 702 int64 file_size, |
| 703 const FilePath& cache_file_path, | 703 const FilePath& cache_file_path, |
| 704 GDataFileError error, | 704 DriveFileError error, |
| 705 const FilePath& drive_file_path, | 705 const FilePath& drive_file_path, |
| 706 scoped_ptr<DriveEntryProto> entry_proto); | 706 scoped_ptr<DriveEntryProto> entry_proto); |
| 707 | 707 |
| 708 // Part of UpdateFileByResourceId(). | 708 // Part of UpdateFileByResourceId(). |
| 709 // Called when GDataUploader::UploadUpdatedFile() is completed for | 709 // Called when GDataUploader::UploadUpdatedFile() is completed for |
| 710 // UpdateFileByResourceId(). | 710 // UpdateFileByResourceId(). |
| 711 // |callback| must not be null. | 711 // |callback| must not be null. |
| 712 void OnUpdatedFileUploaded(const FileOperationCallback& callback, | 712 void OnUpdatedFileUploaded(const FileOperationCallback& callback, |
| 713 GDataFileError error, | 713 DriveFileError error, |
| 714 scoped_ptr<UploadFileInfo> upload_file_info); | 714 scoped_ptr<UploadFileInfo> upload_file_info); |
| 715 | 715 |
| 716 // The following functions are used to forward calls to asynchronous public | 716 // The following functions are used to forward calls to asynchronous public |
| 717 // member functions to UI thread. | 717 // member functions to UI thread. |
| 718 void SearchAsyncOnUIThread(const std::string& search_query, | 718 void SearchAsyncOnUIThread(const std::string& search_query, |
| 719 const GURL& next_feed, | 719 const GURL& next_feed, |
| 720 const SearchCallback& callback); | 720 const SearchCallback& callback); |
| 721 void OpenFileOnUIThread(const FilePath& file_path, | 721 void OpenFileOnUIThread(const FilePath& file_path, |
| 722 const OpenFileCallback& callback); | 722 const OpenFileCallback& callback); |
| 723 void CloseFileOnUIThread(const FilePath& file_path, | 723 void CloseFileOnUIThread(const FilePath& file_path, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 const GetEntryInfoCallback& callback); | 759 const GetEntryInfoCallback& callback); |
| 760 void GetEntryInfoByResourceIdOnUIThread( | 760 void GetEntryInfoByResourceIdOnUIThread( |
| 761 const std::string& resource_id, | 761 const std::string& resource_id, |
| 762 const GetEntryInfoWithFilePathCallback& callback); | 762 const GetEntryInfoWithFilePathCallback& callback); |
| 763 void ReadDirectoryByPathOnUIThread( | 763 void ReadDirectoryByPathOnUIThread( |
| 764 const FilePath& file_path, | 764 const FilePath& file_path, |
| 765 const ReadDirectoryWithSettingCallback& callback); | 765 const ReadDirectoryWithSettingCallback& callback); |
| 766 void RequestDirectoryRefreshOnUIThread(const FilePath& file_path); | 766 void RequestDirectoryRefreshOnUIThread(const FilePath& file_path); |
| 767 void OnRequestDirectoryRefresh(const FilePath& directory_path, | 767 void OnRequestDirectoryRefresh(const FilePath& directory_path, |
| 768 GetDocumentsParams* params, | 768 GetDocumentsParams* params, |
| 769 GDataFileError error); | 769 DriveFileError error); |
| 770 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); | 770 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); |
| 771 void AddUploadedFileOnUIThread(UploadMode upload_mode, | 771 void AddUploadedFileOnUIThread(UploadMode upload_mode, |
| 772 const FilePath& virtual_dir_path, | 772 const FilePath& virtual_dir_path, |
| 773 scoped_ptr<DocumentEntry> entry, | 773 scoped_ptr<DocumentEntry> entry, |
| 774 const FilePath& file_content_path, | 774 const FilePath& file_content_path, |
| 775 DriveCache::FileOperationType cache_operation, | 775 DriveCache::FileOperationType cache_operation, |
| 776 const base::Closure& callback); | 776 const base::Closure& callback); |
| 777 void UpdateEntryDataOnUIThread(const std::string& resource_id, | 777 void UpdateEntryDataOnUIThread(const std::string& resource_id, |
| 778 const std::string& md5, | 778 const std::string& md5, |
| 779 scoped_ptr<DocumentEntry> entry, | 779 scoped_ptr<DocumentEntry> entry, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 793 const FilePath& dest_file_path, | 793 const FilePath& dest_file_path, |
| 794 const FileOperationCallback& callback, | 794 const FileOperationCallback& callback, |
| 795 scoped_ptr<EntryInfoPairResult> result); | 795 scoped_ptr<EntryInfoPairResult> result); |
| 796 | 796 |
| 797 // Part of RemoveOnUIThread(). Called after GetEntryInfoByPath() is | 797 // Part of RemoveOnUIThread(). Called after GetEntryInfoByPath() is |
| 798 // complete. | 798 // complete. |
| 799 void RemoveOnUIThreadAfterGetEntryInfo( | 799 void RemoveOnUIThreadAfterGetEntryInfo( |
| 800 const FilePath& file_path, | 800 const FilePath& file_path, |
| 801 bool is_recursive, | 801 bool is_recursive, |
| 802 const FileOperationCallback& callback, | 802 const FileOperationCallback& callback, |
| 803 GDataFileError error, | 803 DriveFileError error, |
| 804 scoped_ptr<DriveEntryProto> entry_proto); | 804 scoped_ptr<DriveEntryProto> entry_proto); |
| 805 | 805 |
| 806 // Part of RequestDirectoryRefreshOnUIThread(). Called after | 806 // Part of RequestDirectoryRefreshOnUIThread(). Called after |
| 807 // GetEntryInfoByPath() is complete. | 807 // GetEntryInfoByPath() is complete. |
| 808 void RequestDirectoryRefreshOnUIThreadAfterGetEntryInfo( | 808 void RequestDirectoryRefreshOnUIThreadAfterGetEntryInfo( |
| 809 const FilePath& file_path, | 809 const FilePath& file_path, |
| 810 GDataFileError error, | 810 DriveFileError error, |
| 811 scoped_ptr<DriveEntryProto> entry_proto); | 811 scoped_ptr<DriveEntryProto> entry_proto); |
| 812 | 812 |
| 813 // Part of GetEntryByResourceId and GetEntryByPath. Checks whether there is a | 813 // Part of GetEntryByResourceId and GetEntryByPath. Checks whether there is a |
| 814 // local dirty cache for the entry, and if there is, replace the | 814 // local dirty cache for the entry, and if there is, replace the |
| 815 // PlatformFileInfo part of the |entry_proto| with the locally modified info. | 815 // PlatformFileInfo part of the |entry_proto| with the locally modified info. |
| 816 // |callback| must not be null. | 816 // |callback| must not be null. |
| 817 void CheckLocalModificationAndRun(scoped_ptr<DriveEntryProto> entry_proto, | 817 void CheckLocalModificationAndRun(scoped_ptr<DriveEntryProto> entry_proto, |
| 818 const GetEntryInfoCallback& callback); | 818 const GetEntryInfoCallback& callback); |
| 819 void CheckLocalModificationAndRunAfterGetCacheEntry( | 819 void CheckLocalModificationAndRunAfterGetCacheEntry( |
| 820 scoped_ptr<DriveEntryProto> entry_proto, | 820 scoped_ptr<DriveEntryProto> entry_proto, |
| 821 const GetEntryInfoCallback& callback, | 821 const GetEntryInfoCallback& callback, |
| 822 bool success, | 822 bool success, |
| 823 const DriveCacheEntry& cache_entry); | 823 const DriveCacheEntry& cache_entry); |
| 824 void CheckLocalModificationAndRunAfterGetCacheFile( | 824 void CheckLocalModificationAndRunAfterGetCacheFile( |
| 825 scoped_ptr<DriveEntryProto> entry_proto, | 825 scoped_ptr<DriveEntryProto> entry_proto, |
| 826 const GetEntryInfoCallback& callback, | 826 const GetEntryInfoCallback& callback, |
| 827 GDataFileError error, | 827 DriveFileError error, |
| 828 const std::string& resource_id, | 828 const std::string& resource_id, |
| 829 const std::string& md5, | 829 const std::string& md5, |
| 830 const FilePath& local_cache_path); | 830 const FilePath& local_cache_path); |
| 831 void CheckLocalModificationAndRunAfterGetFileInfo( | 831 void CheckLocalModificationAndRunAfterGetFileInfo( |
| 832 scoped_ptr<DriveEntryProto> entry_proto, | 832 scoped_ptr<DriveEntryProto> entry_proto, |
| 833 const GetEntryInfoCallback& callback, | 833 const GetEntryInfoCallback& callback, |
| 834 base::PlatformFileInfo* file_info, | 834 base::PlatformFileInfo* file_info, |
| 835 bool* get_file_info_result); | 835 bool* get_file_info_result); |
| 836 | 836 |
| 837 // All members should be accessed only on UI thread. Do not post tasks to | 837 // All members should be accessed only on UI thread. Do not post tasks to |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 // invalidate the weak pointers before any other members are destroyed. | 876 // invalidate the weak pointers before any other members are destroyed. |
| 877 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_; | 877 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_; |
| 878 // Unlike other classes, we need this as we need this to redirect a task | 878 // Unlike other classes, we need this as we need this to redirect a task |
| 879 // from IO thread to UI thread. | 879 // from IO thread to UI thread. |
| 880 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; | 880 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; |
| 881 }; | 881 }; |
| 882 | 882 |
| 883 } // namespace gdata | 883 } // namespace gdata |
| 884 | 884 |
| 885 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 885 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| OLD | NEW |