| 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_DRIVE_FILE_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 const FilePath& file_path, | 109 const FilePath& file_path, |
| 110 const GetEntryInfoCallback& callback) OVERRIDE; | 110 const GetEntryInfoCallback& callback) OVERRIDE; |
| 111 virtual void ReadDirectoryByPath( | 111 virtual void ReadDirectoryByPath( |
| 112 const FilePath& file_path, | 112 const FilePath& file_path, |
| 113 const ReadDirectoryWithSettingCallback& callback) OVERRIDE; | 113 const ReadDirectoryWithSettingCallback& callback) OVERRIDE; |
| 114 virtual void RequestDirectoryRefresh( | 114 virtual void RequestDirectoryRefresh( |
| 115 const FilePath& file_path) OVERRIDE; | 115 const FilePath& file_path) OVERRIDE; |
| 116 virtual void GetAvailableSpace( | 116 virtual void GetAvailableSpace( |
| 117 const GetAvailableSpaceCallback& callback) OVERRIDE; | 117 const GetAvailableSpaceCallback& callback) OVERRIDE; |
| 118 virtual void AddUploadedFile(UploadMode upload_mode, | 118 virtual void AddUploadedFile(UploadMode upload_mode, |
| 119 const FilePath& virtual_dir_path, | 119 const FilePath& directory_path, |
| 120 scoped_ptr<DocumentEntry> entry, | 120 scoped_ptr<DocumentEntry> doc_entry, |
| 121 const FilePath& file_content_path, | 121 const FilePath& file_content_path, |
| 122 DriveCache::FileOperationType cache_operation, | 122 DriveCache::FileOperationType cache_operation, |
| 123 const base::Closure& callback) OVERRIDE; | 123 const base::Closure& callback) OVERRIDE; |
| 124 virtual void UpdateEntryData(const std::string& resource_id, | 124 virtual void UpdateEntryData(const std::string& resource_id, |
| 125 const std::string& md5, | 125 const std::string& md5, |
| 126 scoped_ptr<DocumentEntry> entry, | 126 scoped_ptr<DocumentEntry> entry, |
| 127 const FilePath& file_content_path, | 127 const FilePath& file_content_path, |
| 128 const base::Closure& callback) OVERRIDE; | 128 const base::Closure& callback) OVERRIDE; |
| 129 | 129 |
| 130 // content::NotificationObserver implementation. | 130 // content::NotificationObserver implementation. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 158 // Target directory found, it's not a directory. | 158 // Target directory found, it's not a directory. |
| 159 FOUND_INVALID, | 159 FOUND_INVALID, |
| 160 // Found missing directory segment while searching for given directory. | 160 // Found missing directory segment while searching for given directory. |
| 161 FOUND_MISSING, | 161 FOUND_MISSING, |
| 162 // Found target directory, it already exists. | 162 // Found target directory, it already exists. |
| 163 DIRECTORY_ALREADY_PRESENT, | 163 DIRECTORY_ALREADY_PRESENT, |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 // Defines set of parameters passes to intermediate callbacks during | 166 // Defines set of parameters passes to intermediate callbacks during |
| 167 // execution of CreateDirectory() method. | 167 // execution of CreateDirectory() method. |
| 168 struct CreateDirectoryParams; | 168 struct CreateDirectoryParams { |
| 169 CreateDirectoryParams(const FilePath& created_directory_path, |
| 170 const FilePath& target_directory_path, |
| 171 bool is_exclusive, |
| 172 bool is_recursive, |
| 173 const FileOperationCallback& callback); |
| 174 ~CreateDirectoryParams(); |
| 175 |
| 176 const FilePath created_directory_path; |
| 177 const FilePath target_directory_path; |
| 178 const bool is_exclusive; |
| 179 const bool is_recursive; |
| 180 FileOperationCallback callback; |
| 181 }; |
| 169 | 182 |
| 170 // Defines set of parameters passed to an intermediate callback | 183 // Defines set of parameters passed to an intermediate callback |
| 171 // OnGetFileCompleteForOpen, during execution of OpenFile() method. | 184 // OnGetFileCompleteForOpen, during execution of OpenFile() method. |
| 172 struct GetFileCompleteForOpenParams; | 185 struct GetFileCompleteForOpenParams; |
| 173 | 186 |
| 174 // Defines set of parameters passed to intermediate callbacks during | 187 // Defines set of parameters passed to intermediate callbacks during |
| 175 // execution of GetFileByPath() method. | 188 // execution of GetFileByPath() method. |
| 176 struct GetFileFromCacheParams; | 189 struct GetFileFromCacheParams; |
| 177 | 190 |
| 178 // Struct used for StartFileUploadOnUIThread(). | 191 // Struct used for StartFileUploadOnUIThread(). |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // name is uniquified by adding a parenthesized serial number like | 357 // name is uniquified by adding a parenthesized serial number like |
| 345 // "foo (2).txt" | 358 // "foo (2).txt" |
| 346 // | 359 // |
| 347 // Can be called from UI thread. |callback| is run on the calling thread. | 360 // Can be called from UI thread. |callback| is run on the calling thread. |
| 348 // |callback| must not be null. | 361 // |callback| must not be null. |
| 349 void Rename(const FilePath& file_path, | 362 void Rename(const FilePath& file_path, |
| 350 const FilePath::StringType& new_name, | 363 const FilePath::StringType& new_name, |
| 351 const FileMoveCallback& callback); | 364 const FileMoveCallback& callback); |
| 352 | 365 |
| 353 // Part of Rename(). Called after GetEntryInfoByPath() is complete. | 366 // Part of Rename(). Called after GetEntryInfoByPath() is complete. |
| 367 // |callback| must not be null. |
| 354 void RenameAfterGetEntryInfo(const FilePath& file_path, | 368 void RenameAfterGetEntryInfo(const FilePath& file_path, |
| 355 const FilePath::StringType& new_name, | 369 const FilePath::StringType& new_name, |
| 356 const FileMoveCallback& callback, | 370 const FileMoveCallback& callback, |
| 357 DriveFileError error, | 371 DriveFileError error, |
| 358 scoped_ptr<DriveEntryProto> entry_proto); | 372 scoped_ptr<DriveEntryProto> entry_proto); |
| 359 | 373 |
| 360 // Moves a file or directory at |file_path| in the root directory to | 374 // Moves a file or directory at |file_path| in the root directory to |
| 361 // another directory at |dir_path|. This function does nothing if | 375 // another directory at |dir_path|. This function does nothing if |
| 362 // |dir_path| points to the root directory. | 376 // |dir_path| points to the root directory. |
| 363 // | 377 // |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 // Callback for handling account metadata fetch. | 444 // Callback for handling account metadata fetch. |
| 431 void OnGetAvailableSpace(const GetAvailableSpaceCallback& callback, | 445 void OnGetAvailableSpace(const GetAvailableSpaceCallback& callback, |
| 432 GDataErrorCode status, | 446 GDataErrorCode status, |
| 433 scoped_ptr<base::Value> data); | 447 scoped_ptr<base::Value> data); |
| 434 | 448 |
| 435 // Callback for handling Drive V2 about resource fetch. | 449 // Callback for handling Drive V2 about resource fetch. |
| 436 void OnGetAboutResource(const GetAvailableSpaceCallback& callback, | 450 void OnGetAboutResource(const GetAvailableSpaceCallback& callback, |
| 437 GDataErrorCode status, | 451 GDataErrorCode status, |
| 438 scoped_ptr<base::Value> data); | 452 scoped_ptr<base::Value> data); |
| 439 | 453 |
| 440 // Callback for handling directory create requests. | 454 // Callback for handling directory create requests. Adds the directory |
| 441 void OnCreateDirectoryCompleted(const CreateDirectoryParams& params, | 455 // represented by |created_entry| to the local filesystem. |
| 442 GDataErrorCode status, | 456 void AddNewDirectory(const CreateDirectoryParams& params, |
| 443 scoped_ptr<base::Value> created_entry); | 457 GDataErrorCode status, |
| 458 scoped_ptr<base::Value> created_entry); |
| 459 |
| 460 // Callback for DriveResourceMetadata::AddEntryToDirectory. Continues the |
| 461 // recursive creation of a directory path by calling CreateDirectory again. |
| 462 void ContinueCreateDirectory( |
| 463 const CreateDirectoryParams& params, |
| 464 DriveFileError error, |
| 465 const FilePath& moved_file_path); |
| 444 | 466 |
| 445 // Callback for handling file downloading requests. | 467 // Callback for handling file downloading requests. |
| 446 void OnFileDownloaded(const GetFileFromCacheParams& params, | 468 void OnFileDownloaded(const GetFileFromCacheParams& params, |
| 447 GDataErrorCode status, | 469 GDataErrorCode status, |
| 448 const GURL& content_url, | 470 const GURL& content_url, |
| 449 const FilePath& downloaded_file_path); | 471 const FilePath& downloaded_file_path); |
| 450 | 472 |
| 451 // Unpins file if cache entry is pinned. | 473 // Unpins file if cache entry is pinned. |
| 452 void UnpinIfPinned(const std::string& resource_id, | 474 void UnpinIfPinned(const std::string& resource_id, |
| 453 const std::string& md5, | 475 const std::string& md5, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 // Callback for DriveServiceInterface::DeleteDocument. Removes the entry with | 512 // Callback for DriveServiceInterface::DeleteDocument. Removes the entry with |
| 491 // |resource_id| from the local snapshot of the filesystem and the cache. | 513 // |resource_id| from the local snapshot of the filesystem and the cache. |
| 492 // |document_url| is unused. |callback| may be null. | 514 // |document_url| is unused. |callback| may be null. |
| 493 void RemoveResourceLocally(const FileOperationCallback& callback, | 515 void RemoveResourceLocally(const FileOperationCallback& callback, |
| 494 const std::string& resource_id, | 516 const std::string& resource_id, |
| 495 GDataErrorCode status, | 517 GDataErrorCode status, |
| 496 const GURL& document_url); | 518 const GURL& document_url); |
| 497 | 519 |
| 498 // Callback when an entry is moved to another directory on the client side. | 520 // Callback when an entry is moved to another directory on the client side. |
| 499 // Notifies the directory change and runs |callback|. | 521 // Notifies the directory change and runs |callback|. |
| 500 // |callback| may be null. | 522 // |callback| must not be null. |
| 501 void NotifyAndRunFileMoveCallback( | 523 void NotifyAndRunFileMoveCallback( |
| 502 const FileMoveCallback& callback, | 524 const FileMoveCallback& callback, |
| 503 DriveFileError error, | 525 DriveFileError error, |
| 504 const FilePath& moved_file_path); | 526 const FilePath& moved_file_path); |
| 505 | 527 |
| 506 // Callback when an entry is moved to another directory on the client side. | 528 // Callback when an entry is moved to another directory on the client side. |
| 507 // Notifies the directory change and runs |callback|. | 529 // Notifies the directory change and runs |callback|. |
| 508 // |callback| must not be null. | 530 // |callback| must not be null. |
| 509 void NotifyAndRunFileOperationCallback( | 531 void NotifyAndRunFileOperationCallback( |
| 510 const FileOperationCallback& callback, | 532 const FileOperationCallback& callback, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 521 // Continues to add an uploaded file after existing entry has been deleted. | 543 // Continues to add an uploaded file after existing entry has been deleted. |
| 522 void ContinueAddUploadedFile(AddUploadedFileParams* params, | 544 void ContinueAddUploadedFile(AddUploadedFileParams* params, |
| 523 DriveFileError error, | 545 DriveFileError error, |
| 524 const FilePath& file_path); | 546 const FilePath& file_path); |
| 525 | 547 |
| 526 // Adds the uploaded file to the cache. | 548 // Adds the uploaded file to the cache. |
| 527 void AddUploadedFileToCache(AddUploadedFileParams* params, | 549 void AddUploadedFileToCache(AddUploadedFileParams* params, |
| 528 DriveFileError error, | 550 DriveFileError error, |
| 529 const FilePath& file_path); | 551 const FilePath& file_path); |
| 530 | 552 |
| 531 // Converts |entry_value| into GFileDocument instance and adds it | |
| 532 // to virtual file system at |directory_path|. | |
| 533 DriveFileError AddNewDirectory(const FilePath& directory_path, | |
| 534 base::Value* entry_value); | |
| 535 | |
| 536 // Given non-existing |directory_path|, finds the first missing parent | 553 // Given non-existing |directory_path|, finds the first missing parent |
| 537 // directory of |directory_path|. | 554 // directory of |directory_path|. |
| 538 FindMissingDirectoryResult FindFirstMissingParentDirectory( | 555 FindMissingDirectoryResult FindFirstMissingParentDirectory( |
| 539 const FilePath& directory_path, | 556 const FilePath& directory_path, |
| 540 GURL* last_dir_content_url, | 557 GURL* last_dir_content_url, |
| 541 FilePath* first_missing_parent_path); | 558 FilePath* first_missing_parent_path); |
| 542 | 559 |
| 543 // Callback for handling results of ReloadFeedFromServerIfNeeded() initiated | 560 // Callback for handling results of ReloadFeedFromServerIfNeeded() initiated |
| 544 // from CheckForUpdates(). This callback checks whether feed is successfully | 561 // from CheckForUpdates(). This callback checks whether feed is successfully |
| 545 // reloaded, and in case of failure, restores the content origin of the root | 562 // reloaded, and in case of failure, restores the content origin of the root |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 const GetEntryInfoWithFilePathCallback& callback); | 763 const GetEntryInfoWithFilePathCallback& callback); |
| 747 void ReadDirectoryByPathOnUIThread( | 764 void ReadDirectoryByPathOnUIThread( |
| 748 const FilePath& file_path, | 765 const FilePath& file_path, |
| 749 const ReadDirectoryWithSettingCallback& callback); | 766 const ReadDirectoryWithSettingCallback& callback); |
| 750 void RequestDirectoryRefreshOnUIThread(const FilePath& file_path); | 767 void RequestDirectoryRefreshOnUIThread(const FilePath& file_path); |
| 751 void OnRequestDirectoryRefresh(const FilePath& directory_path, | 768 void OnRequestDirectoryRefresh(const FilePath& directory_path, |
| 752 GetDocumentsParams* params, | 769 GetDocumentsParams* params, |
| 753 DriveFileError error); | 770 DriveFileError error); |
| 754 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); | 771 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); |
| 755 void AddUploadedFileOnUIThread(UploadMode upload_mode, | 772 void AddUploadedFileOnUIThread(UploadMode upload_mode, |
| 756 const FilePath& virtual_dir_path, | 773 const FilePath& directory_path, |
| 757 scoped_ptr<DocumentEntry> entry, | 774 scoped_ptr<DocumentEntry> doc_entry, |
| 758 const FilePath& file_content_path, | 775 const FilePath& file_content_path, |
| 759 DriveCache::FileOperationType cache_operation, | 776 DriveCache::FileOperationType cache_operation, |
| 760 const base::Closure& callback); | 777 const base::Closure& callback); |
| 761 void UpdateEntryDataOnUIThread(const std::string& resource_id, | 778 void UpdateEntryDataOnUIThread(const std::string& resource_id, |
| 762 const std::string& md5, | 779 const std::string& md5, |
| 763 scoped_ptr<DocumentEntry> entry, | 780 scoped_ptr<DocumentEntry> entry, |
| 764 const FilePath& file_content_path, | 781 const FilePath& file_content_path, |
| 765 const base::Closure& callback); | 782 const base::Closure& callback); |
| 766 | 783 |
| 767 // Part of CopyOnUIThread(). Called after GetEntryInfoPairByPaths() is | 784 // Part of CopyOnUIThread(). Called after GetEntryInfoPairByPaths() is |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 // invalidate the weak pointers before any other members are destroyed. | 875 // invalidate the weak pointers before any other members are destroyed. |
| 859 base::WeakPtrFactory<DriveFileSystem> ui_weak_ptr_factory_; | 876 base::WeakPtrFactory<DriveFileSystem> ui_weak_ptr_factory_; |
| 860 // Unlike other classes, we need this as we need this to redirect a task | 877 // Unlike other classes, we need this as we need this to redirect a task |
| 861 // from IO thread to UI thread. | 878 // from IO thread to UI thread. |
| 862 base::WeakPtr<DriveFileSystem> ui_weak_ptr_; | 879 base::WeakPtr<DriveFileSystem> ui_weak_ptr_; |
| 863 }; | 880 }; |
| 864 | 881 |
| 865 } // namespace gdata | 882 } // namespace gdata |
| 866 | 883 |
| 867 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_H_ | 884 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_H_ |
| OLD | NEW |