Commit 9dccb391 authored by grt@chromium.org's avatar grt@chromium.org

Fix DCHECK in GCF quick-enable.

Make the determination of whether or not Chrome Frame is in use on-demand rather than during initialization.

BUG=92146
TEST=GCF quick-enable should work again.


Review URL: http://codereview.chromium.org/7600021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96370 0039d316-1c4b-4281-b951-d872f2087c98
parent 49c85aaf
...@@ -692,7 +692,7 @@ void AddInstallWorkItems(const InstallationState& original_state, ...@@ -692,7 +692,7 @@ void AddInstallWorkItems(const InstallationState& original_state,
install_list->AddDeleteTreeWorkItem(new_chrome_exe, temp_path); install_list->AddDeleteTreeWorkItem(new_chrome_exe, temp_path);
if (installer_state.is_chrome_frame_running()) { if (installer_state.IsChromeFrameRunning(original_state)) {
VLOG(1) << "Chrome Frame in use. Copying to new_chrome.exe"; VLOG(1) << "Chrome Frame in use. Copying to new_chrome.exe";
install_list->AddCopyTreeWorkItem( install_list->AddCopyTreeWorkItem(
src_path.Append(installer::kChromeExe).value(), src_path.Append(installer::kChromeExe).value(),
......
...@@ -76,8 +76,7 @@ InstallerState::InstallerState() ...@@ -76,8 +76,7 @@ InstallerState::InstallerState()
state_type_(BrowserDistribution::CHROME_BROWSER), state_type_(BrowserDistribution::CHROME_BROWSER),
root_key_(NULL), root_key_(NULL),
msi_(false), msi_(false),
verbose_logging_(false), verbose_logging_(false) {
is_chrome_frame_running_(false) {
} }
InstallerState::InstallerState(Level level) InstallerState::InstallerState(Level level)
...@@ -88,8 +87,7 @@ InstallerState::InstallerState(Level level) ...@@ -88,8 +87,7 @@ InstallerState::InstallerState(Level level)
state_type_(BrowserDistribution::CHROME_BROWSER), state_type_(BrowserDistribution::CHROME_BROWSER),
root_key_(NULL), root_key_(NULL),
msi_(false), msi_(false),
verbose_logging_(false), verbose_logging_(false) {
is_chrome_frame_running_(false) {
// Use set_level() so that root_key_ is updated properly. // Use set_level() so that root_key_ is updated properly.
set_level(level); set_level(level);
} }
...@@ -158,8 +156,6 @@ void InstallerState::Initialize(const CommandLine& command_line, ...@@ -158,8 +156,6 @@ void InstallerState::Initialize(const CommandLine& command_line,
state_key_ = operand->GetStateKey(); state_key_ = operand->GetStateKey();
state_type_ = operand->GetType(); state_type_ = operand->GetType();
is_chrome_frame_running_ = DetectChromeFrameInUse(machine_state);
} }
void InstallerState::set_level(Level level) { void InstallerState::set_level(Level level) {
...@@ -417,22 +413,8 @@ Version* InstallerState::GetCurrentVersion( ...@@ -417,22 +413,8 @@ Version* InstallerState::GetCurrentVersion(
return current_version.release(); return current_version.release();
} }
FilePath InstallerState::GetInstallerDirectory(const Version& version) const { bool InstallerState::IsChromeFrameRunning(
return target_path().Append(ASCIIToWide(version.GetString())) const InstallationState& machine_state) const {
.Append(kInstallerDir);
}
// static
bool InstallerState::IsFileInUse(const FilePath& file) {
// Call CreateFile with a share mode of 0 which should cause this to fail
// with ERROR_SHARING_VIOLATION if the file exists and is in-use.
return !base::win::ScopedHandle(CreateFile(file.value().c_str(),
GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, 0)).IsValid();
}
bool InstallerState::DetectChromeFrameInUse(
const InstallationState& machine_state) {
// We check only for the current version (e.g. the version we are upgrading // We check only for the current version (e.g. the version we are upgrading
// _from_). We don't need to check interstitial versions if any (as would // _from_). We don't need to check interstitial versions if any (as would
// occur in the case of multiple updates) since if they are in use, we are // occur in the case of multiple updates) since if they are in use, we are
...@@ -448,6 +430,20 @@ bool InstallerState::DetectChromeFrameInUse( ...@@ -448,6 +430,20 @@ bool InstallerState::DetectChromeFrameInUse(
return in_use; return in_use;
} }
FilePath InstallerState::GetInstallerDirectory(const Version& version) const {
return target_path().Append(ASCIIToWide(version.GetString()))
.Append(kInstallerDir);
}
// static
bool InstallerState::IsFileInUse(const FilePath& file) {
// Call CreateFile with a share mode of 0 which should cause this to fail
// with ERROR_SHARING_VIOLATION if the file exists and is in-use.
return !base::win::ScopedHandle(CreateFile(file.value().c_str(),
GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, 0)).IsValid();
}
void InstallerState::RemoveOldVersionDirectories( void InstallerState::RemoveOldVersionDirectories(
const Version& new_version, const Version& new_version,
Version* existing_version, Version* existing_version,
......
...@@ -105,11 +105,6 @@ class InstallerState { ...@@ -105,11 +105,6 @@ class InstallerState {
// TODO(grt): Eradicate the bool in favor of the enum. // TODO(grt): Eradicate the bool in favor of the enum.
bool is_multi_install() const; bool is_multi_install() const;
// Returns whether or not there is currently a Chrome Frame instance running.
// Note that there isn't a mechanism to lock Chrome Frame in place, so Chrome
// Frame may either exit or start up after this is called.
bool is_chrome_frame_running() const { return is_chrome_frame_running_; }
// The full path to the place where the operand resides. // The full path to the place where the operand resides.
const FilePath& target_path() const { return target_path_; } const FilePath& target_path() const { return target_path_; }
...@@ -149,6 +144,11 @@ class InstallerState { ...@@ -149,6 +144,11 @@ class InstallerState {
// products are installed. Ownership is passed to the caller. // products are installed. Ownership is passed to the caller.
Version* GetCurrentVersion(const InstallationState& machine_state) const; Version* GetCurrentVersion(const InstallationState& machine_state) const;
// Returns whether or not there is currently a Chrome Frame instance running.
// Note that there isn't a mechanism to lock Chrome Frame in place, so Chrome
// Frame may either exit or start up after this is called.
bool IsChromeFrameRunning(const InstallationState& machine_state) const;
// Returns the path to the installer under Chrome version folder // Returns the path to the installer under Chrome version folder
// (for example <target_path>\Google\Chrome\Application\<Version>\Installer) // (for example <target_path>\Google\Chrome\Application\<Version>\Installer)
FilePath GetInstallerDirectory(const Version& version) const; FilePath GetInstallerDirectory(const Version& version) const;
...@@ -197,7 +197,6 @@ class InstallerState { ...@@ -197,7 +197,6 @@ class InstallerState {
const InstallationState& machine_state); const InstallationState& machine_state);
bool IsMultiInstallUpdate(const MasterPreferences& prefs, bool IsMultiInstallUpdate(const MasterPreferences& prefs,
const InstallationState& machine_state); const InstallationState& machine_state);
bool DetectChromeFrameInUse(const InstallationState& machine_state);
// Sets this object's level and updates the root_key_ accordingly. // Sets this object's level and updates the root_key_ accordingly.
void set_level(Level level); void set_level(Level level);
...@@ -219,7 +218,6 @@ class InstallerState { ...@@ -219,7 +218,6 @@ class InstallerState {
#endif #endif
bool msi_; bool msi_;
bool verbose_logging_; bool verbose_logging_;
bool is_chrome_frame_running_;
private: private:
DISALLOW_COPY_AND_ASSIGN(InstallerState); DISALLOW_COPY_AND_ASSIGN(InstallerState);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment