Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "chrome/browser/browser_shutdown.h" | 5 #include "chrome/browser/browser_shutdown.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 using content::BrowserThread; | 58 using content::BrowserThread; |
| 59 | 59 |
| 60 namespace browser_shutdown { | 60 namespace browser_shutdown { |
| 61 | 61 |
| 62 // Whether the browser is trying to quit (e.g., Quit chosen from menu). | 62 // Whether the browser is trying to quit (e.g., Quit chosen from menu). |
| 63 bool g_trying_to_quit = false; | 63 bool g_trying_to_quit = false; |
| 64 | 64 |
| 65 // Whether the browser should quit without closing browsers. | 65 // Whether the browser should quit without closing browsers. |
| 66 bool g_shutting_down_without_closing_browsers = false; | 66 bool g_shutting_down_without_closing_browsers = false; |
| 67 | 67 |
| 68 #if defined(OS_WIN) | |
| 69 // Whether the next restart should happen in the opposite mode; desktop or | |
| 70 // metro mode. Windows 8 only. | |
| 71 bool g_mode_switch = false; | |
| 72 #endif | |
| 73 | |
| 68 Time* shutdown_started_ = NULL; | 74 Time* shutdown_started_ = NULL; |
| 69 ShutdownType shutdown_type_ = NOT_VALID; | 75 ShutdownType shutdown_type_ = NOT_VALID; |
| 70 int shutdown_num_processes_; | 76 int shutdown_num_processes_; |
| 71 int shutdown_num_processes_slow_; | 77 int shutdown_num_processes_slow_; |
| 72 | 78 |
| 73 const char kShutdownMsFile[] = "chrome_shutdown_ms.txt"; | 79 const char kShutdownMsFile[] = "chrome_shutdown_ms.txt"; |
| 74 | 80 |
| 75 void RegisterPrefs(PrefService* local_state) { | 81 void RegisterPrefs(PrefService* local_state) { |
| 76 local_state->RegisterIntegerPref(prefs::kShutdownType, NOT_VALID); | 82 local_state->RegisterIntegerPref(prefs::kShutdownType, NOT_VALID); |
| 77 local_state->RegisterIntegerPref(prefs::kShutdownNumProcesses, 0); | 83 local_state->RegisterIntegerPref(prefs::kShutdownNumProcesses, 0); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, | 146 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, |
| 141 shutdown_num_processes_slow_); | 147 shutdown_num_processes_slow_); |
| 142 } | 148 } |
| 143 | 149 |
| 144 // Check local state for the restart flag so we can restart the session below. | 150 // Check local state for the restart flag so we can restart the session below. |
| 145 bool restart_last_session = false; | 151 bool restart_last_session = false; |
| 146 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) { | 152 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) { |
| 147 restart_last_session = | 153 restart_last_session = |
| 148 prefs->GetBoolean(prefs::kRestartLastSessionOnShutdown); | 154 prefs->GetBoolean(prefs::kRestartLastSessionOnShutdown); |
| 149 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown); | 155 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown); |
| 156 #if defined(OS_WIN) | |
| 157 if (restart_last_session) { | |
| 158 if (prefs->HasPrefPath(prefs::kRestartSwitchMode)) | |
| 159 g_mode_switch = prefs->GetBoolean(prefs::kRestartSwitchMode); | |
| 160 prefs->SetBoolean(prefs::kRestartSwitchMode, false); | |
|
grt (UTC plus 2)
2012/09/05 01:40:51
either de-indent this line, or put braces around t
cpu_(ooo_6.6-7.5)
2012/09/05 22:20:07
Good catch.
On 2012/09/05 01:40:51, grt wrote:
| |
| 161 } | |
| 162 #endif | |
| 150 } | 163 } |
| 151 | 164 |
| 152 prefs->CommitPendingWrite(); | 165 prefs->CommitPendingWrite(); |
| 153 | 166 |
| 154 #if defined(ENABLE_RLZ) | 167 #if defined(ENABLE_RLZ) |
| 155 // Cleanup any statics created by RLZ. Must be done before NotificationService | 168 // Cleanup any statics created by RLZ. Must be done before NotificationService |
| 156 // is destroyed. | 169 // is destroyed. |
| 157 RLZTracker::CleanupRlz(); | 170 RLZTracker::CleanupRlz(); |
| 158 #endif | 171 #endif |
| 159 | 172 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 switches::RemoveSwitchesForAutostart(&switches); | 216 switches::RemoveSwitchesForAutostart(&switches); |
| 204 // Append the old switches to the new command line. | 217 // Append the old switches to the new command line. |
| 205 for (std::map<std::string, CommandLine::StringType>::const_iterator i = | 218 for (std::map<std::string, CommandLine::StringType>::const_iterator i = |
| 206 switches.begin(); i != switches.end(); ++i) { | 219 switches.begin(); i != switches.end(); ++i) { |
| 207 CommandLine::StringType switch_value = i->second; | 220 CommandLine::StringType switch_value = i->second; |
| 208 if (!switch_value.empty()) | 221 if (!switch_value.empty()) |
| 209 new_cl->AppendSwitchNative(i->first, i->second); | 222 new_cl->AppendSwitchNative(i->first, i->second); |
| 210 else | 223 else |
| 211 new_cl->AppendSwitch(i->first); | 224 new_cl->AppendSwitch(i->first); |
| 212 } | 225 } |
| 226 | |
| 227 #if defined(OS_WIN) | |
| 228 // On Windows 8 we can relaunch in metro or desktop mode. | |
| 229 if (g_mode_switch) | |
| 230 upgrade_util::RelaunchChromeWithModeSwitch(*new_cl.get()); | |
| 231 else | |
| 232 upgrade_util::RelaunchChromeBrowser(*new_cl.get()); | |
| 233 #else | |
| 213 upgrade_util::RelaunchChromeBrowser(*new_cl.get()); | 234 upgrade_util::RelaunchChromeBrowser(*new_cl.get()); |
| 235 #endif // defined(OS_WIN) | |
| 236 | |
| 214 #else | 237 #else |
| 215 NOTIMPLEMENTED(); | 238 NOTIMPLEMENTED(); |
| 216 #endif // !defined(OS_CHROMEOS) | 239 #endif // !defined(OS_CHROMEOS) |
| 217 } | 240 } |
| 218 | 241 |
| 219 if (shutdown_type_ > NOT_VALID && shutdown_num_processes_ > 0) { | 242 if (shutdown_type_ > NOT_VALID && shutdown_num_processes_ > 0) { |
| 220 // Measure total shutdown time as late in the process as possible | 243 // Measure total shutdown time as late in the process as possible |
| 221 // and then write it to a file to be read at startup. | 244 // and then write it to a file to be read at startup. |
| 222 // We can't use prefs since all services are shutdown at this point. | 245 // We can't use prefs since all services are shutdown at this point. |
| 223 TimeDelta shutdown_delta = Time::Now() - *shutdown_started_; | 246 TimeDelta shutdown_delta = Time::Now() - *shutdown_started_; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 | 330 |
| 308 bool ShuttingDownWithoutClosingBrowsers() { | 331 bool ShuttingDownWithoutClosingBrowsers() { |
| 309 return g_shutting_down_without_closing_browsers; | 332 return g_shutting_down_without_closing_browsers; |
| 310 } | 333 } |
| 311 | 334 |
| 312 void SetShuttingDownWithoutClosingBrowsers(bool without_close) { | 335 void SetShuttingDownWithoutClosingBrowsers(bool without_close) { |
| 313 g_shutting_down_without_closing_browsers = without_close; | 336 g_shutting_down_without_closing_browsers = without_close; |
| 314 } | 337 } |
| 315 | 338 |
| 316 } // namespace browser_shutdown | 339 } // namespace browser_shutdown |
| OLD | NEW |