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

Side by Side Diff: content/child/notifications/notification_manager.cc

Issue 1026853002: Integrate the notification database with the normal code path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-db-ConfirmShow
Patch Set: Created 5 years, 8 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 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/child/notifications/notification_manager.h" 5 #include "content/child/notifications/notification_manager.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
9 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
10 #include "base/threading/thread_local.h" 11 #include "base/threading/thread_local.h"
11 #include "content/child/notifications/notification_data_conversions.h" 12 #include "content/child/notifications/notification_data_conversions.h"
12 #include "content/child/notifications/notification_dispatcher.h" 13 #include "content/child/notifications/notification_dispatcher.h"
13 #include "content/child/service_worker/web_service_worker_registration_impl.h" 14 #include "content/child/service_worker/web_service_worker_registration_impl.h"
14 #include "content/child/thread_safe_sender.h" 15 #include "content/child/thread_safe_sender.h"
15 #include "content/child/worker_task_runner.h" 16 #include "content/child/worker_task_runner.h"
16 #include "content/public/common/platform_notification_data.h" 17 #include "content/public/common/platform_notification_data.h"
17 #include "third_party/WebKit/public/platform/WebSerializedOrigin.h" 18 #include "third_party/WebKit/public/platform/WebSerializedOrigin.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return; 158 return;
158 } 159 }
159 160
160 // It should not be possible for Blink to call close() on a Notification which 161 // It should not be possible for Blink to call close() on a Notification which
161 // does not exist in either the pending or active notification lists. 162 // does not exist in either the pending or active notification lists.
162 NOTREACHED(); 163 NOTREACHED();
163 } 164 }
164 165
165 void NotificationManager::closePersistent( 166 void NotificationManager::closePersistent(
166 const blink::WebSerializedOrigin& origin, 167 const blink::WebSerializedOrigin& origin,
167 const blink::WebString& persistent_notification_id) { 168 const blink::WebString& persistent_notification_id_string) {
169 // TODO(peter): Blink should store the persistent_notification_id as an
170 // int64_t instead of a string. The id, created by Chromium, is a decimal
171 // number that fits in an int64_t, so convert it until the API updates.
172 base::string16 string_value = persistent_notification_id_string;
173
174 int64_t persistent_notification_id = 0;
175 if (!base::StringToInt64(string_value,
176 &persistent_notification_id)) {
177 NOTREACHED() << "Unable to close persistent notification; invalid id: "
178 << string_value;
179 return;
180 }
181
168 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ClosePersistent( 182 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ClosePersistent(
169 GURL(origin.string()), 183 GURL(origin.string()),
170 base::UTF16ToUTF8(persistent_notification_id))); 184 persistent_notification_id));
171 } 185 }
172 186
173 void NotificationManager::notifyDelegateDestroyed( 187 void NotificationManager::notifyDelegateDestroyed(
174 blink::WebNotificationDelegate* delegate) { 188 blink::WebNotificationDelegate* delegate) {
175 if (pending_notifications_.CancelPageNotificationFetches(delegate)) 189 if (pending_notifications_.CancelPageNotificationFetches(delegate))
176 return; 190 return;
177 191
178 for (auto& iter : active_page_notifications_) { 192 for (auto& iter : active_page_notifications_) {
179 if (iter.second != delegate) 193 if (iter.second != delegate)
180 continue; 194 continue;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 thread_safe_sender_->Send( 327 thread_safe_sender_->Send(
314 new PlatformNotificationHostMsg_ShowPersistent( 328 new PlatformNotificationHostMsg_ShowPersistent(
315 request_id, 329 request_id,
316 service_worker_registration_id, 330 service_worker_registration_id,
317 GURL(origin.string()), 331 GURL(origin.string()),
318 icon, 332 icon,
319 ToPlatformNotificationData(notification_data))); 333 ToPlatformNotificationData(notification_data)));
320 } 334 }
321 335
322 } // namespace content 336 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/notifications/notification_message_filter.cc ('k') | content/common/platform_notification_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698