summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_main.cc
diff options
context:
space:
mode:
authoratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-08 19:42:54 +0000
committeratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-08 19:42:54 +0000
commit404df1613316a15634d5ba70fdbf32c85c0032e4 (patch)
treef6bab7adf02b7f785aa2101466a32b5eee8404df /chrome/browser/browser_main.cc
parentfc33e999e1c6426050e231d8dfcc38ddd3deb375 (diff)
downloadchromium_src-404df1613316a15634d5ba70fdbf32c85c0032e4.zip
chromium_src-404df1613316a15634d5ba70fdbf32c85c0032e4.tar.gz
chromium_src-404df1613316a15634d5ba70fdbf32c85c0032e4.tar.bz2
This is a new version of the older patch. Main changes include:
1. Rebased to a never Git revision to make things easier to land. 2. Chrome will now preserve the command line switches except for those that are blacklisted. 3. Fixed a race condition that would cause the browser to think it didn't exit cleanly after it's been restarted. 4. Fixed minor nits and omissions (indentation, etc). This patch adds a timer which fires every 6 hours and checks whether the browser is in the "persistent" (background) mode, and whether there's an update pending restart. If both conditions are true, the browser is restarted with blacklisted command line keys and all loose values stripped. In order to restart the browser in the background mode, the --long-lived-extensions key is also added to the command line. This change is Windows-only, and it won't become fully functional until Drew (atwilson) checks in his work that enables Chrome to go into background. Review URL: http://codereview.chromium.org/1617001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43989 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_main.cc')
-rw-r--r--chrome/browser/browser_main.cc53
1 files changed, 32 insertions, 21 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index a993769..25df1a8 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -910,6 +910,29 @@ int BrowserMain(const MainFunctionParams& parameters) {
}
#endif
+ // When another process is running, use that process instead of starting a
+ // new one. NotifyOtherProcess will currently give the other process up to
+ // 20 seconds to respond. Note that this needs to be done before we attempt
+ // to read the profile.
+ switch (process_singleton.NotifyOtherProcess()) {
+ case ProcessSingleton::PROCESS_NONE:
+ // No process already running, fall through to starting a new one.
+ break;
+
+ case ProcessSingleton::PROCESS_NOTIFIED:
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+ printf("%s\n", base::SysWideToNativeMB(
+ l10n_util::GetString(IDS_USED_EXISTING_BROWSER)).c_str());
+#endif
+ return ResultCodes::NORMAL_EXIT;
+
+ case ProcessSingleton::PROFILE_IN_USE:
+ return ResultCodes::PROFILE_IN_USE;
+
+ default:
+ NOTREACHED();
+ }
+
// Profile creation ----------------------------------------------------------
Profile* profile = CreateProfile(parameters, user_data_dir);
@@ -937,29 +960,9 @@ int BrowserMain(const MainFunctionParams& parameters) {
}
#endif
- // When another process is running, use it instead of starting us.
- switch (process_singleton.NotifyOtherProcess()) {
- case ProcessSingleton::PROCESS_NONE:
- // No process already running, fall through to starting a new one.
- break;
-
- case ProcessSingleton::PROCESS_NOTIFIED:
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
- printf("%s\n", base::SysWideToNativeMB(
- l10n_util::GetString(IDS_USED_EXISTING_BROWSER)).c_str());
-#endif
- return ResultCodes::NORMAL_EXIT;
-
- case ProcessSingleton::PROFILE_IN_USE:
- return ResultCodes::PROFILE_IN_USE;
-
- default:
- NOTREACHED();
- }
-
#if defined(OS_WIN)
// Do the tasks if chrome has been upgraded while it was last running.
- if (!already_running && DoUpgradeTasks(parsed_command_line))
+ if (!already_running && Upgrade::DoUpgradeTasks(parsed_command_line))
return ResultCodes::NORMAL_EXIT;
#endif
@@ -1133,6 +1136,14 @@ int BrowserMain(const MainFunctionParams& parameters) {
// the main message loop.
if (browser_init.Start(parsed_command_line, std::wstring(), profile,
&result_code)) {
+#if defined(OS_WIN)
+ // Initialize autoupdate timer. Timer callback costs basically nothing
+ // when browser is not in persistent mode, so it's OK to let it ride on
+ // the main thread. This needs to be done here because we don't want
+ // to start the timer when Chrome is run inside a test harness.
+ g_browser_process->StartAutoupdateTimer();
+#endif
+
// Record now as the last succesful chrome start.
GoogleUpdateSettings::SetLastRunTime();
// Call Recycle() here as late as possible, before going into the loop