| 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/download_path_reservation_tracker.h" | 5 #include "chrome/browser/download/download_path_reservation_tracker.h" | 
| 6 | 6 | 
| 7 #include <map> | 7 #include <map> | 
| 8 | 8 | 
| 9 #include "base/bind.h" | 9 #include "base/bind.h" | 
| 10 #include "base/callback.h" | 10 #include "base/callback.h" | 
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 118 | 118 | 
| 119   // Impossible to satisfy the limit. | 119   // Impossible to satisfy the limit. | 
| 120   if (limit < kTruncatedNameLengthLowerbound + ext.size()) | 120   if (limit < kTruncatedNameLengthLowerbound + ext.size()) | 
| 121     return false; | 121     return false; | 
| 122   limit -= ext.size(); | 122   limit -= ext.size(); | 
| 123 | 123 | 
| 124   // Encoding specific truncation logic. | 124   // Encoding specific truncation logic. | 
| 125   base::FilePath::StringType truncated; | 125   base::FilePath::StringType truncated; | 
| 126 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) | 126 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) | 
| 127   // UTF-8. | 127   // UTF-8. | 
| 128   TruncateUTF8ToByteSize(name, limit, &truncated); | 128   base::TruncateUTF8ToByteSize(name, limit, &truncated); | 
| 129 #elif defined(OS_WIN) | 129 #elif defined(OS_WIN) | 
| 130   // UTF-16. | 130   // UTF-16. | 
| 131   DCHECK(name.size() > limit); | 131   DCHECK(name.size() > limit); | 
| 132   truncated = name.substr(0, CBU16_IS_TRAIL(name[limit]) ? limit - 1 : limit); | 132   truncated = name.substr(0, CBU16_IS_TRAIL(name[limit]) ? limit - 1 : limit); | 
| 133 #else | 133 #else | 
| 134   // We cannot generally assume that the file name encoding is in UTF-8 (see | 134   // We cannot generally assume that the file name encoding is in UTF-8 (see | 
| 135   // the comment for FilePath::AsUTF8Unsafe), hence no safe way to truncate. | 135   // the comment for FilePath::AsUTF8Unsafe), hence no safe way to truncate. | 
| 136 #endif | 136 #endif | 
| 137 | 137 | 
| 138   if (truncated.size() < kTruncatedNameLengthLowerbound) | 138   if (truncated.size() < kTruncatedNameLengthLowerbound) | 
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 357       create_directory, | 357       create_directory, | 
| 358       conflict_action, | 358       conflict_action, | 
| 359       callback)); | 359       callback)); | 
| 360 } | 360 } | 
| 361 | 361 | 
| 362 // static | 362 // static | 
| 363 bool DownloadPathReservationTracker::IsPathInUseForTesting( | 363 bool DownloadPathReservationTracker::IsPathInUseForTesting( | 
| 364     const base::FilePath& path) { | 364     const base::FilePath& path) { | 
| 365   return IsPathInUse(path); | 365   return IsPathInUse(path); | 
| 366 } | 366 } | 
| OLD | NEW | 
|---|