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

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.
Robert Sesek 2016/10/26 18:49:41 nit: blank line after
Miguel Garcia 2016/10/28 14:53:57 Done.
4 #import <AppKit/AppKit.h>
5 #import <Foundation/Foundation.h>
6
7 #import "chrome/browser/ui/cocoa/notifications/xpc_transaction_handler.h"
8
9 @class NSUserNotificationCenter;
10
11 @implementation XPCTransactionHandler {
12 bool transactionOpen_;
13 }
Robert Sesek 2016/10/26 18:49:41 nit: blank line after
Miguel Garcia 2016/10/28 14:53:56 Done.
14 - (instancetype)init {
15 if ((self = [super init])) {
16 transactionOpen_ = NO;
Robert Sesek 2016/10/26 18:49:41 NO -> false
Miguel Garcia 2016/10/28 14:53:57 Done.
17 }
18 return self;
19 }
20
21 - (void)openTransactionIfNeeded {
22 @synchronized(self) {
23 if (transactionOpen_) {
24 return;
25 }
26 xpc_transaction_begin();
27 transactionOpen_ = YES;
Robert Sesek 2016/10/26 18:49:41 YES -> true
Miguel Garcia 2016/10/28 14:53:57 Done.
28 }
29 }
30
31 - (void)closeTransactionIfNeeded {
32 @synchronized(self) {
33 NSUserNotificationCenter* notificationCenter =
34 [NSUserNotificationCenter defaultUserNotificationCenter];
35 NSInteger showing = [[notificationCenter deliveredNotifications] count];
Robert Sesek 2016/10/26 18:49:41 -[NSArray count] returns NSUInteger
Miguel Garcia 2016/10/28 14:53:57 Done.
36 if (showing == 0) {
37 xpc_transaction_end();
38 transactionOpen_ = NO;
Robert Sesek 2016/10/26 18:49:41 NO -> false
Miguel Garcia 2016/10/28 14:53:56 Done.
39 }
40 }
41 }
42 @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