| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 virtual std::string DebugString(bool verbose) const OVERRIDE; | 156 virtual std::string DebugString(bool verbose) const OVERRIDE; |
| 157 | 157 |
| 158 // All remaining public interfaces virtual to allow for DownloadItemImpl | 158 // All remaining public interfaces virtual to allow for DownloadItemImpl |
| 159 // mocks. | 159 // mocks. |
| 160 | 160 |
| 161 // Determines the resume mode for an interrupted download. Requires | 161 // Determines the resume mode for an interrupted download. Requires |
| 162 // last_reason_ to be set, but doesn't require the download to be in | 162 // last_reason_ to be set, but doesn't require the download to be in |
| 163 // INTERRUPTED state. | 163 // INTERRUPTED state. |
| 164 virtual ResumeMode GetResumeMode() const; | 164 virtual ResumeMode GetResumeMode() const; |
| 165 | 165 |
| 166 // Notify the download item that new origin information is available due to a | |
| 167 // resumption request receiving a response. | |
| 168 virtual void MergeOriginInfoOnResume( | |
| 169 const DownloadCreateInfo& new_create_info); | |
| 170 | |
| 171 // State transition operations on regular downloads -------------------------- | 166 // State transition operations on regular downloads -------------------------- |
| 172 | 167 |
| 173 // Start the download. | 168 // Start the download. |
| 174 // |download_file| is the associated file on the storage medium. | 169 // |download_file| is the associated file on the storage medium. |
| 175 // |req_handle| is the new request handle associated with the download. | 170 // |req_handle| is the new request handle associated with the download. |
| 171 // |new_create_info| is a DownloadCreateInfo containing the new response |
| 172 // parameters. It may be different from the DownloadCreateInfo used to create |
| 173 // the DownloadItem if Start() is being called in response for a download |
| 174 // resumption request. |
| 176 virtual void Start(scoped_ptr<DownloadFile> download_file, | 175 virtual void Start(scoped_ptr<DownloadFile> download_file, |
| 177 scoped_ptr<DownloadRequestHandleInterface> req_handle); | 176 scoped_ptr<DownloadRequestHandleInterface> req_handle, |
| 177 const DownloadCreateInfo& new_create_info); |
| 178 | 178 |
| 179 // Needed because of intertwining with DownloadManagerImpl ------------------- | 179 // Needed because of intertwining with DownloadManagerImpl ------------------- |
| 180 | 180 |
| 181 // TODO(rdsmith): Unwind DownloadManagerImpl and DownloadItemImpl, | 181 // TODO(rdsmith): Unwind DownloadManagerImpl and DownloadItemImpl, |
| 182 // removing these from the public interface. | 182 // removing these from the public interface. |
| 183 | 183 |
| 184 // Notify observers that this item is being removed by the user. | 184 // Notify observers that this item is being removed by the user. |
| 185 virtual void NotifyRemoved(); | 185 virtual void NotifyRemoved(); |
| 186 | 186 |
| 187 virtual void OnDownloadedFileRemoved(); | 187 virtual void OnDownloadedFileRemoved(); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 const base::FilePath& full_path); | 332 const base::FilePath& full_path); |
| 333 | 333 |
| 334 // Called if the embedder took over opening a download, to indicate that | 334 // Called if the embedder took over opening a download, to indicate that |
| 335 // the download has been opened. | 335 // the download has been opened. |
| 336 void DelayedDownloadOpened(bool auto_opened); | 336 void DelayedDownloadOpened(bool auto_opened); |
| 337 | 337 |
| 338 // Called when the entire download operation (including renaming etc) | 338 // Called when the entire download operation (including renaming etc) |
| 339 // is completed. | 339 // is completed. |
| 340 void Completed(); | 340 void Completed(); |
| 341 | 341 |
| 342 // Callback invoked when the URLRequest for a download resumption has started. | |
| 343 void OnResumeRequestStarted(DownloadItem* item, | |
| 344 DownloadInterruptReason interrupt_reason); | |
| 345 | |
| 346 // Helper routines ----------------------------------------------------------- | 342 // Helper routines ----------------------------------------------------------- |
| 347 | 343 |
| 348 // Indicate that an error has occurred on the download. | 344 // Indicate that an error has occurred on the download. |
| 349 void Interrupt(DownloadInterruptReason reason); | 345 void Interrupt(DownloadInterruptReason reason); |
| 350 | 346 |
| 351 // Destroy the DownloadFile object. If |destroy_file| is true, the file is | 347 // Destroy the DownloadFile object. If |destroy_file| is true, the file is |
| 352 // destroyed with it. Otherwise, DownloadFile::Detach() is called before | 348 // destroyed with it. Otherwise, DownloadFile::Detach() is called before |
| 353 // object destruction to prevent file destruction. Destroying the file also | 349 // object destruction to prevent file destruction. Destroying the file also |
| 354 // resets |current_path_|. | 350 // resets |current_path_|. |
| 355 void ReleaseDownloadFile(bool destroy_file); | 351 void ReleaseDownloadFile(bool destroy_file); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 367 | 363 |
| 368 // Set the |danger_type_| and invoke obserers if necessary. | 364 // Set the |danger_type_| and invoke obserers if necessary. |
| 369 void SetDangerType(DownloadDangerType danger_type); | 365 void SetDangerType(DownloadDangerType danger_type); |
| 370 | 366 |
| 371 void SetFullPath(const base::FilePath& new_path); | 367 void SetFullPath(const base::FilePath& new_path); |
| 372 | 368 |
| 373 void AutoResumeIfValid(); | 369 void AutoResumeIfValid(); |
| 374 | 370 |
| 375 void ResumeInterruptedDownload(); | 371 void ResumeInterruptedDownload(); |
| 376 | 372 |
| 373 // Update origin information based on the response to a download resumption |
| 374 // request. Should only be called if the resumption request was successful. |
| 375 virtual void MergeOriginInfoOnResume( |
| 376 const DownloadCreateInfo& new_create_info); |
| 377 |
| 377 static DownloadState InternalToExternalState( | 378 static DownloadState InternalToExternalState( |
| 378 DownloadInternalState internal_state); | 379 DownloadInternalState internal_state); |
| 379 static DownloadInternalState ExternalToInternalState( | 380 static DownloadInternalState ExternalToInternalState( |
| 380 DownloadState external_state); | 381 DownloadState external_state); |
| 381 | 382 |
| 382 // Debugging routines -------------------------------------------------------- | 383 // Debugging routines -------------------------------------------------------- |
| 383 static const char* DebugDownloadStateString(DownloadInternalState state); | 384 static const char* DebugDownloadStateString(DownloadInternalState state); |
| 384 static const char* DebugResumeModeString(ResumeMode mode); | 385 static const char* DebugResumeModeString(ResumeMode mode); |
| 385 | 386 |
| 386 // Will be false for save package downloads retrieved from the history. | 387 // Will be false for save package downloads retrieved from the history. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 const net::BoundNetLog bound_net_log_; | 544 const net::BoundNetLog bound_net_log_; |
| 544 | 545 |
| 545 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; | 546 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; |
| 546 | 547 |
| 547 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); | 548 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); |
| 548 }; | 549 }; |
| 549 | 550 |
| 550 } // namespace content | 551 } // namespace content |
| 551 | 552 |
| 552 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 553 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
| OLD | NEW |