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

Unified Diff: chrome/browser/first_run/upgrade_util_win.cc

Issue 6840003: first-run: Refactor Upgrade class into a common upgrade_util API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upgrade_utils -> upgrade_util Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/first_run/upgrade_util_linux.cc ('k') | chrome/browser/first_run/upgrade_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/first_run/upgrade_util_win.cc
diff --git a/chrome/browser/first_run/upgrade_win.cc b/chrome/browser/first_run/upgrade_util_win.cc
similarity index 86%
rename from chrome/browser/first_run/upgrade_win.cc
rename to chrome/browser/first_run/upgrade_util_win.cc
index 42f3b747d1ba0b87d05ea258c446c2eab0e7791c..ee01ffef3ff6e7acdeb87c368a5c8a71cb3f10b7 100644
--- a/chrome/browser/first_run/upgrade_win.cc
+++ b/chrome/browser/first_run/upgrade_util_win.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/first_run/upgrade.h"
+#include "chrome/browser/first_run/upgrade_util.h"
#include <algorithm>
#include <string>
@@ -60,11 +60,24 @@ bool InvokeGoogleUpdateForRename() {
} // namespace
-// static
-CommandLine* Upgrade::new_command_line_ = NULL;
-// static
-bool Upgrade::IsBrowserAlreadyRunning() {
+namespace upgrade_util {
+
+bool RelaunchChromeBrowser(const CommandLine& command_line) {
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ env->UnSetVar(chrome::kChromeVersionEnvVar);
+ return base::LaunchApp(
+ command_line.command_line_string(), false, false, NULL);
+}
+
+bool IsUpdatePendingRestart() {
+ FilePath new_chrome_exe;
+ if (!GetNewerChromeFile(&new_chrome_exe))
+ return false;
+ return file_util::PathExists(new_chrome_exe);
+}
+
+bool IsBrowserAlreadyRunning() {
static HANDLE handle = NULL;
FilePath exe_path;
PathService::Get(base::FILE_EXE, &exe_path);
@@ -79,8 +92,7 @@ bool Upgrade::IsBrowserAlreadyRunning() {
return (error == ERROR_ALREADY_EXISTS || error == ERROR_ACCESS_DENIED);
}
-// static
-bool Upgrade::SwapNewChromeExeIfPresent() {
+bool SwapNewChromeExeIfPresent() {
FilePath new_chrome_exe;
if (!GetNewerChromeFile(&new_chrome_exe))
return false;
@@ -115,43 +127,26 @@ bool Upgrade::SwapNewChromeExeIfPresent() {
return InvokeGoogleUpdateForRename();
}
-// static
-bool Upgrade::DoUpgradeTasks(const CommandLine& command_line) {
- if (!Upgrade::SwapNewChromeExeIfPresent())
+bool DoUpgradeTasks(const CommandLine& command_line) {
+ if (!SwapNewChromeExeIfPresent())
return false;
// At this point the chrome.exe has been swapped with the new one.
- if (!Upgrade::RelaunchChromeBrowser(command_line)) {
+ if (!RelaunchChromeBrowser(command_line)) {
// The re-launch fails. Feel free to panic now.
NOTREACHED();
}
return true;
}
-// static
-Upgrade::TryResult Upgrade::ShowTryChromeDialog(
- size_t version,
- ProcessSingleton* process_singleton) {
+TryResult ShowTryChromeDialog(size_t version,
+ ProcessSingleton* process_singleton) {
if (version > 10000) {
// This is a test value. We want to make sure we exercise
// returning this early. See EarlyReturnTest test harness.
- return Upgrade::NOT_NOW;
+ return NOT_NOW;
}
TryChromeDialogView dialog(version);
return dialog.ShowModal(process_singleton);
}
-// static
-bool Upgrade::RelaunchChromeBrowser(const CommandLine& command_line) {
- scoped_ptr<base::Environment> env(base::Environment::Create());
- env->UnSetVar(chrome::kChromeVersionEnvVar);
- return base::LaunchApp(
- command_line.command_line_string(), false, false, NULL);
-}
-
-// static
-bool Upgrade::IsUpdatePendingRestart() {
- FilePath new_chrome_exe;
- if (!GetNewerChromeFile(&new_chrome_exe))
- return false;
- return file_util::PathExists(new_chrome_exe);
-}
+} // namespace upgrade_util
« no previous file with comments | « chrome/browser/first_run/upgrade_util_linux.cc ('k') | chrome/browser/first_run/upgrade_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698