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

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

Issue 10805020: Kill DownloadItem::IsOtr() (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 8 years, 5 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"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 start_time_(info.start_time), 164 start_time_(info.start_time),
165 end_time_(info.end_time), 165 end_time_(info.end_time),
166 db_handle_(info.db_handle), 166 db_handle_(info.db_handle),
167 delegate_(delegate), 167 delegate_(delegate),
168 is_paused_(false), 168 is_paused_(false),
169 open_when_complete_(false), 169 open_when_complete_(false),
170 file_externally_removed_(false), 170 file_externally_removed_(false),
171 safety_state_(SAFE), 171 safety_state_(SAFE),
172 auto_opened_(false), 172 auto_opened_(false),
173 is_persisted_(true), 173 is_persisted_(true),
174 is_otr_(false),
175 is_temporary_(false), 174 is_temporary_(false),
176 all_data_saved_(false), 175 all_data_saved_(false),
177 opened_(info.opened), 176 opened_(info.opened),
178 open_enabled_(true), 177 open_enabled_(true),
179 delegate_delayed_complete_(false), 178 delegate_delayed_complete_(false),
180 bound_net_log_(bound_net_log), 179 bound_net_log_(bound_net_log),
181 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 180 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
182 delegate_->Attach(); 181 delegate_->Attach();
183 if (IsInProgress()) 182 if (IsInProgress())
184 state_ = CANCELLED; 183 state_ = CANCELLED;
185 if (IsComplete()) 184 if (IsComplete())
186 all_data_saved_ = true; 185 all_data_saved_ = true;
187 Init(false /* not actively downloading */, 186 Init(false /* not actively downloading */,
188 download_net_logs::SRC_HISTORY_IMPORT); 187 download_net_logs::SRC_HISTORY_IMPORT);
189 } 188 }
190 189
191 // Constructing for a regular download: 190 // Constructing for a regular download:
192 DownloadItemImpl::DownloadItemImpl( 191 DownloadItemImpl::DownloadItemImpl(
193 DownloadItemImplDelegate* delegate, 192 DownloadItemImplDelegate* delegate,
194 const DownloadCreateInfo& info, 193 const DownloadCreateInfo& info,
195 scoped_ptr<DownloadRequestHandleInterface> request_handle, 194 scoped_ptr<DownloadRequestHandleInterface> request_handle,
196 bool is_otr,
197 const net::BoundNetLog& bound_net_log) 195 const net::BoundNetLog& bound_net_log)
198 : request_handle_(request_handle.Pass()), 196 : request_handle_(request_handle.Pass()),
199 download_id_(info.download_id), 197 download_id_(info.download_id),
200 target_disposition_( 198 target_disposition_(
201 (info.prompt_user_for_save_location) ? 199 (info.prompt_user_for_save_location) ?
202 TARGET_DISPOSITION_PROMPT : TARGET_DISPOSITION_OVERWRITE), 200 TARGET_DISPOSITION_PROMPT : TARGET_DISPOSITION_OVERWRITE),
203 url_chain_(info.url_chain), 201 url_chain_(info.url_chain),
204 referrer_url_(info.referrer_url), 202 referrer_url_(info.referrer_url),
205 suggested_filename_(UTF16ToUTF8(info.save_info.suggested_name)), 203 suggested_filename_(UTF16ToUTF8(info.save_info.suggested_name)),
206 forced_file_path_(info.save_info.file_path), 204 forced_file_path_(info.save_info.file_path),
(...skipping 13 matching lines...) Expand all
220 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 218 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
221 start_time_(info.start_time), 219 start_time_(info.start_time),
222 db_handle_(DownloadItem::kUninitializedHandle), 220 db_handle_(DownloadItem::kUninitializedHandle),
223 delegate_(delegate), 221 delegate_(delegate),
224 is_paused_(false), 222 is_paused_(false),
225 open_when_complete_(false), 223 open_when_complete_(false),
226 file_externally_removed_(false), 224 file_externally_removed_(false),
227 safety_state_(SAFE), 225 safety_state_(SAFE),
228 auto_opened_(false), 226 auto_opened_(false),
229 is_persisted_(false), 227 is_persisted_(false),
230 is_otr_(is_otr),
231 is_temporary_(!info.save_info.file_path.empty()), 228 is_temporary_(!info.save_info.file_path.empty()),
232 all_data_saved_(false), 229 all_data_saved_(false),
233 opened_(false), 230 opened_(false),
234 open_enabled_(true), 231 open_enabled_(true),
235 delegate_delayed_complete_(false), 232 delegate_delayed_complete_(false),
236 bound_net_log_(bound_net_log), 233 bound_net_log_(bound_net_log),
237 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 234 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
238 delegate_->Attach(); 235 delegate_->Attach();
239 Init(true /* actively downloading */, 236 Init(true /* actively downloading */,
240 download_net_logs::SRC_NEW_DOWNLOAD); 237 download_net_logs::SRC_NEW_DOWNLOAD);
241 238
242 // Link the event sources. 239 // Link the event sources.
243 bound_net_log_.AddEvent( 240 bound_net_log_.AddEvent(
244 net::NetLog::TYPE_DOWNLOAD_URL_REQUEST, 241 net::NetLog::TYPE_DOWNLOAD_URL_REQUEST,
245 info.request_bound_net_log.source().ToEventParametersCallback()); 242 info.request_bound_net_log.source().ToEventParametersCallback());
246 243
247 info.request_bound_net_log.AddEvent( 244 info.request_bound_net_log.AddEvent(
248 net::NetLog::TYPE_DOWNLOAD_STARTED, 245 net::NetLog::TYPE_DOWNLOAD_STARTED,
249 bound_net_log_.source().ToEventParametersCallback()); 246 bound_net_log_.source().ToEventParametersCallback());
250 } 247 }
251 248
252 // Constructing for the "Save Page As..." feature: 249 // Constructing for the "Save Page As..." feature:
253 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate, 250 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
254 const FilePath& path, 251 const FilePath& path,
255 const GURL& url, 252 const GURL& url,
256 bool is_otr,
257 DownloadId download_id, 253 DownloadId download_id,
258 const std::string& mime_type, 254 const std::string& mime_type,
259 const net::BoundNetLog& bound_net_log) 255 const net::BoundNetLog& bound_net_log)
260 : request_handle_(new NullDownloadRequestHandle()), 256 : request_handle_(new NullDownloadRequestHandle()),
261 download_id_(download_id), 257 download_id_(download_id),
262 current_path_(path), 258 current_path_(path),
263 target_path_(path), 259 target_path_(path),
264 target_disposition_(TARGET_DISPOSITION_OVERWRITE), 260 target_disposition_(TARGET_DISPOSITION_OVERWRITE),
265 url_chain_(1, url), 261 url_chain_(1, url),
266 referrer_url_(GURL()), 262 referrer_url_(GURL()),
(...skipping 10 matching lines...) Expand all
277 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 273 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
278 start_time_(base::Time::Now()), 274 start_time_(base::Time::Now()),
279 db_handle_(DownloadItem::kUninitializedHandle), 275 db_handle_(DownloadItem::kUninitializedHandle),
280 delegate_(delegate), 276 delegate_(delegate),
281 is_paused_(false), 277 is_paused_(false),
282 open_when_complete_(false), 278 open_when_complete_(false),
283 file_externally_removed_(false), 279 file_externally_removed_(false),
284 safety_state_(SAFE), 280 safety_state_(SAFE),
285 auto_opened_(false), 281 auto_opened_(false),
286 is_persisted_(false), 282 is_persisted_(false),
287 is_otr_(is_otr),
288 is_temporary_(false), 283 is_temporary_(false),
289 all_data_saved_(false), 284 all_data_saved_(false),
290 opened_(false), 285 opened_(false),
291 open_enabled_(true), 286 open_enabled_(true),
292 delegate_delayed_complete_(false), 287 delegate_delayed_complete_(false),
293 bound_net_log_(bound_net_log), 288 bound_net_log_(bound_net_log),
294 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 289 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
295 delegate_->Attach(); 290 delegate_->Attach();
296 Init(true /* actively downloading */, 291 Init(true /* actively downloading */,
297 download_net_logs::SRC_SAVE_PAGE_AS); 292 download_net_logs::SRC_SAVE_PAGE_AS);
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 } 1024 }
1030 } 1025 }
1031 1026
1032 if (verbose) { 1027 if (verbose) {
1033 description += base::StringPrintf( 1028 description += base::StringPrintf(
1034 " db_handle = %" PRId64 1029 " db_handle = %" PRId64
1035 " total = %" PRId64 1030 " total = %" PRId64
1036 " received = %" PRId64 1031 " received = %" PRId64
1037 " reason = %s" 1032 " reason = %s"
1038 " paused = %c" 1033 " paused = %c"
1039 " otr = %c"
1040 " safety = %s" 1034 " safety = %s"
1041 " last_modified = '%s'" 1035 " last_modified = '%s'"
1042 " etag = '%s'" 1036 " etag = '%s'"
1043 " url_chain = \n\t\"%s\"\n\t" 1037 " url_chain = \n\t\"%s\"\n\t"
1044 " full_path = \"%" PRFilePath "\"" 1038 " full_path = \"%" PRFilePath "\""
1045 " target_path = \"%" PRFilePath "\"", 1039 " target_path = \"%" PRFilePath "\"",
1046 GetDbHandle(), 1040 GetDbHandle(),
1047 GetTotalBytes(), 1041 GetTotalBytes(),
1048 GetReceivedBytes(), 1042 GetReceivedBytes(),
1049 InterruptReasonDebugString(last_reason_).c_str(), 1043 InterruptReasonDebugString(last_reason_).c_str(),
1050 IsPaused() ? 'T' : 'F', 1044 IsPaused() ? 'T' : 'F',
1051 IsOtr() ? 'T' : 'F',
1052 DebugSafetyStateString(GetSafetyState()), 1045 DebugSafetyStateString(GetSafetyState()),
1053 GetLastModifiedTime().c_str(), 1046 GetLastModifiedTime().c_str(),
1054 GetETag().c_str(), 1047 GetETag().c_str(),
1055 url_list.c_str(), 1048 url_list.c_str(),
1056 GetFullPath().value().c_str(), 1049 GetFullPath().value().c_str(),
1057 GetTargetFilePath().value().c_str()); 1050 GetTargetFilePath().value().c_str());
1058 } else { 1051 } else {
1059 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); 1052 description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
1060 } 1053 }
1061 1054
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 } 1121 }
1129 void DownloadItemImpl::SetOpenWhenComplete(bool open) { 1122 void DownloadItemImpl::SetOpenWhenComplete(bool open) {
1130 open_when_complete_ = open; 1123 open_when_complete_ = open;
1131 } 1124 }
1132 bool DownloadItemImpl::GetFileExternallyRemoved() const { 1125 bool DownloadItemImpl::GetFileExternallyRemoved() const {
1133 return file_externally_removed_; 1126 return file_externally_removed_;
1134 } 1127 }
1135 DownloadItem::SafetyState DownloadItemImpl::GetSafetyState() const { 1128 DownloadItem::SafetyState DownloadItemImpl::GetSafetyState() const {
1136 return safety_state_; 1129 return safety_state_;
1137 } 1130 }
1138 bool DownloadItemImpl::IsOtr() const { return is_otr_; }
1139 bool DownloadItemImpl::GetAutoOpened() { return auto_opened_; } 1131 bool DownloadItemImpl::GetAutoOpened() { return auto_opened_; }
1140 FilePath DownloadItemImpl::GetTargetName() const { 1132 FilePath DownloadItemImpl::GetTargetName() const {
1141 return target_path_.BaseName(); 1133 return target_path_.BaseName();
1142 } 1134 }
1143 const FilePath& DownloadItemImpl::GetForcedFilePath() const { 1135 const FilePath& DownloadItemImpl::GetForcedFilePath() const {
1144 // TODO(asanka): Get rid of GetForcedFilePath(). We should instead just 1136 // TODO(asanka): Get rid of GetForcedFilePath(). We should instead just
1145 // require that clients respect GetTargetFilePath() if it is already set. 1137 // require that clients respect GetTargetFilePath() if it is already set.
1146 return forced_file_path_; 1138 return forced_file_path_;
1147 } 1139 }
1148 bool DownloadItemImpl::HasUserGesture() const { 1140 bool DownloadItemImpl::HasUserGesture() const {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 std::map<const void*, ExternalData*>::iterator it = 1178 std::map<const void*, ExternalData*>::iterator it =
1187 external_data_map_.find(key); 1179 external_data_map_.find(key);
1188 1180
1189 if (it == external_data_map_.end()) { 1181 if (it == external_data_map_.end()) {
1190 external_data_map_[key] = data; 1182 external_data_map_[key] = data;
1191 } else if (it->second != data) { 1183 } else if (it->second != data) {
1192 delete it->second; 1184 delete it->second;
1193 it->second = data; 1185 it->second = data;
1194 } 1186 }
1195 } 1187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698