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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 ++g_shutdown_num_processes_slow; | 135 ++g_shutdown_num_processes_slow; |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 base::FilePath GetShutdownMsPath() { | 139 base::FilePath GetShutdownMsPath() { |
140 base::FilePath shutdown_ms_file; | 140 base::FilePath shutdown_ms_file; |
141 PathService::Get(chrome::DIR_USER_DATA, &shutdown_ms_file); | 141 PathService::Get(chrome::DIR_USER_DATA, &shutdown_ms_file); |
142 return shutdown_ms_file.AppendASCII(kShutdownMsFile); | 142 return shutdown_ms_file.AppendASCII(kShutdownMsFile); |
143 } | 143 } |
144 | 144 |
| 145 #if !defined(OS_ANDROID) |
145 bool ShutdownPreThreadsStop() { | 146 bool ShutdownPreThreadsStop() { |
146 #if defined(OS_CHROMEOS) | 147 #if defined(OS_CHROMEOS) |
147 chromeos::BootTimesRecorder::Get()->AddLogoutTimeMarker( | 148 chromeos::BootTimesRecorder::Get()->AddLogoutTimeMarker( |
148 "BrowserShutdownStarted", false); | 149 "BrowserShutdownStarted", false); |
149 #endif | 150 #endif |
150 #if defined(ENABLE_PRINT_PREVIEW) | 151 #if defined(ENABLE_PRINT_PREVIEW) |
151 // Shutdown the IPC channel to the service processes. | 152 // Shutdown the IPC channel to the service processes. |
152 ServiceProcessControl::GetInstance()->Disconnect(); | 153 ServiceProcessControl::GetInstance()->Disconnect(); |
153 #endif // ENABLE_PRINT_PREVIEW | 154 #endif // ENABLE_PRINT_PREVIEW |
154 | 155 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 for (const auto& it : switches) { | 243 for (const auto& it : switches) { |
243 const base::CommandLine::StringType& switch_value = it.second; | 244 const base::CommandLine::StringType& switch_value = it.second; |
244 if (!switch_value.empty()) | 245 if (!switch_value.empty()) |
245 new_cl->AppendSwitchNative(it.first, it.second); | 246 new_cl->AppendSwitchNative(it.first, it.second); |
246 else | 247 else |
247 new_cl->AppendSwitch(it.first); | 248 new_cl->AppendSwitch(it.first); |
248 } | 249 } |
249 | 250 |
250 #if defined(OS_WIN) | 251 #if defined(OS_WIN) |
251 upgrade_util::RelaunchChromeWithMode(*new_cl.get(), g_relaunch_mode); | 252 upgrade_util::RelaunchChromeWithMode(*new_cl.get(), g_relaunch_mode); |
252 #elif defined(OS_POSIX) && !defined(OS_ANDROID) | 253 #elif defined(OS_POSIX) |
253 upgrade_util::RelaunchChromeBrowser(*new_cl.get()); | 254 upgrade_util::RelaunchChromeBrowser(*new_cl.get()); |
254 #endif // defined(OS_WIN) | 255 #endif // defined(OS_WIN) |
255 | 256 |
256 #else | 257 #else |
257 NOTIMPLEMENTED(); | 258 NOTIMPLEMENTED(); |
258 #endif // !defined(OS_CHROMEOS) | 259 #endif // !defined(OS_CHROMEOS) |
259 } | 260 } |
260 | 261 |
261 if (g_shutdown_type > NOT_VALID && g_shutdown_num_processes > 0) { | 262 if (g_shutdown_type > NOT_VALID && g_shutdown_num_processes > 0) { |
262 // Measure total shutdown time as late in the process as possible | 263 // Measure total shutdown time as late in the process as possible |
263 // and then write it to a file to be read at startup. | 264 // and then write it to a file to be read at startup. |
264 // We can't use prefs since all services are shutdown at this point. | 265 // We can't use prefs since all services are shutdown at this point. |
265 TimeDelta shutdown_delta = Time::Now() - *g_shutdown_started; | 266 TimeDelta shutdown_delta = Time::Now() - *g_shutdown_started; |
266 std::string shutdown_ms = | 267 std::string shutdown_ms = |
267 base::Int64ToString(shutdown_delta.InMilliseconds()); | 268 base::Int64ToString(shutdown_delta.InMilliseconds()); |
268 int len = static_cast<int>(shutdown_ms.length()) + 1; | 269 int len = static_cast<int>(shutdown_ms.length()) + 1; |
269 base::FilePath shutdown_ms_file = GetShutdownMsPath(); | 270 base::FilePath shutdown_ms_file = GetShutdownMsPath(); |
270 base::WriteFile(shutdown_ms_file, shutdown_ms.c_str(), len); | 271 base::WriteFile(shutdown_ms_file, shutdown_ms.c_str(), len); |
271 } | 272 } |
272 | 273 |
273 #if defined(OS_CHROMEOS) | 274 #if defined(OS_CHROMEOS) |
274 chrome::NotifyAndTerminate(false); | 275 chrome::NotifyAndTerminate(false); |
275 #endif | 276 #endif |
276 } | 277 } |
| 278 #endif // !defined(OS_ANDROID) |
277 | 279 |
278 void ReadLastShutdownFile(ShutdownType type, | 280 void ReadLastShutdownFile(ShutdownType type, |
279 int num_procs, | 281 int num_procs, |
280 int num_procs_slow) { | 282 int num_procs_slow) { |
281 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 283 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
282 | 284 |
283 base::FilePath shutdown_ms_file = GetShutdownMsPath(); | 285 base::FilePath shutdown_ms_file = GetShutdownMsPath(); |
284 std::string shutdown_ms_str; | 286 std::string shutdown_ms_str; |
285 int64_t shutdown_ms = 0; | 287 int64_t shutdown_ms = 0; |
286 if (base::ReadFileToString(shutdown_ms_file, &shutdown_ms_str)) | 288 if (base::ReadFileToString(shutdown_ms_file, &shutdown_ms_str)) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 339 |
338 void SetTryingToQuit(bool quitting) { | 340 void SetTryingToQuit(bool quitting) { |
339 g_trying_to_quit = quitting; | 341 g_trying_to_quit = quitting; |
340 } | 342 } |
341 | 343 |
342 bool IsTryingToQuit() { | 344 bool IsTryingToQuit() { |
343 return g_trying_to_quit; | 345 return g_trying_to_quit; |
344 } | 346 } |
345 | 347 |
346 } // namespace browser_shutdown | 348 } // namespace browser_shutdown |
OLD | NEW |