| 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_DRIVE_DOWNLOAD_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "chrome/browser/download/all_download_item_notifier.h" | 10 #include "chrome/browser/download/all_download_item_notifier.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 base::FilePath GetCacheFilePath(const content::DownloadItem* download); | 66 base::FilePath GetCacheFilePath(const content::DownloadItem* download); |
| 67 | 67 |
| 68 // Checks if there is a Drive upload associated with |download| | 68 // Checks if there is a Drive upload associated with |download| |
| 69 bool IsDriveDownload(const content::DownloadItem* download); | 69 bool IsDriveDownload(const content::DownloadItem* download); |
| 70 | 70 |
| 71 // Checks a file corresponding to the download item exists in Drive. | 71 // Checks a file corresponding to the download item exists in Drive. |
| 72 void CheckForFileExistence( | 72 void CheckForFileExistence( |
| 73 const content::DownloadItem* download, | 73 const content::DownloadItem* download, |
| 74 const content::CheckForFileExistenceCallback& callback); | 74 const content::CheckForFileExistenceCallback& callback); |
| 75 | 75 |
| 76 // Calculates request space for |downloads|. |
| 77 int64 CalculateRequestSpace( |
| 78 const content::DownloadManager::DownloadVector& downloads); |
| 79 |
| 80 // Checks available storage space and free disk space if necessary. Actual |
| 81 // execution is delayed and rate limited. |
| 82 void FreeDiskSpaceIfNeeded(); |
| 83 |
| 84 // Checks available storage space and free disk space if necessary. This is |
| 85 // executed immediately. |
| 86 void FreeDiskSpaceIfNeededImmediately(); |
| 87 |
| 88 // Sets free disk space delay for testing. |
| 89 void SetFreeDiskSpaceDelayForTesting(const base::TimeDelta& delay); |
| 90 |
| 76 private: | 91 private: |
| 77 // AllDownloadItemNotifier::Observer overrides: | 92 // AllDownloadItemNotifier::Observer overrides: |
| 78 void OnDownloadCreated(content::DownloadManager* manager, | 93 void OnDownloadCreated(content::DownloadManager* manager, |
| 79 content::DownloadItem* download) override; | 94 content::DownloadItem* download) override; |
| 80 void OnDownloadUpdated(content::DownloadManager* manager, | 95 void OnDownloadUpdated(content::DownloadManager* manager, |
| 81 content::DownloadItem* download) override; | 96 content::DownloadItem* download) override; |
| 82 | 97 |
| 83 // Removes the download. | 98 // Removes the download. |
| 84 void RemoveDownload(void* manager_id, int id); | 99 void RemoveDownload(void* manager_id, int id); |
| 85 | 100 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 97 int id, | 112 int id, |
| 98 const base::FilePath* cache_file_path, | 113 const base::FilePath* cache_file_path, |
| 99 FileError error); | 114 FileError error); |
| 100 | 115 |
| 101 // Gets a download manager, given a |manager_id| casted from the pointer to | 116 // Gets a download manager, given a |manager_id| casted from the pointer to |
| 102 // the manager. This is used to validate the manager that may be deleted while | 117 // the manager. This is used to validate the manager that may be deleted while |
| 103 // asynchronous task posting. Returns NULL if the manager is already gone. | 118 // asynchronous task posting. Returns NULL if the manager is already gone. |
| 104 content::DownloadManager* GetDownloadManager(void* manager_id); | 119 content::DownloadManager* GetDownloadManager(void* manager_id); |
| 105 | 120 |
| 106 FileSystemInterface* file_system_; // Owned by DriveIntegrationService. | 121 FileSystemInterface* file_system_; // Owned by DriveIntegrationService. |
| 122 |
| 107 // Observe the DownloadManager for new downloads. | 123 // Observe the DownloadManager for new downloads. |
| 108 scoped_ptr<AllDownloadItemNotifier> notifier_; | 124 scoped_ptr<AllDownloadItemNotifier> notifier_; |
| 109 scoped_ptr<AllDownloadItemNotifier> notifier_incognito_; | 125 scoped_ptr<AllDownloadItemNotifier> notifier_incognito_; |
| 110 | 126 |
| 111 // Temporary download location directory. | 127 // Temporary download location directory. |
| 112 base::FilePath drive_tmp_download_path_; | 128 base::FilePath drive_tmp_download_path_; |
| 113 | 129 |
| 130 // True if there is pending FreeDiskSpaceIfNeeded call. |
| 131 bool has_pending_free_disk_space_; |
| 132 |
| 133 base::TimeDelta free_disk_space_delay_; |
| 134 |
| 114 // Note: This should remain the last member so it'll be destroyed and | 135 // Note: This should remain the last member so it'll be destroyed and |
| 115 // invalidate its weak pointers before any other members are destroyed. | 136 // invalidate its weak pointers before any other members are destroyed. |
| 116 base::WeakPtrFactory<DownloadHandler> weak_ptr_factory_; | 137 base::WeakPtrFactory<DownloadHandler> weak_ptr_factory_; |
| 117 | 138 |
| 118 DISALLOW_COPY_AND_ASSIGN(DownloadHandler); | 139 DISALLOW_COPY_AND_ASSIGN(DownloadHandler); |
| 119 }; | 140 }; |
| 120 | 141 |
| 121 } // namespace drive | 142 } // namespace drive |
| 122 | 143 |
| 123 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_ | 144 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_ |
| OLD | NEW |