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

Unified Diff: content/browser/notifications/notification_message_filter.cc

Issue 2888303004: Minimize the delegate dependencies for non persistent notifications. (Closed)
Patch Set: more fixes Created 3 years, 7 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: content/browser/notifications/notification_message_filter.cc
diff --git a/content/browser/notifications/notification_message_filter.cc b/content/browser/notifications/notification_message_filter.cc
index 56064347d26ab470e7c5aa4d74596e7273e25d19..823eeadc428e76cd98d5f7537bf24357fa4d90b2 100644
--- a/content/browser/notifications/notification_message_filter.cc
+++ b/content/browser/notifications/notification_message_filter.cc
@@ -20,6 +20,7 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/desktop_notification_delegate.h"
#include "content/public/browser/notification_database_data.h"
+#include "content/public/browser/notification_event_dispatcher.h"
#include "content/public/browser/platform_notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_client.h"
@@ -90,13 +91,14 @@ NotificationMessageFilter::NotificationMessageFilter(
BrowserContext* browser_context)
: BrowserMessageFilter(PlatformNotificationMsgStart),
process_id_(process_id),
+ platform_notification_shown_(false),
notification_context_(notification_context),
resource_context_(resource_context),
service_worker_context_(service_worker_context),
browser_context_(browser_context),
weak_factory_io_(this) {}
-NotificationMessageFilter::~NotificationMessageFilter() {}
+NotificationMessageFilter::~NotificationMessageFilter() = default;
void NotificationMessageFilter::DidCloseNotification(
const std::string& notification_id) {
@@ -105,6 +107,12 @@ void NotificationMessageFilter::DidCloseNotification(
}
void NotificationMessageFilter::OnDestruct() const {
+ if (platform_notification_shown_) {
Peter Beverloo 2017/05/31 17:52:43 Just always call it? We'd bail out super early in
Miguel Garcia 2017/06/01 17:00:53 I'm fine with that, it's only that this is called
Peter Beverloo 2017/06/01 17:56:27 We have one NMF per renderer process, so it's much
Miguel Garcia 2017/06/02 12:37:13 As discussed offline I am keeping it with a more c
+ NotificationEventDispatcher* event_dispatcher =
+ content::NotificationEventDispatcher::GetInstance();
+ DCHECK(event_dispatcher);
+ event_dispatcher->RendererGone(process_id_);
+ }
BrowserThread::DeleteOnIOThread::Destruct(this);
}
@@ -161,6 +169,12 @@ void NotificationMessageFilter::OnShowPlatformNotification(
origin, notification_data.tag, non_persistent_notification_id,
process_id_);
+ NotificationEventDispatcher* event_dispatcher =
+ content::NotificationEventDispatcher::GetInstance();
+ platform_notification_shown_ = true;
+ event_dispatcher->RegisterNonPersistentNotification(
+ notification_id, process_id_, non_persistent_notification_id);
+
std::unique_ptr<DesktopNotificationDelegate> delegate(
new PageNotificationDelegate(process_id_, non_persistent_notification_id,
notification_id));

Powered by Google App Engine
This is Rietveld 408576698