Chromium Code Reviews| 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" | |
| 15 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 16 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/browser_process_platform_part.h" | 19 #include "chrome/browser/browser_process_platform_part.h" |
| 18 #include "chrome/browser/browser_shutdown.h" | 20 #include "chrome/browser/browser_shutdown.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/download/download_service.h" | 22 #include "chrome/browser/download/download_service.h" |
| 21 #include "chrome/browser/lifetime/browser_close_manager.h" | 23 #include "chrome/browser/lifetime/browser_close_manager.h" |
| 22 #include "chrome/browser/metrics/thread_watcher.h" | 24 #include "chrome/browser/metrics/thread_watcher.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION); | 271 browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION); |
| 270 | 272 |
| 271 content::NotificationService::current()->Notify( | 273 content::NotificationService::current()->Notify( |
| 272 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 274 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
| 273 content::NotificationService::AllSources(), | 275 content::NotificationService::AllSources(), |
| 274 content::NotificationService::NoDetails()); | 276 content::NotificationService::NoDetails()); |
| 275 | 277 |
| 276 // Write important data first. | 278 // Write important data first. |
| 277 g_browser_process->EndSession(); | 279 g_browser_process->EndSession(); |
| 278 | 280 |
| 281 #if defined(OS_WIN) | |
| 282 // On Windows 7 and later, the system will consider the process ripe for | |
| 283 // termination as soon as it hides or destroys its windows. Since any | |
| 284 // execution past that point will be non-deterministically cut short, we | |
| 285 // might as well put ourselves out of that misery deterministically. | |
| 286 base::KillProcess(base::Process::Current().handle(), 0, false); | |
| 287 #else | |
| 279 CloseAllBrowsers(); | 288 CloseAllBrowsers(); |
| 280 | 289 |
| 281 // Send out notification. This is used during testing so that the test harness | 290 // Send out notification. This is used during testing so that the test harness |
| 282 // can properly shutdown before we exit. | 291 // can properly shutdown before we exit. |
|
gab
2014/06/23 21:09:53
From this comment it appears tests may expect this
Sigurður Ásgeirsson
2014/06/23 21:39:59
Thanks, I guess we'll see - I have a hard time bel
| |
| 283 content::NotificationService::current()->Notify( | 292 content::NotificationService::current()->Notify( |
| 284 chrome::NOTIFICATION_SESSION_END, | 293 chrome::NOTIFICATION_SESSION_END, |
| 285 content::NotificationService::AllSources(), | 294 content::NotificationService::AllSources(), |
| 286 content::NotificationService::NoDetails()); | 295 content::NotificationService::NoDetails()); |
| 287 | 296 |
| 288 #if defined(OS_WIN) | |
| 289 base::win::SetShouldCrashOnProcessDetach(false); | |
|
gab
2014/06/23 21:09:54
Don't you still want to set this before killing th
Sigurður Ásgeirsson
2014/06/23 21:39:59
It really doesn't matter, as TerminateProcess impl
| |
| 290 #endif | |
| 291 // This will end by terminating the process. | 297 // This will end by terminating the process. |
| 292 content::ImmediateShutdownAndExitProcess(); | 298 content::ImmediateShutdownAndExitProcess(); |
| 299 #endif // defined(OS_WIN) | |
| 293 } | 300 } |
| 294 | 301 |
| 295 void IncrementKeepAliveCount() { | 302 void IncrementKeepAliveCount() { |
| 296 // Increment the browser process refcount as long as we're keeping the | 303 // Increment the browser process refcount as long as we're keeping the |
| 297 // application alive. | 304 // application alive. |
| 298 if (!WillKeepAlive()) | 305 if (!WillKeepAlive()) |
| 299 g_browser_process->AddRefModule(); | 306 g_browser_process->AddRefModule(); |
| 300 ++g_keep_alive_count; | 307 ++g_keep_alive_count; |
| 301 } | 308 } |
| 302 | 309 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 // environment is still active. | 404 // environment is still active. |
| 398 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) | 405 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) |
| 399 return !ash::Shell::HasInstance(); | 406 return !ash::Shell::HasInstance(); |
| 400 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | 407 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) |
| 401 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); | 408 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); |
| 402 #endif | 409 #endif |
| 403 return true; | 410 return true; |
| 404 } | 411 } |
| 405 | 412 |
| 406 } // namespace chrome | 413 } // namespace chrome |
| OLD | NEW |