| 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_impl.h" | 5 #include "content/browser/download/download_file_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return file_.AppendDataToFile(data, data_len); | 103 return file_.AppendDataToFile(data, data_len); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void DownloadFileImpl::RenameAndUniquify( | 106 void DownloadFileImpl::RenameAndUniquify( |
| 107 const base::FilePath& full_path, | 107 const base::FilePath& full_path, |
| 108 const RenameCompletionCallback& callback) { | 108 const RenameCompletionCallback& callback) { |
| 109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 110 | 110 |
| 111 base::FilePath new_path(full_path); | 111 base::FilePath new_path(full_path); |
| 112 | 112 |
| 113 int uniquifier = file_util::GetUniquePathNumber( | 113 int uniquifier = base::GetUniquePathNumber( |
| 114 new_path, base::FilePath::StringType()); | 114 new_path, base::FilePath::StringType()); |
| 115 if (uniquifier > 0) { | 115 if (uniquifier > 0) { |
| 116 new_path = new_path.InsertBeforeExtensionASCII( | 116 new_path = new_path.InsertBeforeExtensionASCII( |
| 117 base::StringPrintf(" (%d)", uniquifier)); | 117 base::StringPrintf(" (%d)", uniquifier)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 DownloadInterruptReason reason = file_.Rename(new_path); | 120 DownloadInterruptReason reason = file_.Rename(new_path); |
| 121 if (reason != DOWNLOAD_INTERRUPT_REASON_NONE) { | 121 if (reason != DOWNLOAD_INTERRUPT_REASON_NONE) { |
| 122 // Make sure our information is updated, since we're about to | 122 // Make sure our information is updated, since we're about to |
| 123 // error out. | 123 // error out. |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 observer_, file_.bytes_so_far(), CurrentSpeed(), | 312 observer_, file_.bytes_so_far(), CurrentSpeed(), |
| 313 GetHashState())); | 313 GetHashState())); |
| 314 } | 314 } |
| 315 | 315 |
| 316 // static | 316 // static |
| 317 int DownloadFile::GetNumberOfDownloadFiles() { | 317 int DownloadFile::GetNumberOfDownloadFiles() { |
| 318 return number_active_objects_; | 318 return number_active_objects_; |
| 319 } | 319 } |
| 320 | 320 |
| 321 } // namespace content | 321 } // namespace content |
| OLD | NEW |