diff options
author | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-07 10:06:58 +0000 |
---|---|---|
committer | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-07 10:06:58 +0000 |
commit | 54124ed0423cd16e594535fdd9e779f82235fa1a (patch) | |
tree | 8e6b1d1afe4aabf7a45965fa16d99e1d6498c2f3 | |
parent | 7f81dfa0d6030039bb800127f9ab34db3c56b517 (diff) | |
download | chromium_src-54124ed0423cd16e594535fdd9e779f82235fa1a.zip chromium_src-54124ed0423cd16e594535fdd9e779f82235fa1a.tar.gz chromium_src-54124ed0423cd16e594535fdd9e779f82235fa1a.tar.bz2 |
Convert base::file_util to use File instead of PlatformFile.
BUG=322664
R=brettw@chromium.org
TBR=darin@chromium.org
Review URL: https://codereview.chromium.org/101143006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243235 0039d316-1c4b-4281-b951-d872f2087c98
67 files changed, 172 insertions, 156 deletions
diff --git a/base/file_util.cc b/base/file_util.cc index 1575a07..e44f713 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -166,7 +166,7 @@ bool CreateDirectory(const FilePath& full_path) { } bool GetFileSize(const FilePath& file_path, int64* file_size) { - PlatformFileInfo info; + File::Info info; if (!GetFileInfo(file_path, &info)) return false; *file_size = info.size; @@ -176,22 +176,19 @@ bool GetFileSize(const FilePath& file_path, int64* file_size) { bool TouchFile(const FilePath& path, const Time& last_accessed, const Time& last_modified) { - int flags = PLATFORM_FILE_OPEN | PLATFORM_FILE_WRITE_ATTRIBUTES; + int flags = File::FLAG_OPEN | File::FLAG_WRITE_ATTRIBUTES; #if defined(OS_WIN) // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory. if (DirectoryExists(path)) - flags |= PLATFORM_FILE_BACKUP_SEMANTICS; + flags |= File::FLAG_BACKUP_SEMANTICS; #endif // OS_WIN - const PlatformFile file = CreatePlatformFile(path, flags, NULL, NULL); - if (file != kInvalidPlatformFileValue) { - bool result = TouchPlatformFile(file, last_accessed, last_modified); - ClosePlatformFile(file); - return result; - } + File file(path, flags); + if (!file.IsValid()) + return false; - return false; + return file.SetTimes(last_accessed, last_modified); } bool CloseFile(FILE* file) { diff --git a/base/file_util.h b/base/file_util.h index 3f892e3..f841831 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -25,9 +25,9 @@ #include "base/base_export.h" #include "base/basictypes.h" +#include "base/files/file.h" #include "base/files/file_path.h" #include "base/memory/scoped_ptr.h" -#include "base/platform_file.h" #include "base/strings/string16.h" #if defined(OS_POSIX) @@ -93,7 +93,7 @@ BASE_EXPORT bool Move(const FilePath& from_path, const FilePath& to_path); // Returns false on failure and sets *error appropriately, if it is non-NULL. BASE_EXPORT bool ReplaceFile(const FilePath& from_path, const FilePath& to_path, - PlatformFileError* error); + File::Error* error); // Copies a single file. Use CopyDirectory to copy directories. // This function fails if either path contains traversal components ('..'). @@ -256,7 +256,7 @@ BASE_EXPORT bool CreateTemporaryDirInDir(const FilePath& base_dir, // Returns true on success, leaving *error unchanged. // Returns false on failure and sets *error appropriately, if it is non-NULL. BASE_EXPORT bool CreateDirectoryAndGetError(const FilePath& full_path, - PlatformFileError* error); + File::Error* error); // Backward-compatible convenience method for the above. BASE_EXPORT bool CreateDirectory(const FilePath& full_path); @@ -292,7 +292,7 @@ BASE_EXPORT bool NormalizeToNativeFilePath(const FilePath& path, BASE_EXPORT bool IsLink(const FilePath& file_path); // Returns information about the given file path. -BASE_EXPORT bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* info); +BASE_EXPORT bool GetFileInfo(const FilePath& file_path, File::Info* info); // Sets the time of the last access and the time of the last modification. BASE_EXPORT bool TouchFile(const FilePath& path, @@ -311,7 +311,7 @@ BASE_EXPORT bool TruncateFile(FILE* file); // Reads the given number of bytes from the file into the buffer. Returns // the number of read bytes, or -1 on error. -BASE_EXPORT int ReadFile(const base::FilePath& filename, char* data, int size); +BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int size); } // namespace base diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index ddcd5dd..3f0ee0a 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -244,12 +244,12 @@ bool DeleteFile(const FilePath& path, bool recursive) { bool ReplaceFile(const FilePath& from_path, const FilePath& to_path, - PlatformFileError* error) { + File::Error* error) { ThreadRestrictions::AssertIOAllowed(); if (rename(from_path.value().c_str(), to_path.value().c_str()) == 0) return true; if (error) - *error = ErrnoToPlatformFileError(errno); + *error = File::OSErrorToFileError(errno); return false; } @@ -589,7 +589,7 @@ bool CreateNewTempDirectory(const FilePath::StringType& prefix, } bool CreateDirectoryAndGetError(const FilePath& full_path, - PlatformFileError* error) { + File::Error* error) { ThreadRestrictions::AssertIOAllowed(); // For call to mkdir(). std::vector<FilePath> subpaths; @@ -616,7 +616,7 @@ bool CreateDirectoryAndGetError(const FilePath& full_path, int saved_errno = errno; if (!DirectoryExists(*i)) { if (error) - *error = ErrnoToPlatformFileError(saved_errno); + *error = File::OSErrorToFileError(saved_errno); return false; } } @@ -654,7 +654,7 @@ bool IsLink(const FilePath& file_path) { return false; } -bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* results) { +bool GetFileInfo(const FilePath& file_path, File::Info* results) { stat_wrapper_t file_info; #if defined(OS_ANDROID) if (file_path.IsContentUri()) { diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index b65e171..96e144d 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -485,25 +485,6 @@ TEST_F(FileUtilTest, DevicePathToDriveLetter) { &win32_path)); } -TEST_F(FileUtilTest, GetPlatformFileInfoForDirectory) { - FilePath empty_dir = temp_dir_.path().Append(FPL("gpfi_test")); - ASSERT_TRUE(CreateDirectory(empty_dir)); - win::ScopedHandle dir( - ::CreateFile(empty_dir.value().c_str(), - FILE_ALL_ACCESS, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. - NULL)); - ASSERT_TRUE(dir.IsValid()); - PlatformFileInfo info; - EXPECT_TRUE(GetPlatformFileInfo(dir.Get(), &info)); - EXPECT_TRUE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - EXPECT_EQ(0, info.size); -} - TEST_F(FileUtilTest, CreateTemporaryFileInDirLongPathTest) { // Test that CreateTemporaryFileInDir() creates a path and returns a long path // if it is available. This test requires that: @@ -1912,7 +1893,7 @@ TEST_F(FileUtilTest, TouchFile) { &modification_time)); ASSERT_TRUE(TouchFile(foobar, access_time, modification_time)); - PlatformFileInfo file_info; + File::Info file_info; ASSERT_TRUE(GetFileInfo(foobar, &file_info)); EXPECT_EQ(file_info.last_accessed.ToInternalValue(), access_time.ToInternalValue()); diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 44c1205..6ff1820 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -91,7 +91,7 @@ bool DeleteFile(const FilePath& path, bool recursive) { if (!recursive) { // If not recursing, then first check to see if |path| is a directory. // If it is, then remove it with RemoveDirectory. - PlatformFileInfo file_info; + File::Info file_info; if (GetFileInfo(path, &file_info) && file_info.is_directory) return RemoveDirectory(path.value().c_str()) != 0; @@ -143,7 +143,7 @@ bool DeleteFileAfterReboot(const FilePath& path) { bool ReplaceFile(const FilePath& from_path, const FilePath& to_path, - PlatformFileError* error) { + File::Error* error) { ThreadRestrictions::AssertIOAllowed(); // Try a simple move first. It will only succeed when |to_path| doesn't // already exist. @@ -158,7 +158,7 @@ bool ReplaceFile(const FilePath& from_path, return true; } if (error) - *error = LastErrorToPlatformFileError(GetLastError()); + *error = File::OSErrorToFileError(GetLastError()); return false; } @@ -328,7 +328,7 @@ bool CreateNewTempDirectory(const FilePath::StringType& prefix, } bool CreateDirectoryAndGetError(const FilePath& full_path, - PlatformFileError* error) { + File::Error* error) { ThreadRestrictions::AssertIOAllowed(); // If the path exists, we've succeeded if it's a directory, failed otherwise. @@ -343,7 +343,7 @@ bool CreateDirectoryAndGetError(const FilePath& full_path, DLOG(WARNING) << "CreateDirectory(" << full_path_str << "), " << "conflicts with existing file."; if (error) { - *error = PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; + *error = File::FILE_ERROR_NOT_A_DIRECTORY; } return false; } @@ -356,14 +356,14 @@ bool CreateDirectoryAndGetError(const FilePath& full_path, FilePath parent_path(full_path.DirName()); if (parent_path.value() == full_path.value()) { if (error) { - *error = PLATFORM_FILE_ERROR_NOT_FOUND; + *error = File::FILE_ERROR_NOT_FOUND; } return false; } if (!CreateDirectoryAndGetError(parent_path, error)) { DLOG(WARNING) << "Failed to create one of the parent directories."; if (error) { - DCHECK(*error != PLATFORM_FILE_OK); + DCHECK(*error != File::FILE_OK); } return false; } @@ -378,7 +378,7 @@ bool CreateDirectoryAndGetError(const FilePath& full_path, return true; } else { if (error) - *error = LastErrorToPlatformFileError(error_code); + *error = File::OSErrorToFileError(error_code); DLOG(WARNING) << "Failed to create directory " << full_path_str << ", last error is " << error_code << "."; return false; @@ -505,7 +505,7 @@ bool IsLink(const FilePath& file_path) { return false; } -bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* results) { +bool GetFileInfo(const FilePath& file_path, File::Info* results) { ThreadRestrictions::AssertIOAllowed(); WIN32_FILE_ATTRIBUTE_DATA attr; diff --git a/base/files/file_path_watcher_win.cc b/base/files/file_path_watcher_win.cc index 2abbcea..34b47ce 100644 --- a/base/files/file_path_watcher_win.cc +++ b/base/files/file_path_watcher_win.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/file_util.h" +#include "base/files/file.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/memory/ref_counted.h" @@ -148,7 +149,7 @@ void FilePathWatcherImpl::OnObjectSignaled(HANDLE object) { } // Check whether the event applies to |target_| and notify the callback. - PlatformFileInfo file_info; + File::Info file_info; bool file_exists = GetFileInfo(target_, &file_info); if (file_exists && (last_modified_.is_null() || last_modified_ != file_info.last_modified)) { @@ -229,7 +230,7 @@ bool FilePathWatcherImpl::UpdateWatch() { if (handle_ != INVALID_HANDLE_VALUE) DestroyWatch(); - PlatformFileInfo file_info; + File::Info file_info; if (GetFileInfo(target_, &file_info)) { last_modified_ = file_info.last_modified; first_notification_ = Time::Now(); diff --git a/base/files/file_unittest.cc b/base/files/file_unittest.cc index 16eece1..224776f 100644 --- a/base/files/file_unittest.cc +++ b/base/files/file_unittest.cc @@ -374,3 +374,28 @@ TEST(File, ReadFileAtCurrentPosition) { EXPECT_EQ(std::string(buffer, buffer + kDataSize), std::string(kData)); } + +#if defined(OS_WIN) +TEST(File, GetInfoForDirectory) { + base::ScopedTempDir temp_dir; + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); + FilePath empty_dir = temp_dir.path().Append(FILE_PATH_LITERAL("gpfi_test")); + ASSERT_TRUE(CreateDirectory(empty_dir)); + + base::File dir( + ::CreateFile(empty_dir.value().c_str(), + FILE_ALL_ACCESS, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. + NULL)); + ASSERT_TRUE(dir.IsValid()); + + base::File::Info info; + EXPECT_TRUE(dir.GetInfo(&info)); + EXPECT_TRUE(info.is_directory); + EXPECT_FALSE(info.is_symbolic_link); + EXPECT_EQ(0, info.size); +} +#endif // defined(OS_WIN) diff --git a/base/files/file_util_proxy.cc b/base/files/file_util_proxy.cc index 40cac11..8307234 100644 --- a/base/files/file_util_proxy.cc +++ b/base/files/file_util_proxy.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/file_util.h" +#include "base/files/file.h" #include "base/location.h" #include "base/message_loop/message_loop_proxy.h" #include "base/task_runner.h" @@ -111,7 +112,8 @@ class GetFileInfoHelper { error_ = PLATFORM_FILE_ERROR_NOT_FOUND; return; } - if (!GetFileInfo(file_path, &file_info_)) + // TODO(rvargas): switch this file to base::File. + if (!GetFileInfo(file_path, reinterpret_cast<File::Info*>(&file_info_))) error_ = PLATFORM_FILE_ERROR_FAILED; } diff --git a/base/files/file_util_proxy_unittest.cc b/base/files/file_util_proxy_unittest.cc index 17c7a3f..762d92b0 100644 --- a/base/files/file_util_proxy_unittest.cc +++ b/base/files/file_util_proxy_unittest.cc @@ -225,7 +225,7 @@ TEST_F(FileUtilProxyTest, CreateTemporary) { TEST_F(FileUtilProxyTest, GetFileInfo_File) { // Setup. ASSERT_EQ(4, file_util::WriteFile(test_path(), "test", 4)); - PlatformFileInfo expected_info; + File::Info expected_info; GetFileInfo(test_path(), &expected_info); // Run. @@ -248,7 +248,7 @@ TEST_F(FileUtilProxyTest, GetFileInfo_File) { TEST_F(FileUtilProxyTest, GetFileInfo_Directory) { // Setup. ASSERT_TRUE(base::CreateDirectory(test_path())); - PlatformFileInfo expected_info; + File::Info expected_info; GetFileInfo(test_path(), &expected_info); // Run. @@ -341,7 +341,7 @@ TEST_F(FileUtilProxyTest, Touch) { MessageLoop::current()->Run(); EXPECT_EQ(PLATFORM_FILE_OK, error_); - PlatformFileInfo info; + File::Info info; GetFileInfo(test_path(), &info); // The returned values may only have the seconds precision, so we cast @@ -356,7 +356,7 @@ TEST_F(FileUtilProxyTest, Truncate_Shrink) { // Setup. const char kTestData[] = "0123456789"; ASSERT_EQ(10, file_util::WriteFile(test_path(), kTestData, 10)); - PlatformFileInfo info; + File::Info info; GetFileInfo(test_path(), &info); ASSERT_EQ(10, info.size); @@ -383,7 +383,7 @@ TEST_F(FileUtilProxyTest, Truncate_Expand) { // Setup. const char kTestData[] = "9876543210"; ASSERT_EQ(10, file_util::WriteFile(test_path(), kTestData, 10)); - PlatformFileInfo info; + File::Info info; GetFileInfo(test_path(), &info); ASSERT_EQ(10, info.size); diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc index 261c987..9cbbd73 100644 --- a/base/files/important_file_writer.cc +++ b/base/files/important_file_writer.cc @@ -17,6 +17,7 @@ #include "base/bind.h" #include "base/critical_closure.h" #include "base/file_util.h" +#include "base/files/file.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/metrics/histogram.h" @@ -63,25 +64,18 @@ bool ImportantFileWriter::WriteFileAtomically(const FilePath& path, return false; } - int flags = PLATFORM_FILE_OPEN | PLATFORM_FILE_WRITE; - PlatformFile tmp_file = - CreatePlatformFile(tmp_file_path, flags, NULL, NULL); - if (tmp_file == kInvalidPlatformFileValue) { + File tmp_file(tmp_file_path, File::FLAG_OPEN | File::FLAG_WRITE); + if (!tmp_file.IsValid()) { LogFailure(path, FAILED_OPENING, "could not open temporary file"); return false; } // If this happens in the wild something really bad is going on. CHECK_LE(data.length(), static_cast<size_t>(kint32max)); - int bytes_written = WritePlatformFile( - tmp_file, 0, data.data(), static_cast<int>(data.length())); - FlushPlatformFile(tmp_file); // Ignore return value. - - if (!ClosePlatformFile(tmp_file)) { - LogFailure(path, FAILED_CLOSING, "failed to close temporary file"); - base::DeleteFile(tmp_file_path, false); - return false; - } + int bytes_written = tmp_file.Write(0, data.data(), + static_cast<int>(data.length())); + tmp_file.Flush(); // Ignore return value. + tmp_file.Close(); if (bytes_written < static_cast<int>(data.length())) { LogFailure(path, FAILED_WRITING, "error writing, bytes_written=" + diff --git a/base/nix/mime_util_xdg.cc b/base/nix/mime_util_xdg.cc index dd2c7eb..215a4d3 100644 --- a/base/nix/mime_util_xdg.cc +++ b/base/nix/mime_util_xdg.cc @@ -387,7 +387,7 @@ bool IconTheme::SetDirectories(const std::string& dirs) { bool CheckDirExistsAndGetMtime(const FilePath& dir, Time* last_modified) { if (!DirectoryExists(dir)) return false; - PlatformFileInfo file_info; + File::Info file_info; if (!GetFileInfo(dir, &file_info)) return false; *last_modified = file_info.last_modified; diff --git a/base/sys_info_chromeos.cc b/base/sys_info_chromeos.cc index 7cf6975..4f32f9b 100644 --- a/base/sys_info_chromeos.cc +++ b/base/sys_info_chromeos.cc @@ -7,6 +7,7 @@ #include "base/basictypes.h" #include "base/environment.h" #include "base/file_util.h" +#include "base/files/file.h" #include "base/files/file_path.h" #include "base/lazy_instance.h" #include "base/strings/string_number_conversions.h" @@ -71,7 +72,7 @@ class ChromeOSVersionInfo { ThreadRestrictions::ScopedAllowIO allow_io; FilePath path(kLinuxStandardBaseReleaseFile); ReadFileToString(path, &lsb_release); - PlatformFileInfo fileinfo; + File::Info fileinfo; if (GetFileInfo(path, &fileinfo)) lsb_release_time_ = fileinfo.creation_time; } diff --git a/chrome/browser/browsing_data/browsing_data_database_helper.cc b/chrome/browser/browsing_data/browsing_data_database_helper.cc index 29f65fd..887d1c3 100644 --- a/chrome/browser/browsing_data/browsing_data_database_helper.cc +++ b/chrome/browser/browsing_data/browsing_data_database_helper.cc @@ -87,7 +87,7 @@ void BrowsingDataDatabaseHelper::FetchDatabaseInfoOnFileThread() { db != databases.end(); ++db) { base::FilePath file_path = tracker_->GetFullDBFilePath(ori->GetOriginIdentifier(), *db); - base::PlatformFileInfo file_info; + base::File::Info file_info; if (base::GetFileInfo(file_path, &file_info)) { database_info_.push_back(DatabaseInfo( identifier, diff --git a/chrome/browser/chromeos/drive/file_system.cc b/chrome/browser/chromeos/drive/file_system.cc index d8c0b71..2d5bc97 100644 --- a/chrome/browser/chromeos/drive/file_system.cc +++ b/chrome/browser/chromeos/drive/file_system.cc @@ -74,9 +74,12 @@ FileError GetLocallyStoredResourceEntry( if (error != FILE_ERROR_OK) return error; + // TODO(rvargas): Convert this code to use base::File::Info. base::PlatformFileInfo file_info; - if (!base::GetFileInfo(local_cache_path, &file_info)) + if (!base::GetFileInfo(local_cache_path, + reinterpret_cast<base::File::Info*>(&file_info))) { return FILE_ERROR_NOT_FOUND; + } SetPlatformFileInfoToResourceEntry(file_info, entry); return FILE_ERROR_OK; diff --git a/chrome/browser/chromeos/drive/file_system/download_operation.cc b/chrome/browser/chromeos/drive/file_system/download_operation.cc index 6707102..5257e82 100644 --- a/chrome/browser/chromeos/drive/file_system/download_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/download_operation.cc @@ -61,13 +61,15 @@ FileError CheckPreConditionForEnsureFileDownloaded( // document. if (entry->file_specific_info().is_hosted_document()) { base::FilePath gdoc_file_path; + // TODO(rvargas): Convert this code to use base::File::Info. base::PlatformFileInfo file_info; if (!base::CreateTemporaryFileInDir(temporary_file_directory, &gdoc_file_path) || !util::CreateGDocFile(gdoc_file_path, GURL(entry->file_specific_info().alternate_url()), entry->resource_id()) || - !base::GetFileInfo(gdoc_file_path, &file_info)) + !base::GetFileInfo(gdoc_file_path, + reinterpret_cast<base::File::Info*>(&file_info))) return FILE_ERROR_FAILED; *cache_file_path = gdoc_file_path; @@ -98,7 +100,8 @@ FileError CheckPreConditionForEnsureFileDownloaded( // the drive::FS side is also converted to run fully on blocking pool. if (cache_entry.is_dirty()) { base::PlatformFileInfo file_info; - if (base::GetFileInfo(*cache_file_path, &file_info)) + if (base::GetFileInfo(*cache_file_path, + reinterpret_cast<base::File::Info*>(&file_info))) SetPlatformFileInfoToResourceEntry(file_info, entry); } diff --git a/chrome/browser/chromeos/extensions/echo_private_api.cc b/chrome/browser/chromeos/extensions/echo_private_api.cc index 34915ea..6d722af 100644 --- a/chrome/browser/chromeos/extensions/echo_private_api.cc +++ b/chrome/browser/chromeos/extensions/echo_private_api.cc @@ -170,7 +170,7 @@ bool EchoPrivateGetOobeTimestampFunction::GetOobeTimestampOnFileThread() { const char kOobeTimestampFile[] = "/home/chronos/.oobe_completed"; std::string timestamp = ""; - base::PlatformFileInfo fileInfo; + base::File::Info fileInfo; if (base::GetFileInfo(base::FilePath(kOobeTimestampFile), &fileInfo)) { base::Time::Exploded ctime; fileInfo.creation_time.UTCExplode(&ctime); diff --git a/chrome/browser/chromeos/file_manager/file_browser_handlers.cc b/chrome/browser/chromeos/file_manager/file_browser_handlers.cc index 8877a1c..8996671 100644 --- a/chrome/browser/chromeos/file_manager/file_browser_handlers.cc +++ b/chrome/browser/chromeos/file_manager/file_browser_handlers.cc @@ -239,7 +239,7 @@ FileBrowserHandlerExecutor::SetupFileAccessPermissions( const FileSystemURL& url = file_urls[i]; // Check if this file system entry exists first. - base::PlatformFileInfo file_info; + base::File::Info file_info; base::FilePath local_path = url.path(); base::FilePath virtual_path = url.virtual_path(); diff --git a/chrome/browser/devtools/devtools_file_system_indexer.cc b/chrome/browser/devtools/devtools_file_system_indexer.cc index 34d8ba8..b5826e4 100644 --- a/chrome/browser/devtools/devtools_file_system_indexer.cc +++ b/chrome/browser/devtools/devtools_file_system_indexer.cc @@ -28,7 +28,6 @@ using base::TimeTicks; using base::PassPlatformFile; using base::PlatformFile; using base::PlatformFileError; -using base::PlatformFileInfo; using content::BrowserThread; using std::map; using std::set; diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc index ae0a0fb..3baf2c0 100644 --- a/chrome/browser/extensions/extension_protocols.cc +++ b/chrome/browser/extensions/extension_protocols.cc @@ -230,7 +230,7 @@ class GeneratedBackgroundPageJob : public net::URLRequestSimpleJob { base::Time GetFileLastModifiedTime(const base::FilePath& filename) { if (base::PathExists(filename)) { - base::PlatformFileInfo info; + base::File::Info info; if (base::GetFileInfo(filename, &info)) return info.last_modified; } @@ -239,7 +239,7 @@ base::Time GetFileLastModifiedTime(const base::FilePath& filename) { base::Time GetFileCreationTime(const base::FilePath& filename) { if (base::PathExists(filename)) { - base::PlatformFileInfo info; + base::File::Info info; if (base::GetFileInfo(filename, &info)) return info.creation_time; } diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index eafc32d..a7d3328 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc @@ -554,7 +554,7 @@ void ExtensionServiceTestBase::InitializeInstalledExtensionService( base::FilePath path = temp_dir_.path(); path = path.Append(FILE_PATH_LITERAL("TestingExtensionsPath")); EXPECT_TRUE(base::DeleteFile(path, true)); - base::PlatformFileError error = base::PLATFORM_FILE_OK; + base::File::Error error = base::File::FILE_OK; EXPECT_TRUE(base::CreateDirectoryAndGetError(path, &error)) << error; base::FilePath temp_prefs = path.Append(FILE_PATH_LITERAL("Preferences")); EXPECT_TRUE(base::CopyFile(prefs_file, temp_prefs)); @@ -632,7 +632,7 @@ ExtensionServiceTestBase::CreateDefaultInitParamsInTempDir( base::FilePath path = temp_dir->path(); path = path.Append(FILE_PATH_LITERAL("TestingExtensionsPath")); EXPECT_TRUE(base::DeleteFile(path, true)); - base::PlatformFileError error = base::PLATFORM_FILE_OK; + base::File::Error error = base::File::FILE_OK; EXPECT_TRUE(base::CreateDirectoryAndGetError(path, &error)) << error; base::FilePath prefs_filename = path.Append(FILE_PATH_LITERAL("TestPreferences")); diff --git a/chrome/browser/first_run/upgrade_util_linux.cc b/chrome/browser/first_run/upgrade_util_linux.cc index 8a7618d..3a10031 100644 --- a/chrome/browser/first_run/upgrade_util_linux.cc +++ b/chrome/browser/first_run/upgrade_util_linux.cc @@ -40,7 +40,7 @@ double GetLastModifiedTimeOfExe() { LOG(WARNING) << "Failed to get base::FilePath object for FILE_EXE."; return saved_last_modified_time_of_exe; } - base::PlatformFileInfo exe_file_info; + base::File::Info exe_file_info; if (!base::GetFileInfo(exe_file_path, &exe_file_info)) { LOG(WARNING) << "Failed to get FileInfo object for FILE_EXE - " << exe_file_path.value(); diff --git a/chrome/browser/media_galleries/fileapi/iapps_finder_impl_mac.mm b/chrome/browser/media_galleries/fileapi/iapps_finder_impl_mac.mm index d1d7572..6005c94 100644 --- a/chrome/browser/media_galleries/fileapi/iapps_finder_impl_mac.mm +++ b/chrome/browser/media_galleries/fileapi/iapps_finder_impl_mac.mm @@ -56,7 +56,7 @@ void FindMostRecentDatabase( if (db_path.empty()) continue; - base::PlatformFileInfo file_info; + base::File::Info file_info; if (!base::GetFileInfo(db_path, &file_info)) continue; diff --git a/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc b/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc index e4fdde4..765fba1 100644 --- a/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc +++ b/chrome/browser/media_galleries/fileapi/iphoto_file_util.cc @@ -248,7 +248,7 @@ base::PlatformFileError IPhotoFileUtil::ReadDirectorySync( for (std::map<std::string, base::FilePath>::const_iterator it = locations.begin(); it != locations.end(); it++) { - base::PlatformFileInfo info; + base::File::Info info; if (!base::GetFileInfo(it->second, &info)) return base::PLATFORM_FILE_ERROR_IO; file_list->push_back(DirectoryEntry(it->first, DirectoryEntry::FILE, @@ -263,7 +263,7 @@ base::PlatformFileError IPhotoFileUtil::ReadDirectorySync( for (std::map<std::string, base::FilePath>::const_iterator it = originals.begin(); it != originals.end(); it++) { - base::PlatformFileInfo info; + base::File::Info info; if (!base::GetFileInfo(it->second, &info)) return base::PLATFORM_FILE_ERROR_IO; file_list->push_back(DirectoryEntry(it->first, DirectoryEntry::FILE, diff --git a/chrome/browser/media_galleries/fileapi/itunes_file_util.cc b/chrome/browser/media_galleries/fileapi/itunes_file_util.cc index 12fba52..b8c45c8 100644 --- a/chrome/browser/media_galleries/fileapi/itunes_file_util.cc +++ b/chrome/browser/media_galleries/fileapi/itunes_file_util.cc @@ -158,7 +158,7 @@ base::PlatformFileError ITunesFileUtil::ReadDirectorySync( fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); if (components.size() == 0) { - base::PlatformFileInfo xml_info; + base::File::Info xml_info; if (!base::GetFileInfo(GetDataProvider()->library_path(), &xml_info)) return base::PLATFORM_FILE_ERROR_IO; file_list->push_back(DirectoryEntry(kITunesLibraryXML, @@ -225,7 +225,7 @@ base::PlatformFileError ITunesFileUtil::ReadDirectorySync( return base::PLATFORM_FILE_ERROR_NOT_FOUND; ITunesDataProvider::Album::const_iterator it; for (it = album.begin(); it != album.end(); ++it) { - base::PlatformFileInfo file_info; + base::File::Info file_info; if (media_path_filter()->Match(it->second) && base::GetFileInfo(it->second, &file_info)) { file_list->push_back(DirectoryEntry(it->first, DirectoryEntry::FILE, diff --git a/chrome/browser/media_galleries/fileapi/native_media_file_util.cc b/chrome/browser/media_galleries/fileapi/native_media_file_util.cc index 719bc84..dea110c 100644 --- a/chrome/browser/media_galleries/fileapi/native_media_file_util.cc +++ b/chrome/browser/media_galleries/fileapi/native_media_file_util.cc @@ -653,7 +653,7 @@ NativeMediaFileUtil::GetFilteredLocalFilePathForExistingFileOrDirectory( if (!base::PathExists(file_path)) return failure_error; - base::PlatformFileInfo file_info; + base::File::Info file_info; if (!base::GetFileInfo(file_path, &file_info)) return base::PLATFORM_FILE_ERROR_FAILED; diff --git a/chrome/browser/password_manager/password_store_x_unittest.cc b/chrome/browser/password_manager/password_store_x_unittest.cc index 5a79385..ed41257 100644 --- a/chrome/browser/password_manager/password_store_x_unittest.cc +++ b/chrome/browser/password_manager/password_store_x_unittest.cc @@ -377,7 +377,7 @@ TEST_P(PasswordStoreXTest, NativeMigration) { // Get the initial size of the login DB file, before we populate it. // This will be used later to make sure it gets back to this size. const base::FilePath login_db_file = temp_dir_.path().Append("login_test"); - base::PlatformFileInfo db_file_start_info; + base::File::Info db_file_start_info; ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_start_info)); LoginDatabase* login_db = login_db_.get(); @@ -393,7 +393,7 @@ TEST_P(PasswordStoreXTest, NativeMigration) { } // Get the new size of the login DB file. We expect it to be larger. - base::PlatformFileInfo db_file_full_info; + base::File::Info db_file_full_info; ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info)); EXPECT_GT(db_file_full_info.size, db_file_start_info.size); @@ -467,7 +467,7 @@ TEST_P(PasswordStoreXTest, NativeMigration) { // recreated. We approximate checking for this by checking that the file // size is equal to the size before we populated it, even though it was // larger after populating it. - base::PlatformFileInfo db_file_end_info; + base::File::Info db_file_end_info; ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_end_info)); EXPECT_EQ(db_file_start_info.size, db_file_end_info.size); } diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc index 3eef5a9..28836fc 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database.cc @@ -611,7 +611,7 @@ void SafeBrowsingDatabaseNew::Init(const base::FilePath& filename_base) { << side_effect_free_whitelist_filename_.value(); // If there is no database, the filter cannot be used. - base::PlatformFileInfo db_info; + base::File::Info db_info; if (base::GetFileInfo(side_effect_free_whitelist_filename_, &db_info) && db_info.size != 0) { const base::TimeTicks before = base::TimeTicks::Now(); @@ -1608,7 +1608,7 @@ void SafeBrowsingDatabaseNew::LoadPrefixSet() { DCHECK(!browse_prefix_set_filename_.empty()); // If there is no database, the filter cannot be used. - base::PlatformFileInfo db_info; + base::File::Info db_info; if (!base::GetFileInfo(browse_filename_, &db_info) || db_info.size == 0) return; diff --git a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc index daa0b11..a99fde6 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc @@ -1635,7 +1635,7 @@ TEST_F(SafeBrowsingDatabaseTest, EmptyUpdate) { // Get an older time to reset the lastmod time for detecting whether // the file has been updated. - base::PlatformFileInfo before_info, after_info; + base::File::Info before_info, after_info; ASSERT_TRUE(base::GetFileInfo(filename, &before_info)); const base::Time old_last_modified = before_info.last_modified - base::TimeDelta::FromSeconds(10); diff --git a/chrome/installer/util/duplicate_tree_detector.cc b/chrome/installer/util/duplicate_tree_detector.cc index a55c048..5958375 100644 --- a/chrome/installer/util/duplicate_tree_detector.cc +++ b/chrome/installer/util/duplicate_tree_detector.cc @@ -13,8 +13,8 @@ namespace installer { bool IsIdenticalFileHierarchy(const base::FilePath& src_path, const base::FilePath& dest_path) { - base::PlatformFileInfo src_info; - base::PlatformFileInfo dest_info; + base::File::Info src_info; + base::File::Info dest_info; bool is_identical = false; if (base::GetFileInfo(src_path, &src_info) && diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index 433f363..3dacaa3 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -18,6 +18,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/path_service.h" +#include "base/platform_file.h" #include "base/process/launch.h" #include "base/strings/string_util.h" #include "base/sys_info.h" diff --git a/components/policy/core/common/config_dir_policy_loader.cc b/components/policy/core/common/config_dir_policy_loader.cc index b8bd66a..aa5b09e 100644 --- a/components/policy/core/common/config_dir_policy_loader.cc +++ b/components/policy/core/common/config_dir_policy_loader.cc @@ -92,7 +92,7 @@ base::Time ConfigDirPolicyLoader::LastModificationTime() { }; base::Time last_modification = base::Time(); - base::PlatformFileInfo info; + base::File::Info info; for (size_t i = 0; i < arraysize(kConfigDirSuffixes); ++i) { base::FilePath path(config_dir_.Append(kConfigDirSuffixes[i])); diff --git a/components/policy/core/common/policy_loader_mac.cc b/components/policy/core/common/policy_loader_mac.cc index 6337898..326db7e 100644 --- a/components/policy/core/common/policy_loader_mac.cc +++ b/components/policy/core/common/policy_loader_mac.cc @@ -119,7 +119,7 @@ scoped_ptr<PolicyBundle> PolicyLoaderMac::Load() { } base::Time PolicyLoaderMac::LastModificationTime() { - base::PlatformFileInfo file_info; + base::File::Info file_info; if (!base::GetFileInfo(managed_policy_path_, &file_info) || file_info.is_directory) { return base::Time(); diff --git a/content/browser/fileapi/blob_url_request_job_unittest.cc b/content/browser/fileapi/blob_url_request_job_unittest.cc index a09456b..fe7d586 100644 --- a/content/browser/fileapi/blob_url_request_job_unittest.cc +++ b/content/browser/fileapi/blob_url_request_job_unittest.cc @@ -145,7 +145,7 @@ class BlobURLRequestJobTest : public testing::Test { ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1), file_util::WriteFile(temp_file1_, kTestFileData1, arraysize(kTestFileData1) - 1)); - base::PlatformFileInfo file_info1; + base::File::Info file_info1; base::GetFileInfo(temp_file1_, &file_info1); temp_file_modification_time1_ = file_info1.last_modified; @@ -153,7 +153,7 @@ class BlobURLRequestJobTest : public testing::Test { ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1), file_util::WriteFile(temp_file2_, kTestFileData2, arraysize(kTestFileData2) - 1)); - base::PlatformFileInfo file_info2; + base::File::Info file_info2; base::GetFileInfo(temp_file2_, &file_info2); temp_file_modification_time2_ = file_info2.last_modified; diff --git a/content/browser/fileapi/dragged_file_util_unittest.cc b/content/browser/fileapi/dragged_file_util_unittest.cc index 17b29cc..d35ac4c 100644 --- a/content/browser/fileapi/dragged_file_util_unittest.cc +++ b/content/browser/fileapi/dragged_file_util_unittest.cc @@ -325,7 +325,7 @@ TEST_F(DraggedFileUtilTest, UnregisteredPathsTest) { SetUpOneTestCase(root_path(), test_case); // Make sure regular GetFileInfo succeeds. - base::PlatformFileInfo info; + base::File::Info info; ASSERT_TRUE(base::GetFileInfo(root_path().Append(test_case.path), &info)); if (!test_case.is_directory) ASSERT_EQ(test_case.data_file_size, info.size); diff --git a/content/browser/fileapi/file_system_operation_impl_unittest.cc b/content/browser/fileapi/file_system_operation_impl_unittest.cc index 711181d..ad377d7 100644 --- a/content/browser/fileapi/file_system_operation_impl_unittest.cc +++ b/content/browser/fileapi/file_system_operation_impl_unittest.cc @@ -158,7 +158,7 @@ class FileSystemOperationImplTest } int64 GetFileSize(const std::string& path) { - base::PlatformFileInfo info; + base::File::Info info; EXPECT_TRUE(base::GetFileInfo(PlatformPath(path), &info)); return info.size; } @@ -1106,7 +1106,7 @@ TEST_F(FileSystemOperationImplTest, TestTouchFile) { FileSystemURL file(CreateFile("file")); base::FilePath platform_path = PlatformPath("file"); - base::PlatformFileInfo info; + base::File::Info info; EXPECT_TRUE(base::GetFileInfo(platform_path, &info)); EXPECT_FALSE(info.is_directory); EXPECT_EQ(0, info.size); diff --git a/content/browser/fileapi/local_file_util_unittest.cc b/content/browser/fileapi/local_file_util_unittest.cc index 40995d6..5e83144 100644 --- a/content/browser/fileapi/local_file_util_unittest.cc +++ b/content/browser/fileapi/local_file_util_unittest.cc @@ -84,7 +84,7 @@ class LocalFileUtilTest : public testing::Test { } int64 GetSize(const char *file_name) { - base::PlatformFileInfo info; + base::File::Info info; base::GetFileInfo(LocalPath(file_name), &info); return info.size; } @@ -191,7 +191,7 @@ TEST_F(LocalFileUtilTest, TouchFile) { scoped_ptr<FileSystemOperationContext> context(NewContext()); - base::PlatformFileInfo info; + base::File::Info info; ASSERT_TRUE(base::GetFileInfo(LocalPath(file_name), &info)); const base::Time new_accessed = info.last_accessed + base::TimeDelta::FromHours(10); @@ -219,7 +219,7 @@ TEST_F(LocalFileUtilTest, TouchDirectory) { false /* exclusive */, false /* recursive */)); - base::PlatformFileInfo info; + base::File::Info info; ASSERT_TRUE(base::GetFileInfo(LocalPath(dir_name), &info)); const base::Time new_accessed = info.last_accessed + base::TimeDelta::FromHours(10); diff --git a/content/browser/indexed_db/indexed_db_context_impl.cc b/content/browser/indexed_db/indexed_db_context_impl.cc index daa4174..fc1c932 100644 --- a/content/browser/indexed_db/indexed_db_context_impl.cc +++ b/content/browser/indexed_db/indexed_db_context_impl.cc @@ -297,7 +297,7 @@ base::Time IndexedDBContextImpl::GetOriginLastModified(const GURL& origin_url) { if (data_path_.empty() || !IsInOriginSet(origin_url)) return base::Time(); base::FilePath idb_directory = GetFilePath(origin_url); - base::PlatformFileInfo file_info; + base::File::Info file_info; if (!base::GetFileInfo(idb_directory, &file_info)) return base::Time(); return file_info.last_modified; diff --git a/content/browser/net/sqlite_persistent_cookie_store_unittest.cc b/content/browser/net/sqlite_persistent_cookie_store_unittest.cc index 11c8419..37bd73f 100644 --- a/content/browser/net/sqlite_persistent_cookie_store_unittest.cc +++ b/content/browser/net/sqlite_persistent_cookie_store_unittest.cc @@ -337,7 +337,7 @@ TEST_F(SQLitePersistentCookieStoreTest, TestFlush) { // File timestamps don't work well on all platforms, so we'll determine // whether the DB file has been modified by checking its size. base::FilePath path = temp_dir_.path().Append(kCookieFilename); - base::PlatformFileInfo info; + base::File::Info info; ASSERT_TRUE(base::GetFileInfo(path, &info)); int64 base_size = info.size; diff --git a/content/browser/renderer_host/file_utilities_message_filter.cc b/content/browser/renderer_host/file_utilities_message_filter.cc index 5daa6ff..85edc34 100644 --- a/content/browser/renderer_host/file_utilities_message_filter.cc +++ b/content/browser/renderer_host/file_utilities_message_filter.cc @@ -48,7 +48,8 @@ void FileUtilitiesMessageFilter::OnGetFileInfo( return; } - if (!base::GetFileInfo(path, result)) + // TODO(rvargas): convert this code to use base::File. + if (!base::GetFileInfo(path, reinterpret_cast<base::File::Info*>(result))) *status = base::PLATFORM_FILE_ERROR_FAILED; } diff --git a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc index 8ddf86a..c3ec26c 100644 --- a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc @@ -209,8 +209,10 @@ int32_t PepperFlashFileMessageFilter::OnQueryFile( base::PLATFORM_FILE_ERROR_ACCESS_DENIED); } + // TODO(rvargas): convert this code to use base::File::Info. base::PlatformFileInfo info; - bool result = base::GetFileInfo(full_path, &info); + bool result = base::GetFileInfo(full_path, + reinterpret_cast<base::File::Info*>(&info)); context->reply_msg = PpapiPluginMsg_FlashFile_QueryFileReply(info); return ppapi::PlatformFileErrorToPepperError(result ? base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_ACCESS_DENIED); diff --git a/content/child/npapi/plugin_host.cc b/content/child/npapi/plugin_host.cc index e53f900..4f97f93 100644 --- a/content/child/npapi/plugin_host.cc +++ b/content/child/npapi/plugin_host.cc @@ -469,7 +469,7 @@ static NPError PostURLNotify(NPP id, file_path = base::FilePath::FromUTF8Unsafe(file_path_ascii); } - base::PlatformFileInfo post_file_info; + base::File::Info post_file_info; if (!base::GetFileInfo(file_path, &post_file_info) || post_file_info.is_directory) return NPERR_FILE_NOT_FOUND; diff --git a/content/common/plugin_list_posix.cc b/content/common/plugin_list_posix.cc index 0bfa2a7..72a9310 100644 --- a/content/common/plugin_list_posix.cc +++ b/content/common/plugin_list_posix.cc @@ -545,7 +545,7 @@ void PluginList::GetPluginsInDir( } // Get mtime. - base::PlatformFileInfo info; + base::File::Info info; if (!base::GetFileInfo(path, &info)) continue; diff --git a/net/base/upload_data_stream_unittest.cc b/net/base/upload_data_stream_unittest.cc index 24855a8..fa6c437 100644 --- a/net/base/upload_data_stream_unittest.cc +++ b/net/base/upload_data_stream_unittest.cc @@ -554,7 +554,7 @@ TEST_F(UploadDataStreamTest, FileChanged) { ASSERT_EQ(static_cast<int>(kTestDataSize), file_util::WriteFile(temp_file_path, kTestData, kTestDataSize)); - base::PlatformFileInfo file_info; + base::File::Info file_info; ASSERT_TRUE(base::GetFileInfo(temp_file_path, &file_info)); // Test file not changed. diff --git a/net/base/upload_file_element_reader.cc b/net/base/upload_file_element_reader.cc index ab7dd9e..f320157 100644 --- a/net/base/upload_file_element_reader.cc +++ b/net/base/upload_file_element_reader.cc @@ -61,7 +61,7 @@ int InitInternal(const base::FilePath& path, // from WebKit is based on time_t precision. So we have to convert both to // time_t to compare. This check is used for sliced files. if (!expected_modification_time.is_null()) { - base::PlatformFileInfo info; + base::File::Info info; if (!base::GetFileInfo(path, &info)) { DLOG(WARNING) << "Failed to get file info of \"" << path.value() << "\""; return ERR_FILE_NOT_FOUND; diff --git a/net/base/upload_file_element_reader_unittest.cc b/net/base/upload_file_element_reader_unittest.cc index f3ccb41..52f0f27 100644 --- a/net/base/upload_file_element_reader_unittest.cc +++ b/net/base/upload_file_element_reader_unittest.cc @@ -204,7 +204,7 @@ TEST_F(UploadFileElementReaderTest, Range) { } TEST_F(UploadFileElementReaderTest, FileChanged) { - base::PlatformFileInfo info; + base::File::Info info; ASSERT_TRUE(base::GetFileInfo(temp_file_path_, &info)); // Expect one second before the actual modification time to simulate change. @@ -349,7 +349,7 @@ TEST_F(UploadFileElementReaderSyncTest, Range) { } TEST_F(UploadFileElementReaderSyncTest, FileChanged) { - base::PlatformFileInfo info; + base::File::Info info; ASSERT_TRUE(base::GetFileInfo(temp_file_path_, &info)); // Expect one second before the actual modification time to simulate change. diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index 3aa0d20..300c263 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -3099,7 +3099,7 @@ TEST_F(DiskCacheEntryTest, SimpleCacheCreateDoomRace) { for (int i = 0; i < disk_cache::kSimpleEntryFileCount; ++i) { base::FilePath entry_file_path = cache_path_.AppendASCII( disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, i)); - base::PlatformFileInfo info; + base::File::Info info; EXPECT_FALSE(base::GetFileInfo(entry_file_path, &info)); } } diff --git a/net/disk_cache/simple/simple_index_file.cc b/net/disk_cache/simple/simple_index_file.cc index abd9f7a..37ed234 100644 --- a/net/disk_cache/simple/simple_index_file.cc +++ b/net/disk_cache/simple/simple_index_file.cc @@ -95,7 +95,7 @@ void ProcessEntryFile(SimpleIndex::EntrySet* entries, return; } - base::PlatformFileInfo file_info; + base::File::Info file_info; if (!base::GetFileInfo(file_path, &file_info)) { LOG(ERROR) << "Could not get file info for " << file_path.value(); return; @@ -434,7 +434,7 @@ void SimpleIndexFile::SyncRestoreFromDisk( const base::FilePath& cache_directory, const base::FilePath& index_file_path, SimpleIndexLoadResult* out_result) { - LOG(INFO) << "Simple Cache Index is being restored from disk."; + VLOG(1) << "Simple Cache Index is being restored from disk."; base::DeleteFile(index_file_path, /* recursive = */ false); out_result->Reset(); SimpleIndex::EntrySet* entries = &out_result->entries; diff --git a/net/disk_cache/simple/simple_test_util.cc b/net/disk_cache/simple/simple_test_util.cc index 9a27558..f7209a7 100644 --- a/net/disk_cache/simple/simple_test_util.cc +++ b/net/disk_cache/simple/simple_test_util.cc @@ -4,7 +4,7 @@ #include "net/disk_cache/simple/simple_test_util.h" -#include "base/file_util.h" +#include "base/files/file.h" #include "net/disk_cache/simple/simple_util.h" namespace disk_cache { @@ -14,19 +14,14 @@ bool CreateCorruptFileForTests(const std::string& key, const base::FilePath& cache_path) { base::FilePath entry_file_path = cache_path.AppendASCII( disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, 0)); - int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE; - base::PlatformFile entry_file = - base::CreatePlatformFile(entry_file_path, flags, NULL, NULL); + int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE; + base::File entry_file(entry_file_path, flags); - if (base::kInvalidPlatformFileValue == entry_file) - return false; - if (base::WritePlatformFile(entry_file, 0, "dummy", 1) != 1) - return false; - if (!base::ClosePlatformFile(entry_file)) + if (!entry_file.IsValid()) return false; - return true; + return entry_file.Write(0, "dummy", 1) == 1; } -} // namespace simple_backend +} // namespace simple_util } // namespace disk_cache diff --git a/net/disk_cache/simple/simple_util.cc b/net/disk_cache/simple/simple_util.cc index 0ad2a05..70cd8e4 100644 --- a/net/disk_cache/simple/simple_util.cc +++ b/net/disk_cache/simple/simple_util.cc @@ -125,7 +125,7 @@ bool GetMTime(const base::FilePath& path, base::Time* out_mtime) { return true; } #endif - base::PlatformFileInfo file_info; + base::File::Info file_info; if (!base::GetFileInfo(path, &file_info)) return false; *out_mtime = file_info.last_modified; diff --git a/net/disk_cache/simple/simple_version_upgrade.cc b/net/disk_cache/simple/simple_version_upgrade.cc index dfc6ef4..113ec49 100644 --- a/net/disk_cache/simple/simple_version_upgrade.cc +++ b/net/disk_cache/simple/simple_version_upgrade.cc @@ -11,6 +11,7 @@ #include "base/files/memory_mapped_file.h" #include "base/logging.h" #include "base/pickle.h" +#include "base/platform_file.h" #include "net/disk_cache/simple/simple_backend_version.h" #include "net/disk_cache/simple/simple_entry_format_history.h" #include "third_party/zlib/zlib.h" diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc index d01e5e6..4bbe0cb 100644 --- a/net/proxy/proxy_config_service_linux.cc +++ b/net/proxy/proxy_config_service_linux.cc @@ -884,8 +884,8 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter, base::FilePath kde4_config = KDEHomeToConfigPath(kde4_path); bool use_kde4 = false; if (base::DirectoryExists(kde4_path)) { - base::PlatformFileInfo kde3_info; - base::PlatformFileInfo kde4_info; + base::File::Info kde3_info; + base::File::Info kde4_info; if (base::GetFileInfo(kde4_config, &kde4_info)) { if (base::GetFileInfo(kde3_config, &kde3_info)) { use_kde4 = kde4_info.last_modified >= kde3_info.last_modified; diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index 723e6a0..e2ff2a6 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -197,11 +197,11 @@ URLRequestFileJob::~URLRequestFileJob() { void URLRequestFileJob::FetchMetaInfo(const base::FilePath& file_path, FileMetaInfo* meta_info) { - base::PlatformFileInfo platform_info; - meta_info->file_exists = base::GetFileInfo(file_path, &platform_info); + base::File::Info file_info; + meta_info->file_exists = base::GetFileInfo(file_path, &file_info); if (meta_info->file_exists) { - meta_info->file_size = platform_info.size; - meta_info->is_directory = platform_info.is_directory; + meta_info->file_size = file_info.size; + meta_info->is_directory = file_info.is_directory; } // On Windows GetMimeTypeFromFile() goes to the registry. Thus it should be // done in WorkerPool. diff --git a/net/url_request/url_request_file_job.h b/net/url_request/url_request_file_job.h index 7cd7df0..a94596b 100644 --- a/net/url_request/url_request_file_job.h +++ b/net/url_request/url_request_file_job.h @@ -17,7 +17,6 @@ #include "net/url_request/url_request_job.h" namespace base{ -struct PlatformFileInfo; class TaskRunner; } namespace file_util { diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 8a1fafe..57849cd 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -1009,7 +1009,7 @@ TEST_F(URLRequestTest, FileDirOutputSanity) { // Generate entry for the sentinel file. base::FilePath sentinel_path = path.AppendASCII(sentinel_name); - base::PlatformFileInfo info; + base::File::Info info; EXPECT_TRUE(base::GetFileInfo(sentinel_path, &info)); EXPECT_GT(info.size, 0); std::string sentinel_output = GetDirectoryListingEntry( diff --git a/remoting/host/pairing_registry_delegate_linux.cc b/remoting/host/pairing_registry_delegate_linux.cc index 9b6b3d4..838edd2 100644 --- a/remoting/host/pairing_registry_delegate_linux.cc +++ b/remoting/host/pairing_registry_delegate_linux.cc @@ -108,7 +108,7 @@ PairingRegistry::Pairing PairingRegistryDelegateLinux::Load( bool PairingRegistryDelegateLinux::Save( const PairingRegistry::Pairing& pairing) { base::FilePath registry_path = GetRegistryPath(); - base::PlatformFileError error; + base::File::Error error; if (!base::CreateDirectoryAndGetError(registry_path, &error)) { LOG(ERROR) << "Could not create pairing registry directory: " << error; return false; diff --git a/remoting/host/policy_hack/policy_watcher_linux.cc b/remoting/host/policy_hack/policy_watcher_linux.cc index 37ed8a0..62a3d17 100644 --- a/remoting/host/policy_hack/policy_watcher_linux.cc +++ b/remoting/host/policy_hack/policy_watcher_linux.cc @@ -100,7 +100,7 @@ class PolicyWatcherLinux : public PolicyWatcher { base::Time GetLastModification() { DCHECK(OnPolicyWatcherThread()); base::Time last_modification = base::Time(); - base::PlatformFileInfo file_info; + base::File::Info file_info; // If the path does not exist or points to a directory, it's safe to load. if (!base::GetFileInfo(config_dir_, &file_info) || diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc index 922c5d5..3857be1 100644 --- a/third_party/leveldatabase/env_chromium.cc +++ b/third_party/leveldatabase/env_chromium.cc @@ -841,11 +841,15 @@ Status ChromiumEnv::DeleteFile(const std::string& fname) { Status ChromiumEnv::CreateDir(const std::string& name) { Status result; + // TODO(rvargas): convert this code to base::File::Error. base::PlatformFileError error = base::PLATFORM_FILE_OK; Retrier retrier(kCreateDir, this); do { - if (base::CreateDirectoryAndGetError(CreateFilePath(name), &error)) + if (base::CreateDirectoryAndGetError( + CreateFilePath(name), + reinterpret_cast<base::File::Error*>(&error))) { return result; + } } while (retrier.ShouldKeepTrying(error)); result = MakeIOError(name, "Could not create directory.", kCreateDir, error); RecordOSError(kCreateDir, error); @@ -883,10 +887,13 @@ Status ChromiumEnv::RenameFile(const std::string& src, const std::string& dst) { base::FilePath destination = CreateFilePath(dst); Retrier retrier(kRenameFile, this); + // TODO(rvargas): convert this code to base::File::Error. base::PlatformFileError error = base::PLATFORM_FILE_OK; do { - if (base::ReplaceFile(src_file_path, destination, &error)) + if (base::ReplaceFile(src_file_path, destination, + reinterpret_cast<base::File::Error*>(&error))) { return result; + } } while (retrier.ShouldKeepTrying(error)); DCHECK(error != base::PLATFORM_FILE_OK); diff --git a/third_party/zlib/google/zip.cc b/third_party/zlib/google/zip.cc index 39f58ce..52fc694 100644 --- a/third_party/zlib/google/zip.cc +++ b/third_party/zlib/google/zip.cc @@ -53,7 +53,7 @@ zip_fileinfo TimeToZipFileInfo(const base::Time& file_time) { // Returns a zip_fileinfo with the last modification date of |path| set. zip_fileinfo GetFileInfoForZipping(const base::FilePath& path) { base::Time file_time; - base::PlatformFileInfo file_info; + base::File::Info file_info; if (base::GetFileInfo(path, &file_info)) file_time = file_info.last_modified; return TimeToZipFileInfo(file_time); diff --git a/third_party/zlib/google/zip_unittest.cc b/third_party/zlib/google/zip_unittest.cc index 1d4963e..afa92f1 100644 --- a/third_party/zlib/google/zip_unittest.cc +++ b/third_party/zlib/google/zip_unittest.cc @@ -144,7 +144,7 @@ class ZipTest : public PlatformTest { EXPECT_TRUE(zip::Zip(src_dir, zip_file, true)); ASSERT_TRUE(zip::Unzip(zip_file, out_dir)); - base::PlatformFileInfo file_info; + base::File::Info file_info; EXPECT_TRUE(base::GetFileInfo(out_file, &file_info)); EXPECT_EQ(file_info.size, 1); diff --git a/ui/shell_dialogs/select_file_dialog_win.cc b/ui/shell_dialogs/select_file_dialog_win.cc index e4f0ae4..6baccf4 100644 --- a/ui/shell_dialogs/select_file_dialog_win.cc +++ b/ui/shell_dialogs/select_file_dialog_win.cc @@ -85,7 +85,7 @@ bool CallGetSaveFileName(OPENFILENAME* ofn) { // Distinguish directories from regular files. bool IsDirectory(const base::FilePath& path) { - base::PlatformFileInfo file_info; + base::File::Info file_info; return base::GetFileInfo(path, &file_info) ? file_info.is_directory : path.EndsWithSeparator(); } diff --git a/webkit/browser/blob/local_file_stream_reader_unittest.cc b/webkit/browser/blob/local_file_stream_reader_unittest.cc index 87c77fc..bdd1cdc5 100644 --- a/webkit/browser/blob/local_file_stream_reader_unittest.cc +++ b/webkit/browser/blob/local_file_stream_reader_unittest.cc @@ -67,7 +67,7 @@ class LocalFileStreamReaderTest : public testing::Test { ASSERT_TRUE(dir_.CreateUniqueTempDir()); file_util::WriteFile(test_path(), kTestData, kTestDataSize); - base::PlatformFileInfo info; + base::File::Info info; ASSERT_TRUE(base::GetFileInfo(test_path(), &info)); test_file_modification_time_ = info.last_modified; } diff --git a/webkit/browser/database/database_tracker.cc b/webkit/browser/database/database_tracker.cc index ae4adc9..a9b70d6 100644 --- a/webkit/browser/database/database_tracker.cc +++ b/webkit/browser/database/database_tracker.cc @@ -691,7 +691,7 @@ int DatabaseTracker::DeleteDataModifiedSince( for (std::vector<DatabaseDetails>::const_iterator db = details.begin(); db != details.end(); ++db) { base::FilePath db_file = GetFullDBFilePath(*ori, db->database_name); - base::PlatformFileInfo file_info; + base::File::Info file_info; base::GetFileInfo(db_file, &file_info); if (file_info.last_modified < cutoff) continue; diff --git a/webkit/browser/fileapi/native_file_util.cc b/webkit/browser/fileapi/native_file_util.cc index 9754d6c..e13d8e7 100644 --- a/webkit/browser/fileapi/native_file_util.cc +++ b/webkit/browser/fileapi/native_file_util.cc @@ -202,7 +202,9 @@ PlatformFileError NativeFileUtil::GetFileInfo( base::PlatformFileInfo* file_info) { if (!base::PathExists(path)) return base::PLATFORM_FILE_ERROR_NOT_FOUND; - if (!base::GetFileInfo(path, file_info)) + + // TODO(rvargas): convert this code to use base::File. + if (!base::GetFileInfo(path, reinterpret_cast<base::File::Info*>(file_info))) return base::PLATFORM_FILE_ERROR_FAILED; return base::PLATFORM_FILE_OK; } diff --git a/webkit/browser/fileapi/native_file_util_unittest.cc b/webkit/browser/fileapi/native_file_util_unittest.cc index 73b3e25..587bf9a 100644 --- a/webkit/browser/fileapi/native_file_util_unittest.cc +++ b/webkit/browser/fileapi/native_file_util_unittest.cc @@ -36,7 +36,7 @@ class NativeFileUtilTest : public testing::Test { } int64 GetSize(const base::FilePath& path) { - base::PlatformFileInfo info; + base::File::Info info; base::GetFileInfo(path, &info); return info.size; } @@ -125,7 +125,7 @@ TEST_F(NativeFileUtilTest, TouchFileAndGetFileInfo) { NativeFileUtil::EnsureFileExists(file_name, &created)); ASSERT_TRUE(created); - base::PlatformFileInfo info; + base::File::Info info; ASSERT_TRUE(base::GetFileInfo(file_name, &info)); ASSERT_EQ(base::PLATFORM_FILE_OK, NativeFileUtil::GetFileInfo(file_name, &native_info)); diff --git a/webkit/browser/fileapi/obfuscated_file_util.cc b/webkit/browser/fileapi/obfuscated_file_util.cc index c324f10..1824397 100644 --- a/webkit/browser/fileapi/obfuscated_file_util.cc +++ b/webkit/browser/fileapi/obfuscated_file_util.cc @@ -647,7 +647,7 @@ PlatformFileError ObfuscatedFileUtil::CopyInForeignFile( if (!db) return base::PLATFORM_FILE_ERROR_FAILED; - base::PlatformFileInfo src_platform_file_info; + base::File::Info src_platform_file_info; if (!base::GetFileInfo(src_file_path, &src_platform_file_info)) return base::PLATFORM_FILE_ERROR_NOT_FOUND; diff --git a/webkit/browser/fileapi/sandbox_directory_database.cc b/webkit/browser/fileapi/sandbox_directory_database.cc index dd37611..1eb23b2 100644 --- a/webkit/browser/fileapi/sandbox_directory_database.cc +++ b/webkit/browser/fileapi/sandbox_directory_database.cc @@ -243,7 +243,7 @@ bool DatabaseCheckHelper::ScanDatabase() { return false; // Ensure the backing file exists as a normal file. - base::PlatformFileInfo platform_file_info; + base::File::Info platform_file_info; if (!base::GetFileInfo( path_.Append(file_info.data_path), &platform_file_info) || platform_file_info.is_directory || diff --git a/webkit/glue/webfileutilities_impl.cc b/webkit/glue/webfileutilities_impl.cc index c7f4c7c..6e70ff5 100644 --- a/webkit/glue/webfileutilities_impl.cc +++ b/webkit/glue/webfileutilities_impl.cc @@ -31,8 +31,10 @@ bool WebFileUtilitiesImpl::getFileInfo(const WebString& path, NOTREACHED(); return false; } + // TODO(rvargas): convert this code to use base::File::Info. base::PlatformFileInfo file_info; - if (!base::GetFileInfo(base::FilePath::FromUTF16Unsafe(path), &file_info)) + if (!base::GetFileInfo(base::FilePath::FromUTF16Unsafe(path), + reinterpret_cast<base::File::Info*>(&file_info))) return false; webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); |