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

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, 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"
(...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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 } 1029 }
1035 } 1030 }
1036 1031
1037 if (verbose) { 1032 if (verbose) {
1038 description += base::StringPrintf( 1033 description += base::StringPrintf(
1039 " db_handle = %" PRId64 1034 " db_handle = %" PRId64
1040 " total = %" PRId64 1035 " total = %" PRId64
1041 " received = %" PRId64 1036 " received = %" PRId64
1042 " reason = %s" 1037 " reason = %s"
1043 " paused = %c" 1038 " paused = %c"
1044 " otr = %c"
1045 " safety = %s" 1039 " safety = %s"
1046 " last_modified = '%s'" 1040 " last_modified = '%s'"
1047 " etag = '%s'" 1041 " etag = '%s'"
1048 " url_chain = \n\t\"%s\"\n\t" 1042 " url_chain = \n\t\"%s\"\n\t"
1049 " full_path = \"%" PRFilePath "\"" 1043 " full_path = \"%" PRFilePath "\""
1050 " target_path = \"%" PRFilePath "\"", 1044 " target_path = \"%" PRFilePath "\"",
1051 GetDbHandle(), 1045 GetDbHandle(),
1052 GetTotalBytes(), 1046 GetTotalBytes(),
1053 GetReceivedBytes(), 1047 GetReceivedBytes(),
1054 InterruptReasonDebugString(last_reason_).c_str(), 1048 InterruptReasonDebugString(last_reason_).c_str(),
1055 IsPaused() ? 'T' : 'F', 1049 IsPaused() ? 'T' : 'F',
1056 IsOtr() ? 'T' : 'F',
1057 DebugSafetyStateString(GetSafetyState()), 1050 DebugSafetyStateString(GetSafetyState()),
1058 GetLastModifiedTime().c_str(), 1051 GetLastModifiedTime().c_str(),
1059 GetETag().c_str(), 1052 GetETag().c_str(),
1060 url_list.c_str(), 1053 url_list.c_str(),
1061 GetFullPath().value().c_str(), 1054 GetFullPath().value().c_str(),
1062 GetTargetFilePath().value().c_str()); 1055 GetTargetFilePath().value().c_str());
1063 } else { 1056 } else {
1064 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); 1057 description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
1065 } 1058 }
1066 1059
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 } 1126 }
1134 void DownloadItemImpl::SetOpenWhenComplete(bool open) { 1127 void DownloadItemImpl::SetOpenWhenComplete(bool open) {
1135 open_when_complete_ = open; 1128 open_when_complete_ = open;
1136 } 1129 }
1137 bool DownloadItemImpl::GetFileExternallyRemoved() const { 1130 bool DownloadItemImpl::GetFileExternallyRemoved() const {
1138 return file_externally_removed_; 1131 return file_externally_removed_;
1139 } 1132 }
1140 DownloadItem::SafetyState DownloadItemImpl::GetSafetyState() const { 1133 DownloadItem::SafetyState DownloadItemImpl::GetSafetyState() const {
1141 return safety_state_; 1134 return safety_state_;
1142 } 1135 }
1143 bool DownloadItemImpl::IsOtr() const { return is_otr_; }
1144 bool DownloadItemImpl::GetAutoOpened() { return auto_opened_; } 1136 bool DownloadItemImpl::GetAutoOpened() { return auto_opened_; }
1145 FilePath DownloadItemImpl::GetTargetName() const { 1137 FilePath DownloadItemImpl::GetTargetName() const {
1146 return target_path_.BaseName(); 1138 return target_path_.BaseName();
1147 } 1139 }
1148 const FilePath& DownloadItemImpl::GetForcedFilePath() const { 1140 const FilePath& DownloadItemImpl::GetForcedFilePath() const {
1149 // TODO(asanka): Get rid of GetForcedFilePath(). We should instead just 1141 // TODO(asanka): Get rid of GetForcedFilePath(). We should instead just
1150 // require that clients respect GetTargetFilePath() if it is already set. 1142 // require that clients respect GetTargetFilePath() if it is already set.
1151 return forced_file_path_; 1143 return forced_file_path_;
1152 } 1144 }
1153 bool DownloadItemImpl::HasUserGesture() const { 1145 bool DownloadItemImpl::HasUserGesture() const {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 std::map<const void*, ExternalData*>::iterator it = 1183 std::map<const void*, ExternalData*>::iterator it =
1192 external_data_map_.find(key); 1184 external_data_map_.find(key);
1193 1185
1194 if (it == external_data_map_.end()) { 1186 if (it == external_data_map_.end()) {
1195 external_data_map_[key] = data; 1187 external_data_map_[key] = data;
1196 } else if (it->second != data) { 1188 } else if (it->second != data) {
1197 delete it->second; 1189 delete it->second;
1198 it->second = data; 1190 it->second = data;
1199 } 1191 }
1200 } 1192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698