| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
| 16 #include "base/stringprintf.h" |
| 16 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
| 17 #include "base/string_util.h" | |
| 18 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "base/threading/thread_restrictions.h" | 20 #include "base/threading/thread_restrictions.h" |
| 21 #include "base/time.h" | 21 #include "base/time.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "chrome/browser/about_flags.h" | 23 #include "chrome/browser/about_flags.h" |
| 24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/first_run/upgrade_util.h" | 25 #include "chrome/browser/first_run/upgrade_util.h" |
| 26 #include "chrome/browser/jankometer.h" | 26 #include "chrome/browser/jankometer.h" |
| 27 #include "chrome/browser/metrics/metrics_service.h" | 27 #include "chrome/browser/metrics/metrics_service.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 file_util::Delete(shutdown_ms_file, false); | 276 file_util::Delete(shutdown_ms_file, false); |
| 277 | 277 |
| 278 if (type == NOT_VALID || shutdown_ms == 0 || num_procs == 0) | 278 if (type == NOT_VALID || shutdown_ms == 0 || num_procs == 0) |
| 279 return; | 279 return; |
| 280 | 280 |
| 281 const char *time_fmt = "Shutdown.%s.time"; | 281 const char *time_fmt = "Shutdown.%s.time"; |
| 282 const char *time_per_fmt = "Shutdown.%s.time_per_process"; | 282 const char *time_per_fmt = "Shutdown.%s.time_per_process"; |
| 283 std::string time; | 283 std::string time; |
| 284 std::string time_per; | 284 std::string time_per; |
| 285 if (type == WINDOW_CLOSE) { | 285 if (type == WINDOW_CLOSE) { |
| 286 time = StringPrintf(time_fmt, "window_close"); | 286 time = base::StringPrintf(time_fmt, "window_close"); |
| 287 time_per = StringPrintf(time_per_fmt, "window_close"); | 287 time_per = base::StringPrintf(time_per_fmt, "window_close"); |
| 288 } else if (type == BROWSER_EXIT) { | 288 } else if (type == BROWSER_EXIT) { |
| 289 time = StringPrintf(time_fmt, "browser_exit"); | 289 time = base::StringPrintf(time_fmt, "browser_exit"); |
| 290 time_per = StringPrintf(time_per_fmt, "browser_exit"); | 290 time_per = base::StringPrintf(time_per_fmt, "browser_exit"); |
| 291 } else if (type == END_SESSION) { | 291 } else if (type == END_SESSION) { |
| 292 time = StringPrintf(time_fmt, "end_session"); | 292 time = base::StringPrintf(time_fmt, "end_session"); |
| 293 time_per = StringPrintf(time_per_fmt, "end_session"); | 293 time_per = base::StringPrintf(time_per_fmt, "end_session"); |
| 294 } else { | 294 } else { |
| 295 NOTREACHED(); | 295 NOTREACHED(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 if (time.empty()) | 298 if (time.empty()) |
| 299 return; | 299 return; |
| 300 | 300 |
| 301 // TODO(erikkay): change these to UMA histograms after a bit more testing. | 301 // TODO(erikkay): change these to UMA histograms after a bit more testing. |
| 302 UMA_HISTOGRAM_TIMES(time.c_str(), | 302 UMA_HISTOGRAM_TIMES(time.c_str(), |
| 303 TimeDelta::FromMilliseconds(shutdown_ms)); | 303 TimeDelta::FromMilliseconds(shutdown_ms)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 335 |
| 336 bool ShuttingDownWithoutClosingBrowsers() { | 336 bool ShuttingDownWithoutClosingBrowsers() { |
| 337 #if defined(USE_X11) | 337 #if defined(USE_X11) |
| 338 if (GetShutdownType() == browser_shutdown::END_SESSION) | 338 if (GetShutdownType() == browser_shutdown::END_SESSION) |
| 339 return true; | 339 return true; |
| 340 #endif | 340 #endif |
| 341 return false; | 341 return false; |
| 342 } | 342 } |
| 343 | 343 |
| 344 } // namespace browser_shutdown | 344 } // namespace browser_shutdown |
| OLD | NEW |