| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/timer.h" | 8 #include "base/timer.h" |
| 9 #include "chrome/browser/download/download_manager.h" | 9 #include "chrome/browser/download/download_manager.h" |
| 10 #include "chrome/browser/download/download_util.h" | 10 #include "chrome/browser/download/download_util.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 open_when_complete_(false), | 36 open_when_complete_(false), |
| 37 safety_state_(SAFE), | 37 safety_state_(SAFE), |
| 38 auto_opened_(false), | 38 auto_opened_(false), |
| 39 original_name_(info.original_name), | 39 original_name_(info.original_name), |
| 40 render_process_id_(-1), | 40 render_process_id_(-1), |
| 41 request_id_(-1), | 41 request_id_(-1), |
| 42 save_as_(false), | 42 save_as_(false), |
| 43 is_otr_(false), | 43 is_otr_(false), |
| 44 is_extension_install_(info.is_extension_install), | 44 is_extension_install_(info.is_extension_install), |
| 45 name_finalized_(false), | 45 name_finalized_(false), |
| 46 is_temporary_(false) { | 46 is_temporary_(false), |
| 47 need_final_rename_(false) { |
| 47 if (state_ == IN_PROGRESS) | 48 if (state_ == IN_PROGRESS) |
| 48 state_ = CANCELLED; | 49 state_ = CANCELLED; |
| 49 Init(false /* don't start progress timer */); | 50 Init(false /* don't start progress timer */); |
| 50 } | 51 } |
| 51 | 52 |
| 52 // Constructor for DownloadItem created via user action in the main thread. | 53 // Constructor for DownloadItem created via user action in the main thread. |
| 53 DownloadItem::DownloadItem(int32 download_id, | 54 DownloadItem::DownloadItem(int32 download_id, |
| 54 const FilePath& path, | 55 const FilePath& path, |
| 55 int path_uniquifier, | 56 int path_uniquifier, |
| 56 const GURL& url, | 57 const GURL& url, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 85 open_when_complete_(false), | 86 open_when_complete_(false), |
| 86 safety_state_(is_dangerous ? DANGEROUS : SAFE), | 87 safety_state_(is_dangerous ? DANGEROUS : SAFE), |
| 87 auto_opened_(false), | 88 auto_opened_(false), |
| 88 original_name_(original_name), | 89 original_name_(original_name), |
| 89 render_process_id_(render_process_id), | 90 render_process_id_(render_process_id), |
| 90 request_id_(request_id), | 91 request_id_(request_id), |
| 91 save_as_(save_as), | 92 save_as_(save_as), |
| 92 is_otr_(is_otr), | 93 is_otr_(is_otr), |
| 93 is_extension_install_(is_extension_install), | 94 is_extension_install_(is_extension_install), |
| 94 name_finalized_(false), | 95 name_finalized_(false), |
| 95 is_temporary_(is_temporary) { | 96 is_temporary_(is_temporary), |
| 97 need_final_rename_(false) { |
| 96 Init(true /* start progress timer */); | 98 Init(true /* start progress timer */); |
| 97 } | 99 } |
| 98 | 100 |
| 99 void DownloadItem::Init(bool start_timer) { | 101 void DownloadItem::Init(bool start_timer) { |
| 100 file_name_ = full_path_.BaseName(); | 102 file_name_ = full_path_.BaseName(); |
| 101 if (start_timer) | 103 if (start_timer) |
| 102 StartProgressTimer(); | 104 StartProgressTimer(); |
| 103 } | 105 } |
| 104 | 106 |
| 105 DownloadItem::~DownloadItem() { | 107 DownloadItem::~DownloadItem() { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 FilePath DownloadItem::GetFileName() const { | 228 FilePath DownloadItem::GetFileName() const { |
| 227 if (safety_state_ == DownloadItem::SAFE) | 229 if (safety_state_ == DownloadItem::SAFE) |
| 228 return file_name_; | 230 return file_name_; |
| 229 if (path_uniquifier_ > 0) { | 231 if (path_uniquifier_ > 0) { |
| 230 FilePath name(original_name_); | 232 FilePath name(original_name_); |
| 231 download_util::AppendNumberToPath(&name, path_uniquifier_); | 233 download_util::AppendNumberToPath(&name, path_uniquifier_); |
| 232 return name; | 234 return name; |
| 233 } | 235 } |
| 234 return original_name_; | 236 return original_name_; |
| 235 } | 237 } |
| OLD | NEW |