summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/installer/setup/install.cc9
-rw-r--r--chrome/installer/util/create_dir_work_item.cc26
-rw-r--r--chrome/installer/util/create_dir_work_item.h16
-rw-r--r--chrome/installer/util/create_dir_work_item_unittest.cc10
-rw-r--r--chrome/installer/util/work_item.cc2
-rw-r--r--chrome/installer/util/work_item.h4
-rw-r--r--chrome/installer/util/work_item_list.cc2
-rw-r--r--chrome/installer/util/work_item_list.h4
-rw-r--r--chrome/installer/util/work_item_list_unittest.cc6
9 files changed, 43 insertions, 36 deletions
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index a628327..0465d29 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -59,7 +59,8 @@ void AddInstallerCopyTasks(const std::wstring& exe_path,
bool system_level) {
std::wstring installer_dir(installer::GetInstallerPathUnderChrome(
install_path, new_version));
- install_list->AddCreateDirWorkItem(installer_dir);
+ install_list->AddCreateDirWorkItem(
+ FilePath::FromWStringHack(installer_dir));
std::wstring exe_dst(installer_dir);
std::wstring archive_dst(installer_dir);
@@ -324,11 +325,11 @@ bool installer::InstallNewVersion(const std::wstring& exe_path,
scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList());
// A temp directory that work items need and the actual install directory.
- install_list->AddCreateDirWorkItem(temp_dir);
- install_list->AddCreateDirWorkItem(install_path);
+ install_list->AddCreateDirWorkItem(FilePath::FromWStringHack(temp_dir));
+ install_list->AddCreateDirWorkItem(FilePath::FromWStringHack(install_path));
// If it is system level install copy the version folder (since we want to
- // take the permissions of %ProgramFiles% folder) otherwise just move it.
+ // take the permissions of %ProgramFiles% folder) otherwise just move it.
if (reg_root == HKEY_LOCAL_MACHINE) {
install_list->AddCopyTreeWorkItem(
AppendPath(src_path, new_version.GetString()),
diff --git a/chrome/installer/util/create_dir_work_item.cc b/chrome/installer/util/create_dir_work_item.cc
index d02de53..cdc7d3e 100644
--- a/chrome/installer/util/create_dir_work_item.cc
+++ b/chrome/installer/util/create_dir_work_item.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,33 +9,33 @@
CreateDirWorkItem::~CreateDirWorkItem() {
}
-CreateDirWorkItem::CreateDirWorkItem(const std::wstring& path)
+CreateDirWorkItem::CreateDirWorkItem(const FilePath& path)
: path_(path),
rollback_needed_(false) {
}
void CreateDirWorkItem::GetTopDirToCreate() {
if (file_util::PathExists(path_)) {
- top_path_.clear();
+ top_path_ = FilePath();
return;
}
- std::wstring parent_dir(path_);
+ FilePath parent_dir(path_);
do {
- top_path_.assign(parent_dir);
- file_util::UpOneDirectoryOrEmpty(&parent_dir);
- } while (!parent_dir.empty() && !file_util::PathExists(parent_dir));
+ top_path_ = parent_dir;
+ parent_dir = parent_dir.DirName();
+ } while ((parent_dir != top_path_) && !file_util::PathExists(parent_dir));
return;
}
bool CreateDirWorkItem::Do() {
- LOG(INFO) << "creating directory " << path_;
+ LOG(INFO) << "creating directory " << path_.value();
GetTopDirToCreate();
if (top_path_.empty())
return true;
LOG(INFO) << "top directory that needs to be created: " \
- << top_path_;
+ << top_path_.value();
bool result = file_util::CreateDirectory(path_);
LOG(INFO) << "directory creation result: " << result;
@@ -53,16 +53,16 @@ void CreateDirWorkItem::Rollback() {
// delete non-empty directory. (We may have created a shared directory).
// Instead we walk through path_ to top_path_ and delete directories
// along the way.
- std::wstring path_to_delete(path_);
+ FilePath path_to_delete(path_);
while(1) {
if (file_util::PathExists(path_to_delete)) {
- if (!RemoveDirectory(path_to_delete.c_str()))
+ if (!RemoveDirectory(path_to_delete.value().c_str()))
break;
}
- if (!path_to_delete.compare(top_path_))
+ if (path_to_delete == top_path_)
break;
- file_util::UpOneDirectoryOrEmpty(&path_to_delete);
+ path_to_delete = path_to_delete.DirName();
}
return;
diff --git a/chrome/installer/util/create_dir_work_item.h b/chrome/installer/util/create_dir_work_item.h
index 4f3edf7..2995a3d 100644
--- a/chrome/installer/util/create_dir_work_item.h
+++ b/chrome/installer/util/create_dir_work_item.h
@@ -1,12 +1,14 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H__
-#define CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H__
+#ifndef CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_
+#define CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_
#include <string>
#include <windows.h>
+
+#include "base/file_path.h"
#include "chrome/installer/util/work_item.h"
// A WorkItem subclass that creates a directory with the specified path.
@@ -26,7 +28,7 @@ class CreateDirWorkItem : public WorkItem {
private:
friend class WorkItem;
- CreateDirWorkItem(const std::wstring& path);
+ explicit CreateDirWorkItem(const FilePath& path);
// Get the top most directory that needs to be created in order to create
// "path_", and set "top_path_" accordingly. if "path_" already exists,
@@ -34,12 +36,12 @@ class CreateDirWorkItem : public WorkItem {
void GetTopDirToCreate();
// Path of the directory to be created.
- std::wstring path_;
+ FilePath path_;
// The top most directory that needs to be created.
- std::wstring top_path_;
+ FilePath top_path_;
bool rollback_needed_;
};
-#endif // CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H__
+#endif // CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_
diff --git a/chrome/installer/util/create_dir_work_item_unittest.cc b/chrome/installer/util/create_dir_work_item_unittest.cc
index 8c44038..05739f7 100644
--- a/chrome/installer/util/create_dir_work_item_unittest.cc
+++ b/chrome/installer/util/create_dir_work_item_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -50,7 +50,7 @@ TEST_F(CreateDirWorkItemTest, CreatePath) {
dir_to_create = dir_to_create.AppendASCII("d");
scoped_ptr<CreateDirWorkItem> work_item(
- WorkItem::CreateCreateDirWorkItem(dir_to_create.ToWStringHack()));
+ WorkItem::CreateCreateDirWorkItem(dir_to_create));
EXPECT_TRUE(work_item->Do());
@@ -70,7 +70,7 @@ TEST_F(CreateDirWorkItemTest, CreateExistingPath) {
ASSERT_TRUE(file_util::PathExists(dir_to_create));
scoped_ptr<CreateDirWorkItem> work_item(
- WorkItem::CreateCreateDirWorkItem(dir_to_create.ToWStringHack()));
+ WorkItem::CreateCreateDirWorkItem(dir_to_create));
EXPECT_TRUE(work_item->Do());
@@ -94,7 +94,7 @@ TEST_F(CreateDirWorkItemTest, CreateSharedPath) {
dir_to_create_3 = dir_to_create_3.AppendASCII("ccc");
scoped_ptr<CreateDirWorkItem> work_item(
- WorkItem::CreateCreateDirWorkItem(dir_to_create_3.ToWStringHack()));
+ WorkItem::CreateCreateDirWorkItem(dir_to_create_3));
EXPECT_TRUE(work_item->Do());
@@ -127,7 +127,7 @@ TEST_F(CreateDirWorkItemTest, RollbackWithMissingDir) {
dir_to_create_3 = dir_to_create_3.AppendASCII("cccc");
scoped_ptr<CreateDirWorkItem> work_item(
- WorkItem::CreateCreateDirWorkItem(dir_to_create_3.ToWStringHack()));
+ WorkItem::CreateCreateDirWorkItem(dir_to_create_3));
EXPECT_TRUE(work_item->Do());
diff --git a/chrome/installer/util/work_item.cc b/chrome/installer/util/work_item.cc
index 6cc1578..af14379 100644
--- a/chrome/installer/util/work_item.cc
+++ b/chrome/installer/util/work_item.cc
@@ -30,7 +30,7 @@ CopyTreeWorkItem* WorkItem::CreateCopyTreeWorkItem(
overwrite_option, alternative_path);
}
-CreateDirWorkItem* WorkItem::CreateCreateDirWorkItem(const std::wstring& path) {
+CreateDirWorkItem* WorkItem::CreateCreateDirWorkItem(const FilePath& path) {
return new CreateDirWorkItem(path);
}
diff --git a/chrome/installer/util/work_item.h b/chrome/installer/util/work_item.h
index 08d0c05..9a61363 100644
--- a/chrome/installer/util/work_item.h
+++ b/chrome/installer/util/work_item.h
@@ -12,6 +12,8 @@
#include <windows.h>
#include <string>
+#include "base/file_path.h"
+
class CopyTreeWorkItem;
class CreateDirWorkItem;
class CreateRegKeyWorkItem;
@@ -51,7 +53,7 @@ class WorkItem {
const std::wstring& alternative_path = L"");
// Create a CreateDirWorkItem that creates a directory at the given path.
- static CreateDirWorkItem* CreateCreateDirWorkItem(const std::wstring& path);
+ static CreateDirWorkItem* CreateCreateDirWorkItem(const FilePath& path);
// Create a CreateRegKeyWorkItem that creates a registry key at the given
// path.
diff --git a/chrome/installer/util/work_item_list.cc b/chrome/installer/util/work_item_list.cc
index 3e5ac07..8f4c702 100644
--- a/chrome/installer/util/work_item_list.cc
+++ b/chrome/installer/util/work_item_list.cc
@@ -74,7 +74,7 @@ bool WorkItemList::AddCopyTreeWorkItem(const std::wstring& source_path,
return AddWorkItem(item);
}
-bool WorkItemList::AddCreateDirWorkItem(const std::wstring& path) {
+bool WorkItemList::AddCreateDirWorkItem(const FilePath& path) {
WorkItem* item = reinterpret_cast<WorkItem*>(
WorkItem::CreateCreateDirWorkItem(path));
return AddWorkItem(item);
diff --git a/chrome/installer/util/work_item_list.h b/chrome/installer/util/work_item_list.h
index 5b89b22..1390701 100644
--- a/chrome/installer/util/work_item_list.h
+++ b/chrome/installer/util/work_item_list.h
@@ -10,6 +10,8 @@
#include <list>
#include <string>
+#include "base/file_path.h"
+
#include "chrome/installer/util/work_item.h"
// A WorkItem subclass that recursively contains a list of WorkItems. Thus it
@@ -41,7 +43,7 @@ class WorkItemList : public WorkItem {
const std::wstring& alternative_path = L"");
// Add a CreateDirWorkItem that creates a directory at the given path.
- bool AddCreateDirWorkItem(const std::wstring& path);
+ bool AddCreateDirWorkItem(const FilePath& path);
// Add a CreateRegKeyWorkItem that creates a registry key at the given
// path.
diff --git a/chrome/installer/util/work_item_list_unittest.cc b/chrome/installer/util/work_item_list_unittest.cc
index 160db14..8b91fcd 100644
--- a/chrome/installer/util/work_item_list_unittest.cc
+++ b/chrome/installer/util/work_item_list_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -62,7 +62,7 @@ TEST_F(WorkItemListTest, ExecutionSuccess) {
ASSERT_FALSE(file_util::PathExists(dir_to_create));
work_item.reset(reinterpret_cast<WorkItem*>(
- WorkItem::CreateCreateDirWorkItem(dir_to_create.ToWStringHack())));
+ WorkItem::CreateCreateDirWorkItem(dir_to_create)));
EXPECT_TRUE(work_item_list->AddWorkItem(work_item.release()));
std::wstring key_to_create(test_root);
@@ -111,7 +111,7 @@ TEST_F(WorkItemListTest, ExecutionFailAndRollback) {
ASSERT_FALSE(file_util::PathExists(dir_to_create));
work_item.reset(reinterpret_cast<WorkItem*>(
- WorkItem::CreateCreateDirWorkItem(dir_to_create.ToWStringHack())));
+ WorkItem::CreateCreateDirWorkItem(dir_to_create)));
EXPECT_TRUE(work_item_list->AddWorkItem(work_item.release()));
std::wstring key_to_create(test_root);