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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 const base::FilePath& full_path, | 105 const base::FilePath& full_path, |
106 const RenameCompletionCallback& callback) { | 106 const RenameCompletionCallback& callback) { |
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
108 | 108 |
109 base::FilePath new_path(full_path); | 109 base::FilePath new_path(full_path); |
110 | 110 |
111 int uniquifier = | 111 int uniquifier = |
112 file_util::GetUniquePathNumber(new_path, FILE_PATH_LITERAL("")); | 112 file_util::GetUniquePathNumber(new_path, FILE_PATH_LITERAL("")); |
113 if (uniquifier > 0) { | 113 if (uniquifier > 0) { |
114 new_path = new_path.InsertBeforeExtensionASCII( | 114 new_path = new_path.InsertBeforeExtensionASCII( |
115 StringPrintf(" (%d)", uniquifier)); | 115 base::StringPrintf(" (%d)", uniquifier)); |
116 } | 116 } |
117 | 117 |
118 DownloadInterruptReason reason = file_.Rename(new_path); | 118 DownloadInterruptReason reason = file_.Rename(new_path); |
119 if (reason != DOWNLOAD_INTERRUPT_REASON_NONE) { | 119 if (reason != DOWNLOAD_INTERRUPT_REASON_NONE) { |
120 // Make sure our information is updated, since we're about to | 120 // Make sure our information is updated, since we're about to |
121 // error out. | 121 // error out. |
122 SendUpdate(); | 122 SendUpdate(); |
123 | 123 |
124 // Null out callback so that we don't do any more stream processing. | 124 // Null out callback so that we don't do any more stream processing. |
125 stream_reader_->RegisterCallback(base::Closure()); | 125 stream_reader_->RegisterCallback(base::Closure()); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 base::Bind(&DownloadDestinationObserver::DestinationUpdate, | 308 base::Bind(&DownloadDestinationObserver::DestinationUpdate, |
309 observer_, BytesSoFar(), CurrentSpeed(), GetHashState())); | 309 observer_, BytesSoFar(), CurrentSpeed(), GetHashState())); |
310 } | 310 } |
311 | 311 |
312 // static | 312 // static |
313 int DownloadFile::GetNumberOfDownloadFiles() { | 313 int DownloadFile::GetNumberOfDownloadFiles() { |
314 return number_active_objects_; | 314 return number_active_objects_; |
315 } | 315 } |
316 | 316 |
317 } // namespace content | 317 } // namespace content |
OLD | NEW |