OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/browser/download/download_file.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
51 return download_manager_.get(); | 51 return download_manager_.get(); |
52 } | 52 } |
53 | 53 |
54 std::string DownloadFile::DebugString() const { | 54 std::string DownloadFile::DebugString() const { |
55 return base::StringPrintf("{" | 55 return base::StringPrintf("{" |
56 " id_ = " "%d" | 56 " id_ = " "%d" |
57 " request_handle = %s" | 57 " request_handle = %s" |
58 " Base File = %s" | 58 " Base File = %s" |
59 " }", | 59 " }", |
60 id_, | 60 id_.local(), |
61 request_handle_.DebugString().c_str(), | 61 request_handle_.DebugString().c_str(), |
62 BaseFile::DebugString().c_str()); | 62 BaseFile::DebugString().c_str()); |
63 } | 63 } |
64 | 64 |
65 void DownloadFile::AppendNumberToPath(FilePath* path, int number) { | 65 void DownloadFile::AppendNumberToPath(FilePath* path, int number) { |
66 *path = path->InsertBeforeExtensionASCII(StringPrintf(" (%d)", number)); | 66 *path = path->InsertBeforeExtensionASCII(StringPrintf(" (%d)", number)); |
67 } | 67 } |
68 | 68 |
69 int DownloadFile::GetUniquePathNumber(const FilePath& path) { | 69 int DownloadFile::GetUniquePathNumber(const FilePath& path) { |
70 if (!file_util::PathExists(path)) | 70 if (!file_util::PathExists(path)) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 new_path = FilePath(path); | 104 new_path = FilePath(path); |
105 AppendNumberToPath(&new_path, count); | 105 AppendNumberToPath(&new_path, count); |
106 | 106 |
107 if (!file_util::PathExists(new_path) && | 107 if (!file_util::PathExists(new_path) && |
108 !file_util::PathExists(AppendSuffixToPath(new_path, suffix))) | 108 !file_util::PathExists(AppendSuffixToPath(new_path, suffix))) |
109 return count; | 109 return count; |
110 } | 110 } |
111 | 111 |
112 return -1; | 112 return -1; |
113 } | 113 } |
OLD | NEW |