diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-13 17:26:21 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-13 17:26:21 +0000 |
commit | a26f4aec68d4e5637e19e156a4b34518c6a5804c (patch) | |
tree | 5ad9639e6525f6546c54f7a765c87adeba0a8b47 | |
parent | d12bf78f1d0ed66a9c20405ce4040ab3adeba76a (diff) | |
download | chromium_src-a26f4aec68d4e5637e19e156a4b34518c6a5804c.zip chromium_src-a26f4aec68d4e5637e19e156a4b34518c6a5804c.tar.gz chromium_src-a26f4aec68d4e5637e19e156a4b34518c6a5804c.tar.bz2 |
Move more file_util functions to base namespace.
TBR=jam
Review URL: https://codereview.chromium.org/189333004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256863 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/file_util.cc | 19 | ||||
-rw-r--r-- | base/file_util.h | 64 | ||||
-rw-r--r-- | base/file_util_linux.cc | 6 | ||||
-rw-r--r-- | base/file_util_posix.cc | 45 | ||||
-rw-r--r-- | base/file_util_unittest.cc | 114 | ||||
-rw-r--r-- | base/file_util_win.cc | 20 | ||||
-rw-r--r-- | base/files/file_path.h | 2 | ||||
-rw-r--r-- | base/process/process_linux.cc | 16 | ||||
-rw-r--r-- | chrome/browser/download/download_path_reservation_tracker.cc | 2 | ||||
-rw-r--r-- | chrome/browser/download/download_path_reservation_tracker_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/external_pref_loader.cc | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/webstore_installer.cc | 2 | ||||
-rw-r--r-- | chrome/browser/media_galleries/media_folder_finder_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/web_applications/web_app_win.cc | 3 | ||||
-rw-r--r-- | content/browser/download/download_file_impl.cc | 2 | ||||
-rw-r--r-- | content/browser/indexed_db/indexed_db_backing_store.cc | 2 | ||||
-rw-r--r-- | content/browser/indexed_db/indexed_db_factory_unittest.cc | 2 | ||||
-rw-r--r-- | crypto/nss_util.cc | 6 |
18 files changed, 122 insertions, 196 deletions
diff --git a/base/file_util.cc b/base/file_util.cc index 87b9afb99..c1bf50a 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -236,18 +236,8 @@ bool TruncateFile(FILE* file) { return true; } -} // namespace base - -// ----------------------------------------------------------------------------- - -namespace file_util { - -using base::FilePath; -using base::kMaxUniqueFiles; - -int GetUniquePathNumber( - const FilePath& path, - const FilePath::StringType& suffix) { +int GetUniquePathNumber(const FilePath& path, + const FilePath::StringType& suffix) { bool have_suffix = !suffix.empty(); if (!PathExists(path) && (!have_suffix || !PathExists(FilePath(path.value() + suffix)))) { @@ -256,8 +246,7 @@ int GetUniquePathNumber( FilePath new_path; for (int count = 1; count <= kMaxUniqueFiles; ++count) { - new_path = - path.InsertBeforeExtensionASCII(base::StringPrintf(" (%d)", count)); + new_path = path.InsertBeforeExtensionASCII(StringPrintf(" (%d)", count)); if (!PathExists(new_path) && (!have_suffix || !PathExists(FilePath(new_path.value() + suffix)))) { return count; @@ -267,4 +256,4 @@ int GetUniquePathNumber( return -1; } -} // namespace file_util +} // namespace base diff --git a/base/file_util.h b/base/file_util.h index 3c171f1..431569a 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -349,25 +349,12 @@ BASE_EXPORT bool GetCurrentDirectory(FilePath* path); // Sets the current working directory for the process. BASE_EXPORT bool SetCurrentDirectory(const FilePath& path); -} // namespace base - -// ----------------------------------------------------------------------------- - -namespace file_util { - // Attempts to find a number that can be appended to the |path| to make it // unique. If |path| does not exist, 0 is returned. If it fails to find such // a number, -1 is returned. If |suffix| is not empty, also checks the // existence of it with the given suffix. -BASE_EXPORT int GetUniquePathNumber(const base::FilePath& path, - const base::FilePath::StringType& suffix); - -#if defined(OS_POSIX) -// Creates a directory with a guaranteed unique name based on |path|, returning -// the pathname if successful, or an empty path if there was an error creating -// the directory. Does not create parent directories. -BASE_EXPORT base::FilePath MakeUniqueDirectory(const base::FilePath& path); -#endif +BASE_EXPORT int GetUniquePathNumber(const FilePath& path, + const FilePath::StringType& suffix); #if defined(OS_POSIX) // Test that |path| can only be changed by a given user and members of @@ -402,6 +389,32 @@ BASE_EXPORT bool VerifyPathControlledByAdmin(const base::FilePath& path); // the directory |path|, in the number of FilePath::CharType, or -1 on failure. BASE_EXPORT int GetMaximumPathComponentLength(const base::FilePath& path); +#if defined(OS_LINUX) +// Broad categories of file systems as returned by statfs() on Linux. +enum FileSystemType { + FILE_SYSTEM_UNKNOWN, // statfs failed. + FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS. + FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2 + FILE_SYSTEM_NFS, + FILE_SYSTEM_SMB, + FILE_SYSTEM_CODA, + FILE_SYSTEM_MEMORY, // in-memory file system + FILE_SYSTEM_CGROUP, // cgroup control. + FILE_SYSTEM_OTHER, // any other value. + FILE_SYSTEM_TYPE_COUNT +}; + +// Attempts determine the FileSystemType for |path|. +// Returns false if |path| doesn't exist. +BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); +#endif + +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { + // Functor for |ScopedFILE| (below). struct ScopedFILEClose { inline void operator()(FILE* x) const { @@ -439,27 +452,6 @@ typedef scoped_ptr<int, ScopedFDClose> ScopedFD; typedef ScopedFD ScopedFDCloser; #endif // OS_POSIX -#if defined(OS_LINUX) -// Broad categories of file systems as returned by statfs() on Linux. -enum FileSystemType { - FILE_SYSTEM_UNKNOWN, // statfs failed. - FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS. - FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2 - FILE_SYSTEM_NFS, - FILE_SYSTEM_SMB, - FILE_SYSTEM_CODA, - FILE_SYSTEM_MEMORY, // in-memory file system - FILE_SYSTEM_CGROUP, // cgroup control. - FILE_SYSTEM_OTHER, // any other value. - FILE_SYSTEM_TYPE_COUNT -}; - -// Attempts determine the FileSystemType for |path|. -// Returns false if |path| doesn't exist. -BASE_EXPORT bool GetFileSystemType(const base::FilePath& path, - FileSystemType* type); -#endif - } // namespace file_util // Internal -------------------------------------------------------------------- diff --git a/base/file_util_linux.cc b/base/file_util_linux.cc index 14e801c..2910c9c 100644 --- a/base/file_util_linux.cc +++ b/base/file_util_linux.cc @@ -25,9 +25,9 @@ #define TMPFS_MAGIC 0x01021994 #endif -namespace file_util { +namespace base { -bool GetFileSystemType(const base::FilePath& path, FileSystemType* type) { +bool GetFileSystemType(const FilePath& path, FileSystemType* type) { struct statfs statfs_buf; if (statfs(path.value().c_str(), &statfs_buf) < 0) { if (errno == ENOENT) @@ -75,4 +75,4 @@ bool GetFileSystemType(const base::FilePath& path, FileSystemType* type) { return true; } -} // namespace file_util +} // namespace base diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index db84c3f..7e7dc05 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -772,44 +772,6 @@ bool SetCurrentDirectory(const FilePath& path) { return !ret; } -} // namespace base - -// ----------------------------------------------------------------------------- - -namespace file_util { - -using base::stat_wrapper_t; -using base::CallStat; -using base::CallLstat; -using base::CreateAndOpenFdForTemporaryFile; -using base::DirectoryExists; -using base::FileEnumerator; -using base::FilePath; -using base::MakeAbsoluteFilePath; -using base::VerifySpecificPathControlledByUser; - -base::FilePath MakeUniqueDirectory(const base::FilePath& path) { - const int kMaxAttempts = 20; - for (int attempts = 0; attempts < kMaxAttempts; attempts++) { - int uniquifier = - GetUniquePathNumber(path, base::FilePath::StringType()); - if (uniquifier < 0) - break; - base::FilePath test_path = (uniquifier == 0) ? path : - path.InsertBeforeExtensionASCII( - base::StringPrintf(" (%d)", uniquifier)); - if (mkdir(test_path.value().c_str(), 0777) == 0) - return test_path; - else if (errno != EEXIST) - break; - } - return base::FilePath(); -} - -FILE* OpenFile(const std::string& filename, const char* mode) { - return OpenFile(FilePath(filename), mode); -} - bool VerifyPathControlledByUser(const FilePath& base, const FilePath& path, uid_t owner_uid, @@ -861,7 +823,7 @@ bool VerifyPathControlledByAdmin(const FilePath& path) { }; // Reading the groups database may touch the file system. - base::ThreadRestrictions::AssertIOAllowed(); + ThreadRestrictions::AssertIOAllowed(); std::set<gid_t> allowed_group_ids; for (int i = 0, ie = arraysize(kAdminGroupNames); i < ie; ++i) { @@ -881,13 +843,12 @@ bool VerifyPathControlledByAdmin(const FilePath& path) { #endif // defined(OS_MACOSX) && !defined(OS_IOS) int GetMaximumPathComponentLength(const FilePath& path) { - base::ThreadRestrictions::AssertIOAllowed(); + ThreadRestrictions::AssertIOAllowed(); return pathconf(path.value().c_str(), _PC_NAME_MAX); } -} // namespace file_util +// ----------------------------------------------------------------------------- -namespace base { namespace internal { bool MoveUnsafe(const FilePath& from_path, const FilePath& to_path) { diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index 5b8684f..96b58582 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -2127,23 +2127,23 @@ TEST_F(VerifyPathControlledByUserTest, BadPaths) { .AppendASCII("not") .AppendASCII("exist"); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, does_not_exist, uid_, ok_gids_)); // |base| not a subpath of |path|. EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, base_dir_, uid_, ok_gids_)); // An empty base path will fail to be a prefix for any path. FilePath empty; EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( empty, base_dir_, uid_, ok_gids_)); // Finding that a bad call fails proves nothing unless a good call succeeds. EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, ok_gids_)); } @@ -2156,10 +2156,10 @@ TEST_F(VerifyPathControlledByUserTest, Symlinks) { << "Failed to create symlink."; EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, file_link, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( file_link, file_link, uid_, ok_gids_)); // Symlink from one directory to another within the path. @@ -2171,16 +2171,16 @@ TEST_F(VerifyPathControlledByUserTest, Symlinks) { ASSERT_TRUE(PathExists(file_path_with_link)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, file_path_with_link, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( link_to_sub_dir, file_path_with_link, uid_, ok_gids_)); // Symlinks in parents of base path are allowed. EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( file_path_with_link, file_path_with_link, uid_, ok_gids_)); } @@ -2198,35 +2198,35 @@ TEST_F(VerifyPathControlledByUserTest, OwnershipChecks) { // We control these paths. EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, ok_gids_)); // Another user does not control these paths. EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, bad_uid, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, bad_uid, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, bad_uid, ok_gids_)); // Another group does not control the paths. EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, bad_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, bad_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, bad_gids_)); } @@ -2241,36 +2241,36 @@ TEST_F(VerifyPathControlledByUserTest, GroupWriteTest) { // Any group is okay because the path is not group-writable. EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, bad_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, bad_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, bad_gids_)); // No group is okay, because we don't check the group // if no group can write. std::set<gid_t> no_gids; // Empty set of gids. EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, no_gids)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, no_gids)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, no_gids)); @@ -2284,23 +2284,23 @@ TEST_F(VerifyPathControlledByUserTest, GroupWriteTest) { // Now |ok_gids_| works, but |bad_gids_| fails. EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, bad_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, bad_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, bad_gids_)); // Because any group in the group set is allowed, @@ -2313,13 +2313,13 @@ TEST_F(VerifyPathControlledByUserTest, GroupWriteTest) { std::inserter(multiple_gids, multiple_gids.begin())); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, multiple_gids)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, multiple_gids)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, multiple_gids)); } @@ -2334,78 +2334,78 @@ TEST_F(VerifyPathControlledByUserTest, WriteBitChecks) { // Initialy, we control all parts of the path. EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, ok_gids_)); // Make base_dir_ world-writable. ASSERT_NO_FATAL_FAILURE( ChangePosixFilePermissions(base_dir_, S_IWOTH, 0u)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, ok_gids_)); // Make sub_dir_ world writable. ASSERT_NO_FATAL_FAILURE( ChangePosixFilePermissions(sub_dir_, S_IWOTH, 0u)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, ok_gids_)); // Make text_file_ world writable. ASSERT_NO_FATAL_FAILURE( ChangePosixFilePermissions(text_file_, S_IWOTH, 0u)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, ok_gids_)); // Make sub_dir_ non-world writable. ASSERT_NO_FATAL_FAILURE( ChangePosixFilePermissions(sub_dir_, 0u, S_IWOTH)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, ok_gids_)); // Make base_dir_ non-world-writable. ASSERT_NO_FATAL_FAILURE( ChangePosixFilePermissions(base_dir_, 0u, S_IWOTH)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, ok_gids_)); EXPECT_FALSE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, ok_gids_)); // Back to the initial state: Nothing is writable, so every path @@ -2413,13 +2413,13 @@ TEST_F(VerifyPathControlledByUserTest, WriteBitChecks) { ASSERT_NO_FATAL_FAILURE( ChangePosixFilePermissions(text_file_, 0u, S_IWOTH)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, sub_dir_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( base_dir_, text_file_, uid_, ok_gids_)); EXPECT_TRUE( - file_util::VerifyPathControlledByUser( + base::VerifyPathControlledByUser( sub_dir_, text_file_, uid_, ok_gids_)); } diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 5350b34..f8d7f7b 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -688,23 +688,8 @@ bool SetCurrentDirectory(const FilePath& directory) { return ret != 0; } -} // namespace base - -// ----------------------------------------------------------------------------- - -namespace file_util { - -using base::DirectoryExists; -using base::FilePath; -using base::kFileShareAll; - -FILE* OpenFile(const std::string& filename, const char* mode) { - base::ThreadRestrictions::AssertIOAllowed(); - return _fsopen(filename.c_str(), mode, _SH_DENYNO); -} - int GetMaximumPathComponentLength(const FilePath& path) { - base::ThreadRestrictions::AssertIOAllowed(); + ThreadRestrictions::AssertIOAllowed(); wchar_t volume_path[MAX_PATH]; if (!GetVolumePathNameW(path.NormalizePathSeparators().value().c_str(), @@ -727,9 +712,8 @@ int GetMaximumPathComponentLength(const FilePath& path) { return std::min(whole_path_limit, static_cast<int>(max_length)); } -} // namespace file_util +// ----------------------------------------------------------------------------- -namespace base { namespace internal { bool MoveUnsafe(const FilePath& from_path, const FilePath& to_path) { diff --git a/base/files/file_path.h b/base/files/file_path.h index 734c402..5695767 100644 --- a/base/files/file_path.h +++ b/base/files/file_path.h @@ -246,7 +246,7 @@ class BASE_EXPORT FilePath { // TODO(davidben): Check all our extension-sensitive code to see if // we can rename this to Extension() and the other to something like // LongExtension(), defaulting to short extensions and leaving the - // long "extensions" to logic like file_util::GetUniquePathNumber(). + // long "extensions" to logic like base::GetUniquePathNumber(). StringType FinalExtension() const; // Returns "C:\pics\jojo" for path "C:\pics\jojo.jpg" diff --git a/base/process/process_linux.cc b/base/process/process_linux.cc index c5acf1b..d92d7c3 100644 --- a/base/process/process_linux.cc +++ b/base/process/process_linux.cc @@ -14,6 +14,8 @@ #include "base/strings/stringprintf.h" #include "base/synchronization/lock.h" +namespace base { + namespace { const int kForegroundPriority = 0; @@ -46,13 +48,13 @@ struct CGroups { base::FilePath(base::StringPrintf(kControlPath, kForeground)); background_file = base::FilePath(base::StringPrintf(kControlPath, kBackground)); - file_util::FileSystemType foreground_type; - file_util::FileSystemType background_type; + base::FileSystemType foreground_type; + base::FileSystemType background_type; enabled = - file_util::GetFileSystemType(foreground_file, &foreground_type) && - file_util::GetFileSystemType(background_file, &background_type) && - foreground_type == file_util::FILE_SYSTEM_CGROUP && - background_type == file_util::FILE_SYSTEM_CGROUP; + base::GetFileSystemType(foreground_file, &foreground_type) && + base::GetFileSystemType(background_file, &background_type) && + foreground_type == FILE_SYSTEM_CGROUP && + background_type == FILE_SYSTEM_CGROUP; } }; @@ -62,8 +64,6 @@ const int kBackgroundPriority = 5; #endif } -namespace base { - bool Process::IsProcessBackgrounded() const { DCHECK(process_); diff --git a/chrome/browser/download/download_path_reservation_tracker.cc b/chrome/browser/download/download_path_reservation_tracker.cc index a924164..ce8bbb9 100644 --- a/chrome/browser/download/download_path_reservation_tracker.cc +++ b/chrome/browser/download/download_path_reservation_tracker.cc @@ -198,7 +198,7 @@ void CreateReservation( if (is_path_writeable) { // Check the limit of file name length if it could be obtained. When the // suggested name exceeds the limit, truncate or prompt the user. - int max_length = file_util::GetMaximumPathComponentLength(target_dir); + int max_length = base::GetMaximumPathComponentLength(target_dir); if (max_length != -1) { int limit = max_length - kIntermediateNameSuffixLength; if (limit <= 0 || !TruncateFileName(&target_path, limit)) diff --git a/chrome/browser/download/download_path_reservation_tracker_unittest.cc b/chrome/browser/download/download_path_reservation_tracker_unittest.cc index 1a2728d..de1279b 100644 --- a/chrome/browser/download/download_path_reservation_tracker_unittest.cc +++ b/chrome/browser/download/download_path_reservation_tracker_unittest.cc @@ -595,7 +595,7 @@ TEST_F(DownloadPathReservationTrackerTest, UpdatesToTargetPath) { TEST_F(DownloadPathReservationTrackerTest, BasicTruncation) { int real_max_length = - file_util::GetMaximumPathComponentLength(default_download_path()); + base::GetMaximumPathComponentLength(default_download_path()); ASSERT_NE(-1, real_max_length); // TODO(kinaba): the current implementation leaves spaces for appending @@ -630,7 +630,7 @@ TEST_F(DownloadPathReservationTrackerTest, BasicTruncation) { TEST_F(DownloadPathReservationTrackerTest, TruncationConflict) { int real_max_length = - file_util::GetMaximumPathComponentLength(default_download_path()); + base::GetMaximumPathComponentLength(default_download_path()); ASSERT_NE(-1, real_max_length); const size_t max_length = real_max_length - 11; @@ -670,7 +670,7 @@ TEST_F(DownloadPathReservationTrackerTest, TruncationConflict) { TEST_F(DownloadPathReservationTrackerTest, TruncationFail) { int real_max_length = - file_util::GetMaximumPathComponentLength(default_download_path()); + base::GetMaximumPathComponentLength(default_download_path()); ASSERT_NE(-1, real_max_length); const size_t max_length = real_max_length - 11; diff --git a/chrome/browser/extensions/external_pref_loader.cc b/chrome/browser/extensions/external_pref_loader.cc index 27461af..99572ce 100644 --- a/chrome/browser/extensions/external_pref_loader.cc +++ b/chrome/browser/extensions/external_pref_loader.cc @@ -164,7 +164,7 @@ void ExternalPrefLoader::ReadExternalExtensionPrefFile( if (IsOptionSet(ENSURE_PATH_CONTROLLED_BY_ADMIN)) { #if defined(OS_MACOSX) - if (!file_util::VerifyPathControlledByAdmin(json_file)) { + if (!base::VerifyPathControlledByAdmin(json_file)) { LOG(ERROR) << "Can not read external extensions source. The file " << json_file.value() << " and every directory in its path, " << "must be owned by root, have group \"admin\", and not be " @@ -175,7 +175,7 @@ void ExternalPrefLoader::ReadExternalExtensionPrefFile( } #else // The only platform that uses this check is Mac OS. If you add one, - // you need to implement file_util::VerifyPathControlledByAdmin() for + // you need to implement base::VerifyPathControlledByAdmin() for // that platform. NOTREACHED(); #endif // defined(OS_MACOSX) diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc index f9cacca..5442408 100644 --- a/chrome/browser/extensions/webstore_installer.cc +++ b/chrome/browser/extensions/webstore_installer.cc @@ -117,7 +117,7 @@ void GetDownloadFilePath( download_directory.AppendASCII(id + "_" + random_number + ".crx"); int uniquifier = - file_util::GetUniquePathNumber(file, base::FilePath::StringType()); + base::GetUniquePathNumber(file, base::FilePath::StringType()); if (uniquifier > 0) { file = file.InsertBeforeExtensionASCII( base::StringPrintf(" (%d)", uniquifier)); diff --git a/chrome/browser/media_galleries/media_folder_finder_unittest.cc b/chrome/browser/media_galleries/media_folder_finder_unittest.cc index 4e7fb92..c771208 100644 --- a/chrome/browser/media_galleries/media_folder_finder_unittest.cc +++ b/chrome/browser/media_galleries/media_folder_finder_unittest.cc @@ -119,8 +119,7 @@ class MediaFolderFinderTest : public testing::Test { for (size_t i = 0; i < count; ++i) { base::FilePath test_file(parent_dir.AppendASCII("dummy." + extension)); int uniquifier = - file_util::GetUniquePathNumber(test_file, - base::FilePath::StringType()); + base::GetUniquePathNumber(test_file, base::FilePath::StringType()); if (uniquifier > 0) { test_file = test_file.InsertBeforeExtensionASCII( base::StringPrintf(" (%d)", uniquifier)); diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc index 1cf4800..0a45a70 100644 --- a/chrome/browser/web_applications/web_app_win.cc +++ b/chrome/browser/web_applications/web_app_win.cc @@ -227,7 +227,8 @@ bool CreateShortcutsInPaths( } if (shortcut_paths[i] != web_app_path) { int unique_number = - file_util::GetUniquePathNumber(shortcut_file, FILE_PATH_LITERAL("")); + base::GetUniquePathNumber(shortcut_file, + base::FilePath::StringType()); if (unique_number == -1) { success = false; continue; diff --git a/content/browser/download/download_file_impl.cc b/content/browser/download/download_file_impl.cc index 1d188c0..0efd0a2 100644 --- a/content/browser/download/download_file_impl.cc +++ b/content/browser/download/download_file_impl.cc @@ -110,7 +110,7 @@ void DownloadFileImpl::RenameAndUniquify( base::FilePath new_path(full_path); - int uniquifier = file_util::GetUniquePathNumber( + int uniquifier = base::GetUniquePathNumber( new_path, base::FilePath::StringType()); if (uniquifier > 0) { new_path = new_path.InsertBeforeExtensionASCII( diff --git a/content/browser/indexed_db/indexed_db_backing_store.cc b/content/browser/indexed_db/indexed_db_backing_store.cc index ffd99e2..be909b4 100644 --- a/content/browser/indexed_db/indexed_db_backing_store.cc +++ b/content/browser/indexed_db/indexed_db_backing_store.cc @@ -484,7 +484,7 @@ static void HistogramOpenStatus(IndexedDBBackingStoreOpenResult result, } static bool IsPathTooLong(const base::FilePath& leveldb_dir) { - int limit = file_util::GetMaximumPathComponentLength(leveldb_dir.DirName()); + int limit = base::GetMaximumPathComponentLength(leveldb_dir.DirName()); if (limit == -1) { DLOG(WARNING) << "GetMaximumPathComponentLength returned -1"; // In limited testing, ChromeOS returns 143, other OSes 255. diff --git a/content/browser/indexed_db/indexed_db_factory_unittest.cc b/content/browser/indexed_db/indexed_db_factory_unittest.cc index a7c4fe7..ef045e5 100644 --- a/content/browser/indexed_db/indexed_db_factory_unittest.cc +++ b/content/browser/indexed_db/indexed_db_factory_unittest.cc @@ -163,7 +163,7 @@ TEST_F(IndexedDBFactoryTest, RejectLongOrigins) { const base::FilePath base_path = temp_directory.path(); scoped_refptr<MockIDBFactory> factory = new MockIDBFactory(); - int limit = file_util::GetMaximumPathComponentLength(base_path); + int limit = base::GetMaximumPathComponentLength(base_path); EXPECT_GT(limit, 0); std::string origin(limit + 1, 'x'); diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc index 8e7e9ac..da46b63 100644 --- a/crypto/nss_util.cc +++ b/crypto/nss_util.cc @@ -146,9 +146,9 @@ char* PKCS11PasswordFunc(PK11SlotInfo* slot, PRBool retry, void* arg) { void UseLocalCacheOfNSSDatabaseIfNFS(const base::FilePath& database_dir) { bool db_on_nfs = false; #if defined(OS_LINUX) - file_util::FileSystemType fs_type = file_util::FILE_SYSTEM_UNKNOWN; - if (file_util::GetFileSystemType(database_dir, &fs_type)) - db_on_nfs = (fs_type == file_util::FILE_SYSTEM_NFS); + base::FileSystemType fs_type = base::FILE_SYSTEM_UNKNOWN; + if (base::GetFileSystemType(database_dir, &fs_type)) + db_on_nfs = (fs_type == base::FILE_SYSTEM_NFS); #elif defined(OS_OPENBSD) struct statfs buf; if (statfs(database_dir.value().c_str(), &buf) == 0) |