diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 00:03:07 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 00:03:07 +0000 |
commit | ee1f3c133a452dfea8b405c0ac589e84be98f335 (patch) | |
tree | 8c75d7edf08705bd0cefad0e30b7048f04f0ccf1 /chrome | |
parent | cd4312179c0f13b6b330c7a9e46a6347deb27668 (diff) | |
download | chromium_src-ee1f3c133a452dfea8b405c0ac589e84be98f335.zip chromium_src-ee1f3c133a452dfea8b405c0ac589e84be98f335.tar.gz chromium_src-ee1f3c133a452dfea8b405c0ac589e84be98f335.tar.bz2 |
wstring: use a few more FilePaths to remove Hack functions
BUG=69467
Review URL: http://codereview.chromium.org/6377011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72728 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/installer/util/copy_tree_work_item.cc | 8 | ||||
-rw-r--r-- | chrome/installer/util/copy_tree_work_item.h | 8 | ||||
-rw-r--r-- | chrome/installer/util/copy_tree_work_item_unittest.cc | 108 | ||||
-rw-r--r-- | chrome/installer/util/work_item.cc | 8 | ||||
-rw-r--r-- | chrome/installer/util/work_item.h | 8 | ||||
-rw-r--r-- | chrome/installer/util/work_item_list.cc | 8 |
6 files changed, 80 insertions, 68 deletions
diff --git a/chrome/installer/util/copy_tree_work_item.cc b/chrome/installer/util/copy_tree_work_item.cc index 026bcc8..f60c822 100644 --- a/chrome/installer/util/copy_tree_work_item.cc +++ b/chrome/installer/util/copy_tree_work_item.cc @@ -16,11 +16,11 @@ CopyTreeWorkItem::~CopyTreeWorkItem() { } } -CopyTreeWorkItem::CopyTreeWorkItem(const std::wstring& source_path, - const std::wstring& dest_path, - const std::wstring& temp_dir, +CopyTreeWorkItem::CopyTreeWorkItem(const FilePath& source_path, + const FilePath& dest_path, + const FilePath& temp_dir, CopyOverWriteOption overwrite_option, - const std::wstring& alternative_path) + const FilePath& alternative_path) : source_path_(source_path), dest_path_(dest_path), temp_dir_(temp_dir), diff --git a/chrome/installer/util/copy_tree_work_item.h b/chrome/installer/util/copy_tree_work_item.h index 2c77237..830a0d4 100644 --- a/chrome/installer/util/copy_tree_work_item.h +++ b/chrome/installer/util/copy_tree_work_item.h @@ -37,11 +37,11 @@ class CopyTreeWorkItem : public WorkItem { // Notes on temp_path: to facilitate rollback, the caller needs to supply // a temporary directory to save the original files if they exist under // dest_path. - CopyTreeWorkItem(const std::wstring& source_path, - const std::wstring& dest_path, - const std::wstring& temp_dir, + CopyTreeWorkItem(const FilePath& source_path, + const FilePath& dest_path, + const FilePath& temp_dir, CopyOverWriteOption overwrite_option, - const std::wstring& alternative_path); + const FilePath& alternative_path); // Checks if the path specified is in use (and hence can not be deleted) bool IsFileInUse(const FilePath& path); diff --git a/chrome/installer/util/copy_tree_work_item_unittest.cc b/chrome/installer/util/copy_tree_work_item_unittest.cc index 9314799..931dff8 100644 --- a/chrome/installer/util/copy_tree_work_item_unittest.cc +++ b/chrome/installer/util/copy_tree_work_item_unittest.cc @@ -107,10 +107,11 @@ TEST_F(CopyTreeWorkItemTest, CopyFile) { // test Do() scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), - file_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), - WorkItem::ALWAYS)); + WorkItem::CreateCopyTreeWorkItem(file_name_from, + file_name_to, + temp_dir_, + WorkItem::ALWAYS, + FilePath())); EXPECT_TRUE(work_item->Do()); @@ -148,10 +149,11 @@ TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) { // test Do() with always_overwrite being true. scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), - file_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), - WorkItem::ALWAYS)); + WorkItem::CreateCopyTreeWorkItem(file_name_from, + file_name_to, + temp_dir_, + WorkItem::ALWAYS, + FilePath())); EXPECT_TRUE(work_item->Do()); @@ -171,10 +173,11 @@ TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) { // test Do() with always_overwrite being false. // the file is still overwritten since the content is different. work_item.reset( - WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), - file_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), - WorkItem::IF_DIFFERENT)); + WorkItem::CreateCopyTreeWorkItem(file_name_from, + file_name_to, + temp_dir_, + WorkItem::IF_DIFFERENT, + FilePath())); EXPECT_TRUE(work_item->Do()); @@ -220,10 +223,11 @@ TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) { // test Do() with always_overwrite being true. scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), - file_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), - WorkItem::ALWAYS)); + WorkItem::CreateCopyTreeWorkItem(file_name_from, + file_name_to, + temp_dir_, + WorkItem::ALWAYS, + FilePath())); EXPECT_TRUE(work_item->Do()); @@ -248,10 +252,11 @@ TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) { // test Do() with always_overwrite being false. nothing should change. work_item.reset( - WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), - file_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), - WorkItem::IF_DIFFERENT)); + WorkItem::CreateCopyTreeWorkItem(file_name_from, + file_name_to, + temp_dir_, + WorkItem::IF_DIFFERENT, + FilePath())); EXPECT_TRUE(work_item->Do()); @@ -299,10 +304,11 @@ TEST_F(CopyTreeWorkItemTest, CopyFileAndCleanup) { { // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), - file_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), - WorkItem::IF_DIFFERENT)); + WorkItem::CreateCopyTreeWorkItem(file_name_from, + file_name_to, + temp_dir_, + WorkItem::IF_DIFFERENT, + FilePath())); EXPECT_TRUE(work_item->Do()); @@ -361,10 +367,11 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUse) { // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), - file_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), - WorkItem::IF_DIFFERENT)); + WorkItem::CreateCopyTreeWorkItem(file_name_from, + file_name_to, + temp_dir_, + WorkItem::IF_DIFFERENT, + FilePath())); EXPECT_TRUE(work_item->Do()); @@ -439,11 +446,11 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), - file_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), + WorkItem::CreateCopyTreeWorkItem(file_name_from, + file_name_to, + temp_dir_, WorkItem::NEW_NAME_IF_IN_USE, - alternate_to.ToWStringHack())); + alternate_to)); EXPECT_TRUE(work_item->Do()); @@ -474,9 +481,9 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { // Now the process has terminated, lets try overwriting the file again work_item.reset(WorkItem::CreateCopyTreeWorkItem( - file_name_from.ToWStringHack(), file_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), WorkItem::NEW_NAME_IF_IN_USE, - alternate_to.ToWStringHack())); + file_name_from, file_name_to, + temp_dir_, WorkItem::NEW_NAME_IF_IN_USE, + alternate_to)); if (IsFileInUse(file_name_to)) base::PlatformThread::Sleep(2000); // If file is still in use, the rest of the test will fail. @@ -536,9 +543,11 @@ TEST_F(CopyTreeWorkItemTest, FLAKY_IfNotPresentTest) { // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), - file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), - WorkItem::IF_NOT_PRESENT, L"")); + WorkItem::CreateCopyTreeWorkItem( + file_name_from, + file_name_to, temp_dir_, + WorkItem::IF_NOT_PRESENT, + FilePath())); EXPECT_TRUE(work_item->Do()); // verify that the source, destination have not changed and backup path @@ -563,8 +572,9 @@ TEST_F(CopyTreeWorkItemTest, FLAKY_IfNotPresentTest) { // Now delete the destination and try copying the file again. file_util::Delete(file_name_to, true); work_item.reset(WorkItem::CreateCopyTreeWorkItem( - file_name_from.ToWStringHack(), file_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), WorkItem::IF_NOT_PRESENT, L"")); + file_name_from, file_name_to, + temp_dir_, WorkItem::IF_NOT_PRESENT, + FilePath())); EXPECT_TRUE(work_item->Do()); // verify that the source, destination are the same and backup path @@ -628,10 +638,11 @@ TEST_F(CopyTreeWorkItemTest, FLAKY_CopyFileInUseAndCleanup) { // test Do(). { scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), - file_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), - WorkItem::IF_DIFFERENT)); + WorkItem::CreateCopyTreeWorkItem(file_name_from, + file_name_to, + temp_dir_, + WorkItem::IF_DIFFERENT, + FilePath())); EXPECT_TRUE(work_item->Do()); @@ -690,10 +701,11 @@ TEST_F(CopyTreeWorkItemTest, FLAKY_CopyTree) { // test Do() { scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(dir_name_from.ToWStringHack(), - dir_name_to.ToWStringHack(), - temp_dir_.ToWStringHack(), - WorkItem::ALWAYS)); + WorkItem::CreateCopyTreeWorkItem(dir_name_from, + dir_name_to, + temp_dir_, + WorkItem::ALWAYS, + FilePath())); EXPECT_TRUE(work_item->Do()); } diff --git a/chrome/installer/util/work_item.cc b/chrome/installer/util/work_item.cc index 546b9ebc..c62a383 100644 --- a/chrome/installer/util/work_item.cc +++ b/chrome/installer/util/work_item.cc @@ -23,11 +23,11 @@ WorkItem::~WorkItem() { } CopyTreeWorkItem* WorkItem::CreateCopyTreeWorkItem( - const std::wstring& source_path, - const std::wstring& dest_path, - const std::wstring& temp_dir, + const FilePath& source_path, + const FilePath& dest_path, + const FilePath& temp_dir, CopyOverWriteOption overwrite_option, - const std::wstring& alternative_path) { + const FilePath& alternative_path) { return new CopyTreeWorkItem(source_path, dest_path, temp_dir, overwrite_option, alternative_path); } diff --git a/chrome/installer/util/work_item.h b/chrome/installer/util/work_item.h index 7fd5db2..be7331b 100644 --- a/chrome/installer/util/work_item.h +++ b/chrome/installer/util/work_item.h @@ -59,11 +59,11 @@ class WorkItem { // * If overwrite_option is NEW_NAME_IF_IN_USE, file is copied with an // alternate name specified by alternative_path. static CopyTreeWorkItem* CreateCopyTreeWorkItem( - const std::wstring& source_path, - const std::wstring& dest_path, - const std::wstring& temp_dir, + const FilePath& source_path, + const FilePath& dest_path, + const FilePath& temp_dir, CopyOverWriteOption overwrite_option, - const std::wstring& alternative_path = L""); + const FilePath& alternative_path); // Create a CreateDirWorkItem that creates a directory at the given path. static CreateDirWorkItem* CreateCreateDirWorkItem(const FilePath& path); diff --git a/chrome/installer/util/work_item_list.cc b/chrome/installer/util/work_item_list.cc index 28e2829..05c0b58 100644 --- a/chrome/installer/util/work_item_list.cc +++ b/chrome/installer/util/work_item_list.cc @@ -78,11 +78,11 @@ WorkItem* WorkItemList::AddCopyTreeWorkItem( const std::wstring& temp_dir, CopyOverWriteOption overwrite_option, const std::wstring& alternative_path) { - WorkItem* item = WorkItem::CreateCopyTreeWorkItem(source_path, - dest_path, - temp_dir, + WorkItem* item = WorkItem::CreateCopyTreeWorkItem(FilePath(source_path), + FilePath(dest_path), + FilePath(temp_dir), overwrite_option, - alternative_path); + FilePath(alternative_path)); AddWorkItem(item); return item; } |