diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index f071005e6365..bc5afafaec3b 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -8,6 +8,7 @@ #include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/window_list.h" +#include "base/message_loop/message_loop.h" namespace atom { @@ -30,11 +31,16 @@ void Browser::Quit() { atom::WindowList* window_list = atom::WindowList::GetInstance(); if (window_list->size() == 0) - NotifyAndTerminate(); + NotifyAndShutdown(); window_list->CloseAllWindows(); } +void Browser::Shutdown() { + is_quiting_ = true; + base::MessageLoop::current()->Quit(); +} + std::string Browser::GetVersion() const { if (version_override_.empty()) { std::string version = GetExecutableFileVersion(); @@ -88,7 +94,7 @@ void Browser::DidFinishLaunching() { FOR_EACH_OBSERVER(BrowserObserver, observers_, OnFinishLaunching()); } -void Browser::NotifyAndTerminate() { +void Browser::NotifyAndShutdown() { bool prevent_default = false; FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillQuit(&prevent_default)); @@ -97,7 +103,7 @@ void Browser::NotifyAndTerminate() { return; } - Terminate(); + Shutdown(); } void Browser::OnWindowCloseCancelled(NativeWindow* window) { @@ -112,7 +118,7 @@ void Browser::OnWindowCloseCancelled(NativeWindow* window) { void Browser::OnWindowAllClosed() { if (is_quiting_) - NotifyAndTerminate(); + NotifyAndShutdown(); else FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWindowAllClosed()); } diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 89481b2ec642..d8dd38a05ffc 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -26,8 +26,8 @@ class Browser : public WindowListObserver { // Try to close all windows and quit the application. void Quit(); - // Quit the application immediately without cleanup work. - void Terminate(); + // Cleanup everything and shutdown the application gracefully. + void Shutdown(); // Focus the application. void Focus(); @@ -88,8 +88,8 @@ class Browser : public WindowListObserver { // Returns the name of application bundle or executable file. std::string GetExecutableFileProductName() const; - // Send the will-quit message and then terminate the application. - void NotifyAndTerminate(); + // Send the will-quit message and then shutdown the application. + void NotifyAndShutdown(); // Tell the system we have cancelled quiting. void CancelQuit(); diff --git a/atom/browser/browser_linux.cc b/atom/browser/browser_linux.cc index a62042710d40..c8d50a722ecf 100644 --- a/atom/browser/browser_linux.cc +++ b/atom/browser/browser_linux.cc @@ -12,11 +12,6 @@ namespace atom { -void Browser::Terminate() { - is_quiting_ = true; - exit(0); -} - void Browser::Focus() { // Focus on the first visible window. WindowList* list = WindowList::GetInstance(); diff --git a/atom/browser/browser_mac.mm b/atom/browser/browser_mac.mm index d88be3ca5985..23404edd56ce 100644 --- a/atom/browser/browser_mac.mm +++ b/atom/browser/browser_mac.mm @@ -10,11 +10,6 @@ namespace atom { -void Browser::Terminate() { - is_quiting_ = true; - [[AtomApplication sharedApplication] terminate:nil]; -} - void Browser::Focus() { [[AtomApplication sharedApplication] activateIgnoringOtherApps:YES]; } diff --git a/atom/browser/browser_win.cc b/atom/browser/browser_win.cc index 74953cf09032..c0698f8f3637 100644 --- a/atom/browser/browser_win.cc +++ b/atom/browser/browser_win.cc @@ -33,11 +33,6 @@ BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) { } // namespace -void Browser::Terminate() { - is_quiting_ = true; - PostQuitMessage(0); -} - void Browser::Focus() { // On Windows we just focus on the first window found for this process. DWORD pid = GetCurrentProcessId();