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

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

Issue 2419213003: Ensure the xpc transaction is ended (Closed)
Patch Set: Created 4 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/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 #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
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