OLD | NEW |
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 // 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 browser context in Chrome. | 8 // active browser context in Chrome. |
9 // | 9 // |
10 // Download observers: | 10 // Download observers: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // A DownloadItem was created. This item may be visible before the filename | 76 // A DownloadItem was created. This item may be visible before the filename |
77 // is determined; in this case the return value of GetTargetFileName() will | 77 // is determined; in this case the return value of GetTargetFileName() will |
78 // be null. This method may be called an arbitrary number of times, e.g. | 78 // be null. This method may be called an arbitrary number of times, e.g. |
79 // when loading history on startup. As a result, consumers should avoid | 79 // when loading history on startup. As a result, consumers should avoid |
80 // doing large amounts of work in OnDownloadCreated(). TODO(<whoever>): | 80 // doing large amounts of work in OnDownloadCreated(). TODO(<whoever>): |
81 // When we've fully specified the possible states of the DownloadItem in | 81 // When we've fully specified the possible states of the DownloadItem in |
82 // download_item.h, we should remove the caveat above. | 82 // download_item.h, we should remove the caveat above. |
83 virtual void OnDownloadCreated( | 83 virtual void OnDownloadCreated( |
84 DownloadManager* manager, DownloadItem* item) {} | 84 DownloadManager* manager, DownloadItem* item) {} |
85 | 85 |
| 86 // Happens when a removed item is revived (the removal is undone). |
| 87 virtual void OnDownloadRevived( |
| 88 DownloadManager* manager, DownloadItem* item) {} |
| 89 |
86 // A SavePackage has successfully finished. | 90 // A SavePackage has successfully finished. |
87 virtual void OnSavePackageSuccessfullyFinished( | 91 virtual void OnSavePackageSuccessfullyFinished( |
88 DownloadManager* manager, DownloadItem* item) {} | 92 DownloadManager* manager, DownloadItem* item) {} |
89 | 93 |
90 // Called when the DownloadManager is being destroyed to prevent Observers | 94 // Called when the DownloadManager is being destroyed to prevent Observers |
91 // from calling back to a stale pointer. | 95 // from calling back to a stale pointer. |
92 virtual void ManagerGoingDown(DownloadManager* manager) {} | 96 virtual void ManagerGoingDown(DownloadManager* manager) {} |
93 | 97 |
94 protected: | 98 protected: |
95 virtual ~Observer() {} | 99 virtual ~Observer() {} |
96 }; | 100 }; |
97 | 101 |
98 typedef std::vector<DownloadItem*> DownloadVector; | 102 typedef std::vector<DownloadItem*> DownloadVector; |
99 | 103 |
100 // Add all download items to |downloads|, no matter the type or state, without | 104 // Add all download items to |downloads|, no matter the type or state, without |
101 // clearing |downloads| first. | 105 // clearing |downloads| first. |
102 virtual void GetAllDownloads(DownloadVector* downloads) = 0; | 106 virtual void GetAllDownloads(DownloadVector* downloads) = 0; |
103 | 107 |
104 // Called by a download source (Currently DownloadResourceHandler) | 108 // Called by a download source (Currently DownloadResourceHandler) |
105 // to initiate the non-source portions of a download. | 109 // to initiate the non-source portions of a download. |
106 // Returns the id assigned to the download. If the DownloadCreateInfo | 110 // Returns the id assigned to the download. If the DownloadCreateInfo |
107 // specifies an id, that id will be used. | 111 // specifies an id, that id will be used. |
108 virtual void StartDownload( | 112 virtual void StartDownload( |
109 scoped_ptr<DownloadCreateInfo> info, | 113 scoped_ptr<DownloadCreateInfo> info, |
110 scoped_ptr<ByteStreamReader> stream, | 114 scoped_ptr<ByteStreamReader> stream, |
111 const DownloadUrlParameters::OnStartedCallback& on_started) = 0; | 115 const DownloadUrlParameters::OnStartedCallback& on_started) = 0; |
112 | 116 |
113 // Remove downloads after remove_begin (inclusive) and before remove_end | 117 // Remove downloads after remove_begin (inclusive) and before remove_end |
114 // (exclusive). You may pass in null Time values to do an unbounded delete | 118 // (exclusive). You may pass in null Time values to do an unbounded removal |
115 // in either direction. | 119 // in either direction. |
116 virtual int RemoveDownloadsBetween(base::Time remove_begin, | 120 virtual int RemoveDownloadsBetween(base::Time remove_begin, |
117 base::Time remove_end) = 0; | 121 base::Time remove_end) = 0; |
118 | 122 |
119 // Remove downloads will delete all downloads that have a timestamp that is | 123 // Remove all downloads that have a timestamp that is the same or more recent |
120 // the same or more recent than |remove_begin|. The number of downloads | 124 // than |remove_begin|. The number of downloads deleted is returned back to |
121 // deleted is returned back to the caller. | 125 // the caller. |
122 virtual int RemoveDownloads(base::Time remove_begin) = 0; | 126 virtual int RemoveDownloads(base::Time remove_begin) = 0; |
123 | 127 |
124 // Remove all downloads will delete all downloads. The number of downloads | 128 // Remove all downloads. Returns the number of downloads removed. |
125 // deleted is returned back to the caller. | |
126 virtual int RemoveAllDownloads() = 0; | 129 virtual int RemoveAllDownloads() = 0; |
127 | 130 |
| 131 // Revives a removed download (undoes the removal). |
| 132 virtual void ReviveDownload(uint32 id) = 0; |
| 133 |
| 134 // Finalizes removal of a download. Downloads cannot be revived after this. |
| 135 virtual void FinalizeRemoval(uint32 id) = 0; |
| 136 |
128 // See DownloadUrlParameters for details about controlling the download. | 137 // See DownloadUrlParameters for details about controlling the download. |
129 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> parameters) = 0; | 138 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> parameters) = 0; |
130 | 139 |
131 // Allow objects to observe the download creation process. | 140 // Allow objects to observe the download creation process. |
132 virtual void AddObserver(Observer* observer) = 0; | 141 virtual void AddObserver(Observer* observer) = 0; |
133 | 142 |
134 // Remove a download observer from ourself. | 143 // Remove a download observer from ourself. |
135 virtual void RemoveObserver(Observer* observer) = 0; | 144 virtual void RemoveObserver(Observer* observer) = 0; |
136 | 145 |
137 // Called by the embedder, after creating the download manager, to let it know | 146 // Called by the embedder, after creating the download manager, to let it know |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 virtual void CheckForHistoryFilesRemoval() = 0; | 183 virtual void CheckForHistoryFilesRemoval() = 0; |
175 | 184 |
176 // Get the download item for |id| if present, no matter what type of download | 185 // Get the download item for |id| if present, no matter what type of download |
177 // it is or state it's in. | 186 // it is or state it's in. |
178 virtual DownloadItem* GetDownload(uint32 id) = 0; | 187 virtual DownloadItem* GetDownload(uint32 id) = 0; |
179 }; | 188 }; |
180 | 189 |
181 } // namespace content | 190 } // namespace content |
182 | 191 |
183 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ | 192 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ |
OLD | NEW |