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

Unified Diff: chrome/browser/ui/cocoa/notifications/alert_notification_service.mm

Issue 2419213003: Ensure the xpc transaction is ended (Closed)
Patch Set: review 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/notifications/alert_notification_service.mm
diff --git a/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm b/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm
index 45e22f821884676fd880212af456a8a4ca7d3427..d81f2b6ef1ad8514bcabd04e5fd7dbc3d27a5e66 100644
--- a/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm
+++ b/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm
@@ -7,19 +7,29 @@
#import "base/mac/scoped_nsobject.h"
#import "chrome/browser/ui/cocoa/notifications/notification_builder_mac.h"
#include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h"
+#import "chrome/browser/ui/cocoa/notifications/xpc_transaction_handler.h"
@class NSUserNotificationCenter;
-@implementation AlertNotificationService
+@implementation AlertNotificationService {
+ XPCTransactionHandler* transactionHandler_;
+}
+
+- (instancetype)initWithTransactionHandler:(XPCTransactionHandler*)handler {
+ if ((self = [super init])) {
+ transactionHandler_ = handler;
+ }
+ return self;
+}
- (void)deliverNotification:(NSDictionary*)notificationData {
base::scoped_nsobject<NotificationBuilder> builder(
[[NotificationBuilder alloc] initWithDictionary:notificationData]);
NSUserNotification* toast = [builder buildUserNotification];
-
[[NSUserNotificationCenter defaultUserNotificationCenter]
deliverNotification:toast];
+ [transactionHandler_ openTransactionIfNeeded];
}
- (void)closeNotificationWithId:(NSString*)notificationId
@@ -37,6 +47,7 @@
if ([candidateId isEqualToString:notificationId] &&
[profileId isEqualToString:candidateProfileId]) {
[notificationCenter removeDeliveredNotification:candidate];
+ [transactionHandler_ closeTransactionIfNeeded];
break;
}
}
@@ -45,6 +56,7 @@
- (void)closeAllNotifications {
[[NSUserNotificationCenter defaultUserNotificationCenter]
removeAllDeliveredNotifications];
+ [transactionHandler_ closeTransactionIfNeeded];
}
@end

Powered by Google App Engine
This is Rietveld 408576698