| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 // 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. |
| 246 TimeDelta shutdown_delta = Time::Now() - *shutdown_started_; | 246 TimeDelta shutdown_delta = Time::Now() - *shutdown_started_; |
| 247 std::string shutdown_ms = | 247 std::string shutdown_ms = |
| 248 base::Int64ToString(shutdown_delta.InMilliseconds()); | 248 base::Int64ToString(shutdown_delta.InMilliseconds()); |
| 249 int len = static_cast<int>(shutdown_ms.length()) + 1; | 249 int len = static_cast<int>(shutdown_ms.length()) + 1; |
| 250 FilePath shutdown_ms_file = GetShutdownMsPath(); | 250 FilePath shutdown_ms_file = GetShutdownMsPath(); |
| 251 file_util::WriteFile(shutdown_ms_file, shutdown_ms.c_str(), len); | 251 file_util::WriteFile(shutdown_ms_file, shutdown_ms.c_str(), len); |
| 252 } | 252 } |
| 253 | 253 |
| 254 #if defined(OS_CHROMEOS) | 254 #if defined(OS_CHROMEOS) |
| 255 browser::NotifyAndTerminate(false); | 255 chrome::NotifyAndTerminate(false); |
| 256 #endif | 256 #endif |
| 257 } | 257 } |
| 258 | 258 |
| 259 void ReadLastShutdownFile( | 259 void ReadLastShutdownFile(ShutdownType type, |
| 260 ShutdownType type, | 260 int num_procs, |
| 261 int num_procs, | 261 int num_procs_slow) { |
| 262 int num_procs_slow) { | |
| 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 264 | 263 |
| 265 FilePath shutdown_ms_file = GetShutdownMsPath(); | 264 FilePath shutdown_ms_file = GetShutdownMsPath(); |
| 266 std::string shutdown_ms_str; | 265 std::string shutdown_ms_str; |
| 267 int64 shutdown_ms = 0; | 266 int64 shutdown_ms = 0; |
| 268 if (file_util::ReadFileToString(shutdown_ms_file, &shutdown_ms_str)) | 267 if (file_util::ReadFileToString(shutdown_ms_file, &shutdown_ms_str)) |
| 269 base::StringToInt64(shutdown_ms_str, &shutdown_ms); | 268 base::StringToInt64(shutdown_ms_str, &shutdown_ms); |
| 270 file_util::Delete(shutdown_ms_file, false); | 269 file_util::Delete(shutdown_ms_file, false); |
| 271 | 270 |
| 272 if (type == NOT_VALID || shutdown_ms == 0 || num_procs == 0) | 271 if (type == NOT_VALID || shutdown_ms == 0 || num_procs == 0) |
| 273 return; | 272 return; |
| 274 | 273 |
| 275 const char *time_fmt = "Shutdown.%s.time"; | 274 const char* time_fmt = "Shutdown.%s.time"; |
| 276 const char *time_per_fmt = "Shutdown.%s.time_per_process"; | 275 const char* time_per_fmt = "Shutdown.%s.time_per_process"; |
| 277 std::string time; | 276 std::string time; |
| 278 std::string time_per; | 277 std::string time_per; |
| 279 if (type == WINDOW_CLOSE) { | 278 if (type == WINDOW_CLOSE) { |
| 280 time = base::StringPrintf(time_fmt, "window_close"); | 279 time = base::StringPrintf(time_fmt, "window_close"); |
| 281 time_per = base::StringPrintf(time_per_fmt, "window_close"); | 280 time_per = base::StringPrintf(time_per_fmt, "window_close"); |
| 282 } else if (type == BROWSER_EXIT) { | 281 } else if (type == BROWSER_EXIT) { |
| 283 time = base::StringPrintf(time_fmt, "browser_exit"); | 282 time = base::StringPrintf(time_fmt, "browser_exit"); |
| 284 time_per = base::StringPrintf(time_per_fmt, "browser_exit"); | 283 time_per = base::StringPrintf(time_per_fmt, "browser_exit"); |
| 285 } else if (type == END_SESSION) { | 284 } else if (type == END_SESSION) { |
| 286 time = base::StringPrintf(time_fmt, "end_session"); | 285 time = base::StringPrintf(time_fmt, "end_session"); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 327 |
| 329 bool ShuttingDownWithoutClosingBrowsers() { | 328 bool ShuttingDownWithoutClosingBrowsers() { |
| 330 return g_shutting_down_without_closing_browsers; | 329 return g_shutting_down_without_closing_browsers; |
| 331 } | 330 } |
| 332 | 331 |
| 333 void SetShuttingDownWithoutClosingBrowsers(bool without_close) { | 332 void SetShuttingDownWithoutClosingBrowsers(bool without_close) { |
| 334 g_shutting_down_without_closing_browsers = without_close; | 333 g_shutting_down_without_closing_browsers = without_close; |
| 335 } | 334 } |
| 336 | 335 |
| 337 } // namespace browser_shutdown | 336 } // namespace browser_shutdown |
| OLD | NEW |