Chromium Code Reviews| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
| 10 #include "chrome/browser/download/download_file.h" | 10 #include "chrome/browser/download/download_file.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 145 |
| 146 namespace { | 146 namespace { |
| 147 | 147 |
| 148 const struct { | 148 const struct { |
| 149 FilePath::StringType suggested_path; | 149 FilePath::StringType suggested_path; |
| 150 bool is_dangerous; | 150 bool is_dangerous; |
| 151 bool finish_before_rename; | 151 bool finish_before_rename; |
| 152 bool will_delete_crdownload; | 152 bool will_delete_crdownload; |
| 153 int expected_rename_count; | 153 int expected_rename_count; |
| 154 } kDownloadRenameCases[] = { | 154 } kDownloadRenameCases[] = { |
| 155 // Safe download, download finishes BEFORE rename. | 155 // Safe download, download finishes BEFORE file determined. |
|
Paweł Hajdan Jr.
2011/01/05 07:46:30
nit: file determined -> file name determined?
Randy Smith (Not in Mondays)
2011/01/13 02:13:24
Done (all four cases).
| |
| 156 // Needs to be renamed only once. Crdownload file needs to be deleted. | 156 // Renamed twice (linear path through UI). Crdownload file does not need |
| 157 // to be deleted. | |
| 157 { FILE_PATH_LITERAL("foo.zip"), | 158 { FILE_PATH_LITERAL("foo.zip"), |
| 158 false, | 159 false, |
| 159 true, | 160 true, |
| 160 true, | 161 false, |
| 161 1, }, | 162 2, }, |
| 162 // Dangerous download, download finishes BEFORE rename. | 163 // Dangerous download, download finishes BEFORE file determined. |
| 163 // Needs to be renamed only once. | 164 // Needs to be renamed only once. |
| 164 { FILE_PATH_LITERAL("unconfirmed xxx.crdownload"), | 165 { FILE_PATH_LITERAL("unconfirmed xxx.crdownload"), |
| 165 true, | 166 true, |
| 166 true, | 167 true, |
| 167 false, | 168 false, |
| 168 1, }, | 169 1, }, |
| 169 // Safe download, download finishes AFTER rename. | 170 // Safe download, download finishes AFTER file determined. |
| 170 // Needs to be renamed twice. | 171 // Needs to be renamed twice. |
| 171 { FILE_PATH_LITERAL("foo.zip"), | 172 { FILE_PATH_LITERAL("foo.zip"), |
| 172 false, | 173 false, |
| 173 false, | 174 false, |
| 174 false, | 175 false, |
| 175 2, }, | 176 2, }, |
| 176 // Dangerous download, download finishes AFTER rename. | 177 // Dangerous download, download finishes AFTER file determined. |
| 177 // Needs to be renamed only once. | 178 // Needs to be renamed only once. |
| 178 { FILE_PATH_LITERAL("unconfirmed xxx.crdownload"), | 179 { FILE_PATH_LITERAL("unconfirmed xxx.crdownload"), |
| 179 true, | 180 true, |
| 180 false, | 181 false, |
| 181 false, | 182 false, |
| 182 1, }, | 183 1, }, |
| 183 }; | 184 }; |
| 184 | 185 |
| 185 class MockDownloadFile : public DownloadFile { | 186 class MockDownloadFile : public DownloadFile { |
| 186 public: | 187 public: |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 download_manager_->OnAllDataSaved(i, 1024); | 254 download_manager_->OnAllDataSaved(i, 1024); |
| 254 download_manager_->FileSelected(new_path, i, info); | 255 download_manager_->FileSelected(new_path, i, info); |
| 255 } else { | 256 } else { |
| 256 download_manager_->FileSelected(new_path, i, info); | 257 download_manager_->FileSelected(new_path, i, info); |
| 257 download_manager_->OnAllDataSaved(i, 1024); | 258 download_manager_->OnAllDataSaved(i, 1024); |
| 258 } | 259 } |
| 259 | 260 |
| 260 message_loop_.RunAllPending(); | 261 message_loop_.RunAllPending(); |
| 261 } | 262 } |
| 262 } | 263 } |
| OLD | NEW |