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

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

Issue 2300093002: Make //content responsible for generating notification Ids (Closed)
Patch Set: rebase + comments Created 4 years, 3 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_event_dispatcher_impl.cc
diff --git a/content/browser/notifications/notification_event_dispatcher_impl.cc b/content/browser/notifications/notification_event_dispatcher_impl.cc
index 7c3c0586afd063390471a58b0b686c801f38caf6..9eb1ade75ffd3c59c82fb1d227f5de18b617899b 100644
--- a/content/browser/notifications/notification_event_dispatcher_impl.cc
+++ b/content/browser/notifications/notification_event_dispatcher_impl.cc
@@ -178,10 +178,10 @@ void FindServiceWorkerRegistration(
notification_action_callback, dispatch_error_callback));
}
-// Reads the data associated with the |persistent_notification_id| belonging to
-// |origin| from the notification context.
+// Reads the data associated with the |notification_id| belonging to |origin|
+// from the notification context.
void ReadNotificationDatabaseData(
- int64_t persistent_notification_id,
+ const std::string& notification_id,
const GURL& origin,
const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context,
const scoped_refptr<PlatformNotificationContext>& notification_context,
@@ -189,7 +189,7 @@ void ReadNotificationDatabaseData(
const NotificationDispatchCompleteCallback& dispatch_error_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
notification_context->ReadNotificationData(
- persistent_notification_id, origin,
+ notification_id, origin,
base::Bind(&FindServiceWorkerRegistration, origin, service_worker_context,
notification_context, notification_read_callback,
dispatch_error_callback));
@@ -255,7 +255,7 @@ void OnPersistentNotificationDataDeleted(
// Called when the persistent notification close event has been handled
// to remove the notification from the database.
void DeleteNotificationDataFromDatabase(
- const int64_t notification_id,
+ const std::string& notification_id,
const GURL& origin,
const scoped_refptr<PlatformNotificationContext>& notification_context,
const NotificationDispatchCompleteCallback& dispatch_complete_callback,
@@ -285,14 +285,14 @@ void DispatchNotificationCloseEventOnWorker(
// Actually dispatches the notification close event on the service worker
// registration.
void DoDispatchNotificationCloseEvent(
+ const std::string& notification_id,
bool by_user,
const NotificationDispatchCompleteCallback& dispatch_complete_callback,
const scoped_refptr<PlatformNotificationContext>& notification_context,
const ServiceWorkerRegistration* service_worker_registration,
const NotificationDatabaseData& notification_database_data) {
const ServiceWorkerVersion::StatusCallback dispatch_event_callback =
- base::Bind(&DeleteNotificationDataFromDatabase,
- notification_database_data.notification_id,
+ base::Bind(&DeleteNotificationDataFromDatabase, notification_id,
notification_database_data.origin, notification_context,
dispatch_complete_callback);
if (by_user) {
@@ -312,13 +312,13 @@ void DoDispatchNotificationCloseEvent(
// be done by the |notification_action_callback|.
void DispatchNotificationEvent(
BrowserContext* browser_context,
- int64_t persistent_notification_id,
+ const std::string& notification_id,
const GURL& origin,
const NotificationOperationCallbackWithContext&
notification_action_callback,
const NotificationDispatchCompleteCallback& notification_error_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK_GT(persistent_notification_id, 0);
+ DCHECK(!notification_id.empty());
DCHECK(origin.is_valid());
StoragePartition* partition =
@@ -332,8 +332,8 @@ void DispatchNotificationEvent(
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- base::Bind(&ReadNotificationDatabaseData, persistent_notification_id,
- origin, service_worker_context, notification_context,
+ base::Bind(&ReadNotificationDatabaseData, notification_id, origin,
+ service_worker_context, notification_context,
base::Bind(notification_action_callback, notification_context),
notification_error_callback));
}
@@ -357,12 +357,12 @@ NotificationEventDispatcherImpl::~NotificationEventDispatcherImpl() {}
void NotificationEventDispatcherImpl::DispatchNotificationClickEvent(
BrowserContext* browser_context,
- int64_t persistent_notification_id,
+ const std::string& notification_id,
const GURL& origin,
int action_index,
const NotificationDispatchCompleteCallback& dispatch_complete_callback) {
DispatchNotificationEvent(
- browser_context, persistent_notification_id, origin,
+ browser_context, notification_id, origin,
base::Bind(&DoDispatchNotificationClickEvent, action_index,
dispatch_complete_callback),
dispatch_complete_callback);
@@ -370,14 +370,15 @@ void NotificationEventDispatcherImpl::DispatchNotificationClickEvent(
void NotificationEventDispatcherImpl::DispatchNotificationCloseEvent(
BrowserContext* browser_context,
- int64_t persistent_notification_id,
+ const std::string& notification_id,
const GURL& origin,
bool by_user,
const NotificationDispatchCompleteCallback& dispatch_complete_callback) {
- DispatchNotificationEvent(browser_context, persistent_notification_id, origin,
- base::Bind(&DoDispatchNotificationCloseEvent,
- by_user, dispatch_complete_callback),
- dispatch_complete_callback);
+ DispatchNotificationEvent(
+ browser_context, notification_id, origin,
+ base::Bind(&DoDispatchNotificationCloseEvent, notification_id, by_user,
+ dispatch_complete_callback),
+ dispatch_complete_callback);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698