Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: chrome/browser/lifetime/application_lifetime_mac.mm

Issue 11066035: [Mac] During shutdown, do not post NSApplicationWillTerminateNotification twice. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: kill_me_now Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chrome_browser_application_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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() {
13 // Last browser is closed, so call back to controller to shutdown the app. 36 static bool kill_me_now = false;
14 chrome_browser_application_mac::Terminate(); 37 CHECK(!kill_me_now);
38 kill_me_now = true;
39
40 MessageLoop::current()->PostNonNestableTask(FROM_HERE,
41 base::Bind(&PerformTerminate));
15 } 42 }
16 43
17 } // namespace browser 44 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_application_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698