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

Side by Side Diff: chrome/installer/setup/install.cc

Issue 6538025: Temp dir cleanup:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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 | Annotate | Revision Log
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/setup/install.h" 5 #include "chrome/installer/setup/install.h"
6 6
7 #include <shlobj.h> 7 #include <shlobj.h>
8 #include <time.h> 8 #include <time.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 file_util::AppendToPath(&reg_path, installer::kChromeExe); 50 file_util::AppendToPath(&reg_path, installer::kChromeExe);
51 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; 51 VLOG(1) << "Adding Chrome to Media player list at " << reg_path;
52 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( 52 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem(
53 HKEY_LOCAL_MACHINE, reg_path)); 53 HKEY_LOCAL_MACHINE, reg_path));
54 54
55 // if the operation fails we log the error but still continue 55 // if the operation fails we log the error but still continue
56 if (!work_item.get()->Do()) 56 if (!work_item.get()->Do())
57 LOG(ERROR) << "Could not add Chrome to media player inclusion list."; 57 LOG(ERROR) << "Could not add Chrome to media player inclusion list.";
58 } 58 }
59 59
60 void AddInstallerCopyTasks(const InstallerState& installer_state,
61 const FilePath& setup_path,
62 const FilePath& archive_path,
63 const FilePath& temp_path,
64 const Version& new_version,
65 WorkItemList* install_list) {
66 DCHECK(install_list);
67 FilePath installer_dir(installer_state.GetInstallerDirectory(new_version));
68 install_list->AddCreateDirWorkItem(installer_dir);
69
70 FilePath exe_dst(installer_dir.Append(setup_path.BaseName()));
71 FilePath archive_dst(installer_dir.Append(archive_path.BaseName()));
72
73 install_list->AddCopyTreeWorkItem(setup_path.value(), exe_dst.value(),
74 temp_path.value(), WorkItem::ALWAYS);
75 if (installer_state.system_install()) {
76 install_list->AddCopyTreeWorkItem(archive_path.value(), archive_dst.value(),
77 temp_path.value(), WorkItem::ALWAYS);
78 } else {
79 install_list->AddMoveTreeWorkItem(archive_path.value(), archive_dst.value(),
80 temp_path.value());
81 }
82 }
83
84 // Copy master preferences file provided to installer, in the same folder 60 // Copy master preferences file provided to installer, in the same folder
85 // as chrome.exe so Chrome first run can find it. This function will be called 61 // as chrome.exe so Chrome first run can find it. This function will be called
86 // only on the first install of Chrome. 62 // only on the first install of Chrome.
87 void CopyPreferenceFileForFirstRun(const InstallerState& installer_state, 63 void CopyPreferenceFileForFirstRun(const InstallerState& installer_state,
88 const FilePath& prefs_source_path) { 64 const FilePath& prefs_source_path) {
89 FilePath prefs_dest_path(installer_state.target_path().AppendASCII( 65 FilePath prefs_dest_path(installer_state.target_path().AppendASCII(
90 installer::kDefaultMasterPrefs)); 66 installer::kDefaultMasterPrefs));
91 if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) { 67 if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) {
92 VLOG(1) << "Failed to copy master preferences from:" 68 VLOG(1) << "Failed to copy master preferences from:"
93 << prefs_source_path.value() << " gle: " << ::GetLastError(); 69 << prefs_source_path.value() << " gle: " << ::GetLastError();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 232 }
257 233
258 // This function installs a new version of Chrome to the specified location. 234 // This function installs a new version of Chrome to the specified location.
259 // 235 //
260 // setup_path: Path to the executable (setup.exe) as it will be copied 236 // setup_path: Path to the executable (setup.exe) as it will be copied
261 // to Chrome install folder after install is complete 237 // to Chrome install folder after install is complete
262 // archive_path: Path to the archive (chrome.7z) as it will be copied 238 // archive_path: Path to the archive (chrome.7z) as it will be copied
263 // to Chrome install folder after install is complete 239 // to Chrome install folder after install is complete
264 // src_path: the path that contains a complete and unpacked Chrome package 240 // src_path: the path that contains a complete and unpacked Chrome package
265 // to be installed. 241 // to be installed.
266 // temp_dir: the path of working directory used during installation. This path 242 // temp_path: the path of working directory used during installation. This path
267 // does not need to exist. 243 // does not need to exist.
268 // new_version: new Chrome version that needs to be installed 244 // new_version: new Chrome version that needs to be installed
269 // current_version: returns the current active version (if any) 245 // current_version: returns the current active version (if any)
270 // 246 //
271 // This function makes best effort to do installation in a transactional 247 // This function makes best effort to do installation in a transactional
272 // manner. If failed it tries to rollback all changes on the file system 248 // manner. If failed it tries to rollback all changes on the file system
273 // and registry. For example, if package exists before calling the 249 // and registry. For example, if package exists before calling the
274 // function, it rolls back all new file and directory changes under 250 // function, it rolls back all new file and directory changes under
275 // package. If package does not exist before calling the function 251 // package. If package does not exist before calling the function
276 // (typical new install), the function creates package during install 252 // (typical new install), the function creates package during install
277 // and removes the whole directory during rollback. 253 // and removes the whole directory during rollback.
278 installer::InstallStatus InstallNewVersion( 254 installer::InstallStatus InstallNewVersion(
279 const InstallationState& original_state, 255 const InstallationState& original_state,
280 const InstallerState& installer_state, 256 const InstallerState& installer_state,
281 const FilePath& setup_path, 257 const FilePath& setup_path,
282 const FilePath& archive_path, 258 const FilePath& archive_path,
283 const FilePath& src_path, 259 const FilePath& src_path,
284 const FilePath& temp_dir, 260 const FilePath& temp_path,
285 const Version& new_version, 261 const Version& new_version,
286 scoped_ptr<Version>* current_version) { 262 scoped_ptr<Version>* current_version) {
287 DCHECK(current_version); 263 DCHECK(current_version);
288 264
289 current_version->reset(installer_state.GetCurrentVersion(original_state)); 265 current_version->reset(installer_state.GetCurrentVersion(original_state));
290 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); 266 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList());
291 267
292 AddInstallWorkItems(original_state, 268 AddInstallWorkItems(original_state,
293 installer_state, 269 installer_state,
294 setup_path, 270 setup_path,
295 archive_path, 271 archive_path,
296 src_path, 272 src_path,
297 temp_dir, 273 temp_path,
298 new_version, 274 new_version,
299 current_version, 275 current_version,
300 install_list.get()); 276 install_list.get());
301 277
302 AddElevationPolicyWorkItems(original_state, installer_state, new_version, 278 AddElevationPolicyWorkItems(original_state, installer_state, new_version,
303 install_list.get()); 279 install_list.get());
304 280
305 FilePath new_chrome_exe( 281 FilePath new_chrome_exe(
306 installer_state.target_path().Append(installer::kChromeNewExe)); 282 installer_state.target_path().Append(installer::kChromeNewExe));
307 283
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 result == INSTALL_REPAIRED) { 394 result == INSTALL_REPAIRED) {
419 prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, 395 prefs.GetBool(master_preferences::kMakeChromeDefaultForUser,
420 &force_chrome_default_for_user); 396 &force_chrome_default_for_user);
421 } 397 }
422 398
423 RegisterChromeOnMachine(installer_state, *chrome_install, 399 RegisterChromeOnMachine(installer_state, *chrome_install,
424 make_chrome_default || force_chrome_default_for_user); 400 make_chrome_default || force_chrome_default_for_user);
425 } 401 }
426 402
427 installer_state.RemoveOldVersionDirectories(existing_version.get() ? 403 installer_state.RemoveOldVersionDirectories(existing_version.get() ?
428 *existing_version.get() : new_version); 404 *existing_version.get() : new_version, install_temp_path);
429 } 405 }
430 406
431 return result; 407 return result;
432 } 408 }
433 409
434 } // namespace installer 410 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698