Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #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 Boolean transactionOpen; | |
|
Robert Sesek
2016/10/24 23:11:05
Use BOOL or bool.
Robert Sesek
2016/10/24 23:11:05
naming: needs trailing underscore
Miguel Garcia
2016/10/26 15:56:38
Done.
Miguel Garcia
2016/10/26 15:56:38
Done.
| |
| 13 } | |
| 14 - (instancetype)init { | |
| 15 if ((self = [super init])) { | |
| 16 transactionOpen = NO; | |
| 17 } | |
| 18 return self; | |
| 19 } | |
| 20 | |
| 21 - (void)openTransactionIfNeeded { | |
| 22 @synchronized(self) { | |
|
Robert Sesek
2016/10/24 23:11:05
Why @synchronized here? I assume we're avoiding ba
Miguel Garcia
2016/10/26 15:56:38
We need a synchronized block because alerts are ad
| |
| 23 if (transactionOpen) { | |
| 24 return; | |
| 25 } | |
| 26 xpc_transaction_begin(); | |
| 27 transactionOpen = YES; | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 - (void)closeTransactionIfNeeded { | |
| 32 @synchronized(self) { | |
| 33 NSUserNotificationCenter* notificationCenter = | |
| 34 [NSUserNotificationCenter defaultUserNotificationCenter]; | |
| 35 NSInteger showing = [[notificationCenter deliveredNotifications] count]; | |
| 36 if (showing == 0) { | |
| 37 xpc_transaction_end(); | |
| 38 transactionOpen = NO; | |
| 39 } | |
| 40 } | |
| 41 } | |
| 42 @end | |
| OLD | NEW |