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

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

Issue 99923002: Move temp file functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file defines the methods useful for uninstalling Chrome. 5 // This file defines the methods useful for uninstalling Chrome.
6 6
7 #include "chrome/installer/setup/uninstall.h" 7 #include "chrome/installer/setup/uninstall.h"
8 8
9 #include <windows.h> 9 #include <windows.h>
10 10
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 const std::vector<base::FilePath>& local_state_folders) { 470 const std::vector<base::FilePath>& local_state_folders) {
471 base::FilePath backup; 471 base::FilePath backup;
472 472
473 // Copy the first local state file that is found. 473 // Copy the first local state file that is found.
474 for (size_t i = 0; i < local_state_folders.size(); ++i) { 474 for (size_t i = 0; i < local_state_folders.size(); ++i) {
475 const base::FilePath& local_state_folder = local_state_folders[i]; 475 const base::FilePath& local_state_folder = local_state_folders[i];
476 base::FilePath state_file( 476 base::FilePath state_file(
477 local_state_folder.Append(chrome::kLocalStateFilename)); 477 local_state_folder.Append(chrome::kLocalStateFilename));
478 if (!base::PathExists(state_file)) 478 if (!base::PathExists(state_file))
479 continue; 479 continue;
480 if (!file_util::CreateTemporaryFile(&backup)) 480 if (!base::CreateTemporaryFile(&backup))
481 LOG(ERROR) << "Failed to create temporary file for Local State."; 481 LOG(ERROR) << "Failed to create temporary file for Local State.";
482 else 482 else
483 base::CopyFile(state_file, backup); 483 base::CopyFile(state_file, backup);
484 break; 484 break;
485 } 485 }
486 return backup; 486 return backup;
487 } 487 }
488 488
489 // Deletes all user data directories for a product. 489 // Deletes all user data directories for a product.
490 DeleteResult DeleteLocalState( 490 DeleteResult DeleteLocalState(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 // to change the current directory to the TMP directory. On Windows, each 528 // to change the current directory to the TMP directory. On Windows, each
529 // process has a handle to its CWD. If setup.exe's CWD happens to be within the 529 // process has a handle to its CWD. If setup.exe's CWD happens to be within the
530 // install directory, deletion will fail as a result of the open handle. 530 // install directory, deletion will fail as a result of the open handle.
531 bool MoveSetupOutOfInstallFolder(const InstallerState& installer_state, 531 bool MoveSetupOutOfInstallFolder(const InstallerState& installer_state,
532 const base::FilePath& setup_exe) { 532 const base::FilePath& setup_exe) {
533 bool ret = false; 533 bool ret = false;
534 base::FilePath tmp_dir; 534 base::FilePath tmp_dir;
535 base::FilePath temp_file; 535 base::FilePath temp_file;
536 if (!PathService::Get(base::DIR_TEMP, &tmp_dir)) { 536 if (!PathService::Get(base::DIR_TEMP, &tmp_dir)) {
537 NOTREACHED(); 537 NOTREACHED();
538 } else if (!file_util::CreateTemporaryFileInDir(tmp_dir, &temp_file)) { 538 } else if (!base::CreateTemporaryFileInDir(tmp_dir, &temp_file)) {
539 LOG(ERROR) << "Failed to create temporary file for setup.exe."; 539 LOG(ERROR) << "Failed to create temporary file for setup.exe.";
540 } else { 540 } else {
541 VLOG(1) << "Changing current directory to: " << tmp_dir.value(); 541 VLOG(1) << "Changing current directory to: " << tmp_dir.value();
542 if (!file_util::SetCurrentDirectory(tmp_dir)) 542 if (!file_util::SetCurrentDirectory(tmp_dir))
543 PLOG(ERROR) << "Failed to change the current directory."; 543 PLOG(ERROR) << "Failed to change the current directory.";
544 544
545 VLOG(1) << "Attempting to move setup to: " << temp_file.value(); 545 VLOG(1) << "Attempting to move setup to: " << temp_file.value();
546 ret = base::Move(setup_exe, temp_file); 546 ret = base::Move(setup_exe, temp_file);
547 PLOG_IF(ERROR, !ret) << "Failed to move setup to " << temp_file.value(); 547 PLOG_IF(ERROR, !ret) << "Failed to move setup to " << temp_file.value();
548 548
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 // If we need a reboot to continue, schedule the parent directories for 1493 // If we need a reboot to continue, schedule the parent directories for
1494 // deletion unconditionally. If they are not empty, the session manager 1494 // deletion unconditionally. If they are not empty, the session manager
1495 // will not delete them on reboot. 1495 // will not delete them on reboot.
1496 ScheduleParentAndGrandparentForDeletion(target_path); 1496 ScheduleParentAndGrandparentForDeletion(target_path);
1497 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) { 1497 } else if (DeleteChromeDirectoriesIfEmpty(target_path) == DELETE_FAILED) {
1498 *uninstall_status = UNINSTALL_FAILED; 1498 *uninstall_status = UNINSTALL_FAILED;
1499 } 1499 }
1500 } 1500 }
1501 1501
1502 } // namespace installer 1502 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/setup/setup_util_unittest.cc ('k') | chrome/installer/test/alternate_version_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698