summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-30 22:14:37 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-30 22:14:37 +0000
commit96613eb98e8c56e3046d391e40d4fdadf696614e (patch)
treef6d788badc3178d495ea2d572d8813d2bff58484 /chrome/installer
parent0f8c1125a19d64dcece55111bff692aa98bbcb2b (diff)
downloadchromium_src-96613eb98e8c56e3046d391e40d4fdadf696614e.zip
chromium_src-96613eb98e8c56e3046d391e40d4fdadf696614e.tar.gz
chromium_src-96613eb98e8c56e3046d391e40d4fdadf696614e.tar.bz2
Fixit: Remove bunch of coverity warnings from chrome/installer/*.
BUg=12849 Review URL: http://codereview.chromium.org/151101 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19668 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/gcapi/gcapi.cc4
-rw-r--r--chrome/installer/setup/install.cc6
-rw-r--r--chrome/installer/setup/uninstall.cc12
-rw-r--r--chrome/installer/util/copy_tree_work_item.cc12
-rw-r--r--chrome/installer/util/copy_tree_work_item.h18
-rw-r--r--chrome/installer/util/copy_tree_work_item_unittest.cc4
-rw-r--r--chrome/installer/util/create_reg_key_work_item.cc4
-rw-r--r--chrome/installer/util/create_reg_key_work_item.h4
-rw-r--r--chrome/installer/util/delete_reg_value_work_item.cc9
-rw-r--r--chrome/installer/util/delete_reg_value_work_item.h6
-rw-r--r--chrome/installer/util/delete_tree_work_item.cc8
-rw-r--r--chrome/installer/util/delete_tree_work_item.h13
-rw-r--r--chrome/installer/util/google_chrome_distribution_unittest.cc4
-rw-r--r--chrome/installer/util/l10n_string_util.cc11
-rw-r--r--chrome/installer/util/lzma_util.cc8
-rw-r--r--chrome/installer/util/set_reg_value_work_item.cc25
-rw-r--r--chrome/installer/util/set_reg_value_work_item.h12
-rw-r--r--chrome/installer/util/version.cc4
-rw-r--r--chrome/installer/util/version.h8
-rw-r--r--chrome/installer/util/work_item.cc47
-rw-r--r--chrome/installer/util/work_item.h43
-rw-r--r--chrome/installer/util/work_item_list.cc38
-rw-r--r--chrome/installer/util/work_item_list.h45
23 files changed, 198 insertions, 147 deletions
diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc
index 43498b9..ae07387 100644
--- a/chrome/installer/gcapi/gcapi.cc
+++ b/chrome/installer/gcapi/gcapi.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.
@@ -314,7 +314,7 @@ DLLEXPORT BOOL __stdcall GoogleChromeCompatibilityCheck(BOOL set_flag,
if (reasons != NULL)
*reasons = local_reasons;
- return (*reasons == 0);
+ return (local_reasons == 0);
}
#pragma comment(linker, "/EXPORT:LaunchGoogleChrome=_LaunchGoogleChrome@0,PRIVATE")
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index 24067d2..c409317 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -33,8 +33,8 @@
namespace {
-std::wstring AppendPath(const std::wstring parent_path,
- const std::wstring path) {
+std::wstring AppendPath(const std::wstring& parent_path,
+ const std::wstring& path) {
std::wstring new_path(parent_path);
file_util::AppendToPath(&new_path, path);
return new_path;
@@ -279,7 +279,7 @@ bool Is64bit() {
return false;
}
-void RegisterChromeOnMachine(std::wstring install_path, int options) {
+void RegisterChromeOnMachine(const std::wstring& install_path, int options) {
bool system_level = (options & installer_util::SYSTEM_LEVEL) != 0;
// Try to add Chrome to Media Player shim inclusion list. We don't do any
// error checking here because this operation will fail if user doesn't
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 37da295..a67e01b 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -136,8 +136,10 @@ bool DeleteFilesAndFolders(const std::wstring& exe_path, bool system_uninstall,
file_util::AppendToPath(&setup_exe, file_util::GetFilenameFromPath(exe_path));
std::wstring temp_file;
- file_util::CreateTemporaryFileName(&temp_file);
- file_util::Move(setup_exe, temp_file);
+ if (!file_util::CreateTemporaryFileName(&temp_file))
+ LOG(ERROR) << "Failed to create temporary file for setup.exe.";
+ else
+ file_util::Move(setup_exe, temp_file);
// Move the browser's persisted local state
FilePath user_local_state;
@@ -145,8 +147,10 @@ bool DeleteFilesAndFolders(const std::wstring& exe_path, bool system_uninstall,
std::wstring user_local_file(
user_local_state.Append(chrome::kLocalStateFilename).value());
- file_util::CreateTemporaryFileName(local_state_path);
- file_util::CopyFile(user_local_file, *local_state_path);
+ if (!file_util::CreateTemporaryFileName(local_state_path))
+ LOG(ERROR) << "Failed to create temporary file for Local State.";
+ else
+ file_util::CopyFile(user_local_file, *local_state_path);
}
LOG(INFO) << "Deleting install path " << install_path;
diff --git a/chrome/installer/util/copy_tree_work_item.cc b/chrome/installer/util/copy_tree_work_item.cc
index 5aa601c..ffb3d34 100644
--- a/chrome/installer/util/copy_tree_work_item.cc
+++ b/chrome/installer/util/copy_tree_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.
@@ -14,11 +14,11 @@ CopyTreeWorkItem::~CopyTreeWorkItem() {
}
}
-CopyTreeWorkItem::CopyTreeWorkItem(std::wstring source_path,
- std::wstring dest_path,
- std::wstring temp_dir,
+CopyTreeWorkItem::CopyTreeWorkItem(const std::wstring& source_path,
+ const std::wstring& dest_path,
+ const std::wstring& temp_dir,
CopyOverWriteOption overwrite_option,
- std::wstring alternative_path)
+ const std::wstring& alternative_path)
: source_path_(source_path),
dest_path_(dest_path),
temp_dir_(temp_dir),
@@ -116,7 +116,7 @@ void CopyTreeWorkItem::Rollback() {
}
}
-bool CopyTreeWorkItem::IsFileInUse(std::wstring path) {
+bool CopyTreeWorkItem::IsFileInUse(const std::wstring& path) {
if (!file_util::PathExists(path))
return false;
diff --git a/chrome/installer/util/copy_tree_work_item.h b/chrome/installer/util/copy_tree_work_item.h
index d4c54bd..9fa1d96 100644
--- a/chrome/installer/util/copy_tree_work_item.h
+++ b/chrome/installer/util/copy_tree_work_item.h
@@ -1,9 +1,9 @@
-// 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_COPY_TREE_WORK_ITEM_H__
-#define CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H__
+#ifndef CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_
+#define CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_
#include <string>
#include <windows.h>
@@ -33,12 +33,14 @@ 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(std::wstring source_path, std::wstring dest_path,
- std::wstring temp_dir, CopyOverWriteOption overwrite_option,
- std::wstring alternative_path);
+ CopyTreeWorkItem(const std::wstring& source_path,
+ const std::wstring& dest_path,
+ const std::wstring& temp_dir,
+ CopyOverWriteOption overwrite_option,
+ const std::wstring& alternative_path);
// Checks if the path specified is in use (and hence can not be deleted)
- bool IsFileInUse(std::wstring 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.
@@ -77,4 +79,4 @@ class CopyTreeWorkItem : public WorkItem {
std::wstring backup_path_;
};
-#endif // CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H__
+#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 70ba378..77b6719 100644
--- a/chrome/installer/util/copy_tree_work_item_unittest.cc
+++ b/chrome/installer/util/copy_tree_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.
@@ -61,7 +61,7 @@ namespace {
file.close();
}
- bool IsFileInUse(std::wstring path) {
+ bool IsFileInUse(const std::wstring& path) {
if (!file_util::PathExists(path))
return false;
diff --git a/chrome/installer/util/create_reg_key_work_item.cc b/chrome/installer/util/create_reg_key_work_item.cc
index 78536de..a2a526b 100644
--- a/chrome/installer/util/create_reg_key_work_item.cc
+++ b/chrome/installer/util/create_reg_key_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.
@@ -14,7 +14,7 @@ CreateRegKeyWorkItem::~CreateRegKeyWorkItem() {
}
CreateRegKeyWorkItem::CreateRegKeyWorkItem(HKEY predefined_root,
- std::wstring path)
+ const std::wstring& path)
: predefined_root_(predefined_root),
path_(path),
key_created_(false) {
diff --git a/chrome/installer/util/create_reg_key_work_item.h b/chrome/installer/util/create_reg_key_work_item.h
index 0c6c831..97ea275 100644
--- a/chrome/installer/util/create_reg_key_work_item.h
+++ b/chrome/installer/util/create_reg_key_work_item.h
@@ -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.
@@ -25,7 +25,7 @@ class CreateRegKeyWorkItem : public WorkItem {
private:
friend class WorkItem;
- CreateRegKeyWorkItem(HKEY predefined_root, std::wstring path);
+ CreateRegKeyWorkItem(HKEY predefined_root, const std::wstring& path);
// Initialize key_list_ by adding all paths of keys from predefined_root_
// to path_. Returns true if key_list_ is non empty.
diff --git a/chrome/installer/util/delete_reg_value_work_item.cc b/chrome/installer/util/delete_reg_value_work_item.cc
index ff49167..956eb74 100644
--- a/chrome/installer/util/delete_reg_value_work_item.cc
+++ b/chrome/installer/util/delete_reg_value_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.
@@ -8,14 +8,15 @@
#include "chrome/installer/util/logging_installer.h"
DeleteRegValueWorkItem::DeleteRegValueWorkItem(HKEY predefined_root,
- std::wstring key_path,
- std::wstring value_name,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
bool is_str_type)
: predefined_root_(predefined_root),
key_path_(key_path),
value_name_(value_name),
is_str_type_(is_str_type),
- status_(DELETE_VALUE) {
+ status_(DELETE_VALUE),
+ old_dw_(0) {
}
DeleteRegValueWorkItem::~DeleteRegValueWorkItem() {
diff --git a/chrome/installer/util/delete_reg_value_work_item.h b/chrome/installer/util/delete_reg_value_work_item.h
index 3656ee5..e259422 100644
--- a/chrome/installer/util/delete_reg_value_work_item.h
+++ b/chrome/installer/util/delete_reg_value_work_item.h
@@ -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.
@@ -35,8 +35,8 @@ class DeleteRegValueWorkItem : public WorkItem {
VALUE_UNCHANGED
};
- DeleteRegValueWorkItem(HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, bool is_str_type);
+ DeleteRegValueWorkItem(HKEY predefined_root, const std::wstring& key_path,
+ const std::wstring& value_name, bool is_str_type);
// Root key of the target key under which the value is set. The root key can
// only be one of the predefined keys on Windows.
diff --git a/chrome/installer/util/delete_tree_work_item.cc b/chrome/installer/util/delete_tree_work_item.cc
index dd689ff..8e5610a 100644
--- a/chrome/installer/util/delete_tree_work_item.cc
+++ b/chrome/installer/util/delete_tree_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.
@@ -17,8 +17,8 @@ DeleteTreeWorkItem::~DeleteTreeWorkItem() {
}
}
-DeleteTreeWorkItem::DeleteTreeWorkItem(std::wstring root_path,
- std::wstring key_path)
+DeleteTreeWorkItem::DeleteTreeWorkItem(const std::wstring& root_path,
+ const std::wstring& key_path)
: root_path_(root_path),
key_path_(key_path) {
}
@@ -58,7 +58,7 @@ void DeleteTreeWorkItem::Rollback() {
}
}
-bool DeleteTreeWorkItem::GetBackupPath(std::wstring for_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.
diff --git a/chrome/installer/util/delete_tree_work_item.h b/chrome/installer/util/delete_tree_work_item.h
index 571d2d0..cf7b4be 100644
--- a/chrome/installer/util/delete_tree_work_item.h
+++ b/chrome/installer/util/delete_tree_work_item.h
@@ -1,9 +1,9 @@
-// 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_DELETE_TREE_WORK_ITEM_H__
-#define CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H__
+#ifndef CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_
+#define CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_
#include <string>
#include <windows.h>
@@ -26,9 +26,10 @@ class DeleteTreeWorkItem : public WorkItem {
friend class WorkItem;
// Get a backup path that can keep root_path_ or key_path_
- bool GetBackupPath(std::wstring for_path, std::wstring* backup_path);
+ bool GetBackupPath(const std::wstring& for_path, std::wstring* backup_path);
- DeleteTreeWorkItem(std::wstring root_path, std::wstring key_path);
+ DeleteTreeWorkItem(const std::wstring& root_path,
+ const std::wstring& key_path);
// Root path to delete.
std::wstring root_path_;
@@ -46,4 +47,4 @@ class DeleteTreeWorkItem : public WorkItem {
std::wstring key_backup_path_;
};
-#endif // CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H__
+#endif // CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_
diff --git a/chrome/installer/util/google_chrome_distribution_unittest.cc b/chrome/installer/util/google_chrome_distribution_unittest.cc
index e4bad05..c404061 100644
--- a/chrome/installer/util/google_chrome_distribution_unittest.cc
+++ b/chrome/installer/util/google_chrome_distribution_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.
//
@@ -31,7 +31,7 @@ class GoogleChromeDistributionTest : public testing::Test {
// Creates "ap" key with the value given as parameter. Also adds work
// items to work_item_list given so that they can be rolled back later.
- bool CreateApKey(WorkItemList* work_item_list, std::wstring value) {
+ bool CreateApKey(WorkItemList* work_item_list, const std::wstring& value) {
HKEY reg_root = HKEY_CURRENT_USER;
std::wstring reg_key = GetApKeyPath();
work_item_list->AddCreateRegKeyWorkItem(reg_root, reg_key);
diff --git a/chrome/installer/util/l10n_string_util.cc b/chrome/installer/util/l10n_string_util.cc
index ff4ec3f..029f4dd 100644
--- a/chrome/installer/util/l10n_string_util.cc
+++ b/chrome/installer/util/l10n_string_util.cc
@@ -1,3 +1,10 @@
+// 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.
+//
+// This file defines specific implementation of BrowserDistribution class for
+// Google Chrome.
+
#include <atlbase.h>
#include <shlwapi.h>
@@ -166,8 +173,8 @@ std::wstring GetLocalizedString(int base_message_id) {
// explained here : http://support.microsoft.com/kb/220830
std::wstring GetLocalizedEulaResource() {
wchar_t full_exe_path[MAX_PATH];
- int len = ::GetModuleFileNameW(NULL, full_exe_path, MAX_PATH);
- if (len <= 0 && len >= MAX_PATH)
+ int len = ::GetModuleFileName(NULL, full_exe_path, MAX_PATH);
+ if (len == 0 || len == MAX_PATH)
return L"";
std::wstring language = GetSystemLanguage();
const wchar_t* resource = L"IDR_OEMPG_EN.HTML";
diff --git a/chrome/installer/util/lzma_util.cc b/chrome/installer/util/lzma_util.cc
index 3e931ce..cc8569d 100644
--- a/chrome/installer/util/lzma_util.cc
+++ b/chrome/installer/util/lzma_util.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.
@@ -149,9 +149,9 @@ DWORD LzmaUtil::UnPack(const std::wstring& location) {
break;
}
- WriteFile(hFile, outBuffer + offset, (DWORD) outSizeProcessed,
- &written, NULL);
- if (written != outSizeProcessed) {
+ if ((!WriteFile(hFile, outBuffer + offset, (DWORD) outSizeProcessed,
+ &written, NULL)) ||
+ (written != outSizeProcessed)) {
ret = GetLastError();
CloseHandle(hFile);
break;
diff --git a/chrome/installer/util/set_reg_value_work_item.cc b/chrome/installer/util/set_reg_value_work_item.cc
index 57965d0..74c8d2c 100644
--- a/chrome/installer/util/set_reg_value_work_item.cc
+++ b/chrome/installer/util/set_reg_value_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.
@@ -10,31 +10,34 @@ SetRegValueWorkItem::~SetRegValueWorkItem() {
}
SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root,
- std::wstring key_path,
- std::wstring value_name,
- std::wstring value_data,
- bool overwrite)
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ const std::wstring& value_data,
+ bool overwrite)
: predefined_root_(predefined_root),
key_path_(key_path),
value_name_(value_name),
value_data_str_(value_data),
+ value_data_dword_(0),
overwrite_(overwrite),
status_(SET_VALUE),
- is_str_type_(true) {
+ is_str_type_(true),
+ previous_value_dword_(0) {
}
SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root,
- std::wstring key_path,
- std::wstring value_name,
- DWORD value_data,
- bool overwrite)
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ DWORD value_data,
+ bool overwrite)
: predefined_root_(predefined_root),
key_path_(key_path),
value_name_(value_name),
value_data_dword_(value_data),
overwrite_(overwrite),
status_(SET_VALUE),
- is_str_type_(false) {
+ is_str_type_(false),
+ previous_value_dword_(0) {
}
bool SetRegValueWorkItem::Do() {
diff --git a/chrome/installer/util/set_reg_value_work_item.h b/chrome/installer/util/set_reg_value_work_item.h
index 1dd4869..7eac895 100644
--- a/chrome/installer/util/set_reg_value_work_item.h
+++ b/chrome/installer/util/set_reg_value_work_item.h
@@ -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.
@@ -38,12 +38,14 @@ class SetRegValueWorkItem : public WorkItem {
VALUE_ROLL_BACK
};
- SetRegValueWorkItem(HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, std::wstring value_data,
+ SetRegValueWorkItem(HKEY predefined_root,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ const std::wstring& value_data,
bool overwrite);
- SetRegValueWorkItem(HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, DWORD value_data,
+ SetRegValueWorkItem(HKEY predefined_root, const std::wstring& key_path,
+ const std::wstring& value_name, DWORD value_data,
bool overwrite);
// Root key of the target key under which the value is set. The root key can
diff --git a/chrome/installer/util/version.cc b/chrome/installer/util/version.cc
index 892d5d7..0bd9409 100644
--- a/chrome/installer/util/version.cc
+++ b/chrome/installer/util/version.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.
@@ -33,7 +33,7 @@ bool installer::Version::IsHigherThan(const installer::Version* other) const {
}
installer::Version* installer::Version::GetVersionFromString(
- std::wstring version_str) {
+ const std::wstring& version_str) {
std::vector<std::wstring> numbers;
SplitString(version_str, '.', &numbers);
diff --git a/chrome/installer/util/version.h b/chrome/installer/util/version.h
index 5d7e3c0..8bbabce 100644
--- a/chrome/installer/util/version.h
+++ b/chrome/installer/util/version.h
@@ -1,9 +1,9 @@
-// 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_VERSION_H__
-#define CHROME_INSTALLER_UTIL_VERSION_H__
+#ifndef CHROME_INSTALLER_UTIL_VERSION_H_
+#define CHROME_INSTALLER_UTIL_VERSION_H_
#include <string>
@@ -27,7 +27,7 @@ public:
// Assume that the version string is specified by four integers separated
// by character '.'. Return NULL if string is not of this format.
// Caller is responsible for freeing the Version object once done.
- static Version* GetVersionFromString(std::wstring version_str);
+ static Version* GetVersionFromString(const std::wstring& version_str);
private:
int64 major_;
diff --git a/chrome/installer/util/work_item.cc b/chrome/installer/util/work_item.cc
index dcb4293..6cc1578 100644
--- a/chrome/installer/util/work_item.cc
+++ b/chrome/installer/util/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.
@@ -21,51 +21,62 @@ WorkItem::~WorkItem() {
}
CopyTreeWorkItem* WorkItem::CreateCopyTreeWorkItem(
- std::wstring source_path, std::wstring dest_path, std::wstring temp_dir,
- CopyOverWriteOption overwrite_option, std::wstring alternative_path) {
+ const std::wstring& source_path,
+ const std::wstring& dest_path,
+ const std::wstring& temp_dir,
+ CopyOverWriteOption overwrite_option,
+ const std::wstring& alternative_path) {
return new CopyTreeWorkItem(source_path, dest_path, temp_dir,
overwrite_option, alternative_path);
}
-CreateDirWorkItem* WorkItem::CreateCreateDirWorkItem(std::wstring path) {
+CreateDirWorkItem* WorkItem::CreateCreateDirWorkItem(const std::wstring& path) {
return new CreateDirWorkItem(path);
}
CreateRegKeyWorkItem* WorkItem::CreateCreateRegKeyWorkItem(
- HKEY predefined_root, std::wstring path) {
+ HKEY predefined_root, const std::wstring& path) {
return new CreateRegKeyWorkItem(predefined_root, path);
}
DeleteRegValueWorkItem* WorkItem::CreateDeleteRegValueWorkItem(
- HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, bool is_str_type) {
+ HKEY predefined_root,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ bool is_str_type) {
return new DeleteRegValueWorkItem(predefined_root, key_path,
value_name, is_str_type);
}
-DeleteTreeWorkItem* WorkItem::CreateDeleteTreeWorkItem(std::wstring root_path,
- std::wstring key_path) {
+DeleteTreeWorkItem* WorkItem::CreateDeleteTreeWorkItem(
+ const std::wstring& root_path, const std::wstring& key_path) {
return new DeleteTreeWorkItem(root_path, key_path);
}
-MoveTreeWorkItem* WorkItem::CreateMoveTreeWorkItem(std::wstring source_path,
- std::wstring dest_path,
- std::wstring temp_dir) {
+MoveTreeWorkItem* WorkItem::CreateMoveTreeWorkItem(
+ const std::wstring& source_path,
+ const std::wstring& dest_path,
+ const std::wstring& temp_dir) {
return new MoveTreeWorkItem(source_path, dest_path, temp_dir);
}
SetRegValueWorkItem* WorkItem::CreateSetRegValueWorkItem(
- HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, std::wstring value_data, bool overwrite) {
+ HKEY predefined_root,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ const std::wstring& value_data,
+ bool overwrite) {
return new SetRegValueWorkItem(predefined_root, key_path,
- value_name, value_data, overwrite);
+ value_name, value_data, overwrite);
}
SetRegValueWorkItem* WorkItem::CreateSetRegValueWorkItem(
- HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, DWORD value_data, bool overwrite) {
+ HKEY predefined_root,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ DWORD value_data, bool overwrite) {
return new SetRegValueWorkItem(predefined_root, key_path,
- value_name, value_data, overwrite);
+ value_name, value_data, overwrite);
}
SelfRegWorkItem* WorkItem::CreateSelfRegWorkItem(const std::wstring& dll_path,
diff --git a/chrome/installer/util/work_item.h b/chrome/installer/util/work_item.h
index 1a29c2f0..08d0c05 100644
--- a/chrome/installer/util/work_item.h
+++ b/chrome/installer/util/work_item.h
@@ -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.
//
@@ -43,46 +43,57 @@ class WorkItem {
// overwrites files.
// * If overwrite_option is NEW_NAME_IF_IN_USE, file is copied with an
// alternate name specified by alternative_path.
- static CopyTreeWorkItem* CreateCopyTreeWorkItem(std::wstring source_path,
- std::wstring dest_path, std::wstring temp_dir,
+ static CopyTreeWorkItem* CreateCopyTreeWorkItem(
+ const std::wstring& source_path,
+ const std::wstring& dest_path,
+ const std::wstring& temp_dir,
CopyOverWriteOption overwrite_option,
- std::wstring alternative_path = L"");
+ const std::wstring& alternative_path = L"");
// Create a CreateDirWorkItem that creates a directory at the given path.
- static CreateDirWorkItem* CreateCreateDirWorkItem(std::wstring path);
+ static CreateDirWorkItem* CreateCreateDirWorkItem(const std::wstring& path);
// Create a CreateRegKeyWorkItem that creates a registry key at the given
// path.
static CreateRegKeyWorkItem* CreateCreateRegKeyWorkItem(
- HKEY predefined_root, std::wstring path);
+ HKEY predefined_root, const std::wstring& path);
// Create a DeleteRegValueWorkItem that deletes a registry value
static DeleteRegValueWorkItem* CreateDeleteRegValueWorkItem(
- HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, bool is_str_type);
+ HKEY predefined_root,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ bool is_str_type);
// Create a DeleteTreeWorkItem that recursively deletes a file system
// hierarchy at the given root path. A key file can be optionally specified
// by key_path.
- static DeleteTreeWorkItem* CreateDeleteTreeWorkItem(std::wstring root_path,
- std::wstring key_path);
+ static DeleteTreeWorkItem* CreateDeleteTreeWorkItem(
+ const std::wstring& root_path, const std::wstring& key_path);
// Create a MoveTreeWorkItem that recursively moves a file system hierarchy
// from source path to destination path.
- static MoveTreeWorkItem* CreateMoveTreeWorkItem(std::wstring source_path,
- std::wstring dest_path, std::wstring temp_dir);
+ static MoveTreeWorkItem* CreateMoveTreeWorkItem(
+ const std::wstring& source_path,
+ const std::wstring& dest_path,
+ const std::wstring& temp_dir);
// Create a SetRegValueWorkItem that sets a registry value with REG_SZ type
// at the key with specified path.
static SetRegValueWorkItem* CreateSetRegValueWorkItem(
- HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, std::wstring value_data, bool overwrite);
+ HKEY predefined_root,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ const std::wstring& value_data,
+ bool overwrite);
// Create a SetRegValueWorkItem that sets a registry value with REG_DWORD type
// at the key with specified path.
static SetRegValueWorkItem* CreateSetRegValueWorkItem(
- HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, DWORD value_data, bool overwrite);
+ HKEY predefined_root,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ DWORD value_data, bool overwrite);
// Add a SelfRegWorkItem that registers or unregisters a DLL at the
// specified path.
diff --git a/chrome/installer/util/work_item_list.cc b/chrome/installer/util/work_item_list.cc
index e5aa3bc..3e5ac07 100644
--- a/chrome/installer/util/work_item_list.cc
+++ b/chrome/installer/util/work_item_list.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.
@@ -63,33 +63,33 @@ bool WorkItemList::AddWorkItem(WorkItem* work_item) {
return true;
}
-bool WorkItemList::AddCopyTreeWorkItem(std::wstring source_path,
- std::wstring dest_path,
- std::wstring temp_dir,
+bool WorkItemList::AddCopyTreeWorkItem(const std::wstring& source_path,
+ const std::wstring& dest_path,
+ const std::wstring& temp_dir,
CopyOverWriteOption overwrite_option,
- std::wstring alternative_path) {
+ const std::wstring& alternative_path) {
WorkItem* item = reinterpret_cast<WorkItem*>(
WorkItem::CreateCopyTreeWorkItem(source_path, dest_path, temp_dir,
overwrite_option, alternative_path));
return AddWorkItem(item);
}
-bool WorkItemList::AddCreateDirWorkItem(std::wstring path) {
+bool WorkItemList::AddCreateDirWorkItem(const std::wstring& path) {
WorkItem* item = reinterpret_cast<WorkItem*>(
WorkItem::CreateCreateDirWorkItem(path));
return AddWorkItem(item);
}
bool WorkItemList::AddCreateRegKeyWorkItem(HKEY predefined_root,
- std::wstring path) {
+ const std::wstring& path) {
WorkItem* item = reinterpret_cast<WorkItem*>(
WorkItem::CreateCreateRegKeyWorkItem(predefined_root, path));
return AddWorkItem(item);
}
bool WorkItemList::AddDeleteRegValueWorkItem(HKEY predefined_root,
- std::wstring key_path,
- std::wstring value_name,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
bool is_str_type) {
WorkItem* item = reinterpret_cast<WorkItem*>(
WorkItem::CreateDeleteRegValueWorkItem(predefined_root, key_path,
@@ -97,25 +97,25 @@ bool WorkItemList::AddDeleteRegValueWorkItem(HKEY predefined_root,
return AddWorkItem(item);
}
-bool WorkItemList::AddDeleteTreeWorkItem(std::wstring root_path,
- std::wstring key_path) {
+bool WorkItemList::AddDeleteTreeWorkItem(const std::wstring& root_path,
+ const std::wstring& key_path) {
WorkItem* item = reinterpret_cast<WorkItem*>(
WorkItem::CreateDeleteTreeWorkItem(root_path, key_path));
return AddWorkItem(item);
}
-bool WorkItemList::AddMoveTreeWorkItem(std::wstring source_path,
- std::wstring dest_path,
- std::wstring temp_dir) {
+bool WorkItemList::AddMoveTreeWorkItem(const std::wstring& source_path,
+ const std::wstring& dest_path,
+ const std::wstring& temp_dir) {
WorkItem* item = reinterpret_cast<WorkItem*>(
WorkItem::CreateMoveTreeWorkItem(source_path, dest_path, temp_dir));
return AddWorkItem(item);
}
bool WorkItemList::AddSetRegValueWorkItem(HKEY predefined_root,
- std::wstring key_path,
- std::wstring value_name,
- std::wstring value_data,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ const std::wstring& value_data,
bool overwrite) {
WorkItem* item = reinterpret_cast<WorkItem*>(
WorkItem::CreateSetRegValueWorkItem(predefined_root, key_path, value_name,
@@ -124,8 +124,8 @@ bool WorkItemList::AddSetRegValueWorkItem(HKEY predefined_root,
}
bool WorkItemList::AddSetRegValueWorkItem(HKEY predefined_root,
- std::wstring key_path,
- std::wstring value_name,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
DWORD value_data,
bool overwrite) {
WorkItem* item = reinterpret_cast<WorkItem*>(
diff --git a/chrome/installer/util/work_item_list.h b/chrome/installer/util/work_item_list.h
index b7b4fc3..5b89b22 100644
--- a/chrome/installer/util/work_item_list.h
+++ b/chrome/installer/util/work_item_list.h
@@ -1,9 +1,9 @@
-// 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_WORK_ITEM_LIST_H__
-#define CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H__
+#ifndef CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_
+#define CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_
#include <windows.h>
@@ -34,42 +34,51 @@ class WorkItemList : public WorkItem {
bool AddWorkItem(WorkItem* work_item);
// Add a CopyTreeWorkItem to the list of work items.
- bool AddCopyTreeWorkItem(std::wstring source_path, std::wstring dest_path,
- std::wstring temp_dir,
+ bool AddCopyTreeWorkItem(const std::wstring& source_path,
+ const std::wstring& dest_path,
+ const std::wstring& temp_dir,
CopyOverWriteOption overwrite_option,
- std::wstring alternative_path = L"");
+ const std::wstring& alternative_path = L"");
// Add a CreateDirWorkItem that creates a directory at the given path.
- bool AddCreateDirWorkItem(std::wstring path);
+ bool AddCreateDirWorkItem(const std::wstring& path);
// Add a CreateRegKeyWorkItem that creates a registry key at the given
// path.
- bool AddCreateRegKeyWorkItem(HKEY predefined_root, std::wstring path);
+ bool AddCreateRegKeyWorkItem(HKEY predefined_root, const std::wstring& path);
// Add a DeleteRegValueWorkItem that deletes registry value of type REG_SZ
// or REG_DWORD.
- bool AddDeleteRegValueWorkItem(HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, bool is_str_type);
+ bool AddDeleteRegValueWorkItem(HKEY predefined_root,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ bool is_str_type);
// Add a DeleteTreeWorkItem that recursively deletes a file system
// hierarchy at the given root path. A key file can be optionally specified
// by key_path.
- bool AddDeleteTreeWorkItem(std::wstring root_path, std::wstring key_path);
+ bool AddDeleteTreeWorkItem(const std::wstring& root_path,
+ const std::wstring& key_path);
// Add a MoveTreeWorkItem to the list of work items.
- bool AddMoveTreeWorkItem(std::wstring source_path, std::wstring dest_path,
- std::wstring temp_dir);
+ bool AddMoveTreeWorkItem(const std::wstring& source_path,
+ const std::wstring& dest_path,
+ const std::wstring& temp_dir);
// Add a SetRegValueWorkItem that sets a registry value with REG_SZ type
// at the key with specified path.
- bool AddSetRegValueWorkItem(HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, std::wstring value_data,
+ bool AddSetRegValueWorkItem(HKEY predefined_root,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ const std::wstring& value_data,
bool overwrite);
// Add a SetRegValueWorkItem that sets a registry value with REG_DWORD type
// at the key with specified path.
- bool AddSetRegValueWorkItem(HKEY predefined_root, std::wstring key_path,
- std::wstring value_name, DWORD value_data,
+ bool AddSetRegValueWorkItem(HKEY predefined_root,
+ const std::wstring& key_path,
+ const std::wstring& value_name,
+ DWORD value_data,
bool overwrite);
// Add a SelfRegWorkItem that registers or unregisters a DLL at the
@@ -103,4 +112,4 @@ class WorkItemList : public WorkItem {
WorkItems executed_list_;
};
-#endif // CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H__
+#endif // CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_