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

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

Issue 1568073002: Reduce string copies in GURL creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 <cmath> 7 #include <cmath>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "base/threading/thread_local.h" 14 #include "base/threading/thread_local.h"
15 #include "content/child/notifications/notification_data_conversions.h" 15 #include "content/child/notifications/notification_data_conversions.h"
16 #include "content/child/notifications/notification_dispatcher.h" 16 #include "content/child/notifications/notification_dispatcher.h"
17 #include "content/child/service_worker/web_service_worker_registration_impl.h" 17 #include "content/child/service_worker/web_service_worker_registration_impl.h"
18 #include "content/child/thread_safe_sender.h" 18 #include "content/child/thread_safe_sender.h"
19 #include "content/common/notification_constants.h" 19 #include "content/common/notification_constants.h"
20 #include "content/public/common/platform_notification_data.h" 20 #include "content/public/common/platform_notification_data.h"
21 #include "third_party/WebKit/public/platform/URLConversion.h"
21 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 22 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
22 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onDelegate.h" 23 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onDelegate.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "third_party/skia/include/core/SkBitmap.h"
24 25
25 using blink::WebNotificationPermission; 26 using blink::WebNotificationPermission;
26 27
27 namespace content { 28 namespace content {
28 namespace { 29 namespace {
29 30
30 int CurrentWorkerId() { 31 int CurrentWorkerId() {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 NOTREACHED(); 176 NOTREACHED();
176 } 177 }
177 178
178 void NotificationManager::closePersistent( 179 void NotificationManager::closePersistent(
179 const blink::WebSecurityOrigin& origin, 180 const blink::WebSecurityOrigin& origin,
180 int64_t persistent_notification_id) { 181 int64_t persistent_notification_id) {
181 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ClosePersistent( 182 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ClosePersistent(
182 // TODO(mkwst): This is potentially doing the wrong thing with unique 183 // TODO(mkwst): This is potentially doing the wrong thing with unique
183 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See 184 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See
184 // https://crbug.com/490074 for detail. 185 // https://crbug.com/490074 for detail.
185 GURL(origin.toString()), persistent_notification_id)); 186 blink::WebStringToGURL(origin.toString()), persistent_notification_id));
186 } 187 }
187 188
188 void NotificationManager::notifyDelegateDestroyed( 189 void NotificationManager::notifyDelegateDestroyed(
189 blink::WebNotificationDelegate* delegate) { 190 blink::WebNotificationDelegate* delegate) {
190 if (pending_notifications_.CancelPageNotificationFetches(delegate)) 191 if (pending_notifications_.CancelPageNotificationFetches(delegate))
191 return; 192 return;
192 193
193 for (auto& iter : active_page_notifications_) { 194 for (auto& iter : active_page_notifications_) {
194 if (iter.second != delegate) 195 if (iter.second != delegate)
195 continue; 196 continue;
196 197
197 active_page_notifications_.erase(iter.first); 198 active_page_notifications_.erase(iter.first);
198 return; 199 return;
199 } 200 }
200 } 201 }
201 202
202 WebNotificationPermission NotificationManager::checkPermission( 203 WebNotificationPermission NotificationManager::checkPermission(
203 const blink::WebSecurityOrigin& origin) { 204 const blink::WebSecurityOrigin& origin) {
204 WebNotificationPermission permission = 205 WebNotificationPermission permission =
205 blink::WebNotificationPermissionAllowed; 206 blink::WebNotificationPermissionAllowed;
206 // TODO(mkwst): This is potentially doing the wrong thing with unique 207 // TODO(mkwst): This is potentially doing the wrong thing with unique
207 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See 208 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See
208 // https://crbug.com/490074 for detail. 209 // https://crbug.com/490074 for detail.
209 thread_safe_sender_->Send(new PlatformNotificationHostMsg_CheckPermission( 210 thread_safe_sender_->Send(new PlatformNotificationHostMsg_CheckPermission(
210 GURL(origin.toString()), &permission)); 211 blink::WebStringToGURL(origin.toString()), &permission));
211 212
212 return permission; 213 return permission;
213 } 214 }
214 215
215 size_t NotificationManager::maxActions() { 216 size_t NotificationManager::maxActions() {
216 return kPlatformNotificationMaxActions; 217 return kPlatformNotificationMaxActions;
217 } 218 }
218 219
219 bool NotificationManager::OnMessageReceived(const IPC::Message& message) { 220 bool NotificationManager::OnMessageReceived(const IPC::Message& message) {
220 bool handled = true; 221 bool handled = true;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 blink::WebNotificationDelegate* delegate, 306 blink::WebNotificationDelegate* delegate,
306 const SkBitmap& icon) { 307 const SkBitmap& icon) {
307 int notification_id = 308 int notification_id =
308 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); 309 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId());
309 310
310 active_page_notifications_[notification_id] = delegate; 311 active_page_notifications_[notification_id] = delegate;
311 // TODO(mkwst): This is potentially doing the wrong thing with unique 312 // TODO(mkwst): This is potentially doing the wrong thing with unique
312 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See 313 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See
313 // https://crbug.com/490074 for detail. 314 // https://crbug.com/490074 for detail.
314 thread_safe_sender_->Send(new PlatformNotificationHostMsg_Show( 315 thread_safe_sender_->Send(new PlatformNotificationHostMsg_Show(
315 notification_id, GURL(origin.toString()), icon, 316 notification_id, blink::WebStringToGURL(origin.toString()), icon,
316 ToPlatformNotificationData(notification_data))); 317 ToPlatformNotificationData(notification_data)));
317 } 318 }
318 319
319 void NotificationManager::DisplayPersistentNotification( 320 void NotificationManager::DisplayPersistentNotification(
320 const blink::WebSecurityOrigin& origin, 321 const blink::WebSecurityOrigin& origin,
321 const blink::WebNotificationData& notification_data, 322 const blink::WebNotificationData& notification_data,
322 int64_t service_worker_registration_id, 323 int64_t service_worker_registration_id,
323 scoped_ptr<blink::WebNotificationShowCallbacks> callbacks, 324 scoped_ptr<blink::WebNotificationShowCallbacks> callbacks,
324 const SkBitmap& icon) { 325 const SkBitmap& icon) {
325 // TODO(peter): GenerateNotificationId is more of a request id. Consider 326 // TODO(peter): GenerateNotificationId is more of a request id. Consider
326 // renaming the method in the NotificationDispatcher if this makes sense. 327 // renaming the method in the NotificationDispatcher if this makes sense.
327 int request_id = 328 int request_id =
328 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); 329 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId());
329 330
330 pending_show_notification_requests_.AddWithID(callbacks.release(), 331 pending_show_notification_requests_.AddWithID(callbacks.release(),
331 request_id); 332 request_id);
332 333
333 // TODO(mkwst): This is potentially doing the wrong thing with unique 334 // TODO(mkwst): This is potentially doing the wrong thing with unique
334 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See 335 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See
335 // https://crbug.com/490074 for detail. 336 // https://crbug.com/490074 for detail.
336 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ShowPersistent( 337 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ShowPersistent(
337 request_id, service_worker_registration_id, GURL(origin.toString()), icon, 338 request_id, service_worker_registration_id,
339 blink::WebStringToGURL(origin.toString()), icon,
338 ToPlatformNotificationData(notification_data))); 340 ToPlatformNotificationData(notification_data)));
339 } 341 }
340 342
341 } // namespace content 343 } // namespace content
OLDNEW
« no previous file with comments | « content/child/notifications/notification_data_conversions.cc ('k') | content/renderer/dom_storage/webstoragenamespace_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698