| 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" |
| 11 #include "content/browser/download/download_create_info.h" | 11 #include "content/browser/download/download_create_info.h" |
| 12 #include "content/browser/download/download_manager.h" | 12 #include "content/browser/download/download_manager.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 | 14 |
| 15 using content::BrowserThread; |
| 16 |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| 17 // The maximum number of 'uniquified' files we will try to create. | 19 // The maximum number of 'uniquified' files we will try to create. |
| 18 // This is used when the filename we're trying to download is already in use, | 20 // This is used when the filename we're trying to download is already in use, |
| 19 // so we create a new unique filename by appending " (nnn)" before the | 21 // so we create a new unique filename by appending " (nnn)" before the |
| 20 // extension, where 1 <= nnn <= kMaxUniqueFiles. | 22 // extension, where 1 <= nnn <= kMaxUniqueFiles. |
| 21 // Also used by code that cleans up said files. | 23 // Also used by code that cleans up said files. |
| 22 static const int kMaxUniqueFiles = 100; | 24 static const int kMaxUniqueFiles = 100; |
| 23 | 25 |
| 24 } | 26 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 new_path = FilePath(path); | 106 new_path = FilePath(path); |
| 105 AppendNumberToPath(&new_path, count); | 107 AppendNumberToPath(&new_path, count); |
| 106 | 108 |
| 107 if (!file_util::PathExists(new_path) && | 109 if (!file_util::PathExists(new_path) && |
| 108 !file_util::PathExists(AppendSuffixToPath(new_path, suffix))) | 110 !file_util::PathExists(AppendSuffixToPath(new_path, suffix))) |
| 109 return count; | 111 return count; |
| 110 } | 112 } |
| 111 | 113 |
| 112 return -1; | 114 return -1; |
| 113 } | 115 } |
| OLD | NEW |