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

Side by Side Diff: chrome/browser/download/download_manager.h

Issue 6905049: Detect removed files and reflect the state in chrome://downloads and the download shelf (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: is_path_exists_ => file_exists_, aggregate scattered AddObserver()s into one AddObserver() Created 9 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // The DownloadManager object manages the process of downloading, including 5 // The DownloadManager object manages the process of downloading, including
6 // updates to the history system and providing the information for displaying 6 // updates to the history system and providing the information for displaying
7 // the downloads view in the Destinations tab. There is one DownloadManager per 7 // the downloads view in the Destinations tab. There is one DownloadManager per
8 // active profile in Chrome. 8 // active profile in Chrome.
9 // 9 //
10 // Download observers: 10 // Download observers:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // Browser's download manager: manages all downloads and destination view. 64 // Browser's download manager: manages all downloads and destination view.
65 class DownloadManager 65 class DownloadManager
66 : public base::RefCountedThreadSafe<DownloadManager, 66 : public base::RefCountedThreadSafe<DownloadManager,
67 BrowserThread::DeleteOnUIThread>, 67 BrowserThread::DeleteOnUIThread>,
68 public DownloadStatusUpdaterDelegate, 68 public DownloadStatusUpdaterDelegate,
69 public SelectFileDialog::Listener { 69 public SelectFileDialog::Listener {
70 public: 70 public:
71 explicit DownloadManager(DownloadStatusUpdater* status_updater); 71 explicit DownloadManager(DownloadStatusUpdater* status_updater);
72 72
73 typedef std::vector<std::pair<int64, FilePath> > PathVector;
Paweł Hajdan Jr. 2011/05/10 11:37:51 nit: According to http://google-styleguide.googlec
74
73 // Shutdown the download manager. Must be called before destruction. 75 // Shutdown the download manager. Must be called before destruction.
74 void Shutdown(); 76 void Shutdown();
75 77
76 // Interface to implement for observers that wish to be informed of changes 78 // Interface to implement for observers that wish to be informed of changes
77 // to the DownloadManager's collection of downloads. 79 // to the DownloadManager's collection of downloads.
78 class Observer { 80 class Observer {
79 public: 81 public:
80 // New or deleted download, observers should query us for the current set 82 // New or deleted download, observers should query us for the current set
81 // of downloads. 83 // of downloads.
82 virtual void ModelChanged() = 0; 84 virtual void ModelChanged() = 0;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 virtual int64 GetReceivedDownloadBytes(); 228 virtual int64 GetReceivedDownloadBytes();
227 virtual int64 GetTotalDownloadBytes(); 229 virtual int64 GetTotalDownloadBytes();
228 230
229 // Overridden from SelectFileDialog::Listener: 231 // Overridden from SelectFileDialog::Listener:
230 virtual void FileSelected(const FilePath& path, int index, void* params); 232 virtual void FileSelected(const FilePath& path, int index, void* params);
231 virtual void FileSelectionCanceled(void* params); 233 virtual void FileSelectionCanceled(void* params);
232 234
233 // Called when the user has validated the download of a dangerous file. 235 // Called when the user has validated the download of a dangerous file.
234 void DangerousDownloadValidated(DownloadItem* download); 236 void DangerousDownloadValidated(DownloadItem* download);
235 237
238 // Check the existence of downloaded files.
Paweł Hajdan Jr. 2011/05/10 11:37:51 The comment should be more precise than "Check". I
239 void CheckForFilesRemoval();
240
236 // Callback function after url is checked with safebrowsing service. 241 // Callback function after url is checked with safebrowsing service.
237 void CheckDownloadUrlDone(DownloadCreateInfo* info, bool is_dangerous_url); 242 void CheckDownloadUrlDone(DownloadCreateInfo* info, bool is_dangerous_url);
238 243
239 // Callback function after download file hash is checked with safebrowsing 244 // Callback function after download file hash is checked with safebrowsing
240 // service. 245 // service.
241 void CheckDownloadHashDone(int32 download_id, bool is_dangerous_hash); 246 void CheckDownloadHashDone(int32 download_id, bool is_dangerous_hash);
242 247
243 private: 248 private:
244 // For testing. 249 // For testing.
245 friend class DownloadManagerTest; 250 friend class DownloadManagerTest;
(...skipping 19 matching lines...) Expand all
265 // The original profile's download manager. 270 // The original profile's download manager.
266 DownloadManager* observed_download_manager_; 271 DownloadManager* observed_download_manager_;
267 }; 272 };
268 273
269 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 274 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
270 friend class DeleteTask<DownloadManager>; 275 friend class DeleteTask<DownloadManager>;
271 friend class OtherDownloadManagerObserver; 276 friend class OtherDownloadManagerObserver;
272 277
273 ~DownloadManager(); 278 ~DownloadManager();
274 279
280 // Called on the FILE thread to check the existence of downloaded files.
281 // We don't check the file existence on the UI thread to prevent UI thread
Paweł Hajdan Jr. 2011/05/10 11:37:51 nit: Remove the "We don't" part, we don't write th
282 // from stalling by interacting with the file system.
283 void CheckForFilesRemovalOnFileThread(const PathVector& existing_paths);
Paweł Hajdan Jr. 2011/05/10 11:37:51 nit: How about renaming existing_paths to just pat
284
285 // Called on the UI thread when the FILE thread finishes to check the
286 // existence of downloaded files. The UI thread updates the state of the
287 // downloaded but non-existent files, and then notifies the fact to the
288 // observers of those files.
289 void OnFilesRemovalDetected(const PathVector& removed_paths);
290
275 // Called on the download thread to check whether the suggested file path 291 // Called on the download thread to check whether the suggested file path
276 // exists. We don't check if the file exists on the UI thread to avoid UI 292 // exists. We don't check if the file exists on the UI thread to avoid UI
277 // stalls from interacting with the file system. 293 // stalls from interacting with the file system.
278 void CheckIfSuggestedPathExists(DownloadCreateInfo* info, 294 void CheckIfSuggestedPathExists(DownloadCreateInfo* info,
279 const FilePath& default_path); 295 const FilePath& default_path);
280 296
281 // Called on the UI thread once the DownloadManager has determined whether the 297 // Called on the UI thread once the DownloadManager has determined whether the
282 // suggested file path exists. 298 // suggested file path exists.
283 void OnPathExistenceAvailable(DownloadCreateInfo* info); 299 void OnPathExistenceAvailable(DownloadCreateInfo* info);
284 300
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // The "Save As" dialog box used to ask the user where a file should be 409 // The "Save As" dialog box used to ask the user where a file should be
394 // saved. 410 // saved.
395 scoped_refptr<SelectFileDialog> select_file_dialog_; 411 scoped_refptr<SelectFileDialog> select_file_dialog_;
396 412
397 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; 413 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_;
398 414
399 DISALLOW_COPY_AND_ASSIGN(DownloadManager); 415 DISALLOW_COPY_AND_ASSIGN(DownloadManager);
400 }; 416 };
401 417
402 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ 418 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698