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

Side by Side Diff: content/public/browser/download_item.h

Issue 10704026: Reland DownloadItem::Observer::OnDownloadDestroyed() replaces DownloadItem::REMOVING (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lint Created 8 years, 4 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) 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 // Each download is represented by a DownloadItem, and all DownloadItems 5 // Each download is represented by a DownloadItem, and all DownloadItems
6 // are owned by the DownloadManager which maintains a global list of all 6 // are owned by the DownloadManager which maintains a global list of all
7 // downloads. DownloadItems are created when a user initiates a download, 7 // downloads. DownloadItems are created when a user initiates a download,
8 // and exist for the duration of the browser life time. 8 // and exist for the duration of the browser life time.
9 // 9 //
10 // Download observers: 10 // Download observers:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 enum DownloadState { 55 enum DownloadState {
56 // Download is actively progressing. 56 // Download is actively progressing.
57 IN_PROGRESS = 0, 57 IN_PROGRESS = 0,
58 58
59 // Download is completely finished. 59 // Download is completely finished.
60 COMPLETE, 60 COMPLETE,
61 61
62 // Download has been cancelled. 62 // Download has been cancelled.
63 CANCELLED, 63 CANCELLED,
64 64
65 // This state indicates that the download item is about to be destroyed,
66 // and observers seeing this state should release all references.
67 REMOVING,
68
69 // This state indicates that the download has been interrupted. 65 // This state indicates that the download has been interrupted.
70 INTERRUPTED, 66 INTERRUPTED,
71 67
72 // Maximum value. 68 // Maximum value.
73 MAX_DOWNLOAD_STATE 69 MAX_DOWNLOAD_STATE
74 }; 70 };
75 71
76 enum SafetyState { 72 enum SafetyState {
77 SAFE = 0, 73 SAFE = 0,
78 DANGEROUS, 74 DANGEROUS,
(...skipping 17 matching lines...) Expand all
96 // A fake download table ID which represents a download that has started, 92 // A fake download table ID which represents a download that has started,
97 // but is not yet in the table. 93 // but is not yet in the table.
98 static const int kUninitializedHandle; 94 static const int kUninitializedHandle;
99 95
100 static const char kEmptyFileHash[]; 96 static const char kEmptyFileHash[];
101 97
102 // Interface that observers of a particular download must implement in order 98 // Interface that observers of a particular download must implement in order
103 // to receive updates to the download's status. 99 // to receive updates to the download's status.
104 class CONTENT_EXPORT Observer { 100 class CONTENT_EXPORT Observer {
105 public: 101 public:
106 virtual void OnDownloadUpdated(DownloadItem* download) = 0; 102 virtual void OnDownloadUpdated(DownloadItem* download) {}
107 103
108 // Called when a downloaded file has been opened. 104 // Called when a downloaded file has been opened.
109 virtual void OnDownloadOpened(DownloadItem* download) = 0; 105 virtual void OnDownloadOpened(DownloadItem* download) {}
106
107 // Called when the user removes a download.
108 virtual void OnDownloadRemoved(DownloadItem* download) {}
109
110 // Called when the download is being destroyed. This happens after
111 // every OnDownloadRemoved() as well as when the DownloadManager is going
112 // down.
113 virtual void OnDownloadDestroyed(DownloadItem* download) {}
110 114
111 protected: 115 protected:
112 virtual ~Observer() {} 116 virtual ~Observer() {}
113 }; 117 };
114 118
115 virtual ~DownloadItem() {} 119 virtual ~DownloadItem() {}
116 120
117 virtual void AddObserver(DownloadItem::Observer* observer) = 0; 121 virtual void AddObserver(DownloadItem::Observer* observer) = 0;
118 virtual void RemoveObserver(DownloadItem::Observer* observer) = 0; 122 virtual void RemoveObserver(DownloadItem::Observer* observer) = 0;
119 123
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 virtual FilePath GetUserVerifiedFilePath() const = 0; 290 virtual FilePath GetUserVerifiedFilePath() const = 0;
287 291
288 virtual std::string DebugString(bool verbose) const = 0; 292 virtual std::string DebugString(bool verbose) const = 0;
289 293
290 virtual void MockDownloadOpenForTesting() = 0; 294 virtual void MockDownloadOpenForTesting() = 0;
291 }; 295 };
292 296
293 } // namespace content 297 } // namespace content
294 298
295 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 299 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698