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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/prefs/pref_registry_simple.h" | 16 #include "base/prefs/pref_registry_simple.h" |
17 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
20 #include "base/threading/thread.h" | 20 #include "base/threading/thread.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "chrome/browser/about_flags.h" | 22 #include "chrome/browser/about_flags.h" |
23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/first_run/upgrade_util.h" | 24 #include "chrome/browser/first_run/upgrade_util.h" |
25 #include "chrome/browser/lifetime/application_lifetime.h" | 25 #include "chrome/browser/lifetime/application_lifetime.h" |
26 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
27 #include "chrome/browser/service_process/service_process_control.h" | |
28 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/common/crash_keys.h" | 29 #include "chrome/common/crash_keys.h" |
31 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
32 #include "chrome/common/switch_utils.h" | 31 #include "chrome/common/switch_utils.h" |
33 #include "components/metrics/metrics_service.h" | 32 #include "components/metrics/metrics_service.h" |
34 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
35 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
36 | 35 |
37 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
38 #include "chrome/browser/browser_util_win.h" | 37 #include "chrome/browser/browser_util_win.h" |
39 #include "chrome/browser/first_run/upgrade_util_win.h" | 38 #include "chrome/browser/first_run/upgrade_util_win.h" |
40 #endif | 39 #endif |
41 | 40 |
42 #if defined(ENABLE_RLZ) | 41 #if defined(ENABLE_RLZ) |
43 #include "chrome/browser/rlz/rlz.h" | 42 #include "chrome/browser/rlz/rlz.h" |
44 #endif | 43 #endif |
45 | 44 |
46 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
47 #include "chrome/browser/chromeos/boot_times_loader.h" | 46 #include "chrome/browser/chromeos/boot_times_loader.h" |
48 #endif | 47 #endif |
49 | 48 |
| 49 #if defined(ENABLE_FULL_PRINTING) |
| 50 #include "chrome/browser/service_process/service_process_control.h" |
| 51 #endif |
| 52 |
50 using base::Time; | 53 using base::Time; |
51 using base::TimeDelta; | 54 using base::TimeDelta; |
52 using content::BrowserThread; | 55 using content::BrowserThread; |
53 | 56 |
54 namespace browser_shutdown { | 57 namespace browser_shutdown { |
55 namespace { | 58 namespace { |
56 | 59 |
57 // Whether the browser is trying to quit (e.g., Quit chosen from menu). | 60 // Whether the browser is trying to quit (e.g., Quit chosen from menu). |
58 bool g_trying_to_quit = false; | 61 bool g_trying_to_quit = false; |
59 | 62 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 base::FilePath shutdown_ms_file; | 136 base::FilePath shutdown_ms_file; |
134 PathService::Get(chrome::DIR_USER_DATA, &shutdown_ms_file); | 137 PathService::Get(chrome::DIR_USER_DATA, &shutdown_ms_file); |
135 return shutdown_ms_file.AppendASCII(kShutdownMsFile); | 138 return shutdown_ms_file.AppendASCII(kShutdownMsFile); |
136 } | 139 } |
137 | 140 |
138 bool ShutdownPreThreadsStop() { | 141 bool ShutdownPreThreadsStop() { |
139 #if defined(OS_CHROMEOS) | 142 #if defined(OS_CHROMEOS) |
140 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker( | 143 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker( |
141 "BrowserShutdownStarted", false); | 144 "BrowserShutdownStarted", false); |
142 #endif | 145 #endif |
143 | 146 #if defined(ENABLE_FULL_PRINTING) |
144 // Shutdown the IPC channel to the service processes. | 147 // Shutdown the IPC channel to the service processes. |
145 ServiceProcessControl::GetInstance()->Disconnect(); | 148 ServiceProcessControl::GetInstance()->Disconnect(); |
| 149 #endif // ENABLE_FULL_PRINTING |
146 | 150 |
147 // WARNING: During logoff/shutdown (WM_ENDSESSION) we may not have enough | 151 // WARNING: During logoff/shutdown (WM_ENDSESSION) we may not have enough |
148 // time to get here. If you have something that *must* happen on end session, | 152 // time to get here. If you have something that *must* happen on end session, |
149 // consider putting it in BrowserProcessImpl::EndSession. | 153 // consider putting it in BrowserProcessImpl::EndSession. |
150 PrefService* prefs = g_browser_process->local_state(); | 154 PrefService* prefs = g_browser_process->local_state(); |
151 | 155 |
152 metrics::MetricsService* metrics = g_browser_process->metrics_service(); | 156 metrics::MetricsService* metrics = g_browser_process->metrics_service(); |
153 if (metrics) | 157 if (metrics) |
154 metrics->RecordCompletedSessionEnd(); | 158 metrics->RecordCompletedSessionEnd(); |
155 | 159 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 331 |
328 void SetTryingToQuit(bool quitting) { | 332 void SetTryingToQuit(bool quitting) { |
329 g_trying_to_quit = quitting; | 333 g_trying_to_quit = quitting; |
330 } | 334 } |
331 | 335 |
332 bool IsTryingToQuit() { | 336 bool IsTryingToQuit() { |
333 return g_trying_to_quit; | 337 return g_trying_to_quit; |
334 } | 338 } |
335 | 339 |
336 } // namespace browser_shutdown | 340 } // namespace browser_shutdown |
OLD | NEW |