| 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 "chrome/browser/download/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 state.suggested_path = path; | 519 state.suggested_path = path; |
| 520 } else { | 520 } else { |
| 521 // Do not add the path uniquifier if we are saving to a specific path as in | 521 // Do not add the path uniquifier if we are saving to a specific path as in |
| 522 // the drag-out case. | 522 // the drag-out case. |
| 523 if (state.force_file_name.empty()) { | 523 if (state.force_file_name.empty()) { |
| 524 state.path_uniquifier = download_util::GetUniquePathNumberWithCrDownload( | 524 state.path_uniquifier = download_util::GetUniquePathNumberWithCrDownload( |
| 525 state.suggested_path); | 525 state.suggested_path); |
| 526 } | 526 } |
| 527 // We know the final path, build it if necessary. | 527 // We know the final path, build it if necessary. |
| 528 if (state.path_uniquifier > 0) { | 528 if (state.path_uniquifier > 0) { |
| 529 DownloadFile::AppendNumberToPath(&(state.suggested_path), | 529 file_util::AppendNumberToPath(&(state.suggested_path), |
| 530 state.path_uniquifier); | 530 state.path_uniquifier); |
| 531 // Setting path_uniquifier to 0 to make sure we don't try to unique it | 531 // Setting path_uniquifier to 0 to make sure we don't try to unique it |
| 532 // later on. | 532 // later on. |
| 533 state.path_uniquifier = 0; | 533 state.path_uniquifier = 0; |
| 534 } else if (state.path_uniquifier == -1) { | 534 } else if (state.path_uniquifier == -1) { |
| 535 // We failed to find a unique path. We have to prompt the user. | 535 // We failed to find a unique path. We have to prompt the user. |
| 536 VLOG(1) << "Unable to find a unique path for suggested path \"" | 536 VLOG(1) << "Unable to find a unique path for suggested path \"" |
| 537 << state.suggested_path.value() << "\""; | 537 << state.suggested_path.value() << "\""; |
| 538 state.prompt_user_for_save_location = true; | 538 state.prompt_user_for_save_location = true; |
| 539 } | 539 } |
| 540 } | 540 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 int32 download_id, int64 db_handle) { | 606 int32 download_id, int64 db_handle) { |
| 607 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 607 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
| 608 // call this function with an invalid |db_handle|. For instance, this can | 608 // call this function with an invalid |db_handle|. For instance, this can |
| 609 // happen when the history database is offline. We cannot have multiple | 609 // happen when the history database is offline. We cannot have multiple |
| 610 // DownloadItems with the same invalid db_handle, so we need to assign a | 610 // DownloadItems with the same invalid db_handle, so we need to assign a |
| 611 // unique |db_handle| here. | 611 // unique |db_handle| here. |
| 612 if (db_handle == DownloadItem::kUninitializedHandle) | 612 if (db_handle == DownloadItem::kUninitializedHandle) |
| 613 db_handle = download_history_->GetNextFakeDbHandle(); | 613 db_handle = download_history_->GetNextFakeDbHandle(); |
| 614 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 614 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
| 615 } | 615 } |
| OLD | NEW |