OLD | NEW |
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 Loading... |
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()) |
(...skipping 21 matching lines...) Expand all Loading... |
171 db_handle_(DownloadHistory::kUninitializedHandle), | 169 db_handle_(DownloadHistory::kUninitializedHandle), |
172 download_manager_(download_manager), | 170 download_manager_(download_manager), |
173 is_paused_(false), | 171 is_paused_(false), |
174 open_when_complete_(false), | 172 open_when_complete_(false), |
175 safety_state_(GetSafetyState(info.is_dangerous_file, | 173 safety_state_(GetSafetyState(info.is_dangerous_file, |
176 info.is_dangerous_url)), | 174 info.is_dangerous_url)), |
177 danger_type_(GetDangerType(info.is_dangerous_file, | 175 danger_type_(GetDangerType(info.is_dangerous_file, |
178 info.is_dangerous_url)), | 176 info.is_dangerous_url)), |
179 auto_opened_(false), | 177 auto_opened_(false), |
180 target_name_(info.original_name), | 178 target_name_(info.original_name), |
181 render_process_id_(info.child_id), | 179 process_handle_(info.process_handle), |
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 Loading... |
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 return state() == COMPLETE; | 643 return state() == COMPLETE; |
649 } | 644 } |
650 | 645 |
651 std::string DownloadItem::DebugString(bool verbose) const { | 646 std::string DownloadItem::DebugString(bool verbose) const { |
652 std::string description = | 647 std::string description = |
653 base::StringPrintf("{ id_ = %d" | 648 base::StringPrintf("{ id_ = %d" |
654 " state = %s", | 649 " state = %s", |
655 id_, | 650 id_, |
656 DebugDownloadStateString(state())); | 651 DebugDownloadStateString(state())); |
657 | 652 |
| 653 // Construct a string of the URL chain. |
| 654 std::string url_list("<none>"); |
| 655 if (!url_chain_.empty()) { |
| 656 std::vector<GURL>::const_iterator iter = url_chain_.begin(); |
| 657 std::vector<GURL>::const_iterator last = url_chain_.end(); |
| 658 url_list = (*iter).spec(); |
| 659 ++iter; |
| 660 for ( ; verbose && (iter != last); ++iter) { |
| 661 url_list += " -> "; |
| 662 const GURL& next_url = *iter; |
| 663 url_list += next_url.spec(); |
| 664 } |
| 665 } |
| 666 |
658 if (verbose) { | 667 if (verbose) { |
659 description += base::StringPrintf( | 668 description += base::StringPrintf( |
660 " db_handle = %" PRId64 | 669 " db_handle = %" PRId64 |
661 " total_bytes = %" PRId64 | 670 " total_bytes = %" PRId64 |
662 " is_paused = " "%c" | 671 " is_paused = " "%c" |
663 " is_extension_install = " "%c" | 672 " is_extension_install = " "%c" |
664 " is_otr = " "%c" | 673 " is_otr = " "%c" |
665 " safety_state = " "%s" | 674 " safety_state = " "%s" |
666 " url = " "\"%s\"" | 675 " url_chain = " "\"%s\"" |
667 " target_name_ = \"%" PRFilePath "\"" | 676 " target_name_ = \"%" PRFilePath "\"" |
668 " full_path = \"%" PRFilePath "\"", | 677 " full_path = \"%" PRFilePath "\"", |
669 db_handle(), | 678 db_handle(), |
670 total_bytes(), | 679 total_bytes(), |
671 is_paused() ? 'T' : 'F', | 680 is_paused() ? 'T' : 'F', |
672 is_extension_install() ? 'T' : 'F', | 681 is_extension_install() ? 'T' : 'F', |
673 is_otr() ? 'T' : 'F', | 682 is_otr() ? 'T' : 'F', |
674 DebugSafetyStateString(safety_state()), | 683 DebugSafetyStateString(safety_state()), |
675 url().spec().c_str(), | 684 url_list.c_str(), |
676 target_name_.value().c_str(), | 685 target_name_.value().c_str(), |
677 full_path().value().c_str()); | 686 full_path().value().c_str()); |
678 } else { | 687 } else { |
679 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str()); | 688 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); |
680 } | 689 } |
681 | 690 |
682 description += " }"; | 691 description += " }"; |
683 | 692 |
684 return description; | 693 return description; |
685 } | 694 } |
OLD | NEW |