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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 file_name_count_map_[base_file_name] = 1; | 512 file_name_count_map_[base_file_name] = 1; |
513 ordinal_number = 1; | 513 ordinal_number = 1; |
514 } else { | 514 } else { |
515 // We have met same base-name conflict, use latest ordinal number. | 515 // We have met same base-name conflict, use latest ordinal number. |
516 ordinal_number = it->second; | 516 ordinal_number = it->second; |
517 } | 517 } |
518 | 518 |
519 if (ordinal_number > (kMaxFileOrdinalNumber - 1)) { | 519 if (ordinal_number > (kMaxFileOrdinalNumber - 1)) { |
520 // Use a random file from temporary file. | 520 // Use a random file from temporary file. |
521 base::FilePath temp_file; | 521 base::FilePath temp_file; |
522 file_util::CreateTemporaryFile(&temp_file); | 522 base::CreateTemporaryFile(&temp_file); |
523 file_name = temp_file.RemoveExtension().BaseName().value(); | 523 file_name = temp_file.RemoveExtension().BaseName().value(); |
524 // Get safe pure file name. | 524 // Get safe pure file name. |
525 if (!GetSafePureFileName(saved_main_directory_path_, | 525 if (!GetSafePureFileName(saved_main_directory_path_, |
526 base::FilePath::StringType(), | 526 base::FilePath::StringType(), |
527 max_path, &file_name)) | 527 max_path, &file_name)) |
528 return false; | 528 return false; |
529 } else { | 529 } else { |
530 for (int i = ordinal_number; i < kMaxFileOrdinalNumber; ++i) { | 530 for (int i = ordinal_number; i < kMaxFileOrdinalNumber; ++i) { |
531 base::FilePath::StringType new_name = base_file_name + | 531 base::FilePath::StringType new_name = base_file_name + |
532 base::StringPrintf(FILE_PATH_LITERAL("(%d)"), i) + file_name_ext; | 532 base::StringPrintf(FILE_PATH_LITERAL("(%d)"), i) + file_name_ext; |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 | 1444 |
1445 void SavePackage::FinalizeDownloadEntry() { | 1445 void SavePackage::FinalizeDownloadEntry() { |
1446 DCHECK(download_); | 1446 DCHECK(download_); |
1447 DCHECK(download_manager_); | 1447 DCHECK(download_manager_); |
1448 | 1448 |
1449 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1449 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
1450 StopObservation(); | 1450 StopObservation(); |
1451 } | 1451 } |
1452 | 1452 |
1453 } // namespace content | 1453 } // namespace content |
OLD | NEW |