Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Unified Diff: chrome/browser/chromeos/drive/download_handler.h

Issue 1414753005: Evict drive cache with file download from website if necessary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Free disk space immediately in OnDownloadCreated. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_;
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/download_handler.cc » ('j') | chrome/browser/chromeos/drive/download_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698