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 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 // Main entry points for regular downloads, in order ------------------------- | 148 // Main entry points for regular downloads, in order ------------------------- |
149 | 149 |
150 // TODO(rdsmith): Fold the process that uses these fully into | 150 // TODO(rdsmith): Fold the process that uses these fully into |
151 // DownloadItemImpl and pass callbacks to the delegate so that all of | 151 // DownloadItemImpl and pass callbacks to the delegate so that all of |
152 // these other than Start() can be made private. | 152 // these other than Start() can be made private. |
153 | 153 |
154 // Start the download | 154 // Start the download |
155 virtual void Start(scoped_ptr<DownloadFile> download_file); | 155 virtual void Start(scoped_ptr<DownloadFile> download_file); |
156 | 156 |
157 // If all pre-requisites have been met, complete download processing, i.e. do | |
158 // internal cleanup, file rename, and potentially auto-open. (Dangerous | |
159 // downloads still may block on user acceptance after this point.) | |
160 virtual void MaybeCompleteDownload(); | |
161 | |
162 // Needed because of interwining with DownloadManagerImpl -------------------- | 157 // Needed because of interwining with DownloadManagerImpl -------------------- |
163 | 158 |
164 // TODO(rdsmith): Unwind DownloadManagerImpl and DownloadItemImpl, | 159 // TODO(rdsmith): Unwind DownloadManagerImpl and DownloadItemImpl, |
165 // removing these from the public interface. | 160 // removing these from the public interface. |
166 | 161 |
167 // Notify observers that this item is being removed by the user. | 162 // Notify observers that this item is being removed by the user. |
168 virtual void NotifyRemoved(); | 163 virtual void NotifyRemoved(); |
169 | 164 |
170 virtual void OnDownloadedFileRemoved(); | 165 virtual void OnDownloadedFileRemoved(); |
171 | 166 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 TargetDisposition disposition, | 248 TargetDisposition disposition, |
254 DownloadDangerType danger_type, | 249 DownloadDangerType danger_type, |
255 const FilePath& intermediate_path); | 250 const FilePath& intermediate_path); |
256 | 251 |
257 // Callback from file thread when we initialize the DownloadFile. | 252 // Callback from file thread when we initialize the DownloadFile. |
258 void OnDownloadFileInitialized(DownloadInterruptReason result); | 253 void OnDownloadFileInitialized(DownloadInterruptReason result); |
259 | 254 |
260 void OnDownloadRenamedToIntermediateName( | 255 void OnDownloadRenamedToIntermediateName( |
261 DownloadInterruptReason reason, const FilePath& full_path); | 256 DownloadInterruptReason reason, const FilePath& full_path); |
262 | 257 |
| 258 // If all pre-requisites have been met, complete download processing, i.e. do |
| 259 // internal cleanup, file rename, and potentially auto-open. (Dangerous |
| 260 // downloads still may block on user acceptance after this point.) |
| 261 void MaybeCompleteDownload(); |
| 262 |
263 // Called when the download is ready to complete. | 263 // Called when the download is ready to complete. |
264 // This may perform final rename if necessary and will eventually call | 264 // This may perform final rename if necessary and will eventually call |
265 // DownloadItem::Completed(). | 265 // DownloadItem::Completed(). |
266 virtual void OnDownloadCompleting(); | 266 void OnDownloadCompleting(); |
267 | 267 |
268 // Called after the delegate has given the go-ahead to actually complete | 268 // Called after the delegate has given the go-ahead to actually complete |
269 // the download. | 269 // the download. |
270 void ReadyForDownloadCompletionDone(); | 270 void ReadyForDownloadCompletionDone(); |
271 | 271 |
272 void OnDownloadRenamedToFinalName(DownloadInterruptReason reason, | 272 void OnDownloadRenamedToFinalName(DownloadInterruptReason reason, |
273 const FilePath& full_path); | 273 const FilePath& full_path); |
274 | 274 |
275 // Called if the embedder took over opening a download, to indicate that | 275 // Called if the embedder took over opening a download, to indicate that |
276 // the download has been opened. | 276 // the download has been opened. |
277 virtual void DelayedDownloadOpened(bool auto_opened); | 277 void DelayedDownloadOpened(bool auto_opened); |
278 | 278 |
279 // Called when the entire download operation (including renaming etc) | 279 // Called when the entire download operation (including renaming etc) |
280 // is completed. | 280 // is completed. |
281 void Completed(); | 281 void Completed(); |
282 | 282 |
283 // Helper routines ----------------------------------------------------------- | 283 // Helper routines ----------------------------------------------------------- |
284 | 284 |
285 // Indicate that an error has occurred on the download. | 285 // Indicate that an error has occurred on the download. |
286 virtual void Interrupt(DownloadInterruptReason reason); | 286 void Interrupt(DownloadInterruptReason reason); |
287 | 287 |
288 // Cancel the DownloadFile if we have it. | 288 // Cancel the DownloadFile if we have it. |
289 void CancelDownloadFile(); | 289 void CancelDownloadFile(); |
290 | 290 |
291 // Check if a download is ready for completion. | 291 // Check if a download is ready for completion. |
292 bool IsDownloadReadyForCompletion(); | 292 bool IsDownloadReadyForCompletion(); |
293 | 293 |
294 // Call to transition state; all state transitions should go through this. | 294 // Call to transition state; all state transitions should go through this. |
295 void TransitionTo(DownloadInternalState new_state); | 295 void TransitionTo(DownloadInternalState new_state); |
296 | 296 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 const net::BoundNetLog bound_net_log_; | 468 const net::BoundNetLog bound_net_log_; |
469 | 469 |
470 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; | 470 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; |
471 | 471 |
472 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); | 472 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); |
473 }; | 473 }; |
474 | 474 |
475 } // namespace content | 475 } // namespace content |
476 | 476 |
477 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 477 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
OLD | NEW |