Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: chrome/installer/util/installer_state.cc

Issue 7600021: Fix DCHECK in GCF quick-enable. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/installer/util/installer_state.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/installer/util/installer_state.h" 5 #include "chrome/installer/util/installer_state.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 InstallerState::InstallerState() 71 InstallerState::InstallerState()
72 : operation_(UNINITIALIZED), 72 : operation_(UNINITIALIZED),
73 multi_package_distribution_(NULL), 73 multi_package_distribution_(NULL),
74 level_(UNKNOWN_LEVEL), 74 level_(UNKNOWN_LEVEL),
75 package_type_(UNKNOWN_PACKAGE_TYPE), 75 package_type_(UNKNOWN_PACKAGE_TYPE),
76 state_type_(BrowserDistribution::CHROME_BROWSER), 76 state_type_(BrowserDistribution::CHROME_BROWSER),
77 root_key_(NULL), 77 root_key_(NULL),
78 msi_(false), 78 msi_(false),
79 verbose_logging_(false), 79 verbose_logging_(false) {
80 is_chrome_frame_running_(false) {
81 } 80 }
82 81
83 InstallerState::InstallerState(Level level) 82 InstallerState::InstallerState(Level level)
84 : operation_(UNINITIALIZED), 83 : operation_(UNINITIALIZED),
85 multi_package_distribution_(NULL), 84 multi_package_distribution_(NULL),
86 level_(UNKNOWN_LEVEL), 85 level_(UNKNOWN_LEVEL),
87 package_type_(UNKNOWN_PACKAGE_TYPE), 86 package_type_(UNKNOWN_PACKAGE_TYPE),
88 state_type_(BrowserDistribution::CHROME_BROWSER), 87 state_type_(BrowserDistribution::CHROME_BROWSER),
89 root_key_(NULL), 88 root_key_(NULL),
90 msi_(false), 89 msi_(false),
91 verbose_logging_(false), 90 verbose_logging_(false) {
92 is_chrome_frame_running_(false) {
93 // Use set_level() so that root_key_ is updated properly. 91 // Use set_level() so that root_key_ is updated properly.
94 set_level(level); 92 set_level(level);
95 } 93 }
96 94
97 void InstallerState::Initialize(const CommandLine& command_line, 95 void InstallerState::Initialize(const CommandLine& command_line,
98 const MasterPreferences& prefs, 96 const MasterPreferences& prefs,
99 const InstallationState& machine_state) { 97 const InstallationState& machine_state) {
100 bool pref_bool; 98 bool pref_bool;
101 if (!prefs.GetBool(master_preferences::kSystemLevel, &pref_bool)) 99 if (!prefs.GetBool(master_preferences::kSystemLevel, &pref_bool))
102 pref_bool = false; 100 pref_bool = false;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 149
152 if (operand == NULL) { 150 if (operand == NULL) {
153 operand = BrowserDistribution::GetSpecificDistribution( 151 operand = BrowserDistribution::GetSpecificDistribution(
154 prefs.install_chrome() ? 152 prefs.install_chrome() ?
155 BrowserDistribution::CHROME_BROWSER : 153 BrowserDistribution::CHROME_BROWSER :
156 BrowserDistribution::CHROME_FRAME); 154 BrowserDistribution::CHROME_FRAME);
157 } 155 }
158 156
159 state_key_ = operand->GetStateKey(); 157 state_key_ = operand->GetStateKey();
160 state_type_ = operand->GetType(); 158 state_type_ = operand->GetType();
161
162 is_chrome_frame_running_ = DetectChromeFrameInUse(machine_state);
163 } 159 }
164 160
165 void InstallerState::set_level(Level level) { 161 void InstallerState::set_level(Level level) {
166 level_ = level; 162 level_ = level;
167 switch (level) { 163 switch (level) {
168 case USER_LEVEL: 164 case USER_LEVEL:
169 root_key_ = HKEY_CURRENT_USER; 165 root_key_ = HKEY_CURRENT_USER;
170 break; 166 break;
171 case SYSTEM_LEVEL: 167 case SYSTEM_LEVEL:
172 root_key_ = HKEY_LOCAL_MACHINE; 168 root_key_ = HKEY_LOCAL_MACHINE;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 406
411 if (version == NULL) 407 if (version == NULL)
412 version = &product_state->version(); 408 version = &product_state->version();
413 409
414 current_version.reset(version->Clone()); 410 current_version.reset(version->Clone());
415 } 411 }
416 412
417 return current_version.release(); 413 return current_version.release();
418 } 414 }
419 415
420 FilePath InstallerState::GetInstallerDirectory(const Version& version) const { 416 bool InstallerState::IsChromeFrameRunning(
421 return target_path().Append(ASCIIToWide(version.GetString())) 417 const InstallationState& machine_state) const {
422 .Append(kInstallerDir);
423 }
424
425 // static
426 bool InstallerState::IsFileInUse(const FilePath& file) {
427 // Call CreateFile with a share mode of 0 which should cause this to fail
428 // with ERROR_SHARING_VIOLATION if the file exists and is in-use.
429 return !base::win::ScopedHandle(CreateFile(file.value().c_str(),
430 GENERIC_WRITE, 0, NULL,
431 OPEN_EXISTING, 0, 0)).IsValid();
432 }
433
434 bool InstallerState::DetectChromeFrameInUse(
435 const InstallationState& machine_state) {
436 // We check only for the current version (e.g. the version we are upgrading 418 // We check only for the current version (e.g. the version we are upgrading
437 // _from_). We don't need to check interstitial versions if any (as would 419 // _from_). We don't need to check interstitial versions if any (as would
438 // occur in the case of multiple updates) since if they are in use, we are 420 // occur in the case of multiple updates) since if they are in use, we are
439 // guaranteed that the current version is in use too. 421 // guaranteed that the current version is in use too.
440 bool in_use = false; 422 bool in_use = false;
441 scoped_ptr<Version> current_version(GetCurrentVersion(machine_state)); 423 scoped_ptr<Version> current_version(GetCurrentVersion(machine_state));
442 if (current_version != NULL) { 424 if (current_version != NULL) {
443 FilePath cf_install_path( 425 FilePath cf_install_path(
444 target_path().AppendASCII(current_version->GetString()) 426 target_path().AppendASCII(current_version->GetString())
445 .Append(kChromeFrameDll)); 427 .Append(kChromeFrameDll));
446 in_use = IsFileInUse(cf_install_path); 428 in_use = IsFileInUse(cf_install_path);
447 } 429 }
448 return in_use; 430 return in_use;
449 } 431 }
450 432
433 FilePath InstallerState::GetInstallerDirectory(const Version& version) const {
434 return target_path().Append(ASCIIToWide(version.GetString()))
435 .Append(kInstallerDir);
436 }
437
438 // static
439 bool InstallerState::IsFileInUse(const FilePath& file) {
440 // Call CreateFile with a share mode of 0 which should cause this to fail
441 // with ERROR_SHARING_VIOLATION if the file exists and is in-use.
442 return !base::win::ScopedHandle(CreateFile(file.value().c_str(),
443 GENERIC_WRITE, 0, NULL,
444 OPEN_EXISTING, 0, 0)).IsValid();
445 }
446
451 void InstallerState::RemoveOldVersionDirectories( 447 void InstallerState::RemoveOldVersionDirectories(
452 const Version& new_version, 448 const Version& new_version,
453 Version* existing_version, 449 Version* existing_version,
454 const FilePath& temp_path) const { 450 const FilePath& temp_path) const {
455 file_util::FileEnumerator version_enum(target_path(), false, 451 file_util::FileEnumerator version_enum(target_path(), false,
456 file_util::FileEnumerator::DIRECTORIES); 452 file_util::FileEnumerator::DIRECTORIES);
457 scoped_ptr<Version> version; 453 scoped_ptr<Version> version;
458 std::vector<FilePath> key_files; 454 std::vector<FilePath> key_files;
459 455
460 // We try to delete all directories whose versions are lower than 456 // We try to delete all directories whose versions are lower than
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 if (is_multi_install()) { 606 if (is_multi_install()) {
611 InstallUtil::AddInstallerResultItems( 607 InstallUtil::AddInstallerResultItems(
612 system_install, multi_package_binaries_distribution()->GetStateKey(), 608 system_install, multi_package_binaries_distribution()->GetStateKey(),
613 status, string_resource_id, launch_cmd, install_list.get()); 609 status, string_resource_id, launch_cmd, install_list.get());
614 } 610 }
615 if (!install_list->Do()) 611 if (!install_list->Do())
616 LOG(ERROR) << "Failed to record installer error information in registry."; 612 LOG(ERROR) << "Failed to record installer error information in registry.";
617 } 613 }
618 614
619 } // namespace installer 615 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/installer_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698