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 // This file contains the penultimate pieces of the Mac shutdown puzzle. For | |
| 6 // an in-depth overview of the Mac shutdown path, see the comment above | |
| 7 // -[BrowserCrApplication terminate:]. | |
| 8 | |
| 5 #include "chrome/browser/lifetime/application_lifetime.h" | 9 #include "chrome/browser/lifetime/application_lifetime.h" |
| 6 | 10 |
| 11 #include "base/bind.h" | |
| 12 #include "base/message_loop.h" | |
| 7 #include "chrome/browser/browser_shutdown.h" | 13 #include "chrome/browser/browser_shutdown.h" |
| 8 #import "chrome/browser/chrome_browser_application_mac.h" | 14 #import "chrome/browser/chrome_browser_application_mac.h" |
| 9 | 15 |
| 10 namespace browser { | 16 namespace browser { |
| 11 | 17 |
| 18 namespace { | |
| 19 | |
| 20 // A closure that is used to finalize application shutdown. | |
| 21 void PerformTerminate() { | |
| 22 [[NSNotificationCenter defaultCenter] | |
| 23 postNotificationName:NSApplicationWillTerminateNotification | |
| 24 object:NSApp]; | |
| 25 } | |
| 26 | |
| 27 } // namespace | |
| 28 | |
| 29 // At this point, the user is trying to quit (or the system is forcing the | |
| 30 // application to quit) and all browsers have been successfully closed. The | |
| 31 // final step in shutdown is to post the NSApplicationWillTerminateNotification | |
| 32 // to end the -[NSApplication run] event loop. That is performed via the | |
| 33 // MessageLoop, since this can be called via the destruction path of the last | |
| 34 // Browser object. | |
| 12 void HandleAppExitingForPlatform() { | 35 void HandleAppExitingForPlatform() { |
|
Scott Hess - ex-Googler
2012/10/05 19:04:41
static bool kill_me_now = false;
CHECK(!kill_me_
Robert Sesek
2012/10/05 19:10:43
Done.
| |
| 13 // Last browser is closed, so call back to controller to shutdown the app. | 36 MessageLoop::current()->PostNonNestableTask(FROM_HERE, |
| 14 chrome_browser_application_mac::Terminate(); | 37 base::Bind(&PerformTerminate)); |
| 15 } | 38 } |
| 16 | 39 |
| 17 } // namespace browser | 40 } // namespace browser |
| OLD | NEW |