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

Side by Side Diff: content/browser/download/download_file_manager.cc

Issue 9316004: Move common file path related methods between chrome & content to file_util. I reduced the 4 meth... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove includes Created 8 years, 10 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 "content/browser/download/download_file_manager.h" 5 #include "content/browser/download/download_file_manager.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 int uniquifier = 0; 392 int uniquifier = 0;
393 FilePath new_path = full_path; 393 FilePath new_path = full_path;
394 if (!overwrite_existing_file) { 394 if (!overwrite_existing_file) {
395 // Make our name unique at this point, as if a dangerous file is 395 // Make our name unique at this point, as if a dangerous file is
396 // downloading and a 2nd download is started for a file with the same 396 // downloading and a 2nd download is started for a file with the same
397 // name, they would have the same path. This is because we uniquify 397 // name, they would have the same path. This is because we uniquify
398 // the name on download start, and at that time the first file does 398 // the name on download start, and at that time the first file does
399 // not exists yet, so the second file gets the same name. 399 // not exists yet, so the second file gets the same name.
400 // This should not happen in the SAFE case, and we check for that in the UI 400 // This should not happen in the SAFE case, and we check for that in the UI
401 // thread. 401 // thread.
402 uniquifier = DownloadFile::GetUniquePathNumber(new_path); 402 uniquifier =
403 file_util::GetUniquePathNumber(new_path, FILE_PATH_LITERAL(""));
403 if (uniquifier > 0) { 404 if (uniquifier > 0) {
404 DownloadFile::AppendNumberToPath(&new_path, uniquifier); 405 new_path = new_path.InsertBeforeExtensionASCII(
406 StringPrintf(" (%d)", uniquifier));
405 } 407 }
406 } 408 }
407 409
408 // Rename the file, overwriting if necessary. 410 // Rename the file, overwriting if necessary.
409 net::Error rename_error = download_file->Rename(new_path); 411 net::Error rename_error = download_file->Rename(new_path);
410 if (net::OK != rename_error) { 412 if (net::OK != rename_error) {
411 // Error. Between the time the UI thread generated 'full_path' to the time 413 // Error. Between the time the UI thread generated 'full_path' to the time
412 // this code runs, something happened that prevents us from renaming. 414 // this code runs, something happened that prevents us from renaming.
413 CancelDownloadOnRename(global_id, rename_error); 415 CancelDownloadOnRename(global_id, rename_error);
414 return; 416 return;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 << " id = " << global_id 472 << " id = " << global_id
471 << " download_file = " << download_file->DebugString(); 473 << " download_file = " << download_file->DebugString();
472 474
473 downloads_.erase(global_id); 475 downloads_.erase(global_id);
474 476
475 delete download_file; 477 delete download_file;
476 478
477 if (downloads_.empty()) 479 if (downloads_.empty())
478 StopUpdateTimer(); 480 StopUpdateTimer();
479 } 481 }
OLDNEW
« no previous file with comments | « content/browser/download/download_file_impl.cc ('k') | content/browser/download/download_file_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698