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

Side by Side Diff: content/browser/notifications/notification_event_dispatcher_impl.cc

Issue 794633002: Remove ShowDesktopNotificationHostMsgParams in favor of PlatformNotificationData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/notifications/notification_event_dispatcher_impl.h" 5 #include "content/browser/notifications/notification_event_dispatcher_impl.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "content/browser/service_worker/service_worker_context_wrapper.h" 8 #include "content/browser/service_worker/service_worker_context_wrapper.h"
9 #include "content/browser/service_worker/service_worker_registration.h" 9 #include "content/browser/service_worker/service_worker_registration.h"
10 #include "content/browser/service_worker/service_worker_storage.h" 10 #include "content/browser/service_worker/service_worker_storage.h"
11 #include "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/storage_partition.h" 13 #include "content/public/browser/storage_partition.h"
14 #include "content/public/common/show_desktop_notification_params.h" 14 #include "content/public/common/platform_notification_data.h"
15 15
16 namespace content { 16 namespace content {
17 namespace { 17 namespace {
18 18
19 using NotificationClickDispatchCompleteCallback = 19 using NotificationClickDispatchCompleteCallback =
20 NotificationEventDispatcher::NotificationClickDispatchCompleteCallback; 20 NotificationEventDispatcher::NotificationClickDispatchCompleteCallback;
21 21
22 // To be called when the notificationclick event has finished executing. Will 22 // To be called when the notificationclick event has finished executing. Will
23 // post a task to call |dispatch_complete_callback| on the UI thread. 23 // post a task to call |dispatch_complete_callback| on the UI thread.
24 void NotificationClickEventFinished( 24 void NotificationClickEventFinished(
(...skipping 27 matching lines...) Expand all
52 52
53 BrowserThread::PostTask(BrowserThread::UI, 53 BrowserThread::PostTask(BrowserThread::UI,
54 FROM_HERE, 54 FROM_HERE,
55 base::Bind(dispatch_complete_callback, status)); 55 base::Bind(dispatch_complete_callback, status));
56 } 56 }
57 57
58 // Dispatches the notificationclick on |service_worker_registration| if the 58 // Dispatches the notificationclick on |service_worker_registration| if the
59 // registration was available. Must be called on the IO thread. 59 // registration was available. Must be called on the IO thread.
60 void DispatchNotificationClickEventOnRegistration( 60 void DispatchNotificationClickEventOnRegistration(
61 const std::string& notification_id, 61 const std::string& notification_id,
62 const ShowDesktopNotificationHostMsgParams& notification_data, 62 const PlatformNotificationData& notification_data,
63 const NotificationClickDispatchCompleteCallback& dispatch_complete_callback, 63 const NotificationClickDispatchCompleteCallback& dispatch_complete_callback,
64 ServiceWorkerStatusCode service_worker_status, 64 ServiceWorkerStatusCode service_worker_status,
65 const scoped_refptr<ServiceWorkerRegistration>& 65 const scoped_refptr<ServiceWorkerRegistration>&
66 service_worker_registration) { 66 service_worker_registration) {
67 DCHECK_CURRENTLY_ON(BrowserThread::IO); 67 DCHECK_CURRENTLY_ON(BrowserThread::IO);
68 if (service_worker_status == SERVICE_WORKER_OK) { 68 if (service_worker_status == SERVICE_WORKER_OK) {
69 base::Callback<void(ServiceWorkerStatusCode)> dispatch_event_callback = 69 base::Callback<void(ServiceWorkerStatusCode)> dispatch_event_callback =
70 base::Bind(&NotificationClickEventFinished, 70 base::Bind(&NotificationClickEventFinished,
71 dispatch_complete_callback, 71 dispatch_complete_callback,
72 service_worker_registration); 72 service_worker_registration);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 FROM_HERE, 104 FROM_HERE,
105 base::Bind(dispatch_complete_callback, status)); 105 base::Bind(dispatch_complete_callback, status));
106 } 106 }
107 107
108 // Finds the ServiceWorkerRegistration associated with the |origin| and 108 // Finds the ServiceWorkerRegistration associated with the |origin| and
109 // |service_worker_registration_id|. Must be called on the IO thread. 109 // |service_worker_registration_id|. Must be called on the IO thread.
110 void FindServiceWorkerRegistration( 110 void FindServiceWorkerRegistration(
111 const GURL& origin, 111 const GURL& origin,
112 int64 service_worker_registration_id, 112 int64 service_worker_registration_id,
113 const std::string& notification_id, 113 const std::string& notification_id,
114 const ShowDesktopNotificationHostMsgParams& notification_data, 114 const PlatformNotificationData& notification_data,
115 const NotificationClickDispatchCompleteCallback& dispatch_complete_callback, 115 const NotificationClickDispatchCompleteCallback& dispatch_complete_callback,
116 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { 116 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) {
117 DCHECK_CURRENTLY_ON(BrowserThread::IO); 117 DCHECK_CURRENTLY_ON(BrowserThread::IO);
118 service_worker_context->context()->storage()->FindRegistrationForId( 118 service_worker_context->context()->storage()->FindRegistrationForId(
119 service_worker_registration_id, 119 service_worker_registration_id,
120 origin, 120 origin,
121 base::Bind(&DispatchNotificationClickEventOnRegistration, 121 base::Bind(&DispatchNotificationClickEventOnRegistration,
122 notification_id, 122 notification_id,
123 notification_data, 123 notification_data,
124 dispatch_complete_callback)); 124 dispatch_complete_callback));
(...skipping 14 matching lines...) Expand all
139 139
140 NotificationEventDispatcherImpl::NotificationEventDispatcherImpl() {} 140 NotificationEventDispatcherImpl::NotificationEventDispatcherImpl() {}
141 141
142 NotificationEventDispatcherImpl::~NotificationEventDispatcherImpl() {} 142 NotificationEventDispatcherImpl::~NotificationEventDispatcherImpl() {}
143 143
144 void NotificationEventDispatcherImpl::DispatchNotificationClickEvent( 144 void NotificationEventDispatcherImpl::DispatchNotificationClickEvent(
145 BrowserContext* browser_context, 145 BrowserContext* browser_context,
146 const GURL& origin, 146 const GURL& origin,
147 int64 service_worker_registration_id, 147 int64 service_worker_registration_id,
148 const std::string& notification_id, 148 const std::string& notification_id,
149 const ShowDesktopNotificationHostMsgParams& notification_data, 149 const PlatformNotificationData& notification_data,
150 const NotificationClickDispatchCompleteCallback& 150 const NotificationClickDispatchCompleteCallback&
151 dispatch_complete_callback) { 151 dispatch_complete_callback) {
152 DCHECK_CURRENTLY_ON(BrowserThread::UI); 152 DCHECK_CURRENTLY_ON(BrowserThread::UI);
153 153
154 StoragePartition* partition = 154 StoragePartition* partition =
155 BrowserContext::GetStoragePartitionForSite(browser_context, origin); 155 BrowserContext::GetStoragePartitionForSite(browser_context, origin);
156 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = 156 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context =
157 static_cast<ServiceWorkerContextWrapper*>( 157 static_cast<ServiceWorkerContextWrapper*>(
158 partition->GetServiceWorkerContext()); 158 partition->GetServiceWorkerContext());
159 BrowserThread::PostTask( 159 BrowserThread::PostTask(
160 BrowserThread::IO, 160 BrowserThread::IO,
161 FROM_HERE, 161 FROM_HERE,
162 base::Bind(&FindServiceWorkerRegistration, 162 base::Bind(&FindServiceWorkerRegistration,
163 origin, 163 origin,
164 service_worker_registration_id, 164 service_worker_registration_id,
165 notification_id, 165 notification_id,
166 notification_data, 166 notification_data,
167 dispatch_complete_callback, 167 dispatch_complete_callback,
168 service_worker_context)); 168 service_worker_context));
169 } 169 }
170 170
171 } // namespace content 171 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698