Chromium Code Reviews| Index: chrome/browser/lifetime/application_lifetime_mac.mm | 
| diff --git a/chrome/browser/lifetime/application_lifetime_mac.mm b/chrome/browser/lifetime/application_lifetime_mac.mm | 
| index 86b7fa28e49d51318db68ec0ddfec8d33a6dd0e5..abf668876b5b13cc20379d629eb27b12c24b11ad 100644 | 
| --- a/chrome/browser/lifetime/application_lifetime_mac.mm | 
| +++ b/chrome/browser/lifetime/application_lifetime_mac.mm | 
| @@ -2,16 +2,39 @@ | 
| // Use of this source code is governed by a BSD-style license that can be | 
| // found in the LICENSE file. | 
| +// This file contains the penultimate pieces of the Mac shutdown puzzle. For | 
| +// an in-depth overview of the Mac shutdown path, see the comment above | 
| +// -[BrowserCrApplication terminate:]. | 
| + | 
| #include "chrome/browser/lifetime/application_lifetime.h" | 
| +#include "base/bind.h" | 
| +#include "base/message_loop.h" | 
| #include "chrome/browser/browser_shutdown.h" | 
| #import "chrome/browser/chrome_browser_application_mac.h" | 
| namespace browser { | 
| +namespace { | 
| + | 
| +// A closure that is used to finalize application shutdown. | 
| +void PerformTerminate() { | 
| + [[NSNotificationCenter defaultCenter] | 
| + postNotificationName:NSApplicationWillTerminateNotification | 
| + object:NSApp]; | 
| +} | 
| + | 
| +} // namespace | 
| + | 
| +// At this point, the user is trying to quit (or the system is forcing the | 
| +// application to quit) and all browsers have been successfully closed. The | 
| +// final step in shutdown is to post the NSApplicationWillTerminateNotification | 
| +// to end the -[NSApplication run] event loop. That is performed via the | 
| +// MessageLoop, since this can be called via the destruction path of the last | 
| +// Browser object. | 
| 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.
 
 | 
| - // Last browser is closed, so call back to controller to shutdown the app. | 
| - chrome_browser_application_mac::Terminate(); | 
| + MessageLoop::current()->PostNonNestableTask(FROM_HERE, | 
| + base::Bind(&PerformTerminate)); | 
| } | 
| } // namespace browser |