Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/browser/download/download_path_reservation_tracker.cc

Issue 189333004: Move more file_util functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (!base::PathIsWritable(target_dir)) { 191 if (!base::PathIsWritable(target_dir)) {
192 DVLOG(1) << "Unable to write to directory \"" << target_dir.value() << "\""; 192 DVLOG(1) << "Unable to write to directory \"" << target_dir.value() << "\"";
193 is_path_writeable = false; 193 is_path_writeable = false;
194 PathService::Get(chrome::DIR_USER_DOCUMENTS, &target_dir); 194 PathService::Get(chrome::DIR_USER_DOCUMENTS, &target_dir);
195 target_path = target_dir.Append(filename); 195 target_path = target_dir.Append(filename);
196 } 196 }
197 197
198 if (is_path_writeable) { 198 if (is_path_writeable) {
199 // Check the limit of file name length if it could be obtained. When the 199 // Check the limit of file name length if it could be obtained. When the
200 // suggested name exceeds the limit, truncate or prompt the user. 200 // suggested name exceeds the limit, truncate or prompt the user.
201 int max_length = file_util::GetMaximumPathComponentLength(target_dir); 201 int max_length = base::GetMaximumPathComponentLength(target_dir);
202 if (max_length != -1) { 202 if (max_length != -1) {
203 int limit = max_length - kIntermediateNameSuffixLength; 203 int limit = max_length - kIntermediateNameSuffixLength;
204 if (limit <= 0 || !TruncateFileName(&target_path, limit)) 204 if (limit <= 0 || !TruncateFileName(&target_path, limit))
205 name_too_long = true; 205 name_too_long = true;
206 } 206 }
207 207
208 // Uniquify the name, if it already exists. 208 // Uniquify the name, if it already exists.
209 if (!name_too_long && IsPathInUse(target_path)) { 209 if (!name_too_long && IsPathInUse(target_path)) {
210 has_conflicts = true; 210 has_conflicts = true;
211 if (conflict_action == DownloadPathReservationTracker::OVERWRITE) { 211 if (conflict_action == DownloadPathReservationTracker::OVERWRITE) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « base/process/process_linux.cc ('k') | chrome/browser/download/download_path_reservation_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698