diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 20:24:32 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 20:24:32 +0000 |
commit | 93842c2ee944584ccc652d180955ef62324dcde4 (patch) | |
tree | dba6594152ee7bbcc7c27c605c2acdf83cb51d03 | |
parent | 8436e747836cb3a0e50c59509467921dcc08479c (diff) | |
download | chromium_src-93842c2ee944584ccc652d180955ef62324dcde4.zip chromium_src-93842c2ee944584ccc652d180955ef62324dcde4.tar.gz chromium_src-93842c2ee944584ccc652d180955ef62324dcde4.tar.bz2 |
Convert LOG(INFO) to VLOG(1) - chrome/installer/.
Also remove some extra {}s, avoid "else" after "return"/use some early returns, and simplify some code.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3931004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63258 0039d316-1c4b-4281-b951-d872f2087c98
20 files changed, 215 insertions, 244 deletions
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc index 3a80634..1f2ea11 100644 --- a/chrome/installer/setup/install.cc +++ b/chrome/installer/setup/install.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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,7 +43,7 @@ void AddChromeToMediaPlayerList() { std::wstring reg_path(installer::kMediaPlayerRegPath); // registry paths can also be appended like file system path file_util::AppendToPath(®_path, installer_util::kChromeExe); - LOG(INFO) << "Adding Chrome to Media player list at " << reg_path; + VLOG(1) << "Adding Chrome to Media player list at " << reg_path; scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( HKEY_LOCAL_MACHINE, reg_path)); @@ -235,11 +235,10 @@ void DeleteUninstallShortcutsForMSI(bool is_system_install) { uninstall_link = uninstall_link.Append(dist->GetAppShortCutName()); uninstall_link = uninstall_link.Append( dist->GetUninstallLinkName() + L".lnk"); - LOG(INFO) << "Deleting old uninstall shortcut (if present):" - << uninstall_link.value(); - if (!file_util::Delete(uninstall_link, true)) { - LOG(INFO) << "Failed to delete old uninstall shortcut."; - } + VLOG(1) << "Deleting old uninstall shortcut (if present): " + << uninstall_link.value(); + if (!file_util::Delete(uninstall_link, true)) + VLOG(1) << "Failed to delete old uninstall shortcut."; } } @@ -253,9 +252,8 @@ void CopyPreferenceFileForFirstRun(bool system_level, prefs_dest_path = prefs_dest_path.AppendASCII( installer_util::kDefaultMasterPrefs); if (!file_util::CopyFile(FilePath::FromWStringHack(prefs_source_path), - prefs_dest_path)) { - LOG(INFO) << "Failed to copy master preferences."; - } + prefs_dest_path)) + VLOG(1) << "Failed to copy master preferences."; } // This method creates Chrome shortcuts in Start->Programs for all users or @@ -311,14 +309,14 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, if (!file_util::PathExists(shortcut_path)) file_util::CreateDirectoryW(shortcut_path); - LOG(INFO) << "Creating shortcut to " << chrome_exe << " at " - << chrome_link.value(); + VLOG(1) << "Creating shortcut to " << chrome_exe << " at " + << chrome_link.value(); ret = ret && ShellUtil::UpdateChromeShortcut(chrome_exe, chrome_link.value(), product_desc, true); } else if (file_util::PathExists(chrome_link)) { - LOG(INFO) << "Updating shortcut at " << chrome_link.value() - << " to point to " << chrome_exe; + VLOG(1) << "Updating shortcut at " << chrome_link.value() + << " to point to " << chrome_exe; ret = ret && ShellUtil::UpdateChromeShortcut(chrome_exe, chrome_link.value(), product_desc, false); @@ -344,8 +342,8 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, std::wstring arguments; AppendUninstallCommandLineFlags(&arguments, system_install); - LOG(INFO) << "Creating/updating uninstall link at " - << uninstall_link.value(); + VLOG(1) << "Creating/updating uninstall link at " + << uninstall_link.value(); ret = ret && file_util::CreateShortcutLink(setup_exe.c_str(), uninstall_link.value().c_str(), NULL, @@ -540,7 +538,7 @@ void RegisterChromeOnMachine(const std::wstring& install_path, // otherwise we only register it on the machine as a valid browser. std::wstring chrome_exe(install_path); file_util::AppendToPath(&chrome_exe, installer_util::kChromeExe); - LOG(INFO) << "Registering Chrome as browser"; + VLOG(1) << "Registering Chrome as browser"; if (make_chrome_default) { int level = ShellUtil::CURRENT_USER; if (system_level) @@ -677,44 +675,45 @@ installer_util::InstallStatus InstallNewVersion( new_version.GetString(), true); // overwrite version - installer_util::InstallStatus result = installer_util::INSTALL_FAILED; if (!install_list->Do() || !DoPostInstallTasks(reg_root, exe_path, install_path, new_chrome_exe, *current_version, new_version)) { - if (file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe)) && - !current_version->empty() && - (new_version.GetString() == *current_version)) - result = installer_util::SAME_VERSION_REPAIR_FAILED; + installer_util::InstallStatus result = + (file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe)) && + !current_version->empty() && + (new_version.GetString() == *current_version)) ? + installer_util::SAME_VERSION_REPAIR_FAILED : + installer_util::INSTALL_FAILED; LOG(ERROR) << "Install failed, rolling back... "; install_list->Rollback(); LOG(ERROR) << "Rollback complete. "; - } else { - scoped_ptr<installer::Version> installed_version; - if (!current_version->empty()) - installed_version.reset( - installer::Version::GetVersionFromString(*current_version)); - if (!installed_version.get()) { - LOG(INFO) << "First install of version " << new_version.GetString(); - result = installer_util::FIRST_INSTALL_SUCCESS; - } else if (new_version.GetString() == installed_version->GetString()) { - LOG(INFO) << "Install repaired of version " << new_version.GetString(); - result = installer_util::INSTALL_REPAIRED; - } else if (new_version.IsHigherThan(installed_version.get())) { - if (file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) { - LOG(INFO) << "Version updated to " << new_version.GetString() - << " while running " << installed_version->GetString(); - result = installer_util::IN_USE_UPDATED; - } else { - LOG(INFO) << "Version updated to " << new_version.GetString(); - result = installer_util::NEW_VERSION_UPDATED; - } - } else { - LOG(ERROR) << "Not sure how we got here while updating" - << ", new version: " << new_version.GetString() - << ", old version: " << installed_version->GetString(); + return result; + } + scoped_ptr<installer::Version> installed_version; + if (!current_version->empty()) + installed_version.reset( + installer::Version::GetVersionFromString(*current_version)); + if (!installed_version.get()) { + VLOG(1) << "First install of version " << new_version.GetString(); + return installer_util::FIRST_INSTALL_SUCCESS; + } + if (new_version.GetString() == installed_version->GetString()) { + VLOG(1) << "Install repaired of version " << new_version.GetString(); + return installer_util::INSTALL_REPAIRED; + } + if (new_version.IsHigherThan(installed_version.get())) { + if (file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) { + VLOG(1) << "Version updated to " << new_version.GetString() + << " while running " << installed_version->GetString(); + return installer_util::IN_USE_UPDATED; } + VLOG(1) << "Version updated to " << new_version.GetString(); + return installer_util::NEW_VERSION_UPDATED; } - return result; + LOG(ERROR) << "Not sure how we got here while updating" + << ", new version: " << new_version.GetString() + << ", old version: " << installed_version->GetString(); + return installer_util::INSTALL_FAILED; } } // namespace @@ -739,9 +738,8 @@ installer_util::InstallStatus installer::InstallOrUpdateChrome( if (install_path.empty()) { LOG(ERROR) << "Could not get installation destination path."; return installer_util::INSTALL_FAILED; - } else { - LOG(INFO) << "install destination path: " << install_path; } + VLOG(1) << "install destination path: " << install_path; std::wstring src_path(install_temp_path); file_util::AppendToPath(&src_path, std::wstring(kInstallSourceDir)); diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index 7b674f2..e6929a5 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -75,7 +75,7 @@ DWORD UnPackArchive(const std::wstring& archive, bool system_install, // it is a differential installer if chrome.7z is not found. if (!file_util::PathExists(FilePath::FromWStringHack(uncompressed_archive))) { incremental_install = true; - LOG(INFO) << "Differential patch found. Applying to existing archive."; + VLOG(1) << "Differential patch found. Applying to existing archive."; if (!installed_version) { LOG(ERROR) << "Can not use differential update when Chrome is not " << "installed on the system."; @@ -176,7 +176,7 @@ bool CheckPreInstallConditions(const installer::Version* installed_version, + ASCIIToWide(switches::kFirstRun); InstallUtil::WriteInstallerResult(system_install, status, 0, NULL); - LOG(INFO) << "Launching existing system-level chrome instead."; + VLOG(1) << "Launching existing system-level chrome instead."; base::LaunchApp(chrome_exe, false, false, NULL); return false; } @@ -237,7 +237,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, archive = cmd_line.GetSwitchValuePath( installer_util::switches::kInstallArchive); } - LOG(INFO) << "Archive found to install Chrome " << archive.value(); + VLOG(1) << "Archive found to install Chrome " << archive.value(); // Create a temp folder where we will unpack Chrome archive. If it fails, // then we are doomed, so return immediately and no cleanup is required. @@ -250,7 +250,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, NULL); return installer_util::TEMP_DIR_FAILED; } - LOG(INFO) << "created path " << temp_path.value(); + VLOG(1) << "created path " << temp_path.value(); BrowserDistribution* dist = BrowserDistribution::GetDistribution(); std::wstring unpack_path(temp_path.ToWStringHack()); @@ -265,7 +265,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, NULL); } else { - LOG(INFO) << "unpacked to " << unpack_path; + VLOG(1) << "unpacked to " << unpack_path; std::wstring src_path(unpack_path); file_util::AppendToPath(&src_path, std::wstring(installer::kInstallSourceChromeDir)); @@ -277,7 +277,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, InstallUtil::WriteInstallerResult(system_level, install_status, IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); } else { - LOG(INFO) << "version to install: " << installer_version->GetString(); + VLOG(1) << "version to install: " << installer_version->GetString(); if (installed_version && installed_version->IsHigherThan(installer_version.get())) { LOG(ERROR) << "Higher version is already installed."; @@ -325,7 +325,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, install_msg_base, write_chrome_launch_string ? &chrome_exe : NULL); if (install_status == installer_util::FIRST_INSTALL_SUCCESS) { - LOG(INFO) << "First install successful."; + VLOG(1) << "First install successful."; // We never want to launch Chrome in system level install mode. bool do_not_launch_chrome = false; installer_util::GetDistroBooleanPreference(prefs, @@ -354,7 +354,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, // and master profile file if present. Note that we do not care about rollback // here and we schedule for deletion on reboot below if the deletes fail. As // such, we do not use DeleteTreeWorkItem. - LOG(INFO) << "Deleting temporary directory " << temp_path.value(); + VLOG(1) << "Deleting temporary directory " << temp_path.value(); bool cleanup_success = file_util::Delete(temp_path, true); if (cmd_line.HasSwitch(installer_util::switches::kInstallerData)) { std::wstring prefs_path = cmd_line.GetSwitchValueNative( @@ -386,7 +386,7 @@ installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line, const wchar_t* cmd_params, const installer::Version* version, bool system_install) { - LOG(INFO) << "Uninstalling Chome"; + VLOG(1) << "Uninstalling Chome"; bool force = cmd_line.HasSwitch(installer_util::switches::kForceUninstall); if (!version && !force) { LOG(ERROR) << "No Chrome installation found for uninstall."; @@ -406,7 +406,7 @@ installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line, } installer_util::InstallStatus ShowEULADialog(const std::wstring& inner_frame) { - LOG(INFO) << "About to show EULA"; + VLOG(1) << "About to show EULA"; std::wstring eula_path = installer_util::GetLocalizedEulaResource(); if (eula_path.empty()) { LOG(ERROR) << "No EULA path available"; @@ -425,10 +425,10 @@ installer_util::InstallStatus ShowEULADialog(const std::wstring& inner_frame) { return installer_util::EULA_REJECTED; } if (installer::EulaHTMLDialog::ACCEPTED_OPT_IN == outcome) { - LOG(INFO) << "EULA accepted (opt-in)"; + VLOG(1) << "EULA accepted (opt-in)"; return installer_util::EULA_ACCEPTED_OPT_IN; } - LOG(INFO) << "EULA accepted (no opt-in)"; + VLOG(1) << "EULA accepted (no opt-in)"; return installer_util::EULA_ACCEPTED; } @@ -452,7 +452,7 @@ bool HandleNonInstallCmdLineOptions(const CommandLine& cmd_line, } else { std::wstring setup_patch = cmd_line.GetSwitchValueNative( installer_util::switches::kUpdateSetupExe); - LOG(INFO) << "Opening archive " << setup_patch; + VLOG(1) << "Opening archive " << setup_patch; std::wstring uncompressed_patch; if (LzmaUtil::UnPackArchive(setup_patch, temp_path.ToWStringHack(), &uncompressed_patch) == NO_ERROR) { @@ -629,12 +629,12 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, value) logging::SetMinLogLevel(logging::LOG_INFO); - LOG(INFO) << "Command Line: " << parsed_command_line.command_line_string(); + VLOG(1) << "Command Line: " << parsed_command_line.command_line_string(); bool system_install = false; installer_util::GetDistroBooleanPreference(prefs.get(), installer_util::master_preferences::kSystemLevel, &system_install); - LOG(INFO) << "system install is " << system_install; + VLOG(1) << "system install is " << system_install; // Check to make sure current system is WinXP or later. If not, log // error message and get out. @@ -701,9 +701,8 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, // Check the existing version installed. scoped_ptr<installer::Version> installed_version(InstallUtil::GetChromeVersion(system_install)); - if (installed_version.get()) { + if (installed_version.get()) LOG(INFO) << "version on the system: " << installed_version->GetString(); - } installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS; // If --uninstall option is given, uninstall chrome @@ -748,6 +747,6 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, return_code = dist->GetInstallReturnCode(install_status); } - LOG(INFO) << "Installation complete, returning: " << return_code; + VLOG(1) << "Installation complete, returning: " << return_code; return return_code; } diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc index 84f6c2b..d4fbed1 100644 --- a/chrome/installer/setup/setup_util.cc +++ b/chrome/installer/setup/setup_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. // @@ -16,9 +16,8 @@ int setup_util::ApplyDiffPatch(const FilePath& src, const FilePath& patch, const FilePath& dest) { - LOG(INFO) << "Applying patch " << patch.value() - << " to file " << src.value() - << " and generating file " << dest.value(); + VLOG(1) << "Applying patch " << patch.value() << " to file " << src.value() + << " and generating file " << dest.value(); // Try Courgette first. Courgette checks the patch file first and fails // quickly if the patch file does not have a valid Courgette header. @@ -26,21 +25,17 @@ int setup_util::ApplyDiffPatch(const FilePath& src, courgette::ApplyEnsemblePatch(src.value().c_str(), patch.value().c_str(), dest.value().c_str()); - if (patch_status == courgette::C_OK) { + if (patch_status == courgette::C_OK) return 0; - } else { - LOG(INFO) << "Failed to apply patch " << patch.value() - << " using courgette."; - } + VLOG(1) << "Failed to apply patch " << patch.value() << " using courgette."; return ApplyBinaryPatch(src.value().c_str(), patch.value().c_str(), dest.value().c_str()); } installer::Version* setup_util::GetVersionFromDir( const FilePath& chrome_path) { - LOG(INFO) << "Looking for Chrome version folder under " - << chrome_path.value(); + VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); FilePath root_path = chrome_path.Append(L"*"); WIN32_FIND_DATA find_data; @@ -52,9 +47,10 @@ installer::Version* setup_util::GetVersionFromDir( // version directory. while (ret) { if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - LOG(INFO) << "directory found: " << find_data.cFileName; + VLOG(1) << "directory found: " << find_data.cFileName; version = installer::Version::GetVersionFromString(find_data.cFileName); - if (version) break; + if (version) + break; } ret = FindNextFile(file_handle, &find_data); } diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 173aea9..92f22d1 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -130,7 +130,7 @@ void DeleteChromeShortcuts(bool system_uninstall) { } else { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); shortcut_path = shortcut_path.Append(dist->GetAppShortCutName()); - LOG(INFO) << "Deleting shortcut " << shortcut_path.value(); + VLOG(1) << "Deleting shortcut " << shortcut_path.value(); if (!file_util::Delete(shortcut_path, true)) LOG(ERROR) << "Failed to delete folder: " << shortcut_path.value(); } @@ -195,9 +195,8 @@ DeleteResult DeleteFilesAndFolders(const std::wstring& exe_path, if (install_path.empty()) { LOG(ERROR) << "Could not get installation destination path."; return DELETE_FAILED; // Nothing else we can do to uninstall, so we return. - } else { - LOG(INFO) << "install destination path: " << install_path; } + VLOG(1) << "install destination path: " << install_path; // Move setup.exe to the temp path. std::wstring setup_exe(installer::GetInstallerPathUnderChrome( @@ -238,7 +237,7 @@ DeleteResult DeleteFilesAndFolders(const std::wstring& exe_path, DeleteResult result = DELETE_SUCCEEDED; - LOG(INFO) << "Deleting install path " << install_path; + VLOG(1) << "Deleting install path " << install_path; if (!file_util::Delete(install_path, true)) { LOG(ERROR) << "Failed to delete folder (1st try): " << install_path; if (InstallUtil::IsChromeFrameProcess()) { @@ -258,7 +257,7 @@ DeleteResult DeleteFilesAndFolders(const std::wstring& exe_path, } if (delete_profile && got_local_state) { - LOG(INFO) << "Deleting user profile" << user_local_state.value(); + VLOG(1) << "Deleting user profile" << user_local_state.value(); if (!file_util::Delete(user_local_state, true)) { LOG(ERROR) << "Failed to delete user profile dir: " << user_local_state.value(); @@ -306,19 +305,18 @@ installer_util::InstallStatus IsChromeActiveOrUserCancelled( // - HUNG - chrome.exe was killed by HuntForZombieProcesses() (until we can // give this method some brains and not kill chrome.exe launched // by us, we will not uninstall if we get this return code). - LOG(INFO) << "Launching Chrome to do uninstall tasks."; + VLOG(1) << "Launching Chrome to do uninstall tasks."; if (installer::LaunchChromeAndWaitForResult(system_uninstall, kCmdLineOptions, &exit_code)) { - LOG(INFO) << "chrome.exe launched for uninstall confirmation returned: " - << exit_code; + VLOG(1) << "chrome.exe launched for uninstall confirmation returned: " + << exit_code; if ((exit_code == ResultCodes::UNINSTALL_CHROME_ALIVE) || (exit_code == ResultCodes::UNINSTALL_USER_CANCEL) || - (exit_code == ResultCodes::HUNG)) { + (exit_code == ResultCodes::HUNG)) return installer_util::UNINSTALL_CANCELLED; - } else if (exit_code == ResultCodes::UNINSTALL_DELETE_PROFILE) { + if (exit_code == ResultCodes::UNINSTALL_DELETE_PROFILE) return installer_util::UNINSTALL_DELETE_PROFILE; - } } else { LOG(ERROR) << "Failed to launch chrome.exe for uninstall confirmation."; } @@ -586,7 +584,7 @@ installer_util::InstallStatus installer_setup::UninstallChrome( } if (!force_uninstall) { - LOG(INFO) << "Uninstallation complete. Launching Uninstall survey."; + VLOG(1) << "Uninstallation complete. Launching Uninstall survey."; dist->DoPostUninstallOperations(*installed_version, local_state_path, distribution_data); } diff --git a/chrome/installer/util/copy_tree_work_item.cc b/chrome/installer/util/copy_tree_work_item.cc index bf270e9..026bcc8 100644 --- a/chrome/installer/util/copy_tree_work_item.cc +++ b/chrome/installer/util/copy_tree_work_item.cc @@ -44,9 +44,9 @@ bool CopyTreeWorkItem::Do() { (!file_util::DirectoryExists(source_path_)) && (!file_util::DirectoryExists(dest_path_)) && (file_util::ContentsEqual(source_path_, dest_path_))) { - LOG(INFO) << "Source file " << source_path_.value() - << " and destination file " << dest_path_.value() - << " are exactly same. Returning true."; + VLOG(1) << "Source file " << source_path_.value() + << " and destination file " << dest_path_.value() + << " are exactly same. Returning true."; return true; } else if ((dest_exist) && (overwrite_option_ == WorkItem::NEW_NAME_IF_IN_USE) && @@ -57,13 +57,13 @@ bool CopyTreeWorkItem::Do() { 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_.value() + << " to " << alternative_path_.value(); return false; } else { copied_to_alternate_path_ = true; - LOG(INFO) << "Copied source file " << source_path_.value() - << " to alternative path " << alternative_path_.value(); + VLOG(1) << "Copied source file " << source_path_.value() + << " to alternative path " << alternative_path_.value(); return true; } } else if ((dest_exist) && @@ -79,11 +79,11 @@ 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(); + VLOG(1) << "Moved destination " << dest_path_.value() << + " to backup path " << backup_path_.value(); } else { - LOG(ERROR) << "failed moving " << dest_path_.value() << " to " << - backup_path_.value(); + LOG(ERROR) << "failed moving " << dest_path_.value() + << " to " << backup_path_.value(); return false; } } @@ -91,11 +91,11 @@ 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(); + VLOG(1) << "Copied source " << source_path_.value() + << " to destination " << dest_path_.value(); } else { - LOG(ERROR) << "failed copy " << source_path_.value() << - " to " << dest_path_.value(); + LOG(ERROR) << "failed copy " << source_path_.value() + << " to " << dest_path_.value(); return false; } @@ -112,8 +112,8 @@ void CopyTreeWorkItem::Rollback() { LOG(ERROR) << "Can not delete " << dest_path_.value(); } 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_.value() + << " to " << dest_path_.value(); } if (copied_to_alternate_path_ && !file_util::Delete(alternative_path_, true)) { diff --git a/chrome/installer/util/copy_tree_work_item_unittest.cc b/chrome/installer/util/copy_tree_work_item_unittest.cc index a7498af..269d2fe 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) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -344,8 +344,8 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUse) { file_util::CopyFile(exe_full_path, file_name_to); ASSERT_TRUE(file_util::PathExists(file_name_to)); - LOG(INFO) << "copy ourself from " - << exe_full_path.value() << " to " << file_name_to.value(); + VLOG(1) << "copy ourself from " << exe_full_path.value() + << " to " << file_name_to.value(); // Run the executable in destination path STARTUPINFOW si = {sizeof(si)}; @@ -422,8 +422,8 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { file_util::CopyFile(exe_full_path, file_name_to); ASSERT_TRUE(file_util::PathExists(file_name_to)); - LOG(INFO) << "copy ourself from " - << exe_full_path.value() << " to " << file_name_to.value(); + VLOG(1) << "copy ourself from " << exe_full_path.value() + << " to " << file_name_to.value(); // Run the executable in destination path STARTUPINFOW si = {sizeof(si)}; @@ -610,8 +610,8 @@ TEST_F(CopyTreeWorkItemTest, FLAKY_CopyFileInUseAndCleanup) { file_util::CopyFile(exe_full_path, file_name_to); ASSERT_TRUE(file_util::PathExists(file_name_to)); - LOG(INFO) << "copy ourself from " - << exe_full_path.value() << " to " << file_name_to.value(); + VLOG(1) << "copy ourself from " << exe_full_path.value() + << " to " << file_name_to.value(); // Run the executable in destination path STARTUPINFOW si = {sizeof(si)}; @@ -702,15 +702,15 @@ TEST_F(CopyTreeWorkItemTest, FLAKY_CopyTree) { file_name_to_1 = file_name_to_1.AppendASCII("1"); file_name_to_1 = file_name_to_1.AppendASCII("File_1.txt"); EXPECT_TRUE(file_util::PathExists(file_name_to_1)); - LOG(INFO) << "compare " - << file_name_from_1.value() << " and " << file_name_to_1.value(); + VLOG(1) << "compare " << file_name_from_1.value() + << " and " << file_name_to_1.value(); EXPECT_TRUE(file_util::ContentsEqual(file_name_from_1, file_name_to_1)); FilePath file_name_to_2(dir_name_to); file_name_to_2 = file_name_to_2.AppendASCII("2"); file_name_to_2 = file_name_to_2.AppendASCII("File_2.txt"); EXPECT_TRUE(file_util::PathExists(file_name_to_2)); - LOG(INFO) << "compare " - << file_name_from_2.value() << " and " << file_name_to_2.value(); + VLOG(1) << "compare " << file_name_from_2.value() + << " and " << file_name_to_2.value(); EXPECT_TRUE(file_util::ContentsEqual(file_name_from_2, file_name_to_2)); } diff --git a/chrome/installer/util/create_dir_work_item.cc b/chrome/installer/util/create_dir_work_item.cc index ad19b8e..a9a4bfb 100644 --- a/chrome/installer/util/create_dir_work_item.cc +++ b/chrome/installer/util/create_dir_work_item.cc @@ -30,15 +30,14 @@ void CreateDirWorkItem::GetTopDirToCreate() { } bool CreateDirWorkItem::Do() { - LOG(INFO) << "creating directory " << path_.value(); + VLOG(1) << "creating directory " << path_.value(); GetTopDirToCreate(); if (top_path_.empty()) return true; - LOG(INFO) << "top directory that needs to be created: " \ - << top_path_.value(); + VLOG(1) << "top directory that needs to be created: " << top_path_.value(); bool result = file_util::CreateDirectory(path_); - LOG(INFO) << "directory creation result: " << result; + VLOG(1) << "directory creation result: " << result; rollback_needed_ = true; diff --git a/chrome/installer/util/create_reg_key_work_item.cc b/chrome/installer/util/create_reg_key_work_item.cc index 6c4a2a0..4fa08c6 100644 --- a/chrome/installer/util/create_reg_key_work_item.cc +++ b/chrome/installer/util/create_reg_key_work_item.cc @@ -42,7 +42,7 @@ CreateRegKeyWorkItem::CreateRegKeyWorkItem(HKEY predefined_root, bool CreateRegKeyWorkItem::Do() { if (!InitKeyList()) { // Nothing needs to be done here. - LOG(INFO) << "no key to create"; + VLOG(1) << "no key to create"; return true; } @@ -63,11 +63,11 @@ bool CreateRegKeyWorkItem::Do() { LOG(ERROR) << key_path << " exists, this is not expected."; return false; } - LOG(INFO) << key_path << " exists"; + VLOG(1) << key_path << " exists"; // Remove the key path from list if it is already present. key_list_.pop_back(); } else if (disposition == REG_CREATED_NEW_KEY) { - LOG(INFO) << "created " << key_path; + VLOG(1) << "created " << key_path; key_created_ = true; } else { LOG(ERROR) << "unkown disposition"; @@ -93,9 +93,9 @@ void CreateRegKeyWorkItem::Rollback() { key_path.assign(*itr); if (SHDeleteEmptyKey(predefined_root_, key_path.c_str()) == ERROR_SUCCESS) { - LOG(INFO) << "rollback: delete " << key_path; + VLOG(1) << "rollback: delete " << key_path; } else { - LOG(INFO) << "rollback: can not delete " << key_path; + VLOG(1) << "rollback: can not delete " << key_path; // The key might have been deleted, but we don't reliably know what // error code(s) are returned in this case. So we just keep tring delete // the rest. diff --git a/chrome/installer/util/delete_after_reboot_helper.cc b/chrome/installer/util/delete_after_reboot_helper.cc index 345ba01a..e2449e7 100644 --- a/chrome/installer/util/delete_after_reboot_helper.cc +++ b/chrome/installer/util/delete_after_reboot_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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,23 +33,19 @@ bool IsSafeDirectoryNameForDeletion(const wchar_t* dir_name) { DCHECK(dir_name); // empty name isn't allowed - if (!(dir_name && *dir_name)) { + if (!(dir_name && *dir_name)) return false; - } // require a character other than \/:. after the last : // disallow anything with ".." bool ok = false; for (const wchar_t* s = dir_name; *s; ++s) { - if (*s != L'\\' && *s != L'/' && *s != L':' && *s != L'.') { + if (*s != L'\\' && *s != L'/' && *s != L':' && *s != L'.') ok = true; - } - if (*s == L'.' && s > dir_name && *(s - 1) == L'.') { + if (*s == L'.' && s > dir_name && *(s - 1) == L'.') return false; - } - if (*s == L':') { + if (*s == L':') ok = false; - } } return ok; } @@ -76,7 +72,7 @@ bool ScheduleFileSystemEntityForDeletion(const wchar_t* path) { return false; } - LOG(INFO) << "Scheduled for deletion: " << path; + VLOG(1) << "Scheduled for deletion: " << path; return true; } @@ -134,9 +130,8 @@ bool ScheduleDirectoryForDeletion(const wchar_t* dir_name) { } // Now schedule the empty directory itself - if (!ScheduleFileSystemEntityForDeletion(dir_name)) { + if (!ScheduleFileSystemEntityForDeletion(dir_name)) LOG(ERROR) << "Failed to schedule directory for deletion: " << dir_name; - } return true; } @@ -248,9 +243,8 @@ HRESULT GetPendingMovesValue( base::win::RegKey session_manager_key(HKEY_LOCAL_MACHINE, kSessionManagerKey, KEY_QUERY_VALUE); HKEY session_manager_handle = session_manager_key.Handle(); - if (!session_manager_handle) { + if (!session_manager_handle) return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); - } // The base::RegKey Read code squashes the return code from // ReqQueryValueEx, we have to do things ourselves: @@ -265,32 +259,32 @@ HRESULT GetPendingMovesValue( if (result == ERROR_FILE_NOT_FOUND) { // No pending moves were found. return HRESULT_FROM_WIN32(result); - } else if (result == ERROR_MORE_DATA) { - if (type != REG_MULTI_SZ) { - DLOG(ERROR) << "Found PendingRename value of unexpected type."; - return E_UNEXPECTED; - } - if (buffer_size % 2) { - // The buffer size should be an even number (since we expect wchar_ts). - // If this is not the case, fail here. - DLOG(ERROR) << "Corrupt PendingRename value."; - return E_UNEXPECTED; - } - - // There are pending file renames. Read them in. - buffer.resize(buffer_size); - result = RegQueryValueEx(session_manager_handle, kPendingFileRenameOps, - 0, &type, reinterpret_cast<LPBYTE>(&buffer[0]), - &buffer_size); - if (result != ERROR_SUCCESS) { - DLOG(ERROR) << "Failed to read from " << kPendingFileRenameOps; - return HRESULT_FROM_WIN32(result); - } - } else { + } + if (result != ERROR_MORE_DATA) { // That was unexpected. DLOG(ERROR) << "Unexpected result from RegQueryValueEx: " << result; return HRESULT_FROM_WIN32(result); } + if (type != REG_MULTI_SZ) { + DLOG(ERROR) << "Found PendingRename value of unexpected type."; + return E_UNEXPECTED; + } + if (buffer_size % 2) { + // The buffer size should be an even number (since we expect wchar_ts). + // If this is not the case, fail here. + DLOG(ERROR) << "Corrupt PendingRename value."; + return E_UNEXPECTED; + } + + // There are pending file renames. Read them in. + buffer.resize(buffer_size); + result = RegQueryValueEx(session_manager_handle, kPendingFileRenameOps, + 0, &type, reinterpret_cast<LPBYTE>(&buffer[0]), + &buffer_size); + if (result != ERROR_SUCCESS) { + DLOG(ERROR) << "Failed to read from " << kPendingFileRenameOps; + return HRESULT_FROM_WIN32(result); + } // We now have a buffer of bytes that is actually a sequence of // null-terminated wchar_t strings terminated by an additional null character. @@ -306,9 +300,8 @@ bool MatchPendingDeletePath(const std::wstring& short_form_needle, // First chomp the prefix since that will mess up GetShortPathName. std::wstring prefix(L"\\??\\"); - if (StartsWith(match_path, prefix, false)) { + if (StartsWith(match_path, prefix, false)) match_path = match_path.substr(4); - } // Get the short path name of the entry. std::wstring short_match_path(GetShortPathName(match_path.c_str())); @@ -327,7 +320,8 @@ bool RemoveFromMovesPendingReboot(const wchar_t* directory) { if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) { // No pending moves, nothing to do. return true; - } else if (FAILED(hr)) { + } + if (FAILED(hr)) { // Couldn't read the key or the key was corrupt. return false; } @@ -336,8 +330,8 @@ bool RemoveFromMovesPendingReboot(const wchar_t* directory) { std::wstring short_directory(GetShortPathName(directory)); std::vector<PendingMove> strings_to_keep; - std::vector<PendingMove>::const_iterator iter(pending_moves.begin()); - for (; iter != pending_moves.end(); iter++) { + for (std::vector<PendingMove>::const_iterator iter(pending_moves.begin()); + iter != pending_moves.end(); iter++) { if (!MatchPendingDeletePath(short_directory, iter->first)) { // This doesn't match the deletions we are looking for. Preserve // this string pair, making sure that it is in fact a pair. @@ -359,18 +353,15 @@ bool RemoveFromMovesPendingReboot(const wchar_t* directory) { return false; } - if (strings_to_keep.size() > 1) { - std::vector<char> buffer; - StringArrayToMultiSZBytes(strings_to_keep, &buffer); - DCHECK(buffer.size() > 0); - if (buffer.size() > 0) { - return session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], - buffer.size(), REG_MULTI_SZ); - } else { - return false; - } - } else { + if (strings_to_keep.size() <= 1) { // We have only the trailing NULL string. Don't bother writing that. return session_manager_key.DeleteValue(kPendingFileRenameOps); } + std::vector<char> buffer; + StringArrayToMultiSZBytes(strings_to_keep, &buffer); + DCHECK(buffer.size() > 0); + if (buffer.empty()) + return false; + return session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], + buffer.size(), REG_MULTI_SZ); } diff --git a/chrome/installer/util/delete_reg_value_work_item.cc b/chrome/installer/util/delete_reg_value_work_item.cc index 1c114e2..e663eef 100644 --- a/chrome/installer/util/delete_reg_value_work_item.cc +++ b/chrome/installer/util/delete_reg_value_work_item.cc @@ -57,11 +57,11 @@ bool DeleteRegValueWorkItem::Do() { } void DeleteRegValueWorkItem::Rollback() { - if (status_ == DELETE_VALUE || status_ == VALUE_ROLLED_BACK) { + if (status_ == DELETE_VALUE || status_ == VALUE_ROLLED_BACK) return; - } else if (status_ == VALUE_UNCHANGED || status_ == VALUE_NOT_FOUND) { + if (status_ == VALUE_UNCHANGED || status_ == VALUE_NOT_FOUND) { status_ = VALUE_ROLLED_BACK; - LOG(INFO) << "rollback: setting unchanged, nothing to do"; + VLOG(1) << "rollback: setting unchanged, nothing to do"; return; } @@ -75,7 +75,7 @@ void DeleteRegValueWorkItem::Rollback() { (!is_str_type_ && key.WriteValue(value_name_.c_str(), old_dw_))) { status_ = VALUE_ROLLED_BACK; - LOG(INFO) << "rollback: restored " << value_name_; + VLOG(1) << "rollback: restored " << value_name_; } else { LOG(ERROR) << "failed to restore value " << value_name_; } diff --git a/chrome/installer/util/delete_tree_work_item_unittest.cc b/chrome/installer/util/delete_tree_work_item_unittest.cc index 679fea6..832a8c0 100644 --- a/chrome/installer/util/delete_tree_work_item_unittest.cc +++ b/chrome/installer/util/delete_tree_work_item_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -189,8 +189,8 @@ TEST_F(DeleteTreeWorkItemTest, DeleteTreeInUse) { file_util::CopyFile(exe_full_path, key_path); ASSERT_TRUE(file_util::PathExists(key_path)); - LOG(INFO) << "copy ourself from " - << exe_full_path.value() << " to " << key_path.value(); + VLOG(1) << "copy ourself from " << exe_full_path.value() + << " to " << key_path.value(); // Run the key path file to keep it in use. STARTUPINFOW si = {sizeof(si)}; diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index 90c684c..882ddb3 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -584,7 +584,7 @@ void GoogleChromeDistribution::LaunchUserExperiment( std::wstring brand; if (GoogleUpdateSettings::GetBrand(&brand) && (brand == L"CHXX")) { // Testing only: the user automatically qualifies for the experiment. - LOG(INFO) << "Experiment qualification bypass"; + VLOG(1) << "Experiment qualification bypass"; } else { // Check browser usage inactivity by the age of the last-write time of the // chrome user data directory. @@ -600,19 +600,19 @@ void GoogleChromeDistribution::LaunchUserExperiment( return; } else if (dir_age_hours < kThirtyDays) { // An active user, so it does not qualify. - LOG(INFO) << "Chrome used in last " << dir_age_hours << " hours"; + VLOG(1) << "Chrome used in last " << dir_age_hours << " hours"; SetClient(GetExperimentGroup(kToastActiveGroup, flavor), true); return; } // 1% are in the control group that qualifies but does not get drafted. if (base::RandDouble() > 0.99) { SetClient(GetExperimentGroup(kToastExpControlGroup, flavor), true); - LOG(INFO) << "User is control group"; + VLOG(1) << "User is control group"; return; } } - LOG(INFO) << "User drafted for toast experiment " << flavor; + VLOG(1) << "User drafted for toast experiment " << flavor; SetClient(GetExperimentGroup(kToastExpBaseGroup, flavor), false); // User level: The experiment needs to be performed in a different process // because google_update expects the upgrade process to be quick and nimble. diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc index 747fbb1..5bc3541 100644 --- a/chrome/installer/util/google_update_settings.cc +++ b/chrome/installer/util/google_update_settings.cc @@ -195,9 +195,9 @@ void GoogleUpdateSettings::UpdateDiffInstallStatus(bool system_install, reg_key.append(product_guid); if (!key.Open(reg_root, reg_key.c_str(), KEY_ALL_ACCESS) || !key.ReadValue(google_update::kRegApField, &ap_key_value)) { - LOG(INFO) << "Application key not found."; + VLOG(1) << "Application key not found."; if (!incremental_install || !install_return_code) { - LOG(INFO) << "Returning without changing application key."; + VLOG(1) << "Returning without changing application key."; key.Close(); return; } else if (!key.Valid()) { @@ -229,17 +229,17 @@ std::wstring GoogleUpdateSettings::GetNewGoogleUpdateApKey( bool has_magic_string = false; if ((value.length() >= kMagicSuffix.length()) && (value.rfind(kMagicSuffix) == (value.length() - kMagicSuffix.length()))) { - LOG(INFO) << "Incremental installer failure key already set."; + VLOG(1) << "Incremental installer failure key already set."; has_magic_string = true; } std::wstring new_value(value); if ((!diff_install || !install_return_code) && has_magic_string) { - LOG(INFO) << "Removing failure key from value " << value; + VLOG(1) << "Removing failure key from value " << value; new_value = value.substr(0, value.length() - kMagicSuffix.length()); } else if ((diff_install && install_return_code) && !has_magic_string) { - LOG(INFO) << "Incremental installer failed, setting failure key."; + VLOG(1) << "Incremental installer failed, setting failure key."; new_value.append(kMagicSuffix); } diff --git a/chrome/installer/util/helper.cc b/chrome/installer/util/helper.cc index 9c0dda9..551b9c6 100644 --- a/chrome/installer/util/helper.cc +++ b/chrome/installer/util/helper.cc @@ -105,7 +105,7 @@ void installer::RemoveOldVersionDirs(const std::wstring& chrome_path, // latest_version. while (ret) { if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - LOG(INFO) << "directory found: " << find_file_data.cFileName; + VLOG(1) << "directory found: " << find_file_data.cFileName; version.reset( installer::Version::GetVersionFromString(find_file_data.cFileName)); if (version.get() && latest_version->IsHigherThan(version.get())) { @@ -113,7 +113,7 @@ void installer::RemoveOldVersionDirs(const std::wstring& chrome_path, file_util::AppendToPath(&remove_dir, find_file_data.cFileName); std::wstring chrome_dll_path(remove_dir); file_util::AppendToPath(&chrome_dll_path, installer_util::kChromeDll); - LOG(INFO) << "deleting directory " << remove_dir; + VLOG(1) << "deleting directory " << remove_dir; scoped_ptr<DeleteTreeWorkItem> item; item.reset(WorkItem::CreateDeleteTreeWorkItem(remove_dir, chrome_dll_path)); diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index 601d0eb..5e7673b 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -71,12 +71,12 @@ installer::Version* InstallUtil::GetChromeVersion(bool system_install) { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); if (!key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_READ) || !key.ReadValue(google_update::kRegVersionField, &version_str)) { - LOG(INFO) << "No existing Chrome install found."; + VLOG(1) << "No existing Chrome install found."; key.Close(); return NULL; } key.Close(); - LOG(INFO) << "Existing Chrome version found " << version_str; + VLOG(1) << "Existing Chrome version found " << version_str; return installer::Version::GetVersionFromString(version_str); } @@ -86,13 +86,10 @@ bool InstallUtil::IsOSSupported() { base::win::GetServicePackLevel(&major, &minor); // We do not support Win2K or older, or XP without service pack 2. - LOG(INFO) << "Windows Version: " << version - << ", Service Pack: " << major << "." << minor; - if ((version > base::win::VERSION_XP) || - (version == base::win::VERSION_XP && major >= 2)) { - return true; - } - return false; + VLOG(1) << "Windows Version: " << version + << ", Service Pack: " << major << "." << minor; + return (version > base::win::VERSION_XP) || + (version == base::win::VERSION_XP && major >= 2); } void InstallUtil::WriteInstallerResult(bool system_install, @@ -260,7 +257,7 @@ bool InstallUtil::BuildDLLRegistrationList(const std::wstring& install_path, // otherwise false. bool InstallUtil::DeleteRegistryKey(RegKey& root_key, const std::wstring& key_path) { - LOG(INFO) << "Deleting registry key " << key_path; + VLOG(1) << "Deleting registry key " << key_path; if (!root_key.DeleteKey(key_path.c_str()) && ::GetLastError() != ERROR_MOD_NOT_FOUND) { LOG(ERROR) << "Failed to delete registry key: " << key_path; @@ -276,7 +273,7 @@ bool InstallUtil::DeleteRegistryValue(HKEY reg_root, const std::wstring& key_path, const std::wstring& value_name) { RegKey key(reg_root, key_path.c_str(), KEY_ALL_ACCESS); - LOG(INFO) << "Deleting registry value " << value_name; + VLOG(1) << "Deleting registry value " << value_name; if (key.ValueExists(value_name.c_str()) && !key.DeleteValue(value_name.c_str())) { LOG(ERROR) << "Failed to delete registry value: " << value_name; diff --git a/chrome/installer/util/lzma_util.cc b/chrome/installer/util/lzma_util.cc index 5e4ae29..8f36b5f 100644 --- a/chrome/installer/util/lzma_util.cc +++ b/chrome/installer/util/lzma_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -48,29 +48,23 @@ SZ_RESULT SzFileSeekImp(void *object, CFileSize pos) { value.HighPart = (LONG) ((UInt64) pos >> 32); value.LowPart = SetFilePointer(s->File, value.LowPart, &value.HighPart, FILE_BEGIN); - if (value.LowPart == 0xFFFFFFFF) { - if (GetLastError() != NO_ERROR) { - return SZE_FAIL; - } - } - return SZ_OK; + return ((value.LowPart == 0xFFFFFFFF) && (GetLastError() != NO_ERROR)) ? + SZE_FAIL : SZ_OK; } SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxRequiredSize, size_t *processedSize) { const int kBufferSize = 1 << 12; static Byte g_Buffer[kBufferSize]; - if (maxRequiredSize > kBufferSize) { + if (maxRequiredSize > kBufferSize) maxRequiredSize = kBufferSize; - } CFileInStream *s = (CFileInStream *) object; size_t processedSizeLoc; processedSizeLoc = LzmaReadFile(s->File, g_Buffer, maxRequiredSize); *buffer = g_Buffer; - if (processedSize != 0) { + if (processedSize != 0) *processedSize = processedSizeLoc; - } return SZ_OK; } @@ -80,14 +74,14 @@ SZ_RESULT SzFileReadImp(void *object, void **buffer, int32 LzmaUtil::UnPackArchive(const std::wstring& archive, const std::wstring& output_dir, std::wstring* output_file) { - LOG(INFO) << "Opening archive " << archive; + VLOG(1) << "Opening archive " << archive; LzmaUtil lzma_util; DWORD ret; if ((ret = lzma_util.OpenArchive(archive)) != NO_ERROR) { LOG(ERROR) << "Unable to open install archive: " << archive << ", error: " << ret; } else { - LOG(INFO) << "Uncompressing archive to path " << output_dir; + VLOG(1) << "Uncompressing archive to path " << output_dir; if ((ret = lzma_util.UnPack(output_dir, output_file)) != NO_ERROR) { LOG(ERROR) << "Unable to uncompress archive: " << archive << ", error: " << ret; @@ -111,9 +105,8 @@ DWORD LzmaUtil::OpenArchive(const std::wstring& archivePath) { DWORD ret = NO_ERROR; archive_handle_ = CreateFile(archivePath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (archive_handle_ == INVALID_HANDLE_VALUE) { + if (archive_handle_ == INVALID_HANDLE_VALUE) ret = GetLastError(); - } return ret; } diff --git a/chrome/installer/util/move_tree_work_item.cc b/chrome/installer/util/move_tree_work_item.cc index 02c25d5..95b3650 100644 --- a/chrome/installer/util/move_tree_work_item.cc +++ b/chrome/installer/util/move_tree_work_item.cc @@ -43,8 +43,8 @@ bool MoveTreeWorkItem::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(); + VLOG(1) << "Moved destination " << dest_path_.value() + << " to backup path " << backup_path_.value(); } else { LOG(ERROR) << "failed moving " << dest_path_.value() << " to " << backup_path_.value(); @@ -55,11 +55,11 @@ 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(); + VLOG(1) << "Moved source " << source_path_.value() + << " to destination " << dest_path_.value(); } else { - LOG(ERROR) << "failed move " << source_path_.value() << " to " << - dest_path_.value(); + LOG(ERROR) << "failed move " << source_path_.value() + << " to " << dest_path_.value(); return false; } @@ -68,10 +68,10 @@ 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_.value() + << " to " << source_path_.value(); 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_.value() + << " to " << dest_path_.value(); } diff --git a/chrome/installer/util/set_reg_value_work_item.cc b/chrome/installer/util/set_reg_value_work_item.cc index 0dae573..c808b86 100644 --- a/chrome/installer/util/set_reg_value_work_item.cc +++ b/chrome/installer/util/set_reg_value_work_item.cc @@ -76,7 +76,7 @@ bool SetRegValueWorkItem::Do() { success = key.WriteValue(value_name_.c_str(), value_data_dword_); } if (success) { - LOG(INFO) << "overwritten value for " << value_name_; + VLOG(1) << "overwritten value for " << value_name_; status_ = VALUE_OVERWRITTEN; result = true; } else { @@ -85,7 +85,7 @@ bool SetRegValueWorkItem::Do() { result = false; } } else { - LOG(INFO) << value_name_ << " exists. not changed "; + VLOG(1) << value_name_ << " exists. not changed "; status_ = VALUE_UNCHANGED; result = true; } @@ -97,7 +97,7 @@ bool SetRegValueWorkItem::Do() { success = key.WriteValue(value_name_.c_str(), value_data_dword_); } if (success) { - LOG(INFO) << "created value for " << value_name_; + VLOG(1) << "created value for " << value_name_; status_ = NEW_VALUE_CREATED; result = true; } else { @@ -117,7 +117,7 @@ void SetRegValueWorkItem::Rollback() { if (status_ == VALUE_UNCHANGED) { status_ = VALUE_ROLL_BACK; - LOG(INFO) << "rollback: setting unchanged, nothing to do"; + VLOG(1) << "rollback: setting unchanged, nothing to do"; return; } @@ -125,7 +125,7 @@ void SetRegValueWorkItem::Rollback() { if (!key.Open(predefined_root_, key_path_.c_str(), KEY_READ | KEY_SET_VALUE)) { status_ = VALUE_ROLL_BACK; - LOG(INFO) << "rollback: can not open " << key_path_; + VLOG(1) << "rollback: can not open " << key_path_; return; } @@ -133,7 +133,7 @@ void SetRegValueWorkItem::Rollback() { if (status_ == NEW_VALUE_CREATED) { if (key.DeleteValue(value_name_.c_str())) result_str.assign(L" succeeded"); - LOG(INFO) << "rollback: deleting " << value_name_ << result_str; + VLOG(1) << "rollback: deleting " << value_name_ << result_str; } else if (status_ == VALUE_OVERWRITTEN) { // try restore the previous value bool success = true; @@ -145,7 +145,7 @@ void SetRegValueWorkItem::Rollback() { } if (success) result_str.assign(L" succeeded"); - LOG(INFO) << "rollback: restoring " << value_name_ << result_str; + VLOG(1) << "rollback: restoring " << value_name_ << result_str; } else { // Not reached. } diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 212f04b..343f434 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -622,7 +622,7 @@ bool ShellUtil::MakeChromeDefault(int shell_change, // First use the new "recommended" way on Vista to make Chrome default // browser. if (base::win::GetVersion() >= base::win::VERSION_VISTA) { - LOG(INFO) << "Registering Chrome as default browser on Vista."; + VLOG(1) << "Registering Chrome as default browser on Vista."; IApplicationAssociationRegistration* pAAR; HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), diff --git a/chrome/installer/util/work_item_list.cc b/chrome/installer/util/work_item_list.cc index 35b4590..012bb7e 100644 --- a/chrome/installer/util/work_item_list.cc +++ b/chrome/installer/util/work_item_list.cc @@ -38,7 +38,7 @@ bool WorkItemList::Do() { } if (result) - LOG(INFO) << "list execution succeeded"; + VLOG(1) << "list execution succeeded"; status_ = LIST_EXECUTED; return result; |