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/lifetime/application_lifetime.h" | 5 #include "chrome/browser/lifetime/application_lifetime.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
15 #include "base/process/kill.h" | |
16 #include "base/process/process.h" | |
17 #include "build/build_config.h" | 15 #include "build/build_config.h" |
18 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/browser_process_platform_part.h" | 17 #include "chrome/browser/browser_process_platform_part.h" |
20 #include "chrome/browser/browser_shutdown.h" | 18 #include "chrome/browser/browser_shutdown.h" |
21 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
22 #include "chrome/browser/download/download_service.h" | 20 #include "chrome/browser/download/download_service.h" |
23 #include "chrome/browser/lifetime/browser_close_manager.h" | 21 #include "chrome/browser/lifetime/browser_close_manager.h" |
24 #include "chrome/browser/metrics/thread_watcher.h" | 22 #include "chrome/browser/metrics/thread_watcher.h" |
25 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION); | 269 browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION); |
272 | 270 |
273 content::NotificationService::current()->Notify( | 271 content::NotificationService::current()->Notify( |
274 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 272 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
275 content::NotificationService::AllSources(), | 273 content::NotificationService::AllSources(), |
276 content::NotificationService::NoDetails()); | 274 content::NotificationService::NoDetails()); |
277 | 275 |
278 // Write important data first. | 276 // Write important data first. |
279 g_browser_process->EndSession(); | 277 g_browser_process->EndSession(); |
280 | 278 |
281 #if defined(OS_WIN) | |
282 base::win::SetShouldCrashOnProcessDetach(false); | |
283 | |
284 // On Windows 7 and later, the system will consider the process ripe for | |
285 // termination as soon as it hides or destroys its windows. Since any | |
286 // execution past that point will be non-deterministically cut short, we | |
287 // might as well put ourselves out of that misery deterministically. | |
288 base::KillProcess(base::Process::Current().handle(), 0, false); | |
289 #else | |
290 CloseAllBrowsers(); | 279 CloseAllBrowsers(); |
291 | 280 |
292 // Send out notification. This is used during testing so that the test harness | 281 // Send out notification. This is used during testing so that the test harness |
293 // can properly shutdown before we exit. | 282 // can properly shutdown before we exit. |
294 content::NotificationService::current()->Notify( | 283 content::NotificationService::current()->Notify( |
295 chrome::NOTIFICATION_SESSION_END, | 284 chrome::NOTIFICATION_SESSION_END, |
296 content::NotificationService::AllSources(), | 285 content::NotificationService::AllSources(), |
297 content::NotificationService::NoDetails()); | 286 content::NotificationService::NoDetails()); |
298 | 287 |
| 288 #if defined(OS_WIN) |
| 289 base::win::SetShouldCrashOnProcessDetach(false); |
| 290 #endif |
299 // This will end by terminating the process. | 291 // This will end by terminating the process. |
300 content::ImmediateShutdownAndExitProcess(); | 292 content::ImmediateShutdownAndExitProcess(); |
301 #endif // defined(OS_WIN) | |
302 } | 293 } |
303 | 294 |
304 void IncrementKeepAliveCount() { | 295 void IncrementKeepAliveCount() { |
305 // Increment the browser process refcount as long as we're keeping the | 296 // Increment the browser process refcount as long as we're keeping the |
306 // application alive. | 297 // application alive. |
307 if (!WillKeepAlive()) | 298 if (!WillKeepAlive()) |
308 g_browser_process->AddRefModule(); | 299 g_browser_process->AddRefModule(); |
309 ++g_keep_alive_count; | 300 ++g_keep_alive_count; |
310 } | 301 } |
311 | 302 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 // environment is still active. | 397 // environment is still active. |
407 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) | 398 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) |
408 return !ash::Shell::HasInstance(); | 399 return !ash::Shell::HasInstance(); |
409 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | 400 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) |
410 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); | 401 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); |
411 #endif | 402 #endif |
412 return true; | 403 return true; |
413 } | 404 } |
414 | 405 |
415 } // namespace chrome | 406 } // namespace chrome |
OLD | NEW |