diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 03:41:02 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 03:41:02 +0000 |
commit | 6ec54c1e86aa5d29c7223a86acbfa850be39c806 (patch) | |
tree | 8c0be0238c2f35646c3545060375a9032c50b04d | |
parent | 89f580b14355e7342cff030747d12ec18f8ca012 (diff) | |
download | chromium_src-6ec54c1e86aa5d29c7223a86acbfa850be39c806.zip chromium_src-6ec54c1e86aa5d29c7223a86acbfa850be39c806.tar.gz chromium_src-6ec54c1e86aa5d29c7223a86acbfa850be39c806.tar.bz2 |
Revert wstring patch (r29078 and follow up commits). It is causing failures on the buildbots.
TBR=nsylvain
Review URL: http://codereview.chromium.org/280004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29085 0039d316-1c4b-4281-b951-d872f2087c98
39 files changed, 291 insertions, 289 deletions
diff --git a/base/file_util.cc b/base/file_util.cc index a39d1eb..d3a989b5 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -322,6 +322,10 @@ bool ContentsEqual(const std::wstring& filename1, return ContentsEqual(FilePath::FromWStringHack(filename1), FilePath::FromWStringHack(filename2)); } +bool CopyFile(const std::wstring& from_path, const std::wstring& to_path) { + return CopyFile(FilePath::FromWStringHack(from_path), + FilePath::FromWStringHack(to_path)); +} bool CreateDirectory(const std::wstring& full_path) { return CreateDirectory(FilePath::FromWStringHack(full_path)); } @@ -341,6 +345,9 @@ bool CreateNewTempDirectory(const std::wstring& prefix, bool Delete(const std::wstring& path, bool recursive) { return Delete(FilePath::FromWStringHack(path), recursive); } +bool DirectoryExists(const std::wstring& path) { + return DirectoryExists(FilePath::FromWStringHack(path)); +} bool EndsWithSeparator(std::wstring* path) { return EndsWithSeparator(FilePath::FromWStringHack(*path)); } @@ -382,9 +389,16 @@ bool GetTempDir(std::wstring* path_str) { *path_str = path.ToWStringHack(); return true; } +bool Move(const std::wstring& from_path, const std::wstring& to_path) { + return Move(FilePath::FromWStringHack(from_path), + FilePath::FromWStringHack(to_path)); +} FILE* OpenFile(const std::wstring& filename, const char* mode) { return OpenFile(FilePath::FromWStringHack(filename), mode); } +bool PathExists(const std::wstring& path) { + return PathExists(FilePath::FromWStringHack(path)); +} int ReadFile(const std::wstring& filename, char* data, int size) { return ReadFile(FilePath::FromWStringHack(filename), data, size); } diff --git a/base/file_util.h b/base/file_util.h index af08d4f..37634b9 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -133,6 +133,8 @@ bool Delete(const std::wstring& path, bool recursive); // on different volumes, this will attempt to copy and delete. Returns // true for success. bool Move(const FilePath& from_path, const FilePath& to_path); +// Deprecated temporary compatibility function. +bool Move(const std::wstring& from_path, const std::wstring& to_path); // Renames file |from_path| to |to_path|. Both paths must be on the same // volume, or the function will fail. Destination file will be created @@ -143,6 +145,8 @@ bool ReplaceFile(const FilePath& from_path, const FilePath& to_path); // Copies a single file. Use CopyDirectory to copy directories. bool CopyFile(const FilePath& from_path, const FilePath& to_path); +// Deprecated temporary compatibility function. +bool CopyFile(const std::wstring& from_path, const std::wstring& to_path); // Copies the given path, and optionally all subdirectories and their contents // as well. @@ -160,12 +164,16 @@ bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path, // Returns true if the given path exists on the local filesystem, // false otherwise. bool PathExists(const FilePath& path); +// Deprecated temporary compatibility function. +bool PathExists(const std::wstring& path); // Returns true if the given path is writable by the user, false otherwise. bool PathIsWritable(const FilePath& path); // Returns true if the given path exists and is a directory, false otherwise. bool DirectoryExists(const FilePath& path); +// Deprecated temporary compatibility function. +bool DirectoryExists(const std::wstring& path); #if defined(OS_WIN) // Gets the creation time of the given file (expressed in the local timezone), diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc index 756049e..d329514 100644 --- a/chrome/browser/first_run_win.cc +++ b/chrome/browser/first_run_win.cc @@ -311,7 +311,7 @@ bool Upgrade::SwapNewChromeExeIfPresent() { std::wstring new_chrome_exe; if (!GetNewerChromeFile(&new_chrome_exe)) return false; - if (!file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) + if (!file_util::PathExists(new_chrome_exe)) return false; std::wstring curr_chrome_exe; if (!PathService::Get(base::FILE_EXE, &curr_chrome_exe)) diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc index 794d97e..c529e39 100644 --- a/chrome/browser/importer/firefox2_importer.cc +++ b/chrome/browser/importer/firefox2_importer.cc @@ -291,7 +291,7 @@ void Firefox2Importer::ImportPasswords() { // exist, we try to find its older version. std::wstring file = source_path_; file_util::AppendToPath(&file, L"signons2.txt"); - if (!file_util::PathExists(FilePath::FromWStringHack(file))) { + if (!file_util::PathExists(file)) { file = source_path_; file_util::AppendToPath(&file, L"signons.txt"); } diff --git a/chrome/browser/importer/firefox3_importer.cc b/chrome/browser/importer/firefox3_importer.cc index c347b0c..10d2855 100644 --- a/chrome/browser/importer/firefox3_importer.cc +++ b/chrome/browser/importer/firefox3_importer.cc @@ -68,7 +68,7 @@ void Firefox3Importer::StartImport(ProfileInfo profile_info, void Firefox3Importer::ImportHistory() { std::wstring file = source_path_; file_util::AppendToPath(&file, L"places.sqlite"); - if (!file_util::PathExists(FilePath::FromWStringHack(file))) + if (!file_util::PathExists(file)) return; sqlite3* sqlite; @@ -116,7 +116,7 @@ void Firefox3Importer::ImportHistory() { void Firefox3Importer::ImportBookmarks() { std::wstring file = source_path_; file_util::AppendToPath(&file, L"places.sqlite"); - if (!file_util::PathExists(FilePath::FromWStringHack(file))) + if (!file_util::PathExists(file)) return; sqlite3* sqlite; @@ -314,7 +314,7 @@ void Firefox3Importer::GetSearchEnginesXMLFiles( std::vector<std::wstring>* files) { std::wstring file = source_path_; file_util::AppendToPath(&file, L"search.sqlite"); - if (!file_util::PathExists(FilePath::FromWStringHack(file))) + if (!file_util::PathExists(file)) return; sqlite3* sqlite; diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc index e6d09af6..b6ef1f6 100644 --- a/chrome/browser/importer/importer_unittest.cc +++ b/chrome/browser/importer/importer_unittest.cc @@ -49,7 +49,7 @@ class ImporterTest : public testing::Test { virtual void TearDown() { // Deletes the profile and cleans up the profile directory. ASSERT_TRUE(file_util::Delete(test_path_, true)); - ASSERT_FALSE(file_util::PathExists(FilePath::FromWStringHack(test_path_))); + ASSERT_FALSE(file_util::PathExists(test_path_)); } void Firefox3xImporterTest(std::wstring profile_dir, @@ -70,7 +70,7 @@ class ImporterTest : public testing::Test { if (import_search_plugins) { ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); file_util::AppendToPath(&data_path, L"firefox3_searchplugins"); - if (!file_util::PathExists(FilePath::FromWStringHack(data_path))) { + if (!file_util::PathExists(data_path)) { // TODO(maruel): Create search test data that we can open source! LOG(ERROR) << L"Missing internal test data"; return; @@ -646,7 +646,7 @@ TEST_F(ImporterTest, Firefox2Importer) { CreateDirectory(search_engine_path.c_str(), NULL); ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); file_util::AppendToPath(&data_path, L"firefox2_searchplugins"); - if (!file_util::PathExists(FilePath::FromWStringHack(data_path))) { + if (!file_util::PathExists(data_path)) { // TODO(maruel): Create test data that we can open source! LOG(ERROR) << L"Missing internal test data"; return; diff --git a/chrome/browser/jumplist.cc b/chrome/browser/jumplist.cc index 3dd2c55..69c2a9c 100644 --- a/chrome/browser/jumplist.cc +++ b/chrome/browser/jumplist.cc @@ -486,10 +486,9 @@ void JumpListUpdateTask::Run() { // icon directory, and create a new directory which contains new JumpList // icon files. std::wstring icon_dir_old(icon_dir_ + L"Old"); - if (file_util::PathExists(FilePath::FromWStringHack(icon_dir_old))) + if (file_util::PathExists(icon_dir_old)) file_util::Delete(icon_dir_old, true); - file_util::Move(FilePath::FromWStringHack(icon_dir_), - FilePath::FromWStringHack(icon_dir_old)); + file_util::Move(icon_dir_, icon_dir_old); file_util::CreateDirectory(icon_dir_); // Create temporary icon files for shortcuts in the "Most Visited" category. diff --git a/chrome/browser/printing/printing_layout_uitest.cc b/chrome/browser/printing/printing_layout_uitest.cc index c3bfb6b..a5de41a 100644 --- a/chrome/browser/printing/printing_layout_uitest.cc +++ b/chrome/browser/printing/printing_layout_uitest.cc @@ -73,8 +73,7 @@ class PrintingLayoutTest : public PrintingTest<UITest> { FilePath png(verification_file + L".png"); // Looks for Cleartype override. - if (file_util::PathExists( - FilePath::FromWStringHack(verification_file + L"_cleartype.png")) && + if (file_util::PathExists(verification_file + L"_cleartype.png") && IsClearTypeEnabled()) { png = FilePath(verification_file + L"_cleartype.png"); } diff --git a/chrome/browser/tab_contents/navigation_controller_unittest.cc b/chrome/browser/tab_contents/navigation_controller_unittest.cc index fc31c75..9dc51d4 100644 --- a/chrome/browser/tab_contents/navigation_controller_unittest.cc +++ b/chrome/browser/tab_contents/navigation_controller_unittest.cc @@ -88,7 +88,7 @@ class NavigationControllerHistoryTest : public NavigationControllerTest { NavigationControllerTest::TearDown(); ASSERT_TRUE(file_util::Delete(test_dir_, true)); - ASSERT_FALSE(file_util::PathExists(FilePath::FromWStringHack(test_dir_))); + ASSERT_FALSE(file_util::PathExists(test_dir_)); } // Deletes the current profile manager and creates a new one. Indirectly this diff --git a/chrome/common/chrome_plugin_util.cc b/chrome/common/chrome_plugin_util.cc index 4643a87..809e4e6 100644 --- a/chrome/common/chrome_plugin_util.cc +++ b/chrome/common/chrome_plugin_util.cc @@ -131,7 +131,7 @@ CPError CPB_GetCommandLineArgumentsCommon(const char* url, if (!user_data_dir.empty()) { // Make sure user_data_dir is an absolute path. if (file_util::AbsolutePath(&user_data_dir) && - file_util::PathExists(FilePath::FromWStringHack(user_data_dir))) { + file_util::PathExists(user_data_dir)) { // TODO(evanm): use CommandLine APIs instead of this. arguments_w += std::wstring(L"--") + ASCIIToWide(switches::kUserDataDir) + L"=\"" + user_data_dir + L"\" "; diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc index ce211fd1..1bc8164 100644 --- a/chrome/installer/setup/install.cc +++ b/chrome/installer/setup/install.cc @@ -157,13 +157,12 @@ void AddUninstallShortcutWorkItems(HKEY reg_root, // only on the first install of Chrome. void CopyPreferenceFileForFirstRun(bool system_level, const std::wstring& prefs_source_path) { - FilePath prefs_dest_path = FilePath::FromWStringHack( + std::wstring prefs_dest_path( installer::GetChromeInstallPath(system_level)); - prefs_dest_path = prefs_dest_path.Append(installer_util::kDefaultMasterPrefs); - if (!file_util::CopyFile(FilePath::FromWStringHack(prefs_source_path), - prefs_dest_path)) { + file_util::AppendToPath(&prefs_dest_path, + installer_util::kDefaultMasterPrefs); + if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) LOG(INFO) << "Failed to copy master preferences."; - } } // This method creates Chrome shortcuts in Start->Programs for all users or @@ -305,7 +304,7 @@ bool DoPostInstallTasks(HKEY reg_root, BrowserDistribution* dist = BrowserDistribution::GetDistribution(); std::wstring version_key = dist->GetVersionKey(); - if (file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) { + if (file_util::PathExists(new_chrome_exe)) { // Looks like this was in use update. So make sure we update the 'opv' key // with the current version that is active and 'cmd' key with the rename // command to run. @@ -493,7 +492,7 @@ bool InstallNewVersion(const std::wstring& exe_path, installer_util::kChromeNewExe); BrowserDistribution* dist = BrowserDistribution::GetDistribution(); RegKey chrome_key(reg_root, dist->GetVersionKey().c_str(), KEY_READ); - if (file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) + if (file_util::PathExists(new_chrome_exe)) chrome_key.ReadValue(google_update::kRegOldVersionField, current_version); if (current_version->empty()) chrome_key.ReadValue(google_update::kRegVersionField, current_version); diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index f20e307..3b5377d 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -67,7 +67,7 @@ DWORD UnPackArchive(const std::wstring& archive, bool system_install, // Check if this is differential update and if it is, patch it to the // installer archive that should already be on the machine. We assume // it is a differential installer if chrome.7z is not found. - if (!file_util::PathExists(FilePath::FromWStringHack(uncompressed_archive))) { + if (!file_util::PathExists(uncompressed_archive)) { incremental_install = true; LOG(INFO) << "Differential patch found. Applying to existing archive."; if (!installed_version) { @@ -163,11 +163,10 @@ bool CheckPreInstallConditions(const installer::Version* installed_version, // either does not exist or can be deleted (i.e. is not locked by some other // process). if (!installed_version) { - FilePath install_path = FilePath::FromWStringHack( - installer::GetChromeInstallPath(system_install)); + std::wstring install_path(installer::GetChromeInstallPath(system_install)); if (file_util::PathExists(install_path) && !file_util::Delete(install_path, true)) { - LOG(ERROR) << "Installation directory " << install_path.value() + LOG(ERROR) << "Installation directory " << install_path << " exists and can not be deleted."; status = installer_util::INSTALL_DIR_IN_USE; int str_id = IDS_INSTALL_DIR_IN_USE_BASE; diff --git a/chrome/installer/util/copy_tree_work_item.cc b/chrome/installer/util/copy_tree_work_item.cc index 22007990..ffb3d34 100644 --- a/chrome/installer/util/copy_tree_work_item.cc +++ b/chrome/installer/util/copy_tree_work_item.cc @@ -31,7 +31,7 @@ CopyTreeWorkItem::CopyTreeWorkItem(const std::wstring& source_path, bool CopyTreeWorkItem::Do() { if (!file_util::PathExists(source_path_)) { - LOG(ERROR) << source_path_.value() << " does not exist"; + LOG(ERROR) << source_path_ << " does not exist"; return false; } @@ -39,29 +39,29 @@ bool CopyTreeWorkItem::Do() { // handle overwrite_option_ = IF_DIFFERENT case. if ((dest_exist) && (overwrite_option_ == WorkItem::IF_DIFFERENT) && // only for single file - (!file_util::DirectoryExists(source_path_)) && - (!file_util::DirectoryExists(dest_path_)) && + (!PathIsDirectory(source_path_.c_str())) && + (!PathIsDirectory(dest_path_.c_str())) && (file_util::ContentsEqual(source_path_, dest_path_))) { - LOG(INFO) << "Source file " << source_path_.value() - << " and destination file " << dest_path_.value() + LOG(INFO) << "Source file " << source_path_ + << " and destination file " << dest_path_ << " are exactly same. Returning true."; return true; } else if ((dest_exist) && (overwrite_option_ == WorkItem::NEW_NAME_IF_IN_USE) && - (!file_util::DirectoryExists(source_path_)) && - (!file_util::DirectoryExists(dest_path_)) && + (!PathIsDirectory(source_path_.c_str())) && + (!PathIsDirectory(dest_path_.c_str())) && (IsFileInUse(dest_path_))) { // handle overwrite_option_ = NEW_NAME_IF_IN_USE case. if (alternative_path_.empty() || file_util::PathExists(alternative_path_) || !file_util::CopyFile(source_path_, alternative_path_)) { - LOG(ERROR) << "failed to copy " << source_path_.value() << - " to " << alternative_path_.value(); + LOG(ERROR) << "failed to copy " << source_path_ << + " to " << alternative_path_; return false; } else { copied_to_alternate_path_ = true; - LOG(INFO) << "Copied source file " << source_path_.value() - << " to alternative path " << alternative_path_.value(); + LOG(INFO) << "Copied source file " << source_path_ + << " to alternative path " << alternative_path_; return true; } } else if ((dest_exist) && @@ -77,11 +77,10 @@ bool CopyTreeWorkItem::Do() { if (file_util::Move(dest_path_, backup_path_)) { moved_to_backup_ = true; - LOG(INFO) << "Moved destination " << dest_path_.value() << - " to backup path " << backup_path_.value(); + LOG(INFO) << "Moved destination " << dest_path_ + << " to backup path " << backup_path_; } else { - LOG(ERROR) << "failed moving " << dest_path_.value() << " to " << - backup_path_.value(); + LOG(ERROR) << "failed moving " << dest_path_ << " to " << backup_path_; return false; } } @@ -89,11 +88,10 @@ bool CopyTreeWorkItem::Do() { // In all cases that reach here, copy source to destination. if (file_util::CopyDirectory(source_path_, dest_path_, true)) { copied_to_dest_path_ = true; - LOG(INFO) << "Copied source " << source_path_.value() - << " to destination " << dest_path_.value(); + LOG(INFO) << "Copied source " << source_path_ + << " to destination " << dest_path_; } else { - LOG(ERROR) << "failed copy " << source_path_.value() << - " to " << dest_path_.value(); + LOG(ERROR) << "failed copy " << source_path_ << " to " << dest_path_; return false; } @@ -107,23 +105,22 @@ void CopyTreeWorkItem::Rollback() { // Delete here. For now we just log the error and continue with the // rest of rollback operation. if (copied_to_dest_path_ && !file_util::Delete(dest_path_, true)) { - LOG(ERROR) << "Can not delete " << dest_path_.value(); + LOG(ERROR) << "Can not delete " << dest_path_; } if (moved_to_backup_ && !file_util::Move(backup_path_, dest_path_)) { - LOG(ERROR) << "failed move " << backup_path_.value() << " to " << - dest_path_.value(); + LOG(ERROR) << "failed move " << backup_path_ << " to " << dest_path_; } if (copied_to_alternate_path_ && !file_util::Delete(alternative_path_, true)) { - LOG(ERROR) << "Can not delete " << alternative_path_.value(); + LOG(ERROR) << "Can not delete " << alternative_path_; } } -bool CopyTreeWorkItem::IsFileInUse(const FilePath& path) { +bool CopyTreeWorkItem::IsFileInUse(const std::wstring& path) { if (!file_util::PathExists(path)) return false; - HANDLE handle = ::CreateFile(path.value().c_str(), FILE_ALL_ACCESS, + HANDLE handle = ::CreateFile(path.c_str(), FILE_ALL_ACCESS, NULL, NULL, OPEN_EXISTING, NULL, NULL); if (handle == INVALID_HANDLE_VALUE) return true; @@ -133,14 +130,16 @@ bool CopyTreeWorkItem::IsFileInUse(const FilePath& path) { } bool CopyTreeWorkItem::GetBackupPath() { - backup_path_ = temp_dir_.Append(dest_path_.BaseName()); + std::wstring file_name = file_util::GetFilenameFromPath(dest_path_); + backup_path_.assign(temp_dir_); + file_util::AppendToPath(&backup_path_, file_name); if (file_util::PathExists(backup_path_)) { // Ideally we should not fail immediately. Instead we could try some // random paths under temp_dir_ until we reach certain limit. // For now our caller always provides a good temporary directory so // we don't bother. - LOG(ERROR) << "backup path " << backup_path_.value() << " already exists"; + LOG(ERROR) << "backup path " << backup_path_ << " already exists"; return false; } diff --git a/chrome/installer/util/copy_tree_work_item.h b/chrome/installer/util/copy_tree_work_item.h index b899324..9fa1d96 100644 --- a/chrome/installer/util/copy_tree_work_item.h +++ b/chrome/installer/util/copy_tree_work_item.h @@ -7,8 +7,6 @@ #include <string> #include <windows.h> - -#include "base/file_path.h" #include "chrome/installer/util/work_item.h" // A WorkItem subclass that recursively copies a file system hierarchy from @@ -42,20 +40,20 @@ class CopyTreeWorkItem : public WorkItem { const std::wstring& alternative_path); // Checks if the path specified is in use (and hence can not be deleted) - bool IsFileInUse(const FilePath& path); + bool IsFileInUse(const std::wstring& path); // Get a backup path that can keep the original files under dest_path_, // and set backup_path_ with the result. bool GetBackupPath(); // Source path to copy files from. - FilePath source_path_; + std::wstring source_path_; // Destination path to copy files to. - FilePath dest_path_; + std::wstring dest_path_; // Temporary directory that can be used. - FilePath temp_dir_; + std::wstring temp_dir_; // Controls the behavior for overwriting. CopyOverWriteOption overwrite_option_; @@ -63,7 +61,7 @@ class CopyTreeWorkItem : public WorkItem { // If overwrite_option_ = NEW_NAME_IF_IN_USE, this variables stores the path // to be used if the file is in use and hence we want to copy it to a // different path. - FilePath alternative_path_; + std::wstring alternative_path_; // Whether the source was copied to dest_path_ bool copied_to_dest_path_; @@ -78,7 +76,7 @@ class CopyTreeWorkItem : public WorkItem { // The full path in temporary directory that the original dest_path_ has // been moved to. - FilePath backup_path_; + std::wstring backup_path_; }; #endif // CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ diff --git a/chrome/installer/util/copy_tree_work_item_unittest.cc b/chrome/installer/util/copy_tree_work_item_unittest.cc index bc187e61..c8cae21 100644 --- a/chrome/installer/util/copy_tree_work_item_unittest.cc +++ b/chrome/installer/util/copy_tree_work_item_unittest.cc @@ -61,11 +61,11 @@ namespace { file.close(); } - bool IsFileInUse(const FilePath& path) { + bool IsFileInUse(const std::wstring& path) { if (!file_util::PathExists(path)) return false; - HANDLE handle = ::CreateFile(path.value().c_str(), FILE_ALL_ACCESS, + HANDLE handle = ::CreateFile(path.c_str(), FILE_ALL_ACCESS, NULL, NULL, OPEN_EXISTING, NULL, NULL); if (handle == INVALID_HANDLE_VALUE) return true; @@ -478,10 +478,10 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { file_name_from.ToWStringHack(), file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), WorkItem::NEW_NAME_IF_IN_USE, alternate_to.ToWStringHack())); - if (IsFileInUse(file_name_to)) + if (IsFileInUse(file_name_to.value())) PlatformThread::Sleep(2000); // If file is still in use, the rest of the test will fail. - ASSERT_FALSE(IsFileInUse(file_name_to)); + ASSERT_FALSE(IsFileInUse(file_name_to.value())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(file_name_from)); diff --git a/chrome/installer/util/delete_after_reboot_helper.cc b/chrome/installer/util/delete_after_reboot_helper.cc index 1bc322c..a54acb3 100644 --- a/chrome/installer/util/delete_after_reboot_helper.cc +++ b/chrome/installer/util/delete_after_reboot_helper.cc @@ -64,7 +64,7 @@ bool ScheduleFileSystemEntityForDeletion(const wchar_t* path) { } DWORD flags = MOVEFILE_DELAY_UNTIL_REBOOT; - if (!file_util::DirectoryExists(FilePath::FromWStringHack(path))) { + if (!file_util::DirectoryExists(path)) { // This flag valid only for files flags |= MOVEFILE_REPLACE_EXISTING; } diff --git a/chrome/installer/util/delete_tree_work_item.cc b/chrome/installer/util/delete_tree_work_item.cc index 3102485..8e5610a 100644 --- a/chrome/installer/util/delete_tree_work_item.cc +++ b/chrome/installer/util/delete_tree_work_item.cc @@ -7,11 +7,11 @@ #include "chrome/installer/util/delete_tree_work_item.h" DeleteTreeWorkItem::~DeleteTreeWorkItem() { - FilePath tmp_dir = backup_path_.DirName(); + std::wstring tmp_dir = file_util::GetDirectoryFromPath(backup_path_); if (file_util::PathExists(tmp_dir)) { file_util::Delete(tmp_dir, true); } - tmp_dir = key_backup_path_.DirName(); + tmp_dir = file_util::GetDirectoryFromPath(key_backup_path_); if (file_util::PathExists(tmp_dir)) { file_util::Delete(tmp_dir, true); } @@ -30,8 +30,8 @@ bool DeleteTreeWorkItem::Do() { if (!GetBackupPath(key_path_, &key_backup_path_) || !file_util::CopyDirectory(key_path_, key_backup_path_, true) || !file_util::Delete(key_path_, true)) { - LOG(ERROR) << "can not delete " << key_path_.value() - << " OR copy it to backup path " << key_backup_path_.value(); + LOG(ERROR) << "can not delete " << key_path_ + << " OR copy it to backup path " << key_backup_path_; return false; } } @@ -40,8 +40,8 @@ bool DeleteTreeWorkItem::Do() { if (!GetBackupPath(root_path_, &backup_path_) || !file_util::CopyDirectory(root_path_, backup_path_, true) || !file_util::Delete(root_path_, true)) { - LOG(ERROR) << "can not delete " << root_path_.value() - << " OR copy it to backup path " << backup_path_.value(); + LOG(ERROR) << "can not delete " << root_path_ + << " OR copy it to backup path " << backup_path_; return false; } } @@ -58,14 +58,15 @@ void DeleteTreeWorkItem::Rollback() { } } -bool DeleteTreeWorkItem::GetBackupPath(const FilePath& for_path, - FilePath* backup_path) { +bool DeleteTreeWorkItem::GetBackupPath(const std::wstring& for_path, + std::wstring* backup_path) { if (!file_util::CreateNewTempDirectory(L"", backup_path)) { // We assume that CreateNewTempDirectory() is doing its job well. LOG(ERROR) << "Couldn't get backup path for delete."; return false; } + std::wstring file_name = file_util::GetFilenameFromPath(for_path); + file_util::AppendToPath(backup_path, file_name); - *backup_path = backup_path->Append(for_path.BaseName()); return true; } diff --git a/chrome/installer/util/delete_tree_work_item.h b/chrome/installer/util/delete_tree_work_item.h index b5bcb50..cf7b4be 100644 --- a/chrome/installer/util/delete_tree_work_item.h +++ b/chrome/installer/util/delete_tree_work_item.h @@ -7,8 +7,6 @@ #include <string> #include <windows.h> - -#include "base/file_path.h" #include "chrome/installer/util/work_item.h" // A WorkItem subclass that recursively deletes a file system hierarchy at the @@ -28,25 +26,25 @@ class DeleteTreeWorkItem : public WorkItem { friend class WorkItem; // Get a backup path that can keep root_path_ or key_path_ - bool GetBackupPath(const FilePath& for_path, FilePath* backup_path); + bool GetBackupPath(const std::wstring& for_path, std::wstring* backup_path); DeleteTreeWorkItem(const std::wstring& root_path, const std::wstring& key_path); // Root path to delete. - FilePath root_path_; + std::wstring root_path_; // Path to the key file. If the key file is specified, deletion will be // performed only if the key file is not in use. - FilePath key_path_; + std::wstring key_path_; // The full path in temporary directory that the original root_path_ has // been moved to. - FilePath backup_path_; + std::wstring backup_path_; // The full path in temporary directory that the original key_path_ has // been moved to. - FilePath key_backup_path_; + std::wstring key_backup_path_; }; #endif // CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ diff --git a/chrome/installer/util/move_tree_work_item.cc b/chrome/installer/util/move_tree_work_item.cc index 45c03b2..b90665e 100644 --- a/chrome/installer/util/move_tree_work_item.cc +++ b/chrome/installer/util/move_tree_work_item.cc @@ -26,26 +26,30 @@ MoveTreeWorkItem::MoveTreeWorkItem(const std::wstring& source_path, bool MoveTreeWorkItem::Do() { if (!file_util::PathExists(source_path_)) { - LOG(ERROR) << source_path_.value() << " does not exist"; + LOG(ERROR) << source_path_ << " does not exist"; return false; } + FilePath backup_path; + // If dest_path_ exists, move destination to a backup path. if (file_util::PathExists(dest_path_)) { // Generate a backup path that can keep the original files under dest_path_. if (!file_util::CreateTemporaryFileInDir(FilePath(temp_dir_), - &backup_path_)) { - LOG(ERROR) << "Failed to get backup path in folder " << temp_dir_.value(); + &backup_path)) { + LOG(ERROR) << "Failed to get backup path in folder " << temp_dir_; return false; } + backup_path_ = backup_path.value(); + if (file_util::Move(dest_path_, backup_path_)) { moved_to_backup_ = true; - LOG(INFO) << "Moved destination " << dest_path_.value() - << " to backup path " << backup_path_.value(); + LOG(INFO) << "Moved destination " << dest_path_ + << " to backup path " << backup_path_; } else { - LOG(ERROR) << "failed moving " << dest_path_.value() - << " to " << backup_path_.value(); + LOG(ERROR) << "failed moving " << dest_path_ + << " to " << backup_path_; return false; } } @@ -53,11 +57,10 @@ bool MoveTreeWorkItem::Do() { // Now move source to destination. if (file_util::Move(source_path_, dest_path_)) { moved_to_dest_path_ = true; - LOG(INFO) << "Moved source " << source_path_.value() - << " to destination " << dest_path_.value(); + LOG(INFO) << "Moved source " << source_path_ + << " to destination " << dest_path_; } else { - LOG(ERROR) << "failed move " << source_path_.value() << " to " << - dest_path_.value(); + LOG(ERROR) << "failed move " << source_path_ << " to " << dest_path_; return false; } @@ -66,10 +69,8 @@ bool MoveTreeWorkItem::Do() { void MoveTreeWorkItem::Rollback() { if (moved_to_dest_path_ && !file_util::Move(dest_path_, source_path_)) - LOG(ERROR) << "Can not move " << dest_path_.value() << - " to " << source_path_.value(); + LOG(ERROR) << "Can not move " << dest_path_ << " to " << source_path_; if (moved_to_backup_ && !file_util::Move(backup_path_, dest_path_)) - LOG(ERROR) << "failed move " << backup_path_.value() << - " to " << dest_path_.value(); + LOG(ERROR) << "failed move " << backup_path_ << " to " << dest_path_; } diff --git a/chrome/installer/util/move_tree_work_item.h b/chrome/installer/util/move_tree_work_item.h index cfa86c4..95964fb 100644 --- a/chrome/installer/util/move_tree_work_item.h +++ b/chrome/installer/util/move_tree_work_item.h @@ -38,17 +38,17 @@ class MoveTreeWorkItem : public WorkItem { const std::wstring& temp_dir); // Source path to move files from. - FilePath source_path_; + std::wstring source_path_; // Destination path to move files to. - FilePath dest_path_; + std::wstring dest_path_; // Temporary directory to backup dest_path_ (if it already exists). - FilePath temp_dir_; + std::wstring temp_dir_; // The full path in temp_dir_ where the original dest_path_ has // been moved to. - FilePath backup_path_; + std::wstring backup_path_; // Whether the source was moved to dest_path_ bool moved_to_dest_path_; diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 8e00ba2..86e588b 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -295,7 +295,7 @@ bool ElevateAndRegisterChrome(const std::wstring& chrome_exe, const std::wstring& suffix) { std::wstring exe_path(file_util::GetDirectoryFromPath(chrome_exe)); file_util::AppendToPath(&exe_path, installer_util::kSetupExe); - if (!file_util::PathExists(FilePath::FromWStringHack(exe_path))) { + if (!file_util::PathExists(exe_path)) { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); HKEY reg_root = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; @@ -305,7 +305,7 @@ bool ElevateAndRegisterChrome(const std::wstring& chrome_exe, command_line.ParseFromString(exe_path); exe_path = command_line.program(); } - if (file_util::PathExists(FilePath::FromWStringHack(exe_path))) { + if (file_util::PathExists(exe_path)) { std::wstring params(L"--"); params.append(installer_util::switches::kRegisterChromeBrowser); params.append(L"=\"" + chrome_exe + L"\""); diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.cc b/chrome/test/mini_installer_test/chrome_mini_installer.cc index 3c50b46..75fab2d8 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.cc +++ b/chrome/test/mini_installer_test/chrome_mini_installer.cc @@ -112,7 +112,7 @@ void ChromeMiniInstaller::InstallMiniInstaller(bool over_install, printf("\nChrome will be installed at %ls level\n", install_type_.c_str()); printf("\nWill proceed with the test only if this path exists: %ls\n\n", path.c_str()); - ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(path))); + ASSERT_TRUE(file_util::PathExists(path)); LaunchInstaller(path, exe_name.c_str()); BrowserDistribution* dist = BrowserDistribution::GetDistribution(); ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())); @@ -230,7 +230,7 @@ void ChromeMiniInstaller::UnInstall() { CleanChromeInstall(); return; } - ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(uninstall_path))); + ASSERT_TRUE(file_util::PathExists(uninstall_path)); std::wstring uninstall_args = L"\"" + uninstall_path + L"\"" + L" --uninstall --force-uninstall"; if (install_type_ == mini_installer_constants::kSystemInstall) @@ -403,16 +403,15 @@ void ChromeMiniInstaller::FindChromeShortcut() { path = GetStartMenuShortcutPath(); file_util::AppendToPath(&path, mini_installer_constants::kChromeBuildType); // Verify if path exists. - if (file_util::PathExists(FilePath::FromWStringHack(path))) { + if (file_util::PathExists(path)) { return_val = true; uninstall_lnk = path; file_util::AppendToPath(&path, mini_installer_constants::kChromeLaunchShortcut); file_util::AppendToPath(&uninstall_lnk, mini_installer_constants::kChromeUninstallShortcut); - ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(path))); - ASSERT_TRUE(file_util::PathExists( - FilePath::FromWStringHack(uninstall_lnk))); + ASSERT_TRUE(file_util::PathExists(path)); + ASSERT_TRUE(file_util::PathExists(uninstall_lnk)); } if (return_val) printf("Chrome shortcuts found are:\n%ls\n%ls\n\n", @@ -453,7 +452,7 @@ std::wstring ChromeMiniInstaller::GetUninstallPath() { file_util::AppendToPath(&path, installer_util::kInstallerDir); file_util::AppendToPath(&path, mini_installer_constants::kChromeSetupExecutable); - if (!file_util::PathExists(FilePath::FromWStringHack(path))) { + if (!file_util::PathExists(path)) { printf("This uninstall path is not correct %ls. Will not proceed further", path.c_str()); return L""; @@ -486,7 +485,7 @@ HKEY ChromeMiniInstaller::GetRootRegistryKey() { // Launches the chrome installer and waits for it to end. void ChromeMiniInstaller::LaunchInstaller(const std::wstring& path, const wchar_t* process_name) { - ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(path))); + ASSERT_TRUE(file_util::PathExists(path)); if (install_type_ == mini_installer_constants::kSystemInstall) { std::wstring launch_args = L" -system-level"; base::LaunchApp(L"\"" + path + L"\"" + launch_args, false, false, NULL); @@ -505,7 +504,7 @@ bool ChromeMiniInstaller::GetChromeLaunchPath(std::wstring* launch_path) { file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); file_util::AppendToPath(&path, installer_util::kChromeExe); launch_path->assign(path); - return(file_util::PathExists(FilePath::FromWStringHack(path))); + return(file_util::PathExists(path)); } // Launch Chrome to see if it works after overinstall. Then close it. diff --git a/chrome/test/mini_installer_test/mini_installer_test_util.cc b/chrome/test/mini_installer_test/mini_installer_test_util.cc index 3593f10..9c511d1 100644 --- a/chrome/test/mini_installer_test/mini_installer_test_util.cc +++ b/chrome/test/mini_installer_test/mini_installer_test_util.cc @@ -117,14 +117,14 @@ bool MiniInstallerTestUtil::GetInstaller(const wchar_t* pattern, ++builds_list_size; } else { file_util::AppendToPath(path, exe_list.at(0).name_.c_str()); - if (!file_util::PathExists(FilePath::FromWStringHack(*path))) { + if (!file_util::PathExists(*path)) { ++builds_list_size; } else { break; } } } - return file_util::PathExists(FilePath::FromWStringHack(*path)); + return (file_util::PathExists(path->c_str())); } // This method will get the latest installer filename from the directory. @@ -202,7 +202,7 @@ bool MiniInstallerTestUtil::GetPreviousFullInstaller( &directory_list)) return false; file_util::AppendToPath(previous, directory_list.at(0).name_); - return file_util::PathExists(FilePath::FromWStringHack(*previous)); + return (file_util::PathExists(previous->c_str())); } bool MiniInstallerTestUtil::GetStandaloneInstallerFileName( @@ -210,9 +210,9 @@ bool MiniInstallerTestUtil::GetStandaloneInstallerFileName( std::wstring standalone_installer( mini_installer_constants::kChromeStandAloneInstallerLocation); standalone_installer.append(L"*.exe"); - return GetLatestFile(standalone_installer.c_str(), - mini_installer_constants::kUntaggedInstallerPattern, - file_name); + return (GetLatestFile(standalone_installer.c_str(), + mini_installer_constants::kUntaggedInstallerPattern, + file_name)); } bool MiniInstallerTestUtil::GetStandaloneVersion( diff --git a/chrome/test/mini_installer_test/run_all_unittests.cc b/chrome/test/mini_installer_test/run_all_unittests.cc index 9f2dc9f..767ead2 100644 --- a/chrome/test/mini_installer_test/run_all_unittests.cc +++ b/chrome/test/mini_installer_test/run_all_unittests.cc @@ -15,20 +15,22 @@ void BackUpProfile() { exit(1); } ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); - FilePath path = - FilePath::FromWStringHack(installer.GetChromeInstallDirectoryLocation()); - path = path.Append(mini_installer_constants::kChromeAppDir).DirName(); - FilePath backup_path = path; + std::wstring path = installer.GetChromeInstallDirectoryLocation(); + file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); + file_util::UpOneDirectory(&path); + std::wstring backup_path = path; // Will hold User Data path that needs to be backed-up. - path = path.Append(mini_installer_constants::kChromeUserDataDir); + file_util::AppendToPath(&path, + mini_installer_constants::kChromeUserDataDir); // Will hold new backup path to save the profile. - backup_path = path.Append(mini_installer_constants::kChromeUserDataBackupDir); + file_util::AppendToPath(&backup_path, + mini_installer_constants::kChromeUserDataBackupDir); // Will check if User Data profile is available. if (file_util::PathExists(path)) { // Will check if User Data is already backed up. // If yes, will delete and create new one. if (file_util::PathExists(backup_path)) - file_util::Delete(backup_path, true); + file_util::Delete(backup_path.c_str(), true); file_util::CopyDirectory(path, backup_path, true); } else { printf("Chrome is not installed. Will not take any backup\n"); diff --git a/chrome/tools/crash_service/main.cc b/chrome/tools/crash_service/main.cc index cf6bab9..d6a1a20 100644 --- a/chrome/tools/crash_service/main.cc +++ b/chrome/tools/crash_service/main.cc @@ -17,11 +17,11 @@ namespace { const wchar_t kStandardLogFile[] = L"operation_log.txt"; -bool GetCrashServiceDirectory(FilePath* dir) { - FilePath temp_dir; +bool GetCrashServiceDirectory(std::wstring* dir) { + std::wstring temp_dir; if (!file_util::GetTempDir(&temp_dir)) return false; - temp_dir = temp_dir.Append(L"chrome_crashes"); + file_util::AppendToPath(&temp_dir, L"chrome_crashes"); if (!file_util::PathExists(temp_dir)) { if (!file_util::CreateDirectory(temp_dir)) return false; @@ -40,18 +40,19 @@ int __stdcall wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd_line, CommandLine::Init(0, NULL); // We use/create a directory under the user's temp folder, for logging. - FilePath operating_dir; + std::wstring operating_dir; GetCrashServiceDirectory(&operating_dir); - FilePath log_file = operating_dir.Append(kStandardLogFile); + std::wstring log_file(operating_dir); + file_util::AppendToPath(&log_file, kStandardLogFile); // Logging to a file with pid, tid and timestamp. - logging::InitLogging(log_file.value().c_str(), logging::LOG_ONLY_TO_FILE, + logging::InitLogging(log_file.c_str(), logging::LOG_ONLY_TO_FILE, logging::LOCK_LOG_FILE, logging::APPEND_TO_OLD_LOG_FILE); logging::SetLogItems(true, true, true, false); LOG(INFO) << "session start. cmdline is [" << cmd_line << "]"; - CrashService crash_service(operating_dir.ToWStringHack()); + CrashService crash_service(operating_dir); if (!crash_service.Initialize(::GetCommandLineW())) return 1; diff --git a/chrome_frame/chrome_launcher.cc b/chrome_frame/chrome_launcher.cc index b9af23d..f742a28 100644 --- a/chrome_frame/chrome_launcher.cc +++ b/chrome_frame/chrome_launcher.cc @@ -90,10 +90,10 @@ bool SanitizeAndLaunchChrome(const wchar_t* command_line) { return base::LaunchApp(sanitized.command_line_string(), false, false, NULL); } -FilePath GetChromeExecutablePath() { - FilePath cur_path; +std::wstring GetChromeExecutablePath() { + std::wstring cur_path; PathService::Get(base::DIR_MODULE, &cur_path); - cur_path = cur_path.Append(chrome::kBrowserProcessExecutableName); + file_util::AppendToPath(&cur_path, chrome::kBrowserProcessExecutableName); // The installation model for Chrome places the DLLs in a versioned // sub-folder one down from the Chrome executable. If we fail to find @@ -101,7 +101,8 @@ FilePath GetChromeExecutablePath() { // instead. if (!file_util::PathExists(cur_path)) { PathService::Get(base::DIR_MODULE, &cur_path); - cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName); + file_util::UpOneDirectory(&cur_path); + file_util::AppendToPath(&cur_path, chrome::kBrowserProcessExecutableName); } return cur_path; diff --git a/chrome_frame/chrome_launcher.h b/chrome_frame/chrome_launcher.h index 86dc03f..7c2aea9 100644 --- a/chrome_frame/chrome_launcher.h +++ b/chrome_frame/chrome_launcher.h @@ -7,8 +7,6 @@ #include <string> -#include "base/file_path.h" - class CommandLine; namespace chrome_launcher { @@ -32,12 +30,12 @@ CommandLine* CreateLaunchCommandLine(); void SanitizeCommandLine(const CommandLine& original, CommandLine* sanitized); // Given a command-line without an initial program part, launch our associated -// chrome.exe with a sanitized version of that command line. Returns true iff +// chrome.exe with a sanitized version of that command line. Returns true iff // successful. bool SanitizeAndLaunchChrome(const wchar_t* command_line); // Returns the full path to the Chrome executable. -FilePath GetChromeExecutablePath(); +std::wstring GetChromeExecutablePath(); // The type of the CfLaunchChrome entrypoint exported from this DLL. typedef int (__stdcall *CfLaunchChromeProc)(); diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index 601ef06..923d957d8 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -61,10 +61,10 @@ class ChromeTabModule } if (SUCCEEDED(hr)) { - FilePath app_path = - chrome_launcher::GetChromeExecutablePath().DirName(); - hr = registrar->AddReplacement(L"CHROME_APPPATH", - app_path.value().c_str()); + std::wstring app_path( + chrome_launcher::GetChromeExecutablePath()); + app_path = file_util::GetDirectoryFromPath(app_path); + hr = registrar->AddReplacement(L"CHROME_APPPATH", app_path.c_str()); DCHECK(SUCCEEDED(hr)); } diff --git a/chrome_frame/test/perf/chrome_frame_perftest.cc b/chrome_frame/test/perf/chrome_frame_perftest.cc index c896fa4..79bbd7b 100644 --- a/chrome_frame/test/perf/chrome_frame_perftest.cc +++ b/chrome_frame/test/perf/chrome_frame_perftest.cc @@ -621,8 +621,7 @@ class ChromeFrameMemoryTest : public ChromeFramePerfTestBase { file_util::AppendToPath(&chrome_exe_test_path, chrome::kBrowserProcessExecutableName); - if (!file_util::PathExists( - FilePath::FromWStringHack(chrome_exe_test_path))) { + if (!file_util::PathExists(chrome_exe_test_path)) { file_util::UpOneDirectory(&chrome_exe_path); chrome_exe_test_path = chrome_exe_path; @@ -630,8 +629,7 @@ class ChromeFrameMemoryTest : public ChromeFramePerfTestBase { chrome::kBrowserProcessExecutableName); } - EXPECT_TRUE( - file_util::PathExists(FilePath::FromWStringHack(chrome_exe_test_path))); + EXPECT_TRUE(file_util::PathExists(chrome_exe_test_path)); return chrome_exe_path; } diff --git a/chrome_frame/test_utils.cc b/chrome_frame/test_utils.cc index abfdbee..2d47c71 100644 --- a/chrome_frame/test_utils.cc +++ b/chrome_frame/test_utils.cc @@ -15,18 +15,17 @@ // Statics -FilePath ScopedChromeFrameRegistrar::GetChromeFrameBuildPath() { - FilePath build_path; +std::wstring ScopedChromeFrameRegistrar::GetChromeFrameBuildPath() { + std::wstring build_path; PathService::Get(chrome::DIR_APP, &build_path); - build_path = build_path.Append(L"servers"). - Append(L"npchrome_tab.dll"); + file_util::AppendToPath(&build_path, L"servers\\npchrome_tab.dll"); file_util::PathExists(build_path); return build_path; } void ScopedChromeFrameRegistrar::RegisterDefaults() { - FilePath dll_path = GetChromeFrameBuildPath(); - RegisterAtPath(dll_path.value()); + std::wstring dll_path_ = GetChromeFrameBuildPath(); + RegisterAtPath(dll_path_); } void ScopedChromeFrameRegistrar::RegisterAtPath( @@ -57,7 +56,7 @@ void ScopedChromeFrameRegistrar::RegisterAtPath( // Non-statics ScopedChromeFrameRegistrar::ScopedChromeFrameRegistrar() { - original_dll_path_ = GetChromeFrameBuildPath().ToWStringHack(); + original_dll_path_ = GetChromeFrameBuildPath(); RegisterChromeFrameAtPath(original_dll_path_); } diff --git a/net/tools/crash_cache/crash_cache.cc b/net/tools/crash_cache/crash_cache.cc index dd56247..36c64e2 100644 --- a/net/tools/crash_cache/crash_cache.cc +++ b/net/tools/crash_cache/crash_cache.cc @@ -111,7 +111,7 @@ bool CreateTargetFolder(const std::wstring& path, RankCrashes action, *full_path = path; file_util::AppendToPath(full_path, folders[action]); - if (file_util::PathExists(FilePath::FromWStringHack(*full_path))) + if (file_util::PathExists(*full_path)) return false; return file_util::CreateDirectory(*full_path); diff --git a/skia/ext/vector_canvas_unittest.cc b/skia/ext/vector_canvas_unittest.cc index 2d5d728..59c6d0b 100644 --- a/skia/ext/vector_canvas_unittest.cc +++ b/skia/ext/vector_canvas_unittest.cc @@ -84,7 +84,7 @@ class Bitmap { class Image { public: // Creates the image from the given filename on disk. - explicit Image(const FilePath& filename) : ignore_alpha_(true) { + Image(const std::wstring& filename) : ignore_alpha_(true) { Vector<char> compressed; ReadFileToVector(filename, &compressed); EXPECT_TRUE(compressed.size()); @@ -123,7 +123,7 @@ class Image { int row_length() const { return row_length_; } // Save the image to a png file. Used to create the initial test files. - void SaveToFile(const FilePath& filename) { + void SaveToFile(const std::wstring& filename) { std::vector<unsigned char> compressed; ASSERT_TRUE(gfx::PNGCodec::Encode(&*data_.begin(), gfx::PNGCodec::FORMAT_BGRA, @@ -229,17 +229,18 @@ class ImageTest : public testing::Test { const testing::TestInfo& test_info = *testing::UnitTest::GetInstance()->current_test_info(); PathService::Get(base::DIR_SOURCE_ROOT, &test_dir_); - test_dir_ = test_dir_.AppendASCII("skia"). - AppendASCII("ext"). - AppendASCII("data"). - AppendASCII(test_info.test_case_name()). - AppendASCII(test_info.name()); + file_util::AppendToPath(&test_dir_, L"skia"); + file_util::AppendToPath(&test_dir_, L"ext"); + file_util::AppendToPath(&test_dir_, L"data"); + file_util::AppendToPath(&test_dir_, + ASCIIToWide(test_info.test_case_name())); + file_util::AppendToPath(&test_dir_, ASCIIToWide(test_info.name())); // Hack for a quick lowercase. We assume all the tests names are ASCII. - std::string tmp(WideToASCII(test_dir_.ToWStringHack())); + std::string tmp(WideToASCII(test_dir_)); for (size_t i = 0; i < tmp.size(); ++i) tmp[i] = ToLowerASCII(tmp[i]); - test_dir_ = FilePath::FromWStringHack(ASCIIToWide(tmp)); + test_dir_ = ASCIIToWide(tmp); if (action_ == GENERATE) { // Make sure the directory exist. @@ -248,18 +249,16 @@ class ImageTest : public testing::Test { } // Returns the fully qualified path of a data file. - FilePath test_file(const FilePath::StringType& filename) const { + std::wstring test_file(const std::wstring& filename) const { // Hack for a quick lowercase. We assume all the test data file names are // ASCII. -#if defined(OS_WIN) - std::string tmp = WideToASCII(filename); -#else - std::string tmp(filename); -#endif + std::string tmp(WideToASCII(filename)); for (size_t i = 0; i < tmp.size(); ++i) tmp[i] = ToLowerASCII(tmp[i]); - return test_dir_.AppendASCII(tmp); + std::wstring path(test_dir_); + file_util::AppendToPath(&path, ASCIIToWide(tmp)); + return path; } // Compares or saves the bitmap currently loaded in the context, depending on @@ -267,8 +266,8 @@ class ImageTest : public testing::Test { // 100] on failure. The return value is the percentage of difference between // the image in the file and the image in the canvas. double ProcessCanvas(const skia::PlatformCanvas& canvas, - FilePath::StringType filename) const { - filename = filename + FILE_PATH_LITERAL(".png"); + std::wstring filename) const { + filename += L".png"; switch (action_) { case GENERATE: SaveImage(canvas, filename); @@ -286,7 +285,7 @@ class ImageTest : public testing::Test { // Compares the bitmap currently loaded in the context with the file. Returns // the percentage of pixel difference between both images, between 0 and 100. double CompareImage(const skia::PlatformCanvas& canvas, - const FilePath::StringType& filename) const { + const std::wstring& filename) const { Image image1(canvas); Image image2(test_file(filename)); double diff = image1.PercentageDifferent(image2); @@ -295,14 +294,14 @@ class ImageTest : public testing::Test { // Saves the bitmap currently loaded in the context into the file. void SaveImage(const skia::PlatformCanvas& canvas, - const FilePath::StringType& filename) const { + const std::wstring& filename) const { Image(canvas).SaveToFile(test_file(filename)); } ProcessAction action_; // Path to directory used to contain the test data. - FilePath test_dir_; + std::wstring test_dir_; DISALLOW_COPY_AND_ASSIGN(ImageTest); }; @@ -329,7 +328,7 @@ void Premultiply(SkBitmap bitmap) { } } -void LoadPngFileToSkBitmap(const FilePath& filename, +void LoadPngFileToSkBitmap(const std::wstring& filename, SkBitmap* bitmap, bool is_opaque) { Vector<char> compressed; @@ -398,7 +397,7 @@ class VectorCanvasTest : public ImageTest { // Compares both canvas and returns the pixel difference in percentage between // both images. 0 on success and ]0, 100] on failure. - double ProcessImage(const FilePath::StringType& filename) { + double ProcessImage(const std::wstring& filename) { std::wstring number(StringPrintf(L"%02d_", number_++)); double diff1 = parent::ProcessCanvas(*vcanvas_, number + L"vc_" + filename); double diff2 = parent::ProcessCanvas(*pcanvas_, number + L"pc_" + filename); @@ -461,20 +460,20 @@ TEST_F(VectorCanvasTest, Uninitialized) { // PlatformCanvas default initialization is almost white 0x01FFFEFD (invalid // Skia color) in both Debug and Release. See magicTransparencyColor in // platform_device.cc - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("empty"))); + EXPECT_EQ(0., ProcessImage(L"empty")); } TEST_F(VectorCanvasTest, BasicDrawing) { EXPECT_EQ(Image(*vcanvas_).PercentageDifferent(Image(*pcanvas_)), 0.) << L"clean"; - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("clean"))); + EXPECT_EQ(0., ProcessImage(L"clean")); // Clear white. { vcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); pcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawARGB"))); + EXPECT_EQ(0., ProcessImage(L"drawARGB")); // Diagonal line top-left to bottom-right. { @@ -483,7 +482,7 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawLine(10, 10, 90, 90, paint); pcanvas_->drawLine(10, 10, 90, 90, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawLine_black"))); + EXPECT_EQ(0., ProcessImage(L"drawLine_black")); // Rect. { @@ -492,7 +491,7 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawRectCoords(25, 25, 75, 75, paint); pcanvas_->drawRectCoords(25, 25, 75, 75, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawRect_green"))); + EXPECT_EQ(0., ProcessImage(L"drawRect_green")); // A single-point rect doesn't leave any mark. { @@ -501,7 +500,7 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawRectCoords(5, 5, 5, 5, paint); pcanvas_->drawRectCoords(5, 5, 5, 5, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawRect_noop"))); + EXPECT_EQ(0., ProcessImage(L"drawRect_noop")); // Rect. { @@ -510,14 +509,14 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawRectCoords(75, 50, 80, 55, paint); pcanvas_->drawRectCoords(75, 50, 80, 55, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawRect_noop"))); + EXPECT_EQ(0., ProcessImage(L"drawRect_noop")); // Empty again { vcanvas_->drawPaint(SkPaint()); pcanvas_->drawPaint(SkPaint()); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawPaint_black"))); + EXPECT_EQ(0., ProcessImage(L"drawPaint_black")); // Horizontal line left to right. { @@ -526,7 +525,7 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawLine(10, 20, 90, 20, paint); pcanvas_->drawLine(10, 20, 90, 20, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawLine_left_to_right"))); + EXPECT_EQ(0., ProcessImage(L"drawLine_left_to_right")); // Vertical line downward. { @@ -535,7 +534,7 @@ TEST_F(VectorCanvasTest, BasicDrawing) { vcanvas_->drawLine(30, 10, 30, 90, paint); pcanvas_->drawLine(30, 10, 30, 90, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawLine_red"))); + EXPECT_EQ(0., ProcessImage(L"drawLine_red")); } TEST_F(VectorCanvasTest, Circles) { @@ -553,7 +552,7 @@ TEST_F(VectorCanvasTest, Circles) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_stroke"))); + EXPECT_EQ(0., ProcessImage(L"circle_stroke")); // Filled Circle. { @@ -564,7 +563,7 @@ TEST_F(VectorCanvasTest, Circles) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_fill"))); + EXPECT_EQ(0., ProcessImage(L"circle_fill")); // Stroked Circle over. { @@ -576,7 +575,7 @@ TEST_F(VectorCanvasTest, Circles) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_over_strike"))); + EXPECT_EQ(0., ProcessImage(L"circle_over_strike")); // Stroke and Fill Circle. { @@ -588,7 +587,7 @@ TEST_F(VectorCanvasTest, Circles) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_stroke_and_fill"))); + EXPECT_EQ(0., ProcessImage(L"circle_stroke_and_fill")); // Line + Quad + Cubic. { @@ -607,7 +606,7 @@ TEST_F(VectorCanvasTest, Circles) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("mixed_stroke"))); + EXPECT_EQ(0., ProcessImage(L"mixed_stroke")); } TEST_F(VectorCanvasTest, LineOrientation) { @@ -626,7 +625,7 @@ TEST_F(VectorCanvasTest, LineOrientation) { vcanvas_->drawLine(90, 30, 10, 30, paint); pcanvas_->drawLine(90, 30, 10, 30, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("horizontal"))); + EXPECT_EQ(0., ProcessImage(L"horizontal")); // Vertical lines. { @@ -639,7 +638,7 @@ TEST_F(VectorCanvasTest, LineOrientation) { vcanvas_->drawLine(30, 90, 30, 10, paint); pcanvas_->drawLine(30, 90, 30, 10, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("vertical"))); + EXPECT_EQ(0., ProcessImage(L"vertical")); // Try again with a 180 degres rotation. vcanvas_->rotate(180); @@ -654,7 +653,7 @@ TEST_F(VectorCanvasTest, LineOrientation) { vcanvas_->drawLine(-90, -35, -10, -35, paint); pcanvas_->drawLine(-90, -35, -10, -35, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("horizontal_180"))); + EXPECT_EQ(0., ProcessImage(L"horizontal_180")); // Vertical lines (rotated). { @@ -665,7 +664,7 @@ TEST_F(VectorCanvasTest, LineOrientation) { vcanvas_->drawLine(-35, -90, -35, -10, paint); pcanvas_->drawLine(-35, -90, -35, -10, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("vertical_180"))); + EXPECT_EQ(0., ProcessImage(L"vertical_180")); } TEST_F(VectorCanvasTest, PathOrientation) { @@ -688,7 +687,7 @@ TEST_F(VectorCanvasTest, PathOrientation) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawPath_ltr"))); + EXPECT_EQ(0., ProcessImage(L"drawPath_ltr")); // Horizontal lines. { @@ -705,7 +704,7 @@ TEST_F(VectorCanvasTest, PathOrientation) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawPath_rtl"))); + EXPECT_EQ(0., ProcessImage(L"drawPath_rtl")); } TEST_F(VectorCanvasTest, DiagonalLines) { @@ -714,7 +713,7 @@ TEST_F(VectorCanvasTest, DiagonalLines) { vcanvas_->drawLine(10, 10, 90, 90, paint); pcanvas_->drawLine(10, 10, 90, 90, paint); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("nw-se"))); + EXPECT_EQ(0., ProcessImage(L"nw-se")); // Starting here, there is NO WAY to make them agree. At least verify that the // output doesn't change across versions. This test is disabled. See bug @@ -723,15 +722,15 @@ TEST_F(VectorCanvasTest, DiagonalLines) { vcanvas_->drawLine(10, 95, 90, 15, paint); pcanvas_->drawLine(10, 95, 90, 15, paint); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("sw-ne"))); + EXPECT_EQ(0., ProcessImage(L"sw-ne")); vcanvas_->drawLine(90, 10, 10, 90, paint); pcanvas_->drawLine(90, 10, 10, 90, paint); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("ne-sw"))); + EXPECT_EQ(0., ProcessImage(L"ne-sw")); vcanvas_->drawLine(95, 90, 15, 10, paint); pcanvas_->drawLine(95, 90, 15, 10, paint); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("se-nw"))); + EXPECT_EQ(0., ProcessImage(L"se-nw")); } TEST_F(VectorCanvasTest, PathEffects) { @@ -747,7 +746,7 @@ TEST_F(VectorCanvasTest, PathEffects) { vcanvas_->drawLine(10, 10, 90, 10, paint); pcanvas_->drawLine(10, 10, 90, 10, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("dash_line"))); + EXPECT_EQ(0., ProcessImage(L"dash_line")); // Starting here, there is NO WAY to make them agree. At least verify that the @@ -771,7 +770,7 @@ TEST_F(VectorCanvasTest, PathEffects) { vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("dash_path"))); + EXPECT_EQ(0., ProcessImage(L"dash_path")); { SkPaint paint; @@ -785,7 +784,7 @@ TEST_F(VectorCanvasTest, PathEffects) { vcanvas_->drawRectCoords(20, 20, 30, 30, paint); pcanvas_->drawRectCoords(20, 20, 30, 30, paint); } - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("dash_rect"))); + EXPECT_EQ(0., ProcessImage(L"dash_rect")); // This thing looks like it has been drawn by a 3 years old kid. I haven't // filed a bug on this since I guess nobody is expecting this to look nice. @@ -802,7 +801,7 @@ TEST_F(VectorCanvasTest, PathEffects) { path.addCircle(50, 75, 10); vcanvas_->drawPath(path, paint); pcanvas_->drawPath(path, paint); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle"))); + EXPECT_EQ(0., ProcessImage(L"circle")); } } @@ -812,7 +811,7 @@ TEST_F(VectorCanvasTest, Bitmaps) { LoadPngFileToSkBitmap(test_file(L"bitmap_opaque.png"), &bitmap, true); vcanvas_->drawBitmap(bitmap, 13, 3, NULL); pcanvas_->drawBitmap(bitmap, 13, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("opaque"))); + EXPECT_EQ(0., ProcessImage(L"opaque")); } { @@ -820,7 +819,7 @@ TEST_F(VectorCanvasTest, Bitmaps) { LoadPngFileToSkBitmap(test_file(L"bitmap_alpha.png"), &bitmap, false); vcanvas_->drawBitmap(bitmap, 5, 15, NULL); pcanvas_->drawBitmap(bitmap, 5, 15, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("alpha"))); + EXPECT_EQ(0., ProcessImage(L"alpha")); } } @@ -838,7 +837,7 @@ TEST_F(VectorCanvasTest, ClippingRect) { vcanvas_->drawBitmap(bitmap, 13, 3, NULL); pcanvas_->drawBitmap(bitmap, 13, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rect"))); + EXPECT_EQ(0., ProcessImage(L"rect")); } TEST_F(VectorCanvasTest, ClippingPath) { @@ -852,7 +851,7 @@ TEST_F(VectorCanvasTest, ClippingPath) { vcanvas_->drawBitmap(bitmap, 14, 3, NULL); pcanvas_->drawBitmap(bitmap, 14, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("path"))); + EXPECT_EQ(0., ProcessImage(L"path")); } TEST_F(VectorCanvasTest, ClippingCombined) { @@ -874,7 +873,7 @@ TEST_F(VectorCanvasTest, ClippingCombined) { vcanvas_->drawBitmap(bitmap, 15, 3, NULL); pcanvas_->drawBitmap(bitmap, 15, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("combined"))); + EXPECT_EQ(0., ProcessImage(L"combined")); } TEST_F(VectorCanvasTest, ClippingIntersect) { @@ -896,7 +895,7 @@ TEST_F(VectorCanvasTest, ClippingIntersect) { vcanvas_->drawBitmap(bitmap, 15, 3, NULL); pcanvas_->drawBitmap(bitmap, 15, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("intersect"))); + EXPECT_EQ(0., ProcessImage(L"intersect")); } TEST_F(VectorCanvasTest, ClippingClean) { @@ -915,7 +914,7 @@ TEST_F(VectorCanvasTest, ClippingClean) { vcanvas_->drawBitmap(bitmap, 15, 3, NULL); pcanvas_->drawBitmap(bitmap, 15, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("clipped"))); + EXPECT_EQ(0., ProcessImage(L"clipped")); vcanvas_->clipRegion(old_region, SkRegion::kReplace_Op); pcanvas_->clipRegion(old_region, SkRegion::kReplace_Op); } @@ -923,7 +922,7 @@ TEST_F(VectorCanvasTest, ClippingClean) { // Verify that the clipping region has been fixed back. vcanvas_->drawBitmap(bitmap, 55, 3, NULL); pcanvas_->drawBitmap(bitmap, 55, 3, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("unclipped"))); + EXPECT_EQ(0., ProcessImage(L"unclipped")); } } @@ -936,14 +935,14 @@ TEST_F(VectorCanvasTest, DISABLED_Matrix) { pcanvas_->translate(15, 3); vcanvas_->drawBitmap(bitmap, 0, 0, NULL); pcanvas_->drawBitmap(bitmap, 0, 0, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("translate1"))); + EXPECT_EQ(0., ProcessImage(L"translate1")); } { vcanvas_->translate(-30, -23); pcanvas_->translate(-30, -23); vcanvas_->drawBitmap(bitmap, 0, 0, NULL); pcanvas_->drawBitmap(bitmap, 0, 0, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("translate2"))); + EXPECT_EQ(0., ProcessImage(L"translate2")); } vcanvas_->resetMatrix(); pcanvas_->resetMatrix(); @@ -958,7 +957,7 @@ TEST_F(VectorCanvasTest, DISABLED_Matrix) { pcanvas_->scale(SkDoubleToScalar(1.9), SkDoubleToScalar(1.5)); vcanvas_->drawBitmap(bitmap, 1, 1, NULL); pcanvas_->drawBitmap(bitmap, 1, 1, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("scale"))); + EXPECT_EQ(0., ProcessImage(L"scale")); } vcanvas_->resetMatrix(); pcanvas_->resetMatrix(); @@ -968,7 +967,7 @@ TEST_F(VectorCanvasTest, DISABLED_Matrix) { pcanvas_->rotate(67); vcanvas_->drawBitmap(bitmap, 20, -50, NULL); pcanvas_->drawBitmap(bitmap, 20, -50, NULL); - EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate"))); + EXPECT_EQ(0., ProcessImage(L"rotate")); } } diff --git a/tools/memory_watcher/memory_watcher.cc b/tools/memory_watcher/memory_watcher.cc index a240b92..0d05fcb 100644 --- a/tools/memory_watcher/memory_watcher.cc +++ b/tools/memory_watcher/memory_watcher.cc @@ -82,8 +82,7 @@ void MemoryWatcher::CloseLogFile() { file_ = NULL; std::wstring tmp_name = ASCIIToWide(file_name_); tmp_name += L".tmp"; - file_util::Move(FilePath::FromWStringHack(tmp_name), - FilePath::FromWStringHack(ASCIIToWide(file_name_))); + file_util::Move(tmp_name, ASCIIToWide(file_name_)); } } diff --git a/webkit/default_plugin/plugin_database_handler.cc b/webkit/default_plugin/plugin_database_handler.cc index c597d5a..9e90939 100644 --- a/webkit/default_plugin/plugin_database_handler.cc +++ b/webkit/default_plugin/plugin_database_handler.cc @@ -49,7 +49,7 @@ bool PluginDatabaseHandler::DownloadPluginsFileIfNeeded( plugins_file_ += L"\\chrome_plugins_file.xml"; bool initiate_download = false; - if (!file_util::PathExists(FilePath::FromWStringHack(plugins_file_))) { + if (!file_util::PathExists(plugins_file_)) { initiate_download = true; } else { SYSTEMTIME creation_system_time = {0}; diff --git a/webkit/tools/test_shell/image_decoder_unittest.cc b/webkit/tools/test_shell/image_decoder_unittest.cc index 87af6df..0c73ebd 100644 --- a/webkit/tools/test_shell/image_decoder_unittest.cc +++ b/webkit/tools/test_shell/image_decoder_unittest.cc @@ -6,7 +6,6 @@ #include "webkit/tools/test_shell/image_decoder_unittest.h" -#include "base/file_path.h" #include "base/file_util.h" #include "base/md5.h" #include "base/path_service.h" @@ -20,7 +19,7 @@ namespace { // Determine if we should test with file specified by |path| based // on |file_selection| and the |threshold| for the file size. -bool ShouldSkipFile(const FilePath& path, +bool ShouldSkipFile(const std::wstring& path, ImageDecoderTestFileSelection file_selection, const int64 threshold) { if (file_selection == TEST_ALL) @@ -33,17 +32,16 @@ bool ShouldSkipFile(const FilePath& path, } // anonymous namespace -void ReadFileToVector(const FilePath& path, Vector<char>* contents) { +void ReadFileToVector(const std::wstring& path, Vector<char>* contents) { std::string contents_str; file_util::ReadFileToString(path, &contents_str); contents->resize(contents_str.size()); memcpy(&contents->first(), contents_str.data(), contents_str.size()); } -FilePath GetMD5SumPath(const FilePath& path) { - static const FilePath::StringType kDecodedDataExtension( - FILE_PATH_LITERAL(".md5sum")); - return FilePath(path.value() + kDecodedDataExtension); +std::wstring GetMD5SumPath(const std::wstring& path) { + static const std::wstring kDecodedDataExtension(L".md5sum"); + return path + kDecodedDataExtension; } #ifdef CALCULATE_MD5_SUMS @@ -65,19 +63,18 @@ void SaveMD5Sum(const std::wstring& path, WebCore::RGBA32Buffer* buffer) { } #else void VerifyImage(WebCore::ImageDecoder* decoder, - const FilePath& path, - const FilePath& md5_sum_path, + const std::wstring& path, + const std::wstring& md5_sum_path, size_t frame_index) { // Make sure decoding can complete successfully. - EXPECT_TRUE(decoder->isSizeAvailable()) << path.value(); - EXPECT_GE(decoder->frameCount(), frame_index) << path.value(); + EXPECT_TRUE(decoder->isSizeAvailable()) << path; + EXPECT_GE(decoder->frameCount(), frame_index) << path; WebCore::RGBA32Buffer* image_buffer = decoder->frameBufferAtIndex(frame_index); - ASSERT_NE(static_cast<WebCore::RGBA32Buffer*>(NULL), image_buffer) << - path.value(); + ASSERT_NE(static_cast<WebCore::RGBA32Buffer*>(NULL), image_buffer) << path; EXPECT_EQ(WebCore::RGBA32Buffer::FrameComplete, image_buffer->status()) << - path.value(); - EXPECT_FALSE(decoder->failed()) << path.value(); + path; + EXPECT_FALSE(decoder->failed()) << path; // Calculate MD5 sum. MD5Digest actual_digest; @@ -93,39 +90,36 @@ void VerifyImage(WebCore::ImageDecoder* decoder, std::string file_bytes; file_util::ReadFileToString(md5_sum_path, &file_bytes); MD5Digest expected_digest; - ASSERT_EQ(sizeof expected_digest, file_bytes.size()) << path.value(); + ASSERT_EQ(sizeof expected_digest, file_bytes.size()) << path; memcpy(&expected_digest, file_bytes.data(), sizeof expected_digest); // Verify that the sums are the same. EXPECT_EQ(0, memcmp(&expected_digest, &actual_digest, sizeof(MD5Digest))) << - path.value(); + path; } #endif void ImageDecoderTest::SetUp() { FilePath data_dir; ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir)); - data_dir_ = data_dir.AppendASCII("webkit"). - AppendASCII("data"). - AppendASCII(format_ + "_decoder"); - ASSERT_TRUE(file_util::PathExists(data_dir_)) << data_dir_.value(); + data_dir_ = data_dir.ToWStringHack(); + file_util::AppendToPath(&data_dir_, L"webkit"); + file_util::AppendToPath(&data_dir_, L"data"); + file_util::AppendToPath(&data_dir_, format_ + L"_decoder"); + ASSERT_TRUE(file_util::PathExists(data_dir_)) << data_dir_; } -std::vector<FilePath> ImageDecoderTest::GetImageFiles() const { -#if defined(OS_WIN) - std::wstring pattern = ASCIIToWide("*." + format_); -#else - std::string pattern = "*." + format_; -#endif +std::vector<std::wstring> ImageDecoderTest::GetImageFiles() const { + std::wstring pattern = L"*." + format_; - file_util::FileEnumerator enumerator(data_dir_, + file_util::FileEnumerator enumerator(FilePath::FromWStringHack(data_dir_), false, file_util::FileEnumerator::FILES); - std::vector<FilePath> image_files; - FilePath next_file_name; - while (!(next_file_name = enumerator.Next()).empty()) { - if (!MatchPattern(next_file_name.value(), pattern)) { + std::vector<std::wstring> image_files; + std::wstring next_file_name; + while ((next_file_name = enumerator.Next().ToWStringHack()) != L"") { + if (!MatchPattern(next_file_name, pattern)) { continue; } image_files.push_back(next_file_name); @@ -134,16 +128,15 @@ std::vector<FilePath> ImageDecoderTest::GetImageFiles() const { return image_files; } -bool ImageDecoderTest::ShouldImageFail(const FilePath& path) const { - static const FilePath::StringType kBadSuffix(FILE_PATH_LITERAL(".bad.")); - return (path.value().length() > (kBadSuffix.length() + format_.length()) && - !path.value().compare(path.value().length() - format_.length() - - kBadSuffix.length(), - kBadSuffix.length(), kBadSuffix)); +bool ImageDecoderTest::ShouldImageFail(const std::wstring& path) const { + static const std::wstring kBadSuffix(L".bad."); + return (path.length() > (kBadSuffix.length() + format_.length()) && + !path.compare(path.length() - format_.length() - kBadSuffix.length(), + kBadSuffix.length(), kBadSuffix)); } WebCore::ImageDecoder* ImageDecoderTest::SetupDecoder( - const FilePath& path, + const std::wstring& path, bool split_at_random) const { Vector<char> image_contents; ReadFileToVector(path, &image_contents); @@ -161,7 +154,7 @@ WebCore::ImageDecoder* ImageDecoderTest::SetupDecoder( // Make sure the image decoder doesn't fail when we ask for the frame buffer // for this partial image. decoder->setData(shared_contents.get(), false); - EXPECT_FALSE(decoder->failed()) << path.value(); + EXPECT_FALSE(decoder->failed()) << path; // NOTE: We can't check that frame 0 is non-NULL, because if this is an ICO // and we haven't yet supplied enough data to read the directory, there is // no framecount and thus no first frame. @@ -182,8 +175,8 @@ WebCore::ImageDecoder* ImageDecoderTest::SetupDecoder( void ImageDecoderTest::TestDecoding( ImageDecoderTestFileSelection file_selection, const int64 threshold) const { - const std::vector<FilePath> image_files(GetImageFiles()); - for (std::vector<FilePath>::const_iterator i = image_files.begin(); + const std::vector<std::wstring> image_files(GetImageFiles()); + for (std::vector<std::wstring>::const_iterator i(image_files.begin()); i != image_files.end(); ++i) { if (ShouldSkipFile(*i, file_selection, threshold)) continue; @@ -196,9 +189,9 @@ void ImageDecoderTest::TestDecoding( decoder->frameBufferAtIndex(0); if (image_buffer) { EXPECT_NE(image_buffer->status(), - WebCore::RGBA32Buffer::FrameComplete) << i->value(); + WebCore::RGBA32Buffer::FrameComplete) << (*i); } - EXPECT_TRUE(decoder->failed()) << i->value(); + EXPECT_TRUE(decoder->failed()) << (*i); continue; } @@ -219,8 +212,8 @@ void ImageDecoderTest::TestChunkedDecoding( const Time today = Time::Now().LocalMidnight(); srand(static_cast<unsigned int>(today.ToInternalValue())); - const std::vector<FilePath> image_files(GetImageFiles()); - for (std::vector<FilePath>::const_iterator i = image_files.begin(); + const std::vector<std::wstring> image_files(GetImageFiles()); + for (std::vector<std::wstring>::const_iterator i(image_files.begin()); i != image_files.end(); ++i) { if (ShouldSkipFile(*i, file_selection, threshold)) continue; diff --git a/webkit/tools/test_shell/image_decoder_unittest.h b/webkit/tools/test_shell/image_decoder_unittest.h index 760ac2c..4b1a5d9 100644 --- a/webkit/tools/test_shell/image_decoder_unittest.h +++ b/webkit/tools/test_shell/image_decoder_unittest.h @@ -5,7 +5,6 @@ #ifndef WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ #define WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ -#include <string> #include <vector> #include "Vector.h" @@ -14,7 +13,6 @@ #undef LOG #include "base/basictypes.h" -#include "base/file_path.h" #include "testing/gtest/include/gtest/gtest.h" // If CALCULATE_MD5_SUMS is not defined, then this test decodes a handful of @@ -38,40 +36,40 @@ enum ImageDecoderTestFileSelection { }; // Reads the contents of the specified file into the specified vector. -void ReadFileToVector(const FilePath& path, Vector<char>* contents); +void ReadFileToVector(const std::wstring& path, Vector<char>* contents); // Returns the path the decoded data is saved at. -FilePath GetMD5SumPath(const FilePath& path); +std::wstring GetMD5SumPath(const std::wstring& path); #ifdef CALCULATE_MD5_SUMS // Saves the MD5 sum to the specified file. -void SaveMD5Sum(const FilePath& path, WebCore::RGBA32Buffer* buffer); +void SaveMD5Sum(const std::wstring& path, WebCore::RGBA32Buffer* buffer); #else // Verifies the image. |path| identifies the path the image was loaded from. // |frame_index| indicates which index from the decoder we should examine. void VerifyImage(WebCore::ImageDecoder* decoder, - const FilePath& path, - const FilePath& md5_sum_path, + const std::wstring& path, + const std::wstring& md5_sum_path, size_t frame_index); #endif class ImageDecoderTest : public testing::Test { public: - explicit ImageDecoderTest(const std::string& format) : format_(format) { } + explicit ImageDecoderTest(const std::wstring& format) : format_(format) { } protected: virtual void SetUp(); // Returns the vector of image files for testing. - std::vector<FilePath> GetImageFiles() const; + std::vector<std::wstring> GetImageFiles() const; // Returns true if the image is bogus and should not be successfully decoded. - bool ShouldImageFail(const FilePath& path) const; + bool ShouldImageFail(const std::wstring& path) const; // Creates and returns an ImageDecoder for the file at the given |path|. If // |split_at_random| is true, also verifies that breaking the data supplied to // the decoder into two random pieces does not cause problems. - WebCore::ImageDecoder* SetupDecoder(const FilePath& path, + WebCore::ImageDecoder* SetupDecoder(const std::wstring& path, bool split_at_random) const; // Verifies each of the test image files is decoded correctly and matches the @@ -101,14 +99,14 @@ class ImageDecoderTest : public testing::Test { virtual WebCore::ImageDecoder* CreateDecoder() const = 0; // The format to be decoded, like "bmp" or "ico". - std::string format_; + std::wstring format_; protected: // Path to the test files. - FilePath data_dir_; + std::wstring data_dir_; private: - DISALLOW_COPY_AND_ASSIGN(ImageDecoderTest); + DISALLOW_EVIL_CONSTRUCTORS(ImageDecoderTest); }; #endif // WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ diff --git a/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp b/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp index aa99023a..bc3c681 100644 --- a/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp +++ b/webkit/tools/webcore_unit_tests/BMPImageDecoder_unittest.cpp @@ -34,7 +34,7 @@ class BMPImageDecoderTest : public ImageDecoderTest { public: - BMPImageDecoderTest() : ImageDecoderTest("bmp") { } + BMPImageDecoderTest() : ImageDecoderTest(L"bmp") { } protected: virtual WebCore::ImageDecoder* CreateDecoder() const { diff --git a/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp b/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp index 95c5b15..0203ddf 100644 --- a/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp +++ b/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp @@ -37,7 +37,7 @@ class ICOImageDecoderTest : public ImageDecoderTest { public: - ICOImageDecoderTest() : ImageDecoderTest("ico") { } + ICOImageDecoderTest() : ImageDecoderTest(L"ico") { } protected: virtual WebCore::ImageDecoder* CreateDecoder() const { @@ -59,13 +59,13 @@ TEST_F(ICOImageDecoderTest, FaviconSize) { // Test that the decoder decodes multiple sizes of icons which have them. // Load an icon that has both favicon-size and larger entries. - FilePath multisize_icon_path(data_dir_.AppendASCII("yahoo.ico")); + std::wstring multisize_icon_path(data_dir_); + file_util::AppendToPath(&multisize_icon_path, L"yahoo.ico"); scoped_ptr<WebCore::ImageDecoder> decoder(SetupDecoder(multisize_icon_path, false)); // Verify the decoding. - const FilePath md5_sum_path( - GetMD5SumPath(multisize_icon_path).value() + FILE_PATH_LITERAL("2")); + const std::wstring md5_sum_path(GetMD5SumPath(multisize_icon_path) + L"2"); static const int kDesiredFrameIndex = 3; #ifdef CALCULATE_MD5_SUMS SaveMD5Sum(md5_sum_path, decoder->frameBufferAtIndex(kDesiredFrameIndex)); diff --git a/webkit/tools/webcore_unit_tests/XBMImageDecoder_unittest.cpp b/webkit/tools/webcore_unit_tests/XBMImageDecoder_unittest.cpp index a84b8ce..0f34238 100644 --- a/webkit/tools/webcore_unit_tests/XBMImageDecoder_unittest.cpp +++ b/webkit/tools/webcore_unit_tests/XBMImageDecoder_unittest.cpp @@ -34,7 +34,7 @@ class XBMImageDecoderTest : public ImageDecoderTest { public: - XBMImageDecoderTest() : ImageDecoderTest("xbm") { } + XBMImageDecoderTest() : ImageDecoderTest(L"xbm") { } protected: virtual WebCore::ImageDecoder* CreateDecoder() const { |