Chromium Code Reviews| Index: content/browser/download/download_item.h |
| diff --git a/content/browser/download/download_item.h b/content/browser/download/download_item.h |
| index baf3ca11e0362358588aba9a3271ae9212945697..56a0c3b245812ed4ed5134bca04001522b491a37 100644 |
| --- a/content/browser/download/download_item.h |
| +++ b/content/browser/download/download_item.h |
| @@ -25,6 +25,7 @@ |
| #include "base/observer_list.h" |
| #include "base/time.h" |
| #include "base/timer.h" |
| +#include "content/browser/download/download_item_interface.h" |
| #include "content/browser/download/download_request_handle.h" |
| #include "content/browser/download/download_state_info.h" |
| #include "content/browser/download/interrupt_reasons.h" |
| @@ -43,52 +44,8 @@ struct DownloadPersistentStoreInfo; |
| // Destination tab's download view, may refer to a given DownloadItem. |
| // |
| // This is intended to be used only on the UI thread. |
| -class CONTENT_EXPORT DownloadItem { |
| +class CONTENT_EXPORT DownloadItem : public DownloadItemInterface { |
|
cbentzel
2011/10/20 18:18:53
Naming issue: we usually don't have Interface appe
|
| public: |
| - enum DownloadState { |
| - // Download is actively progressing. |
| - IN_PROGRESS = 0, |
| - |
| - // Download is completely finished. |
| - COMPLETE, |
| - |
| - // Download has been cancelled. |
| - CANCELLED, |
| - |
| - // This state indicates that the download item is about to be destroyed, |
| - // and observers seeing this state should release all references. |
| - REMOVING, |
| - |
| - // This state indicates that the download has been interrupted. |
| - INTERRUPTED, |
| - |
| - // Maximum value. |
| - MAX_DOWNLOAD_STATE |
| - }; |
| - |
| - enum SafetyState { |
| - SAFE = 0, |
| - DANGEROUS, |
| - DANGEROUS_BUT_VALIDATED // Dangerous but the user confirmed the download. |
| - }; |
| - |
| - // This enum is used by histograms. Do not change the ordering or remove |
| - // items. |
| - enum DangerType { |
| - NOT_DANGEROUS = 0, |
| - |
| - // A dangerous file to the system (e.g.: an executable or extension from |
| - // places other than gallery). |
| - DANGEROUS_FILE, |
| - |
| - // Safebrowsing service shows this URL leads to malicious file download. |
| - DANGEROUS_URL, |
| - |
| - // Memory space for histograms is determined by the max. |
| - // ALWAYS ADD NEW VALUES BEFORE THIS ONE. |
| - DANGEROUS_TYPE_MAX |
| - }; |
| - |
| // Reason for deleting the download. Passed to Delete(). |
| enum DeleteReason { |
| DELETE_DUE_TO_BROWSER_SHUTDOWN = 0, |
| @@ -114,7 +71,8 @@ class CONTENT_EXPORT DownloadItem { |
| // Constructing from persistent store: |
| DownloadItem(DownloadManager* download_manager, |
| - const DownloadPersistentStoreInfo& info); |
| + const DownloadPersistentStoreInfo& info, |
| + int id); |
| // Constructing for a regular download: |
| DownloadItem(DownloadManager* download_manager, |
| @@ -238,74 +196,98 @@ class CONTENT_EXPORT DownloadItem { |
| void OnDownloadRenamedToFinalName(const FilePath& full_path); |
| // Returns true if this item matches |query|. |query| must be lower-cased. |
| - bool MatchesQuery(const string16& query) const; |
| + virtual bool MatchesQuery(const string16& query) const OVERRIDE; |
| // Returns true if the download needs more data. |
| - bool IsPartialDownload() const; |
| + virtual bool IsPartialDownload() const OVERRIDE; |
| // Returns true if the download is still receiving data. |
| - bool IsInProgress() const; |
| + virtual bool IsInProgress() const OVERRIDE; |
| // Returns true if the download has been cancelled or was interrupted. |
| - bool IsCancelled() const; |
| + virtual bool IsCancelled() const OVERRIDE; |
| // Returns true if the download was interrupted. |
| - bool IsInterrupted() const; |
| + virtual bool IsInterrupted() const OVERRIDE; |
| // Returns true if we have all the data and know the final file name. |
| - bool IsComplete() const; |
| + virtual bool IsComplete() const OVERRIDE; |
| // Accessors |
| - DownloadState state() const { return state_; } |
| - const FilePath& full_path() const { return full_path_; } |
| + virtual DownloadItemInterface::DownloadState state() const OVERRIDE { |
| + return state_; |
| + } |
| + virtual const FilePath& full_path() const OVERRIDE { return full_path_; } |
| void set_path_uniquifier(int uniquifier) { |
| state_info_.path_uniquifier = uniquifier; |
| } |
| - const GURL& GetURL() const; |
| + virtual const GURL& GetURL() const OVERRIDE; |
| const std::vector<GURL>& url_chain() const { return url_chain_; } |
| - const GURL& original_url() const { return url_chain_.front(); } |
| - const GURL& referrer_url() const { return referrer_url_; } |
| - std::string suggested_filename() const { return suggested_filename_; } |
| - std::string content_disposition() const { return content_disposition_; } |
| - std::string mime_type() const { return mime_type_; } |
| - std::string original_mime_type() const { return original_mime_type_; } |
| - std::string referrer_charset() const { return referrer_charset_; } |
| - int64 total_bytes() const { return total_bytes_; } |
| + virtual const GURL& original_url() const OVERRIDE { |
| + return url_chain_.front(); |
| + } |
| + virtual const GURL& referrer_url() const OVERRIDE { return referrer_url_; } |
| + virtual std::string suggested_filename() const OVERRIDE { |
| + return suggested_filename_; |
| + } |
| + virtual std::string content_disposition() const OVERRIDE { |
| + return content_disposition_; |
| + } |
| + virtual std::string mime_type() const OVERRIDE { return mime_type_; } |
| + virtual std::string original_mime_type() const OVERRIDE { |
| + return original_mime_type_; |
| + } |
| + virtual std::string referrer_charset() const OVERRIDE { |
| + return referrer_charset_; |
| + } |
| + virtual int64 total_bytes() const OVERRIDE { return total_bytes_; } |
| void set_total_bytes(int64 total_bytes) { |
| total_bytes_ = total_bytes; |
| } |
| - int64 received_bytes() const { return received_bytes_; } |
| - int32 id() const { return download_id_; } |
| - DownloadId global_id() const; |
| - base::Time start_time() const { return start_time_; } |
| - base::Time end_time() const { return end_time_; } |
| + virtual int64 received_bytes() const OVERRIDE { return received_bytes_; } |
| + virtual int32 id() const OVERRIDE { return download_id_; } |
| + virtual DownloadId global_id() const OVERRIDE; |
| + virtual base::Time start_time() const OVERRIDE { return start_time_; } |
| + virtual base::Time end_time() const { return end_time_; } |
| void set_db_handle(int64 handle) { db_handle_ = handle; } |
| - int64 db_handle() const { return db_handle_; } |
| - DownloadManager* download_manager() { return download_manager_; } |
| - bool is_paused() const { return is_paused_; } |
| - bool open_when_complete() const { return open_when_complete_; } |
| + virtual int64 db_handle() const OVERRIDE { return db_handle_; } |
| + virtual DownloadManager* download_manager() OVERRIDE { |
| + return download_manager_; |
| + } |
| + virtual bool is_paused() const OVERRIDE { return is_paused_; } |
| + virtual bool open_when_complete() const OVERRIDE { |
| + return open_when_complete_; |
| + } |
| void set_open_when_complete(bool open) { open_when_complete_ = open; } |
| - bool file_externally_removed() const { return file_externally_removed_; } |
| - SafetyState safety_state() const { return safety_state_; } |
| + virtual bool file_externally_removed() const OVERRIDE { |
| + return file_externally_removed_; |
| + } |
| + virtual DownloadItemInterface::SafetyState safety_state() const OVERRIDE { |
| + return safety_state_; |
| + } |
| // Why |safety_state_| is not SAFE. |
| - DangerType GetDangerType() const; |
| - bool IsDangerous() const; |
| + virtual DownloadItemInterface::DangerType GetDangerType() const OVERRIDE; |
| + virtual bool IsDangerous() const OVERRIDE; |
| void MarkFileDangerous(); |
| void MarkUrlDangerous(); |
| - bool auto_opened() { return auto_opened_; } |
| - const FilePath& target_name() const { return state_info_.target_name; } |
| - bool prompt_user_for_save_location() const { |
| + virtual bool auto_opened() const OVERRIDE { return auto_opened_; } |
| + virtual const FilePath& target_name() const OVERRIDE { |
| + return state_info_.target_name; |
| + } |
| + virtual bool prompt_user_for_save_location() const OVERRIDE { |
| return state_info_.prompt_user_for_save_location; |
| } |
| - bool is_otr() const { return is_otr_; } |
| - const FilePath& suggested_path() const { return state_info_.suggested_path; } |
| - bool is_temporary() const { return is_temporary_; } |
| + virtual bool is_otr() const { return is_otr_; } |
| + virtual const FilePath& suggested_path() const OVERRIDE { |
| + return state_info_.suggested_path; |
| + } |
| + virtual bool is_temporary() const OVERRIDE { return is_temporary_; } |
| void set_opened(bool opened) { opened_ = opened; } |
| - bool opened() const { return opened_; } |
| + virtual bool opened() const OVERRIDE { return opened_; } |
| - InterruptReason last_reason() const { return last_reason_; } |
| + virtual InterruptReason last_reason() const OVERRIDE { return last_reason_; } |
| DownloadPersistentStoreInfo GetPersistentStoreInfo() const; |
| DownloadStateInfo state_info() const { return state_info_; } |
| @@ -359,7 +341,7 @@ class CONTENT_EXPORT DownloadItem { |
| void StopProgressTimer(); |
| // Call to transition state; all state transitions should go through this. |
| - void TransitionTo(DownloadState new_state); |
| + void TransitionTo(DownloadItemInterface::DownloadState new_state); |
| // Called when safety_state_ should be recomputed from is_dangerous_file |
| // and is_dangerous_url. |
| @@ -426,7 +408,7 @@ class CONTENT_EXPORT DownloadItem { |
| base::TimeTicks start_tick_; |
| // The current state of this download |
| - DownloadState state_; |
| + DownloadItemInterface::DownloadState state_; |
| // The views of this item in the download shelf and download tab |
| ObserverList<Observer> observers_; |
| @@ -457,7 +439,7 @@ class CONTENT_EXPORT DownloadItem { |
| // Indicates if the download is considered potentially safe or dangerous |
| // (executable files are typically considered dangerous). |
| - SafetyState safety_state_; |
| + DownloadItemInterface::SafetyState safety_state_; |
| // True if the download was auto-opened. We set this rather than using |
| // an observer as it's frequently possible for the download to be auto opened |