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

Side by Side Diff: chrome/browser/ui/cocoa/notifications/xpc_transaction_handler.mm

Issue 2419213003: Ensure the xpc transaction is ended (Closed)
Patch Set: review Created 4 years, 1 month 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/ui/cocoa/notifications/xpc_transaction_handler.h ('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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import <AppKit/AppKit.h>
6 #import <Foundation/Foundation.h>
7
8 #import "chrome/browser/ui/cocoa/notifications/xpc_transaction_handler.h"
9
10 @class NSUserNotificationCenter;
11
12 @implementation XPCTransactionHandler {
13 bool transactionOpen_;
14 }
15
16 - (instancetype)init {
17 if ((self = [super init])) {
18 transactionOpen_ = false;
19 }
20 return self;
21 }
22
23 - (void)openTransactionIfNeeded {
24 @synchronized(self) {
25 if (transactionOpen_) {
26 return;
27 }
28 xpc_transaction_begin();
29 transactionOpen_ = true;
30 }
31 }
32
33 - (void)closeTransactionIfNeeded {
34 @synchronized(self) {
35 NSUserNotificationCenter* notificationCenter =
36 [NSUserNotificationCenter defaultUserNotificationCenter];
37 NSUInteger showing = [[notificationCenter deliveredNotifications] count];
38 if (showing == 0) {
39 xpc_transaction_end();
40 transactionOpen_ = false;
41 }
42 }
43 }
44 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/notifications/xpc_transaction_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698