summaryrefslogtreecommitdiffstats
path: root/content/browser/download/download_file_impl.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 23:16:39 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 23:16:39 +0000
commite285afa63ad7aa2d4efdbdde45568d26c7370fb0 (patch)
tree5d82a8e576bedc37902223eaaf3a7eeb21ee1888 /content/browser/download/download_file_impl.cc
parentaac510a6d64d91040cf589c701575ca09fa3d820 (diff)
downloadchromium_src-e285afa63ad7aa2d4efdbdde45568d26c7370fb0.zip
chromium_src-e285afa63ad7aa2d4efdbdde45568d26c7370fb0.tar.gz
chromium_src-e285afa63ad7aa2d4efdbdde45568d26c7370fb0.tar.bz2
Move common file path related methods between chrome & content to file_util. I reduced the 4 methods into 3 by only having one GetUniquePathNumber which takes an optional suffix.
BUG=98716 Review URL: https://chromiumcodereview.appspot.com/9316004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119984 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download/download_file_impl.cc')
-rw-r--r--content/browser/download/download_file_impl.cc70
1 files changed, 0 insertions, 70 deletions
diff --git a/content/browser/download/download_file_impl.cc b/content/browser/download/download_file_impl.cc
index 408081a..774242b 100644
--- a/content/browser/download/download_file_impl.cc
+++ b/content/browser/download/download_file_impl.cc
@@ -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,