Chromium Code Reviews| 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> |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 struct CreateDirectoryParams; | 164 struct CreateDirectoryParams; |
| 165 | 165 |
| 166 // Defines set of parameters passed to an intermediate callback | 166 // Defines set of parameters passed to an intermediate callback |
| 167 // OnGetFileCompleteForOpen, during execution of OpenFile() method. | 167 // OnGetFileCompleteForOpen, during execution of OpenFile() method. |
| 168 struct GetFileCompleteForOpenParams; | 168 struct GetFileCompleteForOpenParams; |
| 169 | 169 |
| 170 // Defines set of parameters passed to intermediate callbacks during | 170 // Defines set of parameters passed to intermediate callbacks during |
| 171 // execution of GetFileByPath() method. | 171 // execution of GetFileByPath() method. |
| 172 struct GetFileFromCacheParams; | 172 struct GetFileFromCacheParams; |
| 173 | 173 |
| 174 // Callback similar to FileOperationCallback but with a given |file_path|. | |
| 175 typedef base::Callback<void(GDataFileError error, | |
| 176 const FilePath& file_path)> | |
| 177 FilePathUpdateCallback; | |
| 178 | 174 |
| 179 // Struct used for StartFileUploadOnUIThread(). | 175 // Struct used for StartFileUploadOnUIThread(). |
| 180 struct StartFileUploadParams; | 176 struct StartFileUploadParams; |
| 181 | 177 |
| 182 // Callback passed to |LoadFeedFromServer| from |Search| method. | 178 // Callback passed to |LoadFeedFromServer| from |Search| method. |
| 183 // |callback| is that should be run with data received from | 179 // |callback| is that should be run with data received from |
| 184 // |LoadFeedFromServer|. | 180 // |LoadFeedFromServer|. |
| 185 // |params| params used for getting document feed for content search. | 181 // |params| params used for getting document feed for content search. |
| 186 // |error| error code returned by |LoadFeedFromServer|. | 182 // |error| error code returned by |LoadFeedFromServer|. |
| 187 void OnSearch(const SearchCallback& callback, | 183 void OnSearch(const SearchCallback& callback, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 | 344 |
| 349 // Copies a document with |resource_id| to the directory at |dir_path| | 345 // Copies a document with |resource_id| to the directory at |dir_path| |
| 350 // and names the copied document as |new_name|. | 346 // and names the copied document as |new_name|. |
| 351 // | 347 // |
| 352 // Can be called from UI thread. |callback| is run on the calling thread. | 348 // Can be called from UI thread. |callback| is run on the calling thread. |
| 353 void CopyDocumentToDirectory(const FilePath& dir_path, | 349 void CopyDocumentToDirectory(const FilePath& dir_path, |
| 354 const std::string& resource_id, | 350 const std::string& resource_id, |
| 355 const FilePath::StringType& new_name, | 351 const FilePath::StringType& new_name, |
| 356 const FileOperationCallback& callback); | 352 const FileOperationCallback& callback); |
| 357 | 353 |
| 358 // Renames a file or directory at |file_path| to |new_name|. | 354 // Renames a file or directory at |file_path| to |new_name|. |
|
satorux1
2012/08/08 23:25:01
While you are at it, could you add some documentat
achuithb
2012/08/09 00:12:51
Done.
| |
| 359 // | 355 // |
| 360 // Can be called from UI thread. |callback| is run on the calling thread. | 356 // Can be called from UI thread. |callback| is run on the calling thread. |
| 361 void Rename(const FilePath& file_path, | 357 void Rename(const FilePath& file_path, |
| 362 const FilePath::StringType& new_name, | 358 const FilePath::StringType& new_name, |
| 363 const FilePathUpdateCallback& callback); | 359 const FilePathUpdateCallback& callback); |
| 364 | 360 |
| 365 // Part of Rename(). Called after GetEntryInfoByPath() is complete. | 361 // Part of Rename(). Called after GetEntryInfoByPath() is complete. |
| 366 void RenameAfterGetEntryInfo(const FilePath& file_path, | 362 void RenameAfterGetEntryInfo(const FilePath& file_path, |
| 367 const FilePath::StringType& new_name, | 363 const FilePath::StringType& new_name, |
| 368 const FilePathUpdateCallback& callback, | 364 const FilePathUpdateCallback& callback, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 // ready for modification. | 400 // ready for modification. |
| 405 // | 401 // |
| 406 // Must be called on UI thread. | 402 // Must be called on UI thread. |
| 407 void OnMarkDirtyInCacheCompleteForOpenFile( | 403 void OnMarkDirtyInCacheCompleteForOpenFile( |
| 408 const OpenFileCallback& callback, | 404 const OpenFileCallback& callback, |
| 409 GDataFileError error, | 405 GDataFileError error, |
| 410 const std::string& resource_id, | 406 const std::string& resource_id, |
| 411 const std::string& md5, | 407 const std::string& md5, |
| 412 const FilePath& cache_file_path); | 408 const FilePath& cache_file_path); |
| 413 | 409 |
| 414 // Callback for handling resource rename attempt. | |
| 415 void OnRenameResourceCompleted(const FilePath& file_path, | |
| 416 const FilePath::StringType& new_name, | |
| 417 const FilePathUpdateCallback& callback, | |
| 418 GDataErrorCode status, | |
| 419 const GURL& document_url); | |
| 420 | |
| 421 // Callback for handling document copy attempt. | 410 // Callback for handling document copy attempt. |
| 422 void OnCopyDocumentCompleted(const FilePath& dir_path, | 411 void OnCopyDocumentCompleted(const FilePath& dir_path, |
| 423 const FileOperationCallback& callback, | 412 const FileOperationCallback& callback, |
| 424 GDataErrorCode status, | 413 GDataErrorCode status, |
| 425 scoped_ptr<base::Value> data); | 414 scoped_ptr<base::Value> data); |
| 426 | 415 |
| 427 // Callback for handling an attempt to add a file or directory to another | 416 // Callback for handling an attempt to add a file or directory to another |
| 428 // directory. | 417 // directory. |
| 429 void OnAddEntryToDirectoryCompleted(const FileOperationCallback& callback, | 418 void OnAddEntryToDirectoryCompleted(const FileOperationCallback& callback, |
| 430 const FilePath& file_path, | 419 const FilePath& file_path, |
| 431 const FilePath& dir_path, | 420 const FilePath& dir_path, |
| 432 GDataErrorCode status, | 421 GDataErrorCode status, |
| 433 const GURL& document_url); | 422 const GURL& document_url); |
| 434 | 423 |
| 435 // Callback for handling an attempt to remove a file or directory from | |
| 436 // another directory. | |
| 437 void OnRemoveEntryFromDirectoryCompleted( | |
| 438 const FilePathUpdateCallback& callback, | |
| 439 const FilePath& file_path, | |
| 440 const FilePath& dir_path, | |
| 441 GDataErrorCode status, | |
| 442 const GURL& document_url); | |
| 443 | |
| 444 // Callback for handling account metadata fetch. | 424 // Callback for handling account metadata fetch. |
| 445 void OnGetAvailableSpace( | 425 void OnGetAvailableSpace( |
| 446 const GetAvailableSpaceCallback& callback, | 426 const GetAvailableSpaceCallback& callback, |
| 447 GDataErrorCode status, | 427 GDataErrorCode status, |
| 448 scoped_ptr<base::Value> data); | 428 scoped_ptr<base::Value> data); |
| 449 | 429 |
| 450 // Callback for handling document remove attempt. | 430 // Callback for handling document remove attempt. |
| 451 void OnRemovedDocument( | 431 void OnRemovedDocument( |
| 452 const FileOperationCallback& callback, | 432 const FileOperationCallback& callback, |
| 453 const FilePath& file_path, | 433 const FilePath& file_path, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 481 const GURL& content_url, | 461 const GURL& content_url, |
| 482 const FilePath& downloaded_file_path, | 462 const FilePath& downloaded_file_path, |
| 483 bool* has_enough_space); | 463 bool* has_enough_space); |
| 484 | 464 |
| 485 // Callback for handling internal StoreToCache() calls after downloading | 465 // Callback for handling internal StoreToCache() calls after downloading |
| 486 // file content. | 466 // file content. |
| 487 void OnDownloadStoredToCache(GDataFileError error, | 467 void OnDownloadStoredToCache(GDataFileError error, |
| 488 const std::string& resource_id, | 468 const std::string& resource_id, |
| 489 const std::string& md5); | 469 const std::string& md5); |
| 490 | 470 |
| 491 // Renames a file or directory at |file_path| on in-memory snapshot | 471 // Callback for handling resource rename attempt. Renames a file or |
| 492 // of the file system. Returns PLATFORM_FILE_OK if successful. | 472 // directory at |file_path| on in-memory snapshot of the file system. |
| 493 GDataFileError RenameFileOnFilesystem( | 473 void RenameFileOnFileSystem(const FilePath& file_path, |
| 494 const FilePath& file_path, const FilePath::StringType& new_name, | 474 const FilePath::StringType& new_name, |
| 495 FilePath* updated_file_path); | 475 const FilePathUpdateCallback& callback, |
| 476 GDataErrorCode status, | |
| 477 const GURL& document_url); | |
| 496 | 478 |
| 497 // Adds an |entry| to another directory at |dir_path| on in-memory snapshot | 479 // Callback for handling an attempt to remove a file or directory from |
| 498 // of the file system. Returns PLATFORM_FILE_OK if successful. | 480 // another directory. Removes a file or directory at |file_path| and moves it |
| 499 GDataFileError AddEntryToDirectoryOnFilesystem( | 481 // to root on in-memory snapshot of the file system. |
| 500 GDataEntry* entry, const FilePath& dir_path); | 482 void RemoveEntryFromDirectoryOnFileSystem( |
| 501 | 483 const FilePathUpdateCallback& callback, |
| 502 // Removes a file or directory at |file_path| from another directory at | 484 const FilePath& file_path, |
| 503 // |dir_path| on in-memory snapshot of the file system. | 485 const FilePath& dir_path, |
| 504 // Returns PLATFORM_FILE_OK if successful. | 486 GDataErrorCode status, |
| 505 GDataFileError RemoveEntryFromDirectoryOnFilesystem( | 487 const GURL& document_url); |
| 506 const FilePath& file_path, const FilePath& dir_path, | |
| 507 FilePath* updated_file_path); | |
| 508 | 488 |
| 509 // Removes a file or directory under |file_path| from in-memory snapshot of | 489 // Removes a file or directory under |file_path| from in-memory snapshot of |
| 510 // the file system and the corresponding file from cache if it exists. | 490 // the file system and the corresponding file from cache if it exists. |
| 511 // Return PLATFORM_FILE_OK if successful. | 491 // Return PLATFORM_FILE_OK if successful. |
| 512 GDataFileError RemoveEntryFromFileSystem(const FilePath& file_path); | 492 GDataFileError RemoveEntryFromFileSystem(const FilePath& file_path); |
| 513 | 493 |
| 494 // Callback for GDataDirectoryService::AddEntryToDirectory with | |
| 495 // FilePathUpdateCallback. | |
| 496 void OnAddEntryToDirectoryWithFileUpdateCallback( | |
| 497 const FilePathUpdateCallback& callback, | |
| 498 GDataFileError error, | |
| 499 const FilePath& updated_file_path); | |
| 500 | |
| 501 // Callback for GDataDirectoryService::AddEntryToDirectory with | |
| 502 // FileOperationCallback. | |
| 503 void OnAddEntryToDirectoryWithFileOperationCallback( | |
| 504 const FileOperationCallback& callback, | |
| 505 GDataFileError error, | |
| 506 const FilePath& updated_file_path); | |
| 507 | |
| 514 // Callback for GetEntryByResourceIdAsync. | 508 // Callback for GetEntryByResourceIdAsync. |
| 515 // Removes stale entry upon upload of file. | 509 // Removes stale entry upon upload of file. |
| 516 static void RemoveStaleEntryOnUpload(const std::string& resource_id, | 510 static void RemoveStaleEntryOnUpload(const std::string& resource_id, |
| 517 GDataDirectory* parent_dir, | 511 GDataDirectory* parent_dir, |
| 518 GDataEntry* existing_entry); | 512 GDataEntry* existing_entry); |
| 519 | 513 |
| 520 // Converts |entry_value| into GFileDocument instance and adds it | 514 // Converts |entry_value| into GFileDocument instance and adds it |
| 521 // to virtual file system at |directory_path|. | 515 // to virtual file system at |directory_path|. |
| 522 GDataFileError AddNewDirectory(const FilePath& directory_path, | 516 GDataFileError AddNewDirectory(const FilePath& directory_path, |
| 523 base::Value* entry_value); | 517 base::Value* entry_value); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 // invalidate the weak pointers before any other members are destroyed. | 805 // invalidate the weak pointers before any other members are destroyed. |
| 812 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_; | 806 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_; |
| 813 // Unlike other classes, we need this as we need this to redirect a task | 807 // Unlike other classes, we need this as we need this to redirect a task |
| 814 // from IO thread to UI thread. | 808 // from IO thread to UI thread. |
| 815 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; | 809 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; |
| 816 }; | 810 }; |
| 817 | 811 |
| 818 } // namespace gdata | 812 } // namespace gdata |
| 819 | 813 |
| 820 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 814 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| OLD | NEW |