Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: content/browser/download/download_item_impl.cc

Issue 10665049: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "content/browser/download/download_item_impl.h" 5 #include "content/browser/download/download_item_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/i18n/case_conversion.h" 13 #include "base/i18n/case_conversion.h"
14 #include "base/i18n/string_search.h" 14 #include "base/i18n/string_search.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "content/browser/download/download_create_info.h" 20 #include "content/browser/download/download_create_info.h"
21 #include "content/browser/download/download_file.h" 21 #include "content/browser/download/download_file.h"
22 #include "content/browser/download/download_file_manager.h" 22 #include "content/browser/download/download_file_manager.h"
23 #include "content/browser/download/download_interrupt_reasons_impl.h" 23 #include "content/browser/download/download_interrupt_reasons_impl.h"
24 #include "content/browser/download/download_item_impl_delegate.h" 24 #include "content/browser/download/download_item_impl_delegate.h"
25 #include "content/browser/download/download_request_handle.h" 25 #include "content/browser/download/download_request_handle.h"
26 #include "content/browser/download/download_stats.h" 26 #include "content/browser/download/download_stats.h"
27 #include "content/browser/web_contents/web_contents_impl.h" 27 #include "content/browser/web_contents/web_contents_impl.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/content_browser_client.h" 29 #include "content/public/browser/content_browser_client.h"
30 #include "content/public/browser/download_persistent_store_info.h"
31 #include "net/base/net_util.h" 30 #include "net/base/net_util.h"
32 31
33 using content::BrowserThread; 32 using content::BrowserThread;
34 using content::DownloadFile; 33 using content::DownloadFile;
35 using content::DownloadId; 34 using content::DownloadId;
36 using content::DownloadItem; 35 using content::DownloadItem;
37 using content::DownloadManager; 36 using content::DownloadManager;
38 using content::DownloadPersistentStoreInfo;
39 using content::WebContents; 37 using content::WebContents;
40 38
41 // A DownloadItem normally goes through the following states: 39 // A DownloadItem normally goes through the following states:
42 // * Created (when download starts) 40 // * Created (when download starts)
43 // * Made visible to consumers (e.g. Javascript) after the 41 // * Made visible to consumers (e.g. Javascript) after the
44 // destination file has been determined. 42 // destination file has been determined.
45 // * Entered into the history database. 43 // * Entered into the history database.
46 // * Made visible in the download shelf. 44 // * Made visible in the download shelf.
47 // * All data is saved. Note that the actual data download occurs 45 // * All data is saved. Note that the actual data download occurs
48 // in parallel with the above steps, but until those steps are 46 // in parallel with the above steps, but until those steps are
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 virtual void CancelRequest() const OVERRIDE {} 114 virtual void CancelRequest() const OVERRIDE {}
117 virtual std::string DebugString() const OVERRIDE { 115 virtual std::string DebugString() const OVERRIDE {
118 return "Null DownloadRequestHandle"; 116 return "Null DownloadRequestHandle";
119 } 117 }
120 }; 118 };
121 119
122 } // namespace 120 } // namespace
123 121
124 namespace content { 122 namespace content {
125 123
126 // Our download table ID starts at 1, so we use 0 to represent a download that
127 // has started, but has not yet had its data persisted in the table. We use fake
128 // database handles in incognito mode starting at -1 and progressively getting
129 // more negative.
130 // static
131 const int DownloadItem::kUninitializedHandle = 0;
132
133 const char DownloadItem::kEmptyFileHash[] = ""; 124 const char DownloadItem::kEmptyFileHash[] = "";
134 125
135 } 126 }
136 127
137 // Our download table ID starts at 1, so we use 0 to represent a download that 128 // Our download table ID starts at 1, so we use 0 to represent a download that
138 // has started, but has not yet had its data persisted in the table. We use fake 129 // has started, but has not yet had its data persisted in the table. We use fake
139 // database handles in incognito mode starting at -1 and progressively getting 130 // database handles in incognito mode starting at -1 and progressively getting
140 // more negative. 131 // more negative.
141 132
142 // Constructor for reading from the history service. 133 // Constructor for reading from the history service.
143 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate, 134 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
144 DownloadId download_id, 135 DownloadId download_id,
145 const DownloadPersistentStoreInfo& info, 136 const FilePath& path,
137 const GURL& url,
138 const GURL& referrer_url,
139 const base::Time& start_time,
140 const base::Time& end_time,
141 int64 received_bytes,
142 int64 total_bytes,
143 DownloadItem::DownloadState state,
144 bool opened,
146 const net::BoundNetLog& bound_net_log) 145 const net::BoundNetLog& bound_net_log)
147 : download_id_(download_id), 146 : download_id_(download_id),
148 current_path_(info.path), 147 current_path_(path),
149 target_path_(info.path), 148 target_path_(path),
150 target_disposition_(TARGET_DISPOSITION_OVERWRITE), 149 target_disposition_(TARGET_DISPOSITION_OVERWRITE),
151 url_chain_(1, info.url), 150 url_chain_(1, url),
152 referrer_url_(info.referrer_url), 151 referrer_url_(referrer_url),
153 transition_type_(content::PAGE_TRANSITION_LINK), 152 transition_type_(content::PAGE_TRANSITION_LINK),
154 has_user_gesture_(false), 153 has_user_gesture_(false),
155 total_bytes_(info.total_bytes), 154 total_bytes_(total_bytes),
156 received_bytes_(info.received_bytes), 155 received_bytes_(received_bytes),
157 bytes_per_sec_(0), 156 bytes_per_sec_(0),
158 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 157 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
159 start_tick_(base::TimeTicks()), 158 start_tick_(base::TimeTicks()),
160 state_(info.state), 159 state_(state),
161 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 160 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
162 start_time_(info.start_time), 161 start_time_(start_time),
163 end_time_(info.end_time), 162 end_time_(end_time),
164 db_handle_(info.db_handle),
165 delegate_(delegate), 163 delegate_(delegate),
166 is_paused_(false), 164 is_paused_(false),
167 open_when_complete_(false), 165 open_when_complete_(false),
168 file_externally_removed_(false), 166 file_externally_removed_(false),
169 safety_state_(SAFE), 167 safety_state_(SAFE),
170 auto_opened_(false), 168 auto_opened_(false),
171 is_persisted_(true),
172 is_temporary_(false), 169 is_temporary_(false),
173 all_data_saved_(false), 170 all_data_saved_(false),
174 opened_(info.opened), 171 opened_(opened),
175 open_enabled_(true), 172 open_enabled_(true),
176 delegate_delayed_complete_(false), 173 delegate_delayed_complete_(false),
177 bound_net_log_(bound_net_log), 174 bound_net_log_(bound_net_log),
178 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 175 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
179 delegate_->Attach(); 176 delegate_->Attach();
180 if (IsInProgress()) 177 if (IsInProgress())
181 state_ = CANCELLED; 178 state_ = CANCELLED;
182 if (IsComplete()) 179 if (IsComplete())
183 all_data_saved_ = true; 180 all_data_saved_ = true;
184 Init(false /* not actively downloading */, 181 Init(false /* not actively downloading */,
(...skipping 23 matching lines...) Expand all
208 referrer_charset_(info.referrer_charset), 205 referrer_charset_(info.referrer_charset),
209 remote_address_(info.remote_address), 206 remote_address_(info.remote_address),
210 total_bytes_(info.total_bytes), 207 total_bytes_(info.total_bytes),
211 received_bytes_(0), 208 received_bytes_(0),
212 bytes_per_sec_(0), 209 bytes_per_sec_(0),
213 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 210 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
214 start_tick_(base::TimeTicks::Now()), 211 start_tick_(base::TimeTicks::Now()),
215 state_(IN_PROGRESS), 212 state_(IN_PROGRESS),
216 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 213 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
217 start_time_(info.start_time), 214 start_time_(info.start_time),
218 db_handle_(DownloadItem::kUninitializedHandle),
219 delegate_(delegate), 215 delegate_(delegate),
220 is_paused_(false), 216 is_paused_(false),
221 open_when_complete_(false), 217 open_when_complete_(false),
222 file_externally_removed_(false), 218 file_externally_removed_(false),
223 safety_state_(SAFE), 219 safety_state_(SAFE),
224 auto_opened_(false), 220 auto_opened_(false),
225 is_persisted_(false),
226 is_temporary_(!info.save_info.file_path.empty()), 221 is_temporary_(!info.save_info.file_path.empty()),
227 all_data_saved_(false), 222 all_data_saved_(false),
228 opened_(false), 223 opened_(false),
229 open_enabled_(true), 224 open_enabled_(true),
230 delegate_delayed_complete_(false), 225 delegate_delayed_complete_(false),
231 bound_net_log_(bound_net_log), 226 bound_net_log_(bound_net_log),
232 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 227 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
233 delegate_->Attach(); 228 delegate_->Attach();
234 Init(true /* actively downloading */, 229 Init(true /* actively downloading */,
235 download_net_logs::SRC_NEW_DOWNLOAD); 230 download_net_logs::SRC_NEW_DOWNLOAD);
(...skipping 27 matching lines...) Expand all
263 mime_type_(mime_type), 258 mime_type_(mime_type),
264 original_mime_type_(mime_type), 259 original_mime_type_(mime_type),
265 total_bytes_(0), 260 total_bytes_(0),
266 received_bytes_(0), 261 received_bytes_(0),
267 bytes_per_sec_(0), 262 bytes_per_sec_(0),
268 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 263 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
269 start_tick_(base::TimeTicks::Now()), 264 start_tick_(base::TimeTicks::Now()),
270 state_(IN_PROGRESS), 265 state_(IN_PROGRESS),
271 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 266 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
272 start_time_(base::Time::Now()), 267 start_time_(base::Time::Now()),
273 db_handle_(DownloadItem::kUninitializedHandle),
274 delegate_(delegate), 268 delegate_(delegate),
275 is_paused_(false), 269 is_paused_(false),
276 open_when_complete_(false), 270 open_when_complete_(false),
277 file_externally_removed_(false), 271 file_externally_removed_(false),
278 safety_state_(SAFE), 272 safety_state_(SAFE),
279 auto_opened_(false), 273 auto_opened_(false),
280 is_persisted_(false),
281 is_temporary_(false), 274 is_temporary_(false),
282 all_data_saved_(false), 275 all_data_saved_(false),
283 opened_(false), 276 opened_(false),
284 open_enabled_(true), 277 open_enabled_(true),
285 delegate_delayed_complete_(false), 278 delegate_delayed_complete_(false),
286 bound_net_log_(bound_net_log), 279 bound_net_log_(bound_net_log),
287 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 280 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
288 delegate_->Attach(); 281 delegate_->Attach();
289 Init(true /* actively downloading */, 282 Init(true /* actively downloading */,
290 download_net_logs::SRC_SAVE_PAGE_AS); 283 download_net_logs::SRC_SAVE_PAGE_AS);
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 return (danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || 807 return (danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
815 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || 808 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL ||
816 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || 809 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT ||
817 danger_type_ == content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT); 810 danger_type_ == content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT);
818 #else 811 #else
819 return (danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || 812 return (danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
820 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL); 813 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL);
821 #endif 814 #endif
822 } 815 }
823 816
824 DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const {
825 // TODO(asanka): Persist GetTargetFilePath() as well.
826 return DownloadPersistentStoreInfo(GetFullPath(),
827 GetURL(),
828 GetReferrerUrl(),
829 GetStartTime(),
830 GetEndTime(),
831 GetReceivedBytes(),
832 GetTotalBytes(),
833 GetState(),
834 GetDbHandle(),
835 GetOpened());
836 }
837
838 WebContents* DownloadItemImpl::GetWebContents() const { 817 WebContents* DownloadItemImpl::GetWebContents() const {
839 // TODO(rdsmith): Remove null check after removing GetWebContents() from 818 // TODO(rdsmith): Remove null check after removing GetWebContents() from
840 // paths that might be used by DownloadItems created from history import. 819 // paths that might be used by DownloadItems created from history import.
841 // Currently such items have null request_handle_s, where other items 820 // Currently such items have null request_handle_s, where other items
842 // (regular and SavePackage downloads) have actual objects off the pointer. 821 // (regular and SavePackage downloads) have actual objects off the pointer.
843 if (request_handle_.get()) 822 if (request_handle_.get())
844 return request_handle_->GetWebContents(); 823 return request_handle_->GetWebContents();
845 return NULL; 824 return NULL;
846 } 825 }
847 826
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 938
960 bound_net_log_.BeginEvent( 939 bound_net_log_.BeginEvent(
961 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, 940 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE,
962 base::Bind(&download_net_logs::ItemActivatedCallback, 941 base::Bind(&download_net_logs::ItemActivatedCallback,
963 this, download_type, &file_name)); 942 this, download_type, &file_name));
964 943
965 // If this is not an active download, end the ACTIVE event now. 944 // If this is not an active download, end the ACTIVE event now.
966 if (!active) { 945 if (!active) {
967 bound_net_log_.AddEvent( 946 bound_net_log_.AddEvent(
968 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, 947 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY,
969 net::NetLog::Int64Callback("db_handle", db_handle_)); 948 net::NetLog::Int64Callback("id", GetId()));
970 949
971 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE); 950 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE);
972 } 951 }
973 952
974 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); 953 VLOG(20) << __FUNCTION__ << "() " << DebugString(true);
975 } 954 }
976 955
977 bool DownloadItemImpl::NeedsRename() const { 956 bool DownloadItemImpl::NeedsRename() const {
978 DCHECK(target_path_.DirName() == current_path_.DirName()); 957 DCHECK(target_path_.DirName() == current_path_.DirName());
979 return target_path_ != current_path_; 958 return target_path_ != current_path_;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 ++iter; 1002 ++iter;
1024 for ( ; verbose && (iter != last); ++iter) { 1003 for ( ; verbose && (iter != last); ++iter) {
1025 url_list += " ->\n\t"; 1004 url_list += " ->\n\t";
1026 const GURL& next_url = *iter; 1005 const GURL& next_url = *iter;
1027 url_list += next_url.spec(); 1006 url_list += next_url.spec();
1028 } 1007 }
1029 } 1008 }
1030 1009
1031 if (verbose) { 1010 if (verbose) {
1032 description += base::StringPrintf( 1011 description += base::StringPrintf(
1033 " db_handle = %" PRId64
1034 " total = %" PRId64 1012 " total = %" PRId64
1035 " received = %" PRId64 1013 " received = %" PRId64
1036 " reason = %s" 1014 " reason = %s"
1037 " paused = %c" 1015 " paused = %c"
1038 " safety = %s" 1016 " safety = %s"
1039 " last_modified = '%s'" 1017 " last_modified = '%s'"
1040 " etag = '%s'" 1018 " etag = '%s'"
1041 " url_chain = \n\t\"%s\"\n\t" 1019 " url_chain = \n\t\"%s\"\n\t"
1042 " full_path = \"%" PRFilePath "\"" 1020 " full_path = \"%" PRFilePath "\""
1043 " target_path = \"%" PRFilePath "\"", 1021 " target_path = \"%" PRFilePath "\"",
1044 GetDbHandle(),
1045 GetTotalBytes(), 1022 GetTotalBytes(),
1046 GetReceivedBytes(), 1023 GetReceivedBytes(),
1047 InterruptReasonDebugString(last_reason_).c_str(), 1024 InterruptReasonDebugString(last_reason_).c_str(),
1048 IsPaused() ? 'T' : 'F', 1025 IsPaused() ? 'T' : 'F',
1049 DebugSafetyStateString(GetSafetyState()), 1026 DebugSafetyStateString(GetSafetyState()),
1050 GetLastModifiedTime().c_str(), 1027 GetLastModifiedTime().c_str(),
1051 GetETag().c_str(), 1028 GetETag().c_str(),
1052 url_list.c_str(), 1029 url_list.c_str(),
1053 GetFullPath().value().c_str(), 1030 GetFullPath().value().c_str(),
1054 GetTargetFilePath().value().c_str()); 1031 GetTargetFilePath().value().c_str());
1055 } else { 1032 } else {
1056 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); 1033 description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
1057 } 1034 }
1058 1035
1059 description += " }"; 1036 description += " }";
1060 1037
1061 return description; 1038 return description;
1062 } 1039 }
1063 1040
1064 bool DownloadItemImpl::AllDataSaved() const { return all_data_saved_; } 1041 bool DownloadItemImpl::AllDataSaved() const { return all_data_saved_; }
1042
1065 DownloadItem::DownloadState DownloadItemImpl::GetState() const { 1043 DownloadItem::DownloadState DownloadItemImpl::GetState() const {
1066 return state_; 1044 return state_;
1067 } 1045 }
1046
1068 const std::vector<GURL>& DownloadItemImpl::GetUrlChain() const { 1047 const std::vector<GURL>& DownloadItemImpl::GetUrlChain() const {
1069 return url_chain_; 1048 return url_chain_;
1070 } 1049 }
1050
1071 const GURL& DownloadItemImpl::GetOriginalUrl() const { 1051 const GURL& DownloadItemImpl::GetOriginalUrl() const {
1072 return url_chain_.front(); 1052 return url_chain_.front();
1073 } 1053 }
1054
1074 const GURL& DownloadItemImpl::GetReferrerUrl() const { return referrer_url_; } 1055 const GURL& DownloadItemImpl::GetReferrerUrl() const { return referrer_url_; }
1056
1075 std::string DownloadItemImpl::GetSuggestedFilename() const { 1057 std::string DownloadItemImpl::GetSuggestedFilename() const {
1076 return suggested_filename_; 1058 return suggested_filename_;
1077 } 1059 }
1060
1078 std::string DownloadItemImpl::GetContentDisposition() const { 1061 std::string DownloadItemImpl::GetContentDisposition() const {
1079 return content_disposition_; 1062 return content_disposition_;
1080 } 1063 }
1064
1081 std::string DownloadItemImpl::GetMimeType() const { return mime_type_; } 1065 std::string DownloadItemImpl::GetMimeType() const { return mime_type_; }
1066
1082 std::string DownloadItemImpl::GetOriginalMimeType() const { 1067 std::string DownloadItemImpl::GetOriginalMimeType() const {
1083 return original_mime_type_; 1068 return original_mime_type_;
1084 } 1069 }
1070
1085 std::string DownloadItemImpl::GetReferrerCharset() const { 1071 std::string DownloadItemImpl::GetReferrerCharset() const {
1086 return referrer_charset_; 1072 return referrer_charset_;
1087 } 1073 }
1074
1088 std::string DownloadItemImpl::GetRemoteAddress() const { 1075 std::string DownloadItemImpl::GetRemoteAddress() const {
1089 return remote_address_; 1076 return remote_address_;
1090 } 1077 }
1078
1091 int64 DownloadItemImpl::GetTotalBytes() const { return total_bytes_; } 1079 int64 DownloadItemImpl::GetTotalBytes() const { return total_bytes_; }
1080
1092 void DownloadItemImpl::SetTotalBytes(int64 total_bytes) { 1081 void DownloadItemImpl::SetTotalBytes(int64 total_bytes) {
1093 total_bytes_ = total_bytes; 1082 total_bytes_ = total_bytes;
1094 } 1083 }
1084
1095 const std::string& DownloadItemImpl::GetHash() const { return hash_; } 1085 const std::string& DownloadItemImpl::GetHash() const { return hash_; }
1086
1096 int64 DownloadItemImpl::GetReceivedBytes() const { return received_bytes_; } 1087 int64 DownloadItemImpl::GetReceivedBytes() const { return received_bytes_; }
1088
1097 const std::string& DownloadItemImpl::GetHashState() const { 1089 const std::string& DownloadItemImpl::GetHashState() const {
1098 return hash_state_; 1090 return hash_state_;
1099 } 1091 }
1092
1100 int32 DownloadItemImpl::GetId() const { return download_id_.local(); } 1093 int32 DownloadItemImpl::GetId() const { return download_id_.local(); }
1094
1101 DownloadId DownloadItemImpl::GetGlobalId() const { return download_id_; } 1095 DownloadId DownloadItemImpl::GetGlobalId() const { return download_id_; }
1096
1102 base::Time DownloadItemImpl::GetStartTime() const { return start_time_; } 1097 base::Time DownloadItemImpl::GetStartTime() const { return start_time_; }
1098
1103 base::Time DownloadItemImpl::GetEndTime() const { return end_time_; } 1099 base::Time DownloadItemImpl::GetEndTime() const { return end_time_; }
1104 1100
1105 void DownloadItemImpl::SetIsPersisted() { 1101 bool DownloadItemImpl::IsPaused() const { return is_paused_; }
1106 is_persisted_ = true;
1107 }
1108 1102
1109 bool DownloadItemImpl::IsPersisted() const {
1110 return is_persisted_;
1111 }
1112
1113 void DownloadItemImpl::SetDbHandle(int64 handle) {
1114 db_handle_ = handle;
1115
1116 bound_net_log_.AddEvent(
1117 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY,
1118 net::NetLog::Int64Callback("db_handle", db_handle_));
1119 }
1120
1121 int64 DownloadItemImpl::GetDbHandle() const { return db_handle_; }
1122 bool DownloadItemImpl::IsPaused() const { return is_paused_; }
1123 bool DownloadItemImpl::GetOpenWhenComplete() const { 1103 bool DownloadItemImpl::GetOpenWhenComplete() const {
1124 return open_when_complete_; 1104 return open_when_complete_;
1125 } 1105 }
1106
1126 void DownloadItemImpl::SetOpenWhenComplete(bool open) { 1107 void DownloadItemImpl::SetOpenWhenComplete(bool open) {
1127 open_when_complete_ = open; 1108 open_when_complete_ = open;
1128 } 1109 }
1110
1129 bool DownloadItemImpl::GetFileExternallyRemoved() const { 1111 bool DownloadItemImpl::GetFileExternallyRemoved() const {
1130 return file_externally_removed_; 1112 return file_externally_removed_;
1131 } 1113 }
1114
1132 DownloadItem::SafetyState DownloadItemImpl::GetSafetyState() const { 1115 DownloadItem::SafetyState DownloadItemImpl::GetSafetyState() const {
1133 return safety_state_; 1116 return safety_state_;
1134 } 1117 }
1135 bool DownloadItemImpl::GetAutoOpened() { return auto_opened_; } 1118 bool DownloadItemImpl::GetAutoOpened() { return auto_opened_; }
1119
1136 FilePath DownloadItemImpl::GetTargetName() const { 1120 FilePath DownloadItemImpl::GetTargetName() const {
1137 return target_path_.BaseName(); 1121 return target_path_.BaseName();
1138 } 1122 }
1123
1139 const FilePath& DownloadItemImpl::GetForcedFilePath() const { 1124 const FilePath& DownloadItemImpl::GetForcedFilePath() const {
1140 // TODO(asanka): Get rid of GetForcedFilePath(). We should instead just 1125 // TODO(asanka): Get rid of GetForcedFilePath(). We should instead just
1141 // require that clients respect GetTargetFilePath() if it is already set. 1126 // require that clients respect GetTargetFilePath() if it is already set.
1142 return forced_file_path_; 1127 return forced_file_path_;
1143 } 1128 }
1129
1144 bool DownloadItemImpl::HasUserGesture() const { 1130 bool DownloadItemImpl::HasUserGesture() const {
1145 return has_user_gesture_; 1131 return has_user_gesture_;
1146 }; 1132 };
1133
1147 content::PageTransition DownloadItemImpl::GetTransitionType() const { 1134 content::PageTransition DownloadItemImpl::GetTransitionType() const {
1148 return transition_type_; 1135 return transition_type_;
1149 }; 1136 };
1137
1150 bool DownloadItemImpl::IsTemporary() const { return is_temporary_; } 1138 bool DownloadItemImpl::IsTemporary() const { return is_temporary_; }
1139
1151 void DownloadItemImpl::SetIsTemporary(bool temporary) { 1140 void DownloadItemImpl::SetIsTemporary(bool temporary) {
1152 is_temporary_ = temporary; 1141 is_temporary_ = temporary;
1153 } 1142 }
1143
1154 void DownloadItemImpl::SetOpened(bool opened) { opened_ = opened; } 1144 void DownloadItemImpl::SetOpened(bool opened) { opened_ = opened; }
1145
1155 bool DownloadItemImpl::GetOpened() const { return opened_; } 1146 bool DownloadItemImpl::GetOpened() const { return opened_; }
1147
1156 const std::string& DownloadItemImpl::GetLastModifiedTime() const { 1148 const std::string& DownloadItemImpl::GetLastModifiedTime() const {
1157 return last_modified_time_; 1149 return last_modified_time_;
1158 } 1150 }
1151
1159 const std::string& DownloadItemImpl::GetETag() const { return etag_; } 1152 const std::string& DownloadItemImpl::GetETag() const { return etag_; }
1153
1160 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const { 1154 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const {
1161 return last_reason_; 1155 return last_reason_;
1162 } 1156 }
1157
1163 void DownloadItemImpl::MockDownloadOpenForTesting() { open_enabled_ = false; } 1158 void DownloadItemImpl::MockDownloadOpenForTesting() { open_enabled_ = false; }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698