| 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/save_package.h" | 5 #include "content/browser/download/save_package.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 file_util::CreateTemporaryFile(&temp_file); | 508 file_util::CreateTemporaryFile(&temp_file); |
| 509 file_name = temp_file.RemoveExtension().BaseName().value(); | 509 file_name = temp_file.RemoveExtension().BaseName().value(); |
| 510 // Get safe pure file name. | 510 // Get safe pure file name. |
| 511 if (!GetSafePureFileName(saved_main_directory_path_, | 511 if (!GetSafePureFileName(saved_main_directory_path_, |
| 512 base::FilePath::StringType(), | 512 base::FilePath::StringType(), |
| 513 max_path, &file_name)) | 513 max_path, &file_name)) |
| 514 return false; | 514 return false; |
| 515 } else { | 515 } else { |
| 516 for (int i = ordinal_number; i < kMaxFileOrdinalNumber; ++i) { | 516 for (int i = ordinal_number; i < kMaxFileOrdinalNumber; ++i) { |
| 517 base::FilePath::StringType new_name = base_file_name + | 517 base::FilePath::StringType new_name = base_file_name + |
| 518 StringPrintf(FILE_PATH_LITERAL("(%d)"), i) + file_name_ext; | 518 base::StringPrintf(FILE_PATH_LITERAL("(%d)"), i) + file_name_ext; |
| 519 if (file_name_set_.find(new_name) == file_name_set_.end()) { | 519 if (file_name_set_.find(new_name) == file_name_set_.end()) { |
| 520 // Resolved name conflict. | 520 // Resolved name conflict. |
| 521 file_name = new_name; | 521 file_name = new_name; |
| 522 file_name_count_map_[base_file_name] = ++i; | 522 file_name_count_map_[base_file_name] = ++i; |
| 523 break; | 523 break; |
| 524 } | 524 } |
| 525 } | 525 } |
| 526 } | 526 } |
| 527 | 527 |
| 528 file_name_set_.insert(file_name); | 528 file_name_set_.insert(file_name); |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 | 1427 |
| 1428 void SavePackage::FinalizeDownloadEntry() { | 1428 void SavePackage::FinalizeDownloadEntry() { |
| 1429 DCHECK(download_); | 1429 DCHECK(download_); |
| 1430 DCHECK(download_manager_); | 1430 DCHECK(download_manager_); |
| 1431 | 1431 |
| 1432 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1432 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
| 1433 StopObservation(); | 1433 StopObservation(); |
| 1434 } | 1434 } |
| 1435 | 1435 |
| 1436 } // namespace content | 1436 } // namespace content |
| OLD | NEW |