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

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, 4 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 124 // 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 125 // 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 126 // database handles in incognito mode starting at -1 and progressively getting
129 // more negative. 127 // more negative.
130 // static 128 // static
131 const int DownloadItem::kUninitializedHandle = 0; 129 const int DownloadItem::kUninitializedHandle = 0;
Randy Smith (Not in Mondays) 2012/08/20 18:57:04 Shouldn't this be nuked as well?
benjhayden 2012/08/24 15:32:15 Done.
132 130
133 const char DownloadItem::kEmptyFileHash[] = ""; 131 const char DownloadItem::kEmptyFileHash[] = "";
134 132
135 } 133 }
136 134
137 // Our download table ID starts at 1, so we use 0 to represent a download that 135 // 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 136 // 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 137 // database handles in incognito mode starting at -1 and progressively getting
140 // more negative. 138 // more negative.
141 139
142 // Constructor for reading from the history service. 140 // Constructor for reading from the history service.
143 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate, 141 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
144 DownloadId download_id, 142 DownloadId download_id,
145 const DownloadPersistentStoreInfo& info, 143 const FilePath& path,
144 const GURL& url,
145 const GURL& referrer_url,
146 const base::Time& start_time,
147 const base::Time& end_time,
148 int64 received_bytes,
149 int64 total_bytes,
150 DownloadItem::DownloadState state,
151 bool opened,
146 const net::BoundNetLog& bound_net_log) 152 const net::BoundNetLog& bound_net_log)
147 : download_id_(download_id), 153 : download_id_(download_id),
148 current_path_(info.path), 154 current_path_(path),
149 target_path_(info.path), 155 target_path_(path),
150 target_disposition_(TARGET_DISPOSITION_OVERWRITE), 156 target_disposition_(TARGET_DISPOSITION_OVERWRITE),
151 url_chain_(1, info.url), 157 url_chain_(1, url),
152 referrer_url_(info.referrer_url), 158 referrer_url_(referrer_url),
153 transition_type_(content::PAGE_TRANSITION_LINK), 159 transition_type_(content::PAGE_TRANSITION_LINK),
154 has_user_gesture_(false), 160 has_user_gesture_(false),
155 total_bytes_(info.total_bytes), 161 total_bytes_(total_bytes),
156 received_bytes_(info.received_bytes), 162 received_bytes_(received_bytes),
157 bytes_per_sec_(0), 163 bytes_per_sec_(0),
158 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 164 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
159 start_tick_(base::TimeTicks()), 165 start_tick_(base::TimeTicks()),
160 state_(info.state), 166 state_(state),
161 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 167 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
162 start_time_(info.start_time), 168 start_time_(start_time),
163 end_time_(info.end_time), 169 end_time_(end_time),
164 db_handle_(info.db_handle),
165 delegate_(delegate), 170 delegate_(delegate),
166 is_paused_(false), 171 is_paused_(false),
167 open_when_complete_(false), 172 open_when_complete_(false),
168 file_externally_removed_(false), 173 file_externally_removed_(false),
169 safety_state_(SAFE), 174 safety_state_(SAFE),
170 auto_opened_(false), 175 auto_opened_(false),
171 is_persisted_(true),
172 is_temporary_(false), 176 is_temporary_(false),
173 all_data_saved_(false), 177 all_data_saved_(false),
174 opened_(info.opened), 178 opened_(opened),
175 open_enabled_(true), 179 open_enabled_(true),
176 delegate_delayed_complete_(false), 180 delegate_delayed_complete_(false),
177 bound_net_log_(bound_net_log), 181 bound_net_log_(bound_net_log),
178 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 182 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
179 delegate_->Attach(); 183 delegate_->Attach();
180 if (IsInProgress()) 184 if (IsInProgress())
181 state_ = CANCELLED; 185 state_ = CANCELLED;
182 if (IsComplete()) 186 if (IsComplete())
183 all_data_saved_ = true; 187 all_data_saved_ = true;
184 Init(false /* not actively downloading */, 188 Init(false /* not actively downloading */,
(...skipping 23 matching lines...) Expand all
208 referrer_charset_(info.referrer_charset), 212 referrer_charset_(info.referrer_charset),
209 remote_address_(info.remote_address), 213 remote_address_(info.remote_address),
210 total_bytes_(info.total_bytes), 214 total_bytes_(info.total_bytes),
211 received_bytes_(0), 215 received_bytes_(0),
212 bytes_per_sec_(0), 216 bytes_per_sec_(0),
213 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 217 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
214 start_tick_(base::TimeTicks::Now()), 218 start_tick_(base::TimeTicks::Now()),
215 state_(IN_PROGRESS), 219 state_(IN_PROGRESS),
216 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 220 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
217 start_time_(info.start_time), 221 start_time_(info.start_time),
218 db_handle_(DownloadItem::kUninitializedHandle),
219 delegate_(delegate), 222 delegate_(delegate),
220 is_paused_(false), 223 is_paused_(false),
221 open_when_complete_(false), 224 open_when_complete_(false),
222 file_externally_removed_(false), 225 file_externally_removed_(false),
223 safety_state_(SAFE), 226 safety_state_(SAFE),
224 auto_opened_(false), 227 auto_opened_(false),
225 is_persisted_(false),
226 is_temporary_(!info.save_info.file_path.empty()), 228 is_temporary_(!info.save_info.file_path.empty()),
227 all_data_saved_(false), 229 all_data_saved_(false),
228 opened_(false), 230 opened_(false),
229 open_enabled_(true), 231 open_enabled_(true),
230 delegate_delayed_complete_(false), 232 delegate_delayed_complete_(false),
231 bound_net_log_(bound_net_log), 233 bound_net_log_(bound_net_log),
232 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 234 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
233 delegate_->Attach(); 235 delegate_->Attach();
234 Init(true /* actively downloading */, 236 Init(true /* actively downloading */,
235 download_net_logs::SRC_NEW_DOWNLOAD); 237 download_net_logs::SRC_NEW_DOWNLOAD);
(...skipping 27 matching lines...) Expand all
263 mime_type_(mime_type), 265 mime_type_(mime_type),
264 original_mime_type_(mime_type), 266 original_mime_type_(mime_type),
265 total_bytes_(0), 267 total_bytes_(0),
266 received_bytes_(0), 268 received_bytes_(0),
267 bytes_per_sec_(0), 269 bytes_per_sec_(0),
268 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 270 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
269 start_tick_(base::TimeTicks::Now()), 271 start_tick_(base::TimeTicks::Now()),
270 state_(IN_PROGRESS), 272 state_(IN_PROGRESS),
271 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 273 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
272 start_time_(base::Time::Now()), 274 start_time_(base::Time::Now()),
273 db_handle_(DownloadItem::kUninitializedHandle),
274 delegate_(delegate), 275 delegate_(delegate),
275 is_paused_(false), 276 is_paused_(false),
276 open_when_complete_(false), 277 open_when_complete_(false),
277 file_externally_removed_(false), 278 file_externally_removed_(false),
278 safety_state_(SAFE), 279 safety_state_(SAFE),
279 auto_opened_(false), 280 auto_opened_(false),
280 is_persisted_(false),
281 is_temporary_(false), 281 is_temporary_(false),
282 all_data_saved_(false), 282 all_data_saved_(false),
283 opened_(false), 283 opened_(false),
284 open_enabled_(true), 284 open_enabled_(true),
285 delegate_delayed_complete_(false), 285 delegate_delayed_complete_(false),
286 bound_net_log_(bound_net_log), 286 bound_net_log_(bound_net_log),
287 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 287 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
288 delegate_->Attach(); 288 delegate_->Attach();
289 Init(true /* actively downloading */, 289 Init(true /* actively downloading */,
290 download_net_logs::SRC_SAVE_PAGE_AS); 290 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 || 814 return (danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
815 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || 815 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL ||
816 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || 816 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT ||
817 danger_type_ == content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT); 817 danger_type_ == content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT);
818 #else 818 #else
819 return (danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || 819 return (danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
820 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL); 820 danger_type_ == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL);
821 #endif 821 #endif
822 } 822 }
823 823
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 { 824 WebContents* DownloadItemImpl::GetWebContents() const {
839 // TODO(rdsmith): Remove null check after removing GetWebContents() from 825 // TODO(rdsmith): Remove null check after removing GetWebContents() from
840 // paths that might be used by DownloadItems created from history import. 826 // paths that might be used by DownloadItems created from history import.
841 // Currently such items have null request_handle_s, where other items 827 // Currently such items have null request_handle_s, where other items
842 // (regular and SavePackage downloads) have actual objects off the pointer. 828 // (regular and SavePackage downloads) have actual objects off the pointer.
843 if (request_handle_.get()) 829 if (request_handle_.get())
844 return request_handle_->GetWebContents(); 830 return request_handle_->GetWebContents();
845 return NULL; 831 return NULL;
846 } 832 }
847 833
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 945
960 bound_net_log_.BeginEvent( 946 bound_net_log_.BeginEvent(
961 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, 947 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE,
962 base::Bind(&download_net_logs::ItemActivatedCallback, 948 base::Bind(&download_net_logs::ItemActivatedCallback,
963 this, download_type, &file_name)); 949 this, download_type, &file_name));
964 950
965 // If this is not an active download, end the ACTIVE event now. 951 // If this is not an active download, end the ACTIVE event now.
966 if (!active) { 952 if (!active) {
967 bound_net_log_.AddEvent( 953 bound_net_log_.AddEvent(
968 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, 954 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY,
969 net::NetLog::Int64Callback("db_handle", db_handle_)); 955 net::NetLog::Int64Callback("id", GetId()));
970 956
971 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE); 957 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE);
972 } 958 }
973 959
974 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); 960 VLOG(20) << __FUNCTION__ << "() " << DebugString(true);
975 } 961 }
976 962
977 bool DownloadItemImpl::NeedsRename() const { 963 bool DownloadItemImpl::NeedsRename() const {
978 DCHECK(target_path_.DirName() == current_path_.DirName()); 964 DCHECK(target_path_.DirName() == current_path_.DirName());
979 return target_path_ != current_path_; 965 return target_path_ != current_path_;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 ++iter; 1009 ++iter;
1024 for ( ; verbose && (iter != last); ++iter) { 1010 for ( ; verbose && (iter != last); ++iter) {
1025 url_list += " ->\n\t"; 1011 url_list += " ->\n\t";
1026 const GURL& next_url = *iter; 1012 const GURL& next_url = *iter;
1027 url_list += next_url.spec(); 1013 url_list += next_url.spec();
1028 } 1014 }
1029 } 1015 }
1030 1016
1031 if (verbose) { 1017 if (verbose) {
1032 description += base::StringPrintf( 1018 description += base::StringPrintf(
1033 " db_handle = %" PRId64
1034 " total = %" PRId64 1019 " total = %" PRId64
1035 " received = %" PRId64 1020 " received = %" PRId64
1036 " reason = %s" 1021 " reason = %s"
1037 " paused = %c" 1022 " paused = %c"
1038 " safety = %s" 1023 " safety = %s"
1039 " last_modified = '%s'" 1024 " last_modified = '%s'"
1040 " etag = '%s'" 1025 " etag = '%s'"
1041 " url_chain = \n\t\"%s\"\n\t" 1026 " url_chain = \n\t\"%s\"\n\t"
1042 " full_path = \"%" PRFilePath "\"" 1027 " full_path = \"%" PRFilePath "\""
1043 " target_path = \"%" PRFilePath "\"", 1028 " target_path = \"%" PRFilePath "\"",
1044 GetDbHandle(),
1045 GetTotalBytes(), 1029 GetTotalBytes(),
1046 GetReceivedBytes(), 1030 GetReceivedBytes(),
1047 InterruptReasonDebugString(last_reason_).c_str(), 1031 InterruptReasonDebugString(last_reason_).c_str(),
1048 IsPaused() ? 'T' : 'F', 1032 IsPaused() ? 'T' : 'F',
1049 DebugSafetyStateString(GetSafetyState()), 1033 DebugSafetyStateString(GetSafetyState()),
1050 GetLastModifiedTime().c_str(), 1034 GetLastModifiedTime().c_str(),
1051 GetETag().c_str(), 1035 GetETag().c_str(),
1052 url_list.c_str(), 1036 url_list.c_str(),
1053 GetFullPath().value().c_str(), 1037 GetFullPath().value().c_str(),
1054 GetTargetFilePath().value().c_str()); 1038 GetTargetFilePath().value().c_str());
1055 } else { 1039 } else {
1056 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); 1040 description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
1057 } 1041 }
1058 1042
1059 description += " }"; 1043 description += " }";
1060 1044
1061 return description; 1045 return description;
1062 } 1046 }
1063 1047
1064 bool DownloadItemImpl::AllDataSaved() const { return all_data_saved_; } 1048 bool DownloadItemImpl::AllDataSaved() const { return all_data_saved_; }
1049
1065 DownloadItem::DownloadState DownloadItemImpl::GetState() const { 1050 DownloadItem::DownloadState DownloadItemImpl::GetState() const {
1066 return state_; 1051 return state_;
1067 } 1052 }
1053
1068 const std::vector<GURL>& DownloadItemImpl::GetUrlChain() const { 1054 const std::vector<GURL>& DownloadItemImpl::GetUrlChain() const {
1069 return url_chain_; 1055 return url_chain_;
1070 } 1056 }
1057
1071 const GURL& DownloadItemImpl::GetOriginalUrl() const { 1058 const GURL& DownloadItemImpl::GetOriginalUrl() const {
1072 return url_chain_.front(); 1059 return url_chain_.front();
1073 } 1060 }
1061
1074 const GURL& DownloadItemImpl::GetReferrerUrl() const { return referrer_url_; } 1062 const GURL& DownloadItemImpl::GetReferrerUrl() const { return referrer_url_; }
1063
1075 std::string DownloadItemImpl::GetSuggestedFilename() const { 1064 std::string DownloadItemImpl::GetSuggestedFilename() const {
1076 return suggested_filename_; 1065 return suggested_filename_;
1077 } 1066 }
1067
1078 std::string DownloadItemImpl::GetContentDisposition() const { 1068 std::string DownloadItemImpl::GetContentDisposition() const {
1079 return content_disposition_; 1069 return content_disposition_;
1080 } 1070 }
1071
1081 std::string DownloadItemImpl::GetMimeType() const { return mime_type_; } 1072 std::string DownloadItemImpl::GetMimeType() const { return mime_type_; }
1073
1082 std::string DownloadItemImpl::GetOriginalMimeType() const { 1074 std::string DownloadItemImpl::GetOriginalMimeType() const {
1083 return original_mime_type_; 1075 return original_mime_type_;
1084 } 1076 }
1077
1085 std::string DownloadItemImpl::GetReferrerCharset() const { 1078 std::string DownloadItemImpl::GetReferrerCharset() const {
1086 return referrer_charset_; 1079 return referrer_charset_;
1087 } 1080 }
1081
1088 std::string DownloadItemImpl::GetRemoteAddress() const { 1082 std::string DownloadItemImpl::GetRemoteAddress() const {
1089 return remote_address_; 1083 return remote_address_;
1090 } 1084 }
1085
1091 int64 DownloadItemImpl::GetTotalBytes() const { return total_bytes_; } 1086 int64 DownloadItemImpl::GetTotalBytes() const { return total_bytes_; }
1087
1092 void DownloadItemImpl::SetTotalBytes(int64 total_bytes) { 1088 void DownloadItemImpl::SetTotalBytes(int64 total_bytes) {
1093 total_bytes_ = total_bytes; 1089 total_bytes_ = total_bytes;
1094 } 1090 }
1091
1095 const std::string& DownloadItemImpl::GetHash() const { return hash_; } 1092 const std::string& DownloadItemImpl::GetHash() const { return hash_; }
1093
1096 int64 DownloadItemImpl::GetReceivedBytes() const { return received_bytes_; } 1094 int64 DownloadItemImpl::GetReceivedBytes() const { return received_bytes_; }
1095
1097 const std::string& DownloadItemImpl::GetHashState() const { 1096 const std::string& DownloadItemImpl::GetHashState() const {
1098 return hash_state_; 1097 return hash_state_;
1099 } 1098 }
1099
1100 int32 DownloadItemImpl::GetId() const { return download_id_.local(); } 1100 int32 DownloadItemImpl::GetId() const { return download_id_.local(); }
1101
1101 DownloadId DownloadItemImpl::GetGlobalId() const { return download_id_; } 1102 DownloadId DownloadItemImpl::GetGlobalId() const { return download_id_; }
1103
1102 base::Time DownloadItemImpl::GetStartTime() const { return start_time_; } 1104 base::Time DownloadItemImpl::GetStartTime() const { return start_time_; }
1105
1103 base::Time DownloadItemImpl::GetEndTime() const { return end_time_; } 1106 base::Time DownloadItemImpl::GetEndTime() const { return end_time_; }
1104 1107
1105 void DownloadItemImpl::SetIsPersisted() { 1108 bool DownloadItemImpl::IsPaused() const { return is_paused_; }
1106 is_persisted_ = true;
1107 }
1108 1109
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 { 1110 bool DownloadItemImpl::GetOpenWhenComplete() const {
1124 return open_when_complete_; 1111 return open_when_complete_;
1125 } 1112 }
1113
1126 void DownloadItemImpl::SetOpenWhenComplete(bool open) { 1114 void DownloadItemImpl::SetOpenWhenComplete(bool open) {
1127 open_when_complete_ = open; 1115 open_when_complete_ = open;
1128 } 1116 }
1117
1129 bool DownloadItemImpl::GetFileExternallyRemoved() const { 1118 bool DownloadItemImpl::GetFileExternallyRemoved() const {
1130 return file_externally_removed_; 1119 return file_externally_removed_;
1131 } 1120 }
1121
1132 DownloadItem::SafetyState DownloadItemImpl::GetSafetyState() const { 1122 DownloadItem::SafetyState DownloadItemImpl::GetSafetyState() const {
1133 return safety_state_; 1123 return safety_state_;
1134 } 1124 }
1135 bool DownloadItemImpl::GetAutoOpened() { return auto_opened_; } 1125 bool DownloadItemImpl::GetAutoOpened() { return auto_opened_; }
1126
1136 FilePath DownloadItemImpl::GetTargetName() const { 1127 FilePath DownloadItemImpl::GetTargetName() const {
1137 return target_path_.BaseName(); 1128 return target_path_.BaseName();
1138 } 1129 }
1130
1139 const FilePath& DownloadItemImpl::GetForcedFilePath() const { 1131 const FilePath& DownloadItemImpl::GetForcedFilePath() const {
1140 // TODO(asanka): Get rid of GetForcedFilePath(). We should instead just 1132 // TODO(asanka): Get rid of GetForcedFilePath(). We should instead just
1141 // require that clients respect GetTargetFilePath() if it is already set. 1133 // require that clients respect GetTargetFilePath() if it is already set.
1142 return forced_file_path_; 1134 return forced_file_path_;
1143 } 1135 }
1136
1144 bool DownloadItemImpl::HasUserGesture() const { 1137 bool DownloadItemImpl::HasUserGesture() const {
1145 return has_user_gesture_; 1138 return has_user_gesture_;
1146 }; 1139 };
1140
1147 content::PageTransition DownloadItemImpl::GetTransitionType() const { 1141 content::PageTransition DownloadItemImpl::GetTransitionType() const {
1148 return transition_type_; 1142 return transition_type_;
1149 }; 1143 };
1144
1150 bool DownloadItemImpl::IsTemporary() const { return is_temporary_; } 1145 bool DownloadItemImpl::IsTemporary() const { return is_temporary_; }
1146
1151 void DownloadItemImpl::SetIsTemporary(bool temporary) { 1147 void DownloadItemImpl::SetIsTemporary(bool temporary) {
1152 is_temporary_ = temporary; 1148 is_temporary_ = temporary;
1153 } 1149 }
1150
1154 void DownloadItemImpl::SetOpened(bool opened) { opened_ = opened; } 1151 void DownloadItemImpl::SetOpened(bool opened) { opened_ = opened; }
1152
1155 bool DownloadItemImpl::GetOpened() const { return opened_; } 1153 bool DownloadItemImpl::GetOpened() const { return opened_; }
1154
1156 const std::string& DownloadItemImpl::GetLastModifiedTime() const { 1155 const std::string& DownloadItemImpl::GetLastModifiedTime() const {
1157 return last_modified_time_; 1156 return last_modified_time_;
1158 } 1157 }
1158
1159 const std::string& DownloadItemImpl::GetETag() const { return etag_; } 1159 const std::string& DownloadItemImpl::GetETag() const { return etag_; }
1160
1160 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const { 1161 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const {
1161 return last_reason_; 1162 return last_reason_;
1162 } 1163 }
1164
1163 void DownloadItemImpl::MockDownloadOpenForTesting() { open_enabled_ = false; } 1165 void DownloadItemImpl::MockDownloadOpenForTesting() { open_enabled_ = false; }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698