summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_process_impl.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-30 01:23:32 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-30 01:23:32 +0000
commit1979689363e58c9917d751d5134287d8616528e5 (patch)
tree6342d081e86670f1a05b07933888278d6e355759 /chrome/browser/browser_process_impl.cc
parent27d3571b99a7e69bedb8ac0282b981325906edc2 (diff)
downloadchromium_src-1979689363e58c9917d751d5134287d8616528e5.zip
chromium_src-1979689363e58c9917d751d5134287d8616528e5.tar.gz
chromium_src-1979689363e58c9917d751d5134287d8616528e5.tar.bz2
Revert r46023: "Detect new instance of the browser when running in the background in persistent"
Broke the build. Review URL: http://codereview.chromium.org/1718024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46025 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_process_impl.cc')
-rw-r--r--chrome/browser/browser_process_impl.cc43
1 files changed, 17 insertions, 26 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 05ea69f..ac623a5 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -4,8 +4,6 @@
#include "chrome/browser/browser_process_impl.h"
-#include <map>
-
#include "app/clipboard/clipboard.h"
#include "app/l10n_util.h"
#include "base/command_line.h"
@@ -65,12 +63,6 @@
#include "chrome/common/render_messages.h"
#endif
-#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
-// How often to check if the persistent instance of Chrome needs to restart
-// to install an update.
-static const int kUpdateCheckIntervalHours = 6;
-#endif
-
BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
: created_resource_dispatcher_host_(false),
created_metrics_service_(false),
@@ -456,14 +448,14 @@ void BrowserProcessImpl::CheckForInspectorFiles() {
NewRunnableMethod(this, &BrowserProcessImpl::DoInspectorFilesCheck));
}
-#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
+#if defined(OS_WIN)
void BrowserProcessImpl::StartAutoupdateTimer() {
autoupdate_timer_.Start(
- TimeDelta::FromHours(kUpdateCheckIntervalHours),
+ TimeDelta::FromHours(google_update::kUpdateCheckInvervalHours),
this,
&BrowserProcessImpl::OnAutoupdateTimer);
}
-#endif
+#endif // OS_WIN
#if defined(IPC_MESSAGE_LOG_ENABLED)
@@ -516,8 +508,8 @@ void BrowserProcessImpl::DoInspectorFilesCheck() {
have_inspector_files_ = result;
}
-// Mac is currently not supported.
-#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
+#if defined(OS_WIN) // Linux doesn't do rename on restart, and Mac is currently
+ // not supported.
bool BrowserProcessImpl::CanAutorestartForUpdate() const {
// Check if browser is in the background and if it needs to be restarted to
@@ -539,13 +531,13 @@ const char* const kSwitchesToRemoveOnAutorestart[] = {
void BrowserProcessImpl::RestartPersistentInstance() {
CommandLine* old_cl = CommandLine::ForCurrentProcess();
- scoped_ptr<CommandLine> new_cl(new CommandLine(old_cl->GetProgram()));
+ CommandLine new_cl(old_cl->GetProgram());
std::map<std::string, CommandLine::StringType> switches =
old_cl->GetSwitches();
// Remove the keys that we shouldn't pass through during restart.
- for (size_t i = 0; i < arraysize(kSwitchesToRemoveOnAutorestart); i++) {
+ for (int i = 0; i < arraysize(kSwitchesToRemoveOnAutorestart); i++) {
switches.erase(kSwitchesToRemoveOnAutorestart[i]);
}
@@ -555,29 +547,28 @@ void BrowserProcessImpl::RestartPersistentInstance() {
switches.begin(); i != switches.end(); ++i) {
CommandLine::StringType switch_value = i->second;
if (switch_value.length() > 0) {
- new_cl->AppendSwitchWithValue(i->first, i->second);
+ new_cl.AppendSwitchWithValue(i->first, i->second);
} else {
- new_cl->AppendSwitch(i->first);
+ new_cl.AppendSwitch(i->first);
}
}
// TODO(atwilson): Uncomment the following two lines to add the "persistence"
// switch when the corresponding CL is committed.
- // if (!new_cl->HasSwitch(switches::kLongLivedExtensions))
- // new_cl->AppendSwitch(switches::kLongLivedExtensions);
-
- DLOG(WARNING) << "Shutting down current instance of the browser.";
- BrowserList::CloseAllBrowsersAndExit();
+ // if (!new_cl.HasSwitch(switches::kLongLivedExtensions))
+ // new_cl.AppendSwitch(switches::kLongLivedExtensions);
- // Transfer ownership to Upgrade.
- Upgrade::SetNewCommandLine(new_cl.release());
+ if (Upgrade::RelaunchChromeBrowser(new_cl)) {
+ BrowserList::CloseAllBrowsersAndExit();
+ } else {
+ DLOG(ERROR) << "Could not restart browser for autoupdate.";
+ }
}
void BrowserProcessImpl::OnAutoupdateTimer() {
if (CanAutorestartForUpdate()) {
- DLOG(WARNING) << "Detected update. Restarting browser.";
RestartPersistentInstance();
}
}
-#endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
+#endif