Commit d32d9a39 authored by peter's avatar peter Committed by Commit bot

Verify that the RPH is still alive when handling incoming Notification IPCs.

The NotificationMessageFilter still receives a number of IPC messages on
the UI thread. It is possible that the IPC message gets handled after
the profile has been shut down, so make sure that this isn't the case
by verifying that the RenderProcessHost still exists.

BUG=457590

Review URL: https://codereview.chromium.org/1023633003

Cr-Commit-Position: refs/heads/master@{#321421}
parent 92667403
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "content/public/browser/desktop_notification_delegate.h" #include "content/public/browser/desktop_notification_delegate.h"
#include "content/public/browser/platform_notification_context.h" #include "content/public/browser/platform_notification_context.h"
#include "content/public/browser/platform_notification_service.h" #include "content/public/browser/platform_notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
namespace content { namespace content {
...@@ -81,6 +82,10 @@ void NotificationMessageFilter::OnShowPlatformNotification( ...@@ -81,6 +82,10 @@ void NotificationMessageFilter::OnShowPlatformNotification(
const GURL& origin, const GURL& origin,
const SkBitmap& icon, const SkBitmap& icon,
const PlatformNotificationData& notification_data) { const PlatformNotificationData& notification_data) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!RenderProcessHost::FromID(process_id_))
return;
scoped_ptr<DesktopNotificationDelegate> delegate( scoped_ptr<DesktopNotificationDelegate> delegate(
new PageNotificationDelegate(process_id_, notification_id)); new PageNotificationDelegate(process_id_, notification_id));
...@@ -109,6 +114,8 @@ void NotificationMessageFilter::OnShowPersistentNotification( ...@@ -109,6 +114,8 @@ void NotificationMessageFilter::OnShowPersistentNotification(
const SkBitmap& icon, const SkBitmap& icon,
const PlatformNotificationData& notification_data) { const PlatformNotificationData& notification_data) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!RenderProcessHost::FromID(process_id_))
return;
PlatformNotificationService* service = PlatformNotificationService* service =
GetContentClient()->browser()->GetPlatformNotificationService(); GetContentClient()->browser()->GetPlatformNotificationService();
...@@ -124,6 +131,10 @@ void NotificationMessageFilter::OnShowPersistentNotification( ...@@ -124,6 +131,10 @@ void NotificationMessageFilter::OnShowPersistentNotification(
void NotificationMessageFilter::OnClosePlatformNotification( void NotificationMessageFilter::OnClosePlatformNotification(
int notification_id) { int notification_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!RenderProcessHost::FromID(process_id_))
return;
if (!close_closures_.count(notification_id)) if (!close_closures_.count(notification_id))
return; return;
...@@ -135,6 +146,8 @@ void NotificationMessageFilter::OnClosePersistentNotification( ...@@ -135,6 +146,8 @@ void NotificationMessageFilter::OnClosePersistentNotification(
const GURL& origin, const GURL& origin,
const std::string& persistent_notification_id) { const std::string& persistent_notification_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!RenderProcessHost::FromID(process_id_))
return;
PlatformNotificationService* service = PlatformNotificationService* service =
GetContentClient()->browser()->GetPlatformNotificationService(); GetContentClient()->browser()->GetPlatformNotificationService();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment