Chromium Code Reviews| Index: chrome/browser/chromeos/drive/download_handler.h |
| diff --git a/chrome/browser/chromeos/drive/download_handler.h b/chrome/browser/chromeos/drive/download_handler.h |
| index 9973224c1b5c5fad0aa60af49d60f97ce55ee510..983d384ee3e3bd383871a5ece503f003dd328d87 100644 |
| --- a/chrome/browser/chromeos/drive/download_handler.h |
| +++ b/chrome/browser/chromeos/drive/download_handler.h |
| @@ -73,6 +73,14 @@ class DownloadHandler : public AllDownloadItemNotifier::Observer { |
| const content::DownloadItem* download, |
| const content::CheckForFileExistenceCallback& callback); |
| + // Checks available storage space and free disk space if necessary for |
| + // |download|. If |immediate| is false, execution is delayed and rate limited. |
| + void FreeDiskSpaceIfNeeded(const content::DownloadItem* download, |
| + bool immediate); |
|
hashimoto
2015/10/28 09:06:16
Generally, boolean parameters make the code less r
yawano
2015/10/29 02:52:43
Split a method into two methods, FreeDiskSpaceIfNe
|
| + |
| + // Sets free disk space delay for testing. |
| + void SetFreeDiskSpaceDelayForTesting(const base::TimeDelta& delay); |
| + |
| private: |
| // AllDownloadItemNotifier::Observer overrides: |
| void OnDownloadCreated(content::DownloadManager* manager, |
| @@ -98,12 +106,15 @@ class DownloadHandler : public AllDownloadItemNotifier::Observer { |
| const base::FilePath* cache_file_path, |
| FileError error); |
| + void ExecuteFreeDiskSpaceIfNeededFor(); |
| + |
| // Gets a download manager, given a |manager_id| casted from the pointer to |
| // the manager. This is used to validate the manager that may be deleted while |
| // asynchronous task posting. Returns NULL if the manager is already gone. |
| content::DownloadManager* GetDownloadManager(void* manager_id); |
| FileSystemInterface* file_system_; // Owned by DriveIntegrationService. |
| + |
| // Observe the DownloadManager for new downloads. |
| scoped_ptr<AllDownloadItemNotifier> notifier_; |
| scoped_ptr<AllDownloadItemNotifier> notifier_incognito_; |
| @@ -111,6 +122,11 @@ class DownloadHandler : public AllDownloadItemNotifier::Observer { |
| // Temporary download location directory. |
| base::FilePath drive_tmp_download_path_; |
| + // Pending requested space. 0 is set if there is no request. |
| + int64 pending_request_space_; |
| + |
| + base::TimeDelta free_disk_space_delay_; |
| + |
| // Note: This should remain the last member so it'll be destroyed and |
| // invalidate its weak pointers before any other members are destroyed. |
| base::WeakPtrFactory<DownloadHandler> weak_ptr_factory_; |