| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } kDownloadRenameCases[] = { | 159 } kDownloadRenameCases[] = { |
| 160 // Safe download, download finishes BEFORE rename. | 160 // Safe download, download finishes BEFORE rename. |
| 161 // Needs to be renamed only once. Crdownload file needs to be deleted. | 161 // Needs to be renamed only once. Crdownload file needs to be deleted. |
| 162 { FILE_PATH_LITERAL("foo.zip"), | 162 { FILE_PATH_LITERAL("foo.zip"), |
| 163 false, | 163 false, |
| 164 true, | 164 true, |
| 165 true, | 165 true, |
| 166 1, }, | 166 1, }, |
| 167 // Dangerous download, download finishes BEFORE rename. | 167 // Dangerous download, download finishes BEFORE rename. |
| 168 // Needs to be renamed only once. | 168 // Needs to be renamed only once. |
| 169 { FILE_PATH_LITERAL("unconfirmed xxx.crdownload"), | 169 { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), |
| 170 true, | 170 true, |
| 171 true, | 171 true, |
| 172 false, | 172 false, |
| 173 1, }, | 173 1, }, |
| 174 // Safe download, download finishes AFTER rename. | 174 // Safe download, download finishes AFTER rename. |
| 175 // Needs to be renamed twice. | 175 // Needs to be renamed twice. |
| 176 { FILE_PATH_LITERAL("foo.zip"), | 176 { FILE_PATH_LITERAL("foo.zip"), |
| 177 false, | 177 false, |
| 178 false, | 178 false, |
| 179 false, | 179 false, |
| 180 2, }, | 180 2, }, |
| 181 // Dangerous download, download finishes AFTER rename. | 181 // Dangerous download, download finishes AFTER rename. |
| 182 // Needs to be renamed only once. | 182 // Needs to be renamed only once. |
| 183 { FILE_PATH_LITERAL("unconfirmed xxx.crdownload"), | 183 { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), |
| 184 true, | 184 true, |
| 185 false, | 185 false, |
| 186 false, | 186 false, |
| 187 1, }, | 187 1, }, |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 class MockDownloadFile : public DownloadFile { | 190 class MockDownloadFile : public DownloadFile { |
| 191 public: | 191 public: |
| 192 explicit MockDownloadFile(DownloadCreateInfo* info) | 192 explicit MockDownloadFile(DownloadCreateInfo* info) |
| 193 : DownloadFile(info, NULL), renamed_count_(0) { } | 193 : DownloadFile(info, NULL), renamed_count_(0) { } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 download_manager_->OnAllDataSaved(i, 1024); | 258 download_manager_->OnAllDataSaved(i, 1024); |
| 259 download_manager_->FileSelected(new_path, i, info); | 259 download_manager_->FileSelected(new_path, i, info); |
| 260 } else { | 260 } else { |
| 261 download_manager_->FileSelected(new_path, i, info); | 261 download_manager_->FileSelected(new_path, i, info); |
| 262 download_manager_->OnAllDataSaved(i, 1024); | 262 download_manager_->OnAllDataSaved(i, 1024); |
| 263 } | 263 } |
| 264 | 264 |
| 265 message_loop_.RunAllPending(); | 265 message_loop_.RunAllPending(); |
| 266 } | 266 } |
| 267 } | 267 } |
| OLD | NEW |