OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/thread.h" | 13 #include "base/thread.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/waitable_event.h" | 15 #include "base/waitable_event.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 17 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
18 #include "chrome/browser/first_run.h" | 18 #include "chrome/browser/first_run.h" |
19 #include "chrome/browser/jankometer.h" | 19 #include "chrome/browser/jankometer.h" |
20 #include "chrome/browser/metrics/metrics_service.h" | 20 #include "chrome/browser/metrics/metrics_service.h" |
21 #include "chrome/browser/plugin_process_host.h" | 21 #include "chrome/browser/plugin_process_host.h" |
22 #include "chrome/browser/renderer_host/render_process_host.h" | 22 #include "chrome/browser/renderer_host/render_process_host.h" |
23 #include "chrome/browser/renderer_host/render_view_host.h" | 23 #include "chrome/browser/renderer_host/render_view_host.h" |
24 #include "chrome/browser/renderer_host/render_widget_host.h" | 24 #include "chrome/browser/renderer_host/render_widget_host.h" |
25 #include "chrome/browser/rlz/rlz.h" | |
26 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
27 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
28 #include "chrome/common/pref_service.h" | 27 #include "chrome/common/pref_service.h" |
29 #include "chrome/common/chrome_plugin_lib.h" | 28 #include "chrome/common/chrome_plugin_lib.h" |
30 #include "net/dns_global.h" | 29 #include "net/dns_global.h" |
31 | 30 |
| 31 #if defined(OS_WIN) |
| 32 #include "chrome/browser/rlz/rlz.h" |
| 33 #endif |
32 | 34 |
33 using base::Time; | 35 using base::Time; |
34 using base::TimeDelta; | 36 using base::TimeDelta; |
35 | 37 |
36 namespace browser_shutdown { | 38 namespace browser_shutdown { |
37 | 39 |
38 Time shutdown_started_; | 40 Time shutdown_started_; |
39 ShutdownType shutdown_type_ = NOT_VALID; | 41 ShutdownType shutdown_type_ = NOT_VALID; |
40 int shutdown_num_processes_; | 42 int shutdown_num_processes_; |
41 int shutdown_num_processes_slow_; | 43 int shutdown_num_processes_slow_; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Record the shutdown info so that we can put it into a histogram at next | 126 // Record the shutdown info so that we can put it into a histogram at next |
125 // startup. | 127 // startup. |
126 prefs->SetInteger(prefs::kShutdownType, shutdown_type_); | 128 prefs->SetInteger(prefs::kShutdownType, shutdown_type_); |
127 prefs->SetInteger(prefs::kShutdownNumProcesses, shutdown_num_processes_); | 129 prefs->SetInteger(prefs::kShutdownNumProcesses, shutdown_num_processes_); |
128 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, | 130 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, |
129 shutdown_num_processes_slow_); | 131 shutdown_num_processes_slow_); |
130 } | 132 } |
131 | 133 |
132 prefs->SavePersistentPrefs(); | 134 prefs->SavePersistentPrefs(); |
133 | 135 |
| 136 #if defined(OS_WIN) |
134 // Cleanup any statics created by RLZ. Must be done before NotificationService | 137 // Cleanup any statics created by RLZ. Must be done before NotificationService |
135 // is destroyed. | 138 // is destroyed. |
136 RLZTracker::CleanupRlz(); | 139 RLZTracker::CleanupRlz(); |
| 140 #endif |
137 | 141 |
138 // The jank'o'meter requires that the browser process has been destroyed | 142 // The jank'o'meter requires that the browser process has been destroyed |
139 // before calling UninstallJankometer(). | 143 // before calling UninstallJankometer(). |
140 delete g_browser_process; | 144 delete g_browser_process; |
141 g_browser_process = NULL; | 145 g_browser_process = NULL; |
142 | 146 |
143 // Uninstall Jank-O-Meter here after the IO thread is no longer running. | 147 // Uninstall Jank-O-Meter here after the IO thread is no longer running. |
144 UninstallJankometer(); | 148 UninstallJankometer(); |
145 | 149 |
146 if (delete_resources_on_shutdown) | 150 if (delete_resources_on_shutdown) |
147 ResourceBundle::CleanupSharedInstance(); | 151 ResourceBundle::CleanupSharedInstance(); |
148 | 152 |
| 153 #if defined(OS_WIN) |
149 if (!Upgrade::IsBrowserAlreadyRunning()) { | 154 if (!Upgrade::IsBrowserAlreadyRunning()) { |
150 Upgrade::SwapNewChromeExeIfPresent(); | 155 Upgrade::SwapNewChromeExeIfPresent(); |
151 } | 156 } |
152 | 157 |
153 #if defined(OS_WIN) | |
154 if (shutdown_type_ > NOT_VALID && shutdown_num_processes_ > 0) { | 158 if (shutdown_type_ > NOT_VALID && shutdown_num_processes_ > 0) { |
155 // Measure total shutdown time as late in the process as possible | 159 // Measure total shutdown time as late in the process as possible |
156 // and then write it to a file to be read at startup. | 160 // and then write it to a file to be read at startup. |
157 // We can't use prefs since all services are shutdown at this point. | 161 // We can't use prefs since all services are shutdown at this point. |
158 TimeDelta shutdown_delta = Time::Now() - shutdown_started_; | 162 TimeDelta shutdown_delta = Time::Now() - shutdown_started_; |
159 std::string shutdown_ms = Int64ToString(shutdown_delta.InMilliseconds()); | 163 std::string shutdown_ms = Int64ToString(shutdown_delta.InMilliseconds()); |
160 int len = static_cast<int>(shutdown_ms.length()) + 1; | 164 int len = static_cast<int>(shutdown_ms.length()) + 1; |
161 FilePath shutdown_ms_file = GetShutdownMsPath(); | 165 FilePath shutdown_ms_file = GetShutdownMsPath(); |
162 file_util::WriteFile(shutdown_ms_file, shutdown_ms.c_str(), len); | 166 file_util::WriteFile(shutdown_ms_file, shutdown_ms.c_str(), len); |
163 } | 167 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 UMA_HISTOGRAM_TIMES(time_per.c_str(), | 213 UMA_HISTOGRAM_TIMES(time_per.c_str(), |
210 TimeDelta::FromMilliseconds(shutdown_ms / num_procs)); | 214 TimeDelta::FromMilliseconds(shutdown_ms / num_procs)); |
211 UMA_HISTOGRAM_COUNTS_100("Shutdown.renderers.total", num_procs); | 215 UMA_HISTOGRAM_COUNTS_100("Shutdown.renderers.total", num_procs); |
212 UMA_HISTOGRAM_COUNTS_100("Shutdown.renderers.slow", num_procs_slow); | 216 UMA_HISTOGRAM_COUNTS_100("Shutdown.renderers.slow", num_procs_slow); |
213 } | 217 } |
214 } | 218 } |
215 } | 219 } |
216 #endif | 220 #endif |
217 | 221 |
218 } // namespace browser_shutdown | 222 } // namespace browser_shutdown |
OLD | NEW |