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

Side by Side Diff: chrome/browser/download/download_item.cc

Issue 6932046: Added DownloadProcessHandle class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: download_process_handle Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/download/download_item.h" 5 #include "chrome/browser/download/download_item.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 state_(static_cast<DownloadState>(info.state)), 128 state_(static_cast<DownloadState>(info.state)),
129 start_time_(info.start_time), 129 start_time_(info.start_time),
130 db_handle_(info.db_handle), 130 db_handle_(info.db_handle),
131 download_manager_(download_manager), 131 download_manager_(download_manager),
132 is_paused_(false), 132 is_paused_(false),
133 open_when_complete_(false), 133 open_when_complete_(false),
134 safety_state_(SAFE), 134 safety_state_(SAFE),
135 danger_type_(NOT_DANGEROUS), 135 danger_type_(NOT_DANGEROUS),
136 auto_opened_(false), 136 auto_opened_(false),
137 target_name_(info.original_name), 137 target_name_(info.original_name),
138 render_process_id_(-1),
139 request_id_(-1),
140 save_as_(false), 138 save_as_(false),
141 is_otr_(false), 139 is_otr_(false),
142 is_extension_install_(info.is_extension_install), 140 is_extension_install_(info.is_extension_install),
143 name_finalized_(false), 141 name_finalized_(false),
144 is_temporary_(false), 142 is_temporary_(false),
145 all_data_saved_(false), 143 all_data_saved_(false),
146 opened_(false) { 144 opened_(false) {
147 if (IsInProgress()) 145 if (IsInProgress())
148 state_ = CANCELLED; 146 state_ = CANCELLED;
149 if (IsComplete()) 147 if (IsComplete())
150 all_data_saved_ = true; 148 all_data_saved_ = true;
151 Init(false /* don't start progress timer */); 149 Init(false /* don't start progress timer */);
152 } 150 }
153 151
154 // Constructing for a regular download: 152 // Constructing for a regular download:
155 DownloadItem::DownloadItem(DownloadManager* download_manager, 153 DownloadItem::DownloadItem(DownloadManager* download_manager,
156 const DownloadCreateInfo& info, 154 const DownloadCreateInfo& info,
157 bool is_otr) 155 bool is_otr)
158 : id_(info.download_id), 156 : id_(info.download_id),
159 full_path_(info.path), 157 full_path_(info.path),
160 path_uniquifier_(info.path_uniquifier), 158 path_uniquifier_(info.path_uniquifier),
161 url_chain_(info.url_chain), 159 url_chain_(info.url_chain),
162 referrer_url_(info.referrer_url), 160 referrer_url_(info.referrer_url),
163 mime_type_(info.mime_type), 161 mime_type_(info.mime_type),
164 original_mime_type_(info.original_mime_type), 162 original_mime_type_(info.original_mime_type),
165 total_bytes_(info.total_bytes), 163 total_bytes_(info.total_bytes),
166 received_bytes_(0), 164 received_bytes_(0),
165 process_handle_(info.process_handle),
167 last_os_error_(0), 166 last_os_error_(0),
168 start_tick_(base::TimeTicks::Now()), 167 start_tick_(base::TimeTicks::Now()),
169 state_(IN_PROGRESS), 168 state_(IN_PROGRESS),
170 start_time_(info.start_time), 169 start_time_(info.start_time),
171 db_handle_(DownloadHistory::kUninitializedHandle), 170 db_handle_(DownloadHistory::kUninitializedHandle),
172 download_manager_(download_manager), 171 download_manager_(download_manager),
173 is_paused_(false), 172 is_paused_(false),
174 open_when_complete_(false), 173 open_when_complete_(false),
175 safety_state_(GetSafetyState(info.is_dangerous_file, 174 safety_state_(GetSafetyState(info.is_dangerous_file,
176 info.is_dangerous_url)), 175 info.is_dangerous_url)),
177 danger_type_(GetDangerType(info.is_dangerous_file, 176 danger_type_(GetDangerType(info.is_dangerous_file,
178 info.is_dangerous_url)), 177 info.is_dangerous_url)),
179 auto_opened_(false), 178 auto_opened_(false),
180 target_name_(info.original_name), 179 target_name_(info.original_name),
181 render_process_id_(info.child_id),
182 request_id_(info.request_id),
183 save_as_(info.prompt_user_for_save_location), 180 save_as_(info.prompt_user_for_save_location),
184 is_otr_(is_otr), 181 is_otr_(is_otr),
185 is_extension_install_(info.is_extension_install), 182 is_extension_install_(info.is_extension_install),
186 name_finalized_(false), 183 name_finalized_(false),
187 is_temporary_(!info.save_info.file_path.empty()), 184 is_temporary_(!info.save_info.file_path.empty()),
188 all_data_saved_(false), 185 all_data_saved_(false),
189 opened_(false) { 186 opened_(false) {
190 Init(true /* start progress timer */); 187 Init(true /* start progress timer */);
191 } 188 }
192 189
(...skipping 15 matching lines...) Expand all
208 start_tick_(base::TimeTicks::Now()), 205 start_tick_(base::TimeTicks::Now()),
209 state_(IN_PROGRESS), 206 state_(IN_PROGRESS),
210 start_time_(base::Time::Now()), 207 start_time_(base::Time::Now()),
211 db_handle_(DownloadHistory::kUninitializedHandle), 208 db_handle_(DownloadHistory::kUninitializedHandle),
212 download_manager_(download_manager), 209 download_manager_(download_manager),
213 is_paused_(false), 210 is_paused_(false),
214 open_when_complete_(false), 211 open_when_complete_(false),
215 safety_state_(SAFE), 212 safety_state_(SAFE),
216 danger_type_(NOT_DANGEROUS), 213 danger_type_(NOT_DANGEROUS),
217 auto_opened_(false), 214 auto_opened_(false),
218 render_process_id_(-1),
219 request_id_(-1),
220 save_as_(false), 215 save_as_(false),
221 is_otr_(is_otr), 216 is_otr_(is_otr),
222 is_extension_install_(false), 217 is_extension_install_(false),
223 name_finalized_(false), 218 name_finalized_(false),
224 is_temporary_(false), 219 is_temporary_(false),
225 all_data_saved_(false), 220 all_data_saved_(false),
226 opened_(false) { 221 opened_(false) {
227 Init(true /* start progress timer */); 222 Init(true /* start progress timer */);
228 } 223 }
229 224
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 target_name_.value().c_str(), 671 target_name_.value().c_str(),
677 full_path().value().c_str()); 672 full_path().value().c_str());
678 } else { 673 } else {
679 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str()); 674 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str());
680 } 675 }
681 676
682 description += " }"; 677 description += " }";
683 678
684 return description; 679 return description;
685 } 680 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698