| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/download/download_file_manager.h" | 5 #include "content/browser/download/download_file_manager.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 int uniquifier = 0; | 392 int uniquifier = 0; |
| 393 FilePath new_path = full_path; | 393 FilePath new_path = full_path; |
| 394 if (!overwrite_existing_file) { | 394 if (!overwrite_existing_file) { |
| 395 // Make our name unique at this point, as if a dangerous file is | 395 // Make our name unique at this point, as if a dangerous file is |
| 396 // downloading and a 2nd download is started for a file with the same | 396 // downloading and a 2nd download is started for a file with the same |
| 397 // name, they would have the same path. This is because we uniquify | 397 // name, they would have the same path. This is because we uniquify |
| 398 // the name on download start, and at that time the first file does | 398 // the name on download start, and at that time the first file does |
| 399 // not exists yet, so the second file gets the same name. | 399 // not exists yet, so the second file gets the same name. |
| 400 // This should not happen in the SAFE case, and we check for that in the UI | 400 // This should not happen in the SAFE case, and we check for that in the UI |
| 401 // thread. | 401 // thread. |
| 402 uniquifier = DownloadFile::GetUniquePathNumber(new_path); | 402 uniquifier = |
| 403 file_util::GetUniquePathNumber(new_path, FILE_PATH_LITERAL("")); |
| 403 if (uniquifier > 0) { | 404 if (uniquifier > 0) { |
| 404 DownloadFile::AppendNumberToPath(&new_path, uniquifier); | 405 file_util::AppendNumberToPath(&new_path, uniquifier); |
| 405 } | 406 } |
| 406 } | 407 } |
| 407 | 408 |
| 408 // Rename the file, overwriting if necessary. | 409 // Rename the file, overwriting if necessary. |
| 409 net::Error rename_error = download_file->Rename(new_path); | 410 net::Error rename_error = download_file->Rename(new_path); |
| 410 if (net::OK != rename_error) { | 411 if (net::OK != rename_error) { |
| 411 // Error. Between the time the UI thread generated 'full_path' to the time | 412 // Error. Between the time the UI thread generated 'full_path' to the time |
| 412 // this code runs, something happened that prevents us from renaming. | 413 // this code runs, something happened that prevents us from renaming. |
| 413 CancelDownloadOnRename(global_id, rename_error); | 414 CancelDownloadOnRename(global_id, rename_error); |
| 414 return; | 415 return; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 << " id = " << global_id | 471 << " id = " << global_id |
| 471 << " download_file = " << download_file->DebugString(); | 472 << " download_file = " << download_file->DebugString(); |
| 472 | 473 |
| 473 downloads_.erase(global_id); | 474 downloads_.erase(global_id); |
| 474 | 475 |
| 475 delete download_file; | 476 delete download_file; |
| 476 | 477 |
| 477 if (downloads_.empty()) | 478 if (downloads_.empty()) |
| 478 StopUpdateTimer(); | 479 StopUpdateTimer(); |
| 479 } | 480 } |
| OLD | NEW |