| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 14 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "content/browser/download/download_destination_observer.h" | 20 #include "content/browser/download/download_destination_observer.h" |
| 20 #include "content/browser/download/download_net_log_parameters.h" | 21 #include "content/browser/download/download_net_log_parameters.h" |
| 21 #include "content/browser/download/download_request_handle.h" | 22 #include "content/browser/download/download_request_handle.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 | 417 |
| 417 // Called when the target path has been determined. |target_path| is the | 418 // Called when the target path has been determined. |target_path| is the |
| 418 // suggested target path. |disposition| indicates how the target path should | 419 // suggested target path. |disposition| indicates how the target path should |
| 419 // be used (see TargetDisposition). |danger_type| is the danger level of | 420 // be used (see TargetDisposition). |danger_type| is the danger level of |
| 420 // |target_path| as determined by the caller. |intermediate_path| is the path | 421 // |target_path| as determined by the caller. |intermediate_path| is the path |
| 421 // to use to store the download until OnDownloadCompleting() is called. | 422 // to use to store the download until OnDownloadCompleting() is called. |
| 422 virtual void OnDownloadTargetDetermined( | 423 virtual void OnDownloadTargetDetermined( |
| 423 const base::FilePath& target_path, | 424 const base::FilePath& target_path, |
| 424 TargetDisposition disposition, | 425 TargetDisposition disposition, |
| 425 DownloadDangerType danger_type, | 426 DownloadDangerType danger_type, |
| 426 const base::FilePath& intermediate_path); | 427 const base::FilePath& intermediate_path, |
| 428 DownloadInterruptReason interrupt_reason); |
| 427 | 429 |
| 428 void OnDownloadRenamedToIntermediateName( | 430 void OnDownloadRenamedToIntermediateName( |
| 429 DownloadInterruptReason reason, const base::FilePath& full_path); | 431 DownloadInterruptReason reason, const base::FilePath& full_path); |
| 430 | 432 |
| 433 void OnTargetResolved(); |
| 434 |
| 431 // If all pre-requisites have been met, complete download processing, i.e. do | 435 // If all pre-requisites have been met, complete download processing, i.e. do |
| 432 // internal cleanup, file rename, and potentially auto-open. (Dangerous | 436 // internal cleanup, file rename, and potentially auto-open. (Dangerous |
| 433 // downloads still may block on user acceptance after this point.) | 437 // downloads still may block on user acceptance after this point.) |
| 434 void MaybeCompleteDownload(); | 438 void MaybeCompleteDownload(); |
| 435 | 439 |
| 436 // Called when the download is ready to complete. | 440 // Called when the download is ready to complete. |
| 437 // This may perform final rename if necessary and will eventually call | 441 // This may perform final rename if necessary and will eventually call |
| 438 // DownloadItem::Completed(). | 442 // DownloadItem::Completed(). |
| 439 void OnDownloadCompleting(); | 443 void OnDownloadCompleting(); |
| 440 | 444 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 // when the user closes the shelf before the item has been opened but should | 629 // when the user closes the shelf before the item has been opened but should |
| 626 // be treated as though the user opened it. | 630 // be treated as though the user opened it. |
| 627 bool opened_ = false; | 631 bool opened_ = false; |
| 628 | 632 |
| 629 // Time when the download was last accessed. | 633 // Time when the download was last accessed. |
| 630 base::Time last_access_time_; | 634 base::Time last_access_time_; |
| 631 | 635 |
| 632 // Did the delegate delay calling Complete on this download? | 636 // Did the delegate delay calling Complete on this download? |
| 633 bool delegate_delayed_complete_ = false; | 637 bool delegate_delayed_complete_ = false; |
| 634 | 638 |
| 635 // Error return from DestinationError. Stored separately from | 639 // Error return from DestinationError or received at Start(). Stored |
| 636 // last_reason_ so that we can avoid handling destination errors until | 640 // separately from last_reason_ so that we can avoid handling destination |
| 637 // after file name determination has occurred. | 641 // errors until after file name determination has occurred. |
| 638 DownloadInterruptReason destination_error_ = DOWNLOAD_INTERRUPT_REASON_NONE; | 642 DownloadInterruptReason deferred_interrupt_reason_ = |
| 643 DOWNLOAD_INTERRUPT_REASON_NONE; |
| 639 | 644 |
| 640 // The following fields describe the current state of the download file. | 645 // The following fields describe the current state of the download file. |
| 641 | 646 |
| 642 // DownloadFile associated with this download. Note that this | 647 // DownloadFile associated with this download. Note that this |
| 643 // pointer may only be used or destroyed on the FILE thread. | 648 // pointer may only be used or destroyed on the FILE thread. |
| 644 // This pointer will be non-null only while the DownloadItem is in | 649 // This pointer will be non-null only while the DownloadItem is in |
| 645 // the IN_PROGRESS state. | 650 // the IN_PROGRESS state. |
| 646 std::unique_ptr<DownloadFile> download_file_; | 651 std::unique_ptr<DownloadFile> download_file_; |
| 647 | 652 |
| 648 // Full path to the downloaded or downloading file. This is the path to the | 653 // Full path to the downloaded or downloading file. This is the path to the |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 std::unique_ptr<DownloadJob> job_; | 700 std::unique_ptr<DownloadJob> job_; |
| 696 | 701 |
| 697 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; | 702 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; |
| 698 | 703 |
| 699 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); | 704 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); |
| 700 }; | 705 }; |
| 701 | 706 |
| 702 } // namespace content | 707 } // namespace content |
| 703 | 708 |
| 704 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 709 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
| OLD | NEW |