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

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

Issue 2888303004: Minimize the delegate dependencies for non persistent notifications. (Closed)
Patch Set: review 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..9f28e1b237ae652c6e65602869fa91d16bc58417 100644
--- a/content/browser/notifications/notification_message_filter.cc
+++ b/content/browser/notifications/notification_message_filter.cc
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/feature_list.h"
#include "content/browser/bad_message.h"
+#include "content/browser/notifications/notification_event_dispatcher_impl.h"
#include "content/browser/notifications/notification_id_generator.h"
#include "content/browser/notifications/page_notification_delegate.h"
#include "content/browser/notifications/platform_notification_context_impl.h"
@@ -90,13 +91,14 @@ NotificationMessageFilter::NotificationMessageFilter(
BrowserContext* browser_context)
: BrowserMessageFilter(PlatformNotificationMsgStart),
process_id_(process_id),
+ non_persistent__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 (non_persistent__notification_shown_) {
+ NotificationEventDispatcherImpl* event_dispatcher =
+ content::NotificationEventDispatcherImpl::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_);
+ NotificationEventDispatcherImpl* event_dispatcher =
+ content::NotificationEventDispatcherImpl::GetInstance();
+ non_persistent__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));
« no previous file with comments | « content/browser/notifications/notification_message_filter.h ('k') | content/public/browser/notification_event_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698