Chromium Code Reviews| 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 528e198b6fad9f6c0d3a80010173a5109f479bd5..ad17ed2c63d3695214f7ab12ed2da91f2b687e73 100644 |
| --- a/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm |
| +++ b/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm |
| @@ -4,20 +4,41 @@ |
| #import "chrome/browser/ui/cocoa/notifications/alert_notification_service.h" |
| +#include <unistd.h> |
| + |
| #import "base/mac/scoped_nsobject.h" |
| +#include "base/strings/string_number_conversions.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" |
| #include "third_party/crashpad/crashpad/client/crashpad_client.h" |
| +#include "third_party/crashpad/crashpad/client/crashpad_info.h" |
| +#include "third_party/crashpad/crashpad/client/simple_string_dictionary.h" |
| @class NSUserNotificationCenter; |
| +namespace { |
| + |
| +crashpad::SimpleStringDictionary* GetCrashpadAnnotations() { |
| + static crashpad::SimpleStringDictionary* annotations = []() { |
| + auto* annotations = new crashpad::SimpleStringDictionary(); |
| + annotations->SetKeyValue("ptype", "AlertNotificationService.xpc"); |
| + annotations->SetKeyValue("pid", base::IntToString(getpid()).c_str()); |
| + return annotations; |
| + }(); |
| + return annotations; |
| +} |
| + |
| +} // namespace |
| + |
| @implementation AlertNotificationService { |
| XPCTransactionHandler* transactionHandler_; |
| // Ensures that the XPC service has been configured for crash reporting. |
| // Other messages should not be sent to a new instance of the service |
| // before -setMachExceptionPort: is called. |
| + // Because XPC callouts occur on a concurrent dispatch queue, this must be |
| + // accessed in a @synchronized(self) block. |
| BOOL didSetExceptionPort_; |
| } |
| @@ -35,9 +56,18 @@ |
| return; |
| } |
| - crashpad::CrashpadClient client; |
| - didSetExceptionPort_ = client.SetHandlerMachPort(std::move(sendRight)); |
| - DCHECK(didSetExceptionPort_); |
| + @synchronized(self) { |
| + if (didSetExceptionPort_) { |
| + return; |
| + } |
| + |
| + crashpad::CrashpadClient client; |
| + didSetExceptionPort_ = client.SetHandlerMachPort(std::move(sendRight)); |
| + DCHECK(didSetExceptionPort_); |
| + } |
| + |
| + crashpad::CrashpadInfo::GetCrashpadInfo()->set_simple_annotations( |
|
Mark Mentovai
2017/03/30 18:00:50
This should move into the @synchronized block.
Ot
Robert Sesek
2017/03/30 18:04:22
Done.
|
| + GetCrashpadAnnotations()); |
| } |
| - (void)deliverNotification:(NSDictionary*)notificationData { |