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

Unified Diff: content/browser/download/download_file_impl.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, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/download/download_file.h ('k') | content/browser/download/download_file_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_file_impl.cc
===================================================================
--- content/browser/download/download_file_impl.cc (revision 119906)
+++ content/browser/download/download_file_impl.cc (working copy)
@@ -7,7 +7,6 @@
#include <string>
#include "base/file_util.h"
-#include "base/stringprintf.h"
#include "content/browser/download/download_create_info.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
@@ -15,75 +14,6 @@
using content::BrowserThread;
using content::DownloadId;
-namespace {
-
-// The maximum number of 'uniquified' files we will try to create.
-// This is used when the filename we're trying to download is already in use,
-// so we create a new unique filename by appending " (nnn)" before the
-// extension, where 1 <= nnn <= kMaxUniqueFiles.
-// Also used by code that cleans up said files.
-static const int kMaxUniqueFiles = 100;
-
-}
-
-namespace content {
-
-// static
-void DownloadFile::AppendNumberToPath(FilePath* path, int number) {
- *path = path->InsertBeforeExtensionASCII(StringPrintf(" (%d)", number));
-}
-
-// static
-FilePath DownloadFile::AppendSuffixToPath(
- const FilePath& path,
- const FilePath::StringType& suffix) {
- FilePath::StringType file_name;
- base::SStringPrintf(
- &file_name, PRFilePathLiteral PRFilePathLiteral, path.value().c_str(),
- suffix.c_str());
- return FilePath(file_name);
-}
-
-// static
-int DownloadFile::GetUniquePathNumber(const FilePath& path) {
- if (!file_util::PathExists(path))
- return 0;
-
- FilePath new_path;
- for (int count = 1; count <= kMaxUniqueFiles; ++count) {
- new_path = FilePath(path);
- AppendNumberToPath(&new_path, count);
-
- if (!file_util::PathExists(new_path))
- return count;
- }
-
- return -1;
-}
-
-// static
-int DownloadFile::GetUniquePathNumberWithSuffix(
- const FilePath& path,
- const FilePath::StringType& suffix) {
- if (!file_util::PathExists(path) &&
- !file_util::PathExists(AppendSuffixToPath(path, suffix)))
- return 0;
-
- FilePath new_path;
- for (int count = 1; count <= kMaxUniqueFiles; ++count) {
- new_path = FilePath(path);
- AppendNumberToPath(&new_path, count);
-
- if (!file_util::PathExists(new_path) &&
- !file_util::PathExists(AppendSuffixToPath(new_path, suffix)))
- return count;
- }
-
- return -1;
-}
-
-}
-
DownloadFileImpl::DownloadFileImpl(
const DownloadCreateInfo* info,
DownloadRequestHandleInterface* request_handle,
« no previous file with comments | « content/browser/download/download_file.h ('k') | content/browser/download/download_file_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698