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

Side by Side 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, 1 month 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 unified diff | Download patch
OLDNEW
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
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 // Checks available storage space and free disk space if necessary for
77 // |download|. If |immediate| is false, execution is delayed and rate limited.
78 void FreeDiskSpaceIfNeeded(const content::DownloadItem* download,
79 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
80
81 // Sets free disk space delay for testing.
82 void SetFreeDiskSpaceDelayForTesting(const base::TimeDelta& delay);
83
76 private: 84 private:
77 // AllDownloadItemNotifier::Observer overrides: 85 // AllDownloadItemNotifier::Observer overrides:
78 void OnDownloadCreated(content::DownloadManager* manager, 86 void OnDownloadCreated(content::DownloadManager* manager,
79 content::DownloadItem* download) override; 87 content::DownloadItem* download) override;
80 void OnDownloadUpdated(content::DownloadManager* manager, 88 void OnDownloadUpdated(content::DownloadManager* manager,
81 content::DownloadItem* download) override; 89 content::DownloadItem* download) override;
82 90
83 // Removes the download. 91 // Removes the download.
84 void RemoveDownload(void* manager_id, int id); 92 void RemoveDownload(void* manager_id, int id);
85 93
86 // Callback for FileSystem::CreateDirectory(). 94 // Callback for FileSystem::CreateDirectory().
87 // Used to implement SubstituteDriveDownloadPath(). 95 // Used to implement SubstituteDriveDownloadPath().
88 void OnCreateDirectory(const SubstituteDriveDownloadPathCallback& callback, 96 void OnCreateDirectory(const SubstituteDriveDownloadPathCallback& callback,
89 FileError error); 97 FileError error);
90 98
91 // Starts the upload of a downloaded/downloading file. 99 // Starts the upload of a downloaded/downloading file.
92 void UploadDownloadItem(content::DownloadManager* manager, 100 void UploadDownloadItem(content::DownloadManager* manager,
93 content::DownloadItem* download); 101 content::DownloadItem* download);
94 102
95 // Sets |cache_file_path| as user data of the download item specified by |id|. 103 // Sets |cache_file_path| as user data of the download item specified by |id|.
96 void SetCacheFilePath(void* manager_id, 104 void SetCacheFilePath(void* manager_id,
97 int id, 105 int id,
98 const base::FilePath* cache_file_path, 106 const base::FilePath* cache_file_path,
99 FileError error); 107 FileError error);
100 108
109 void ExecuteFreeDiskSpaceIfNeededFor();
110
101 // Gets a download manager, given a |manager_id| casted from the pointer to 111 // 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 112 // 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. 113 // asynchronous task posting. Returns NULL if the manager is already gone.
104 content::DownloadManager* GetDownloadManager(void* manager_id); 114 content::DownloadManager* GetDownloadManager(void* manager_id);
105 115
106 FileSystemInterface* file_system_; // Owned by DriveIntegrationService. 116 FileSystemInterface* file_system_; // Owned by DriveIntegrationService.
117
107 // Observe the DownloadManager for new downloads. 118 // Observe the DownloadManager for new downloads.
108 scoped_ptr<AllDownloadItemNotifier> notifier_; 119 scoped_ptr<AllDownloadItemNotifier> notifier_;
109 scoped_ptr<AllDownloadItemNotifier> notifier_incognito_; 120 scoped_ptr<AllDownloadItemNotifier> notifier_incognito_;
110 121
111 // Temporary download location directory. 122 // Temporary download location directory.
112 base::FilePath drive_tmp_download_path_; 123 base::FilePath drive_tmp_download_path_;
113 124
125 // Pending requested space. 0 is set if there is no request.
126 int64 pending_request_space_;
127
128 base::TimeDelta free_disk_space_delay_;
129
114 // Note: This should remain the last member so it'll be destroyed and 130 // Note: This should remain the last member so it'll be destroyed and
115 // invalidate its weak pointers before any other members are destroyed. 131 // invalidate its weak pointers before any other members are destroyed.
116 base::WeakPtrFactory<DownloadHandler> weak_ptr_factory_; 132 base::WeakPtrFactory<DownloadHandler> weak_ptr_factory_;
117 133
118 DISALLOW_COPY_AND_ASSIGN(DownloadHandler); 134 DISALLOW_COPY_AND_ASSIGN(DownloadHandler);
119 }; 135 };
120 136
121 } // namespace drive 137 } // namespace drive
122 138
123 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_ 139 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DOWNLOAD_HANDLER_H_
OLDNEW
« 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