Delay notification events to next tick
It is possible that the events get emitted when calling Show(), which would then delete the class before Show() ends, results in using members of a deleted class. By delaying the events to next tick we can effectively avoid this.
This commit is contained in:
		
					parent
					
						
							
								f4c27c6d29
							
						
					
				
			
			
				commit
				
					
						593fb8cdf0
					
				
			
		
					 1 changed files with 10 additions and 3 deletions
				
			
		|  | @ -12,6 +12,7 @@ | ||||||
| #include "browser/win/scoped_hstring.h" | #include "browser/win/scoped_hstring.h" | ||||||
| #include "browser/win/notification_presenter_win.h" | #include "browser/win/notification_presenter_win.h" | ||||||
| #include "common/application_info.h" | #include "common/application_info.h" | ||||||
|  | #include "content/public/browser/browser_thread.h" | ||||||
| 
 | 
 | ||||||
| using namespace ABI::Windows::Data::Xml::Dom; | using namespace ABI::Windows::Data::Xml::Dom; | ||||||
| 
 | 
 | ||||||
|  | @ -384,21 +385,27 @@ ToastEventHandler::~ToastEventHandler() { | ||||||
| 
 | 
 | ||||||
| IFACEMETHODIMP ToastEventHandler::Invoke( | IFACEMETHODIMP ToastEventHandler::Invoke( | ||||||
|     ABI::Windows::UI::Notifications::IToastNotification* sender, IInspectable* args) { |     ABI::Windows::UI::Notifications::IToastNotification* sender, IInspectable* args) { | ||||||
|   notification_->NotificationClicked(); |   content::BrowserThread::PostTask( | ||||||
|  |       content::BrowserThread::UI, FROM_HERE, | ||||||
|  |       base::Bind(&Notification::NotificationClicked, notification_)); | ||||||
|   return S_OK; |   return S_OK; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| IFACEMETHODIMP ToastEventHandler::Invoke( | IFACEMETHODIMP ToastEventHandler::Invoke( | ||||||
|     ABI::Windows::UI::Notifications::IToastNotification* sender, |     ABI::Windows::UI::Notifications::IToastNotification* sender, | ||||||
|     ABI::Windows::UI::Notifications::IToastDismissedEventArgs* e) { |     ABI::Windows::UI::Notifications::IToastDismissedEventArgs* e) { | ||||||
|   notification_->NotificationDismissed(); |   content::BrowserThread::PostTask( | ||||||
|  |       content::BrowserThread::UI, FROM_HERE, | ||||||
|  |       base::Bind(&Notification::NotificationDismissed, notification_)); | ||||||
|   return S_OK; |   return S_OK; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| IFACEMETHODIMP ToastEventHandler::Invoke( | IFACEMETHODIMP ToastEventHandler::Invoke( | ||||||
|     ABI::Windows::UI::Notifications::IToastNotification* sender, |     ABI::Windows::UI::Notifications::IToastNotification* sender, | ||||||
|     ABI::Windows::UI::Notifications::IToastFailedEventArgs* e) { |     ABI::Windows::UI::Notifications::IToastFailedEventArgs* e) { | ||||||
|   notification_->NotificationFailed(); |   content::BrowserThread::PostTask( | ||||||
|  |       content::BrowserThread::UI, FROM_HERE, | ||||||
|  |       base::Bind(&Notification::NotificationFailed, notification_)); | ||||||
|   return S_OK; |   return S_OK; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Cheng Zhao
				Cheng Zhao