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

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

Issue 2867693004: Snapshot of all changes to get jumbo in blink and content.
Patch Set: Exclude certain files from jumbo because of a Windows problem Created 3 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 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 <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/threading/thread_local.h" 12 #include "base/threading/thread_local.h"
13 #include "content/child/notifications/notification_data_conversions.h" 13 #include "content/child/notifications/notification_data_conversions.h"
14 #include "content/child/notifications/notification_dispatcher.h" 14 #include "content/child/notifications/notification_dispatcher.h"
15 #include "content/child/service_worker/web_service_worker_registration_impl.h" 15 #include "content/child/service_worker/web_service_worker_registration_impl.h"
16 #include "content/child/thread_safe_sender.h" 16 #include "content/child/thread_safe_sender.h"
17 #include "content/public/common/notification_resources.h" 17 #include "content/public/common/notification_resources.h"
18 #include "content/public/common/platform_notification_data.h" 18 #include "content/public/common/platform_notification_data.h"
19 #include "third_party/WebKit/public/platform/URLConversion.h" 19 #include "third_party/WebKit/public/platform/URLConversion.h"
20 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 20 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
21 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onDelegate.h" 21 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onDelegate.h"
22 #include "url/origin.h" 22 #include "url/origin.h"
23 23
24 using blink::WebString; 24 using blink::WebString;
25 25
26 namespace content { 26 namespace content {
27 namespace { 27 namespace {
28 28
29 int CurrentWorkerId() { 29 int NotificationCurrentWorkerId() {
30 return WorkerThread::GetCurrentId(); 30 return WorkerThread::GetCurrentId();
31 } 31 }
32 32
33 NotificationResources ToNotificationResources( 33 NotificationResources ToNotificationResources(
34 std::unique_ptr<blink::WebNotificationResources> web_resources) { 34 std::unique_ptr<blink::WebNotificationResources> web_resources) {
35 NotificationResources resources; 35 NotificationResources resources;
36 resources.image = web_resources->image; 36 resources.image = web_resources->image;
37 resources.notification_icon = web_resources->icon; 37 resources.notification_icon = web_resources->icon;
38 resources.badge = web_resources->badge; 38 resources.badge = web_resources->badge;
39 for (const auto& action_icon : web_resources->action_icons) 39 for (const auto& action_icon : web_resources->action_icons)
(...skipping 27 matching lines...) Expand all
67 } 67 }
68 68
69 NotificationManager* NotificationManager::ThreadSpecificInstance( 69 NotificationManager* NotificationManager::ThreadSpecificInstance(
70 ThreadSafeSender* thread_safe_sender, 70 ThreadSafeSender* thread_safe_sender,
71 NotificationDispatcher* notification_dispatcher) { 71 NotificationDispatcher* notification_dispatcher) {
72 if (g_notification_manager_tls.Pointer()->Get()) 72 if (g_notification_manager_tls.Pointer()->Get())
73 return g_notification_manager_tls.Pointer()->Get(); 73 return g_notification_manager_tls.Pointer()->Get();
74 74
75 NotificationManager* manager = 75 NotificationManager* manager =
76 new NotificationManager(thread_safe_sender, notification_dispatcher); 76 new NotificationManager(thread_safe_sender, notification_dispatcher);
77 if (CurrentWorkerId()) 77 if (NotificationCurrentWorkerId())
78 WorkerThread::AddObserver(manager); 78 WorkerThread::AddObserver(manager);
79 return manager; 79 return manager;
80 } 80 }
81 81
82 void NotificationManager::WillStopCurrentWorkerThread() { 82 void NotificationManager::WillStopCurrentWorkerThread() {
83 delete this; 83 delete this;
84 } 84 }
85 85
86 void NotificationManager::Show( 86 void NotificationManager::Show(
87 const blink::WebSecurityOrigin& origin, 87 const blink::WebSecurityOrigin& origin,
88 const blink::WebNotificationData& notification_data, 88 const blink::WebNotificationData& notification_data,
89 std::unique_ptr<blink::WebNotificationResources> notification_resources, 89 std::unique_ptr<blink::WebNotificationResources> notification_resources,
90 blink::WebNotificationDelegate* delegate) { 90 blink::WebNotificationDelegate* delegate) {
91 DCHECK_EQ(0u, notification_data.actions.size()); 91 DCHECK_EQ(0u, notification_data.actions.size());
92 DCHECK_EQ(0u, notification_resources->action_icons.size()); 92 DCHECK_EQ(0u, notification_resources->action_icons.size());
93 93
94 GURL origin_gurl = url::Origin(origin).GetURL(); 94 GURL origin_gurl = url::Origin(origin).GetURL();
95 95
96 int notification_id = 96 int notification_id =
97 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); 97 notification_dispatcher_->GenerateNotificationId(NotificationCurrentWorker Id());
98 98
99 active_page_notifications_[notification_id] = ActiveNotificationData( 99 active_page_notifications_[notification_id] = ActiveNotificationData(
100 delegate, origin_gurl, 100 delegate, origin_gurl,
101 notification_data.tag.Utf8( 101 notification_data.tag.Utf8(
102 WebString::UTF8ConversionMode::kStrictReplacingErrorsWithFFFD)); 102 WebString::UTF8ConversionMode::kStrictReplacingErrorsWithFFFD));
103 103
104 // TODO(mkwst): This is potentially doing the wrong thing with unique 104 // TODO(mkwst): This is potentially doing the wrong thing with unique
105 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See 105 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See
106 // https://crbug.com/490074 for detail. 106 // https://crbug.com/490074 for detail.
107 thread_safe_sender_->Send(new PlatformNotificationHostMsg_Show( 107 thread_safe_sender_->Send(new PlatformNotificationHostMsg_Show(
(...skipping 30 matching lines...) Expand all
138 UMA_HISTOGRAM_COUNTS_1000("Notifications.AuthorDataSize", author_data_size); 138 UMA_HISTOGRAM_COUNTS_1000("Notifications.AuthorDataSize", author_data_size);
139 139
140 if (author_data_size > PlatformNotificationData::kMaximumDeveloperDataSize) { 140 if (author_data_size > PlatformNotificationData::kMaximumDeveloperDataSize) {
141 callbacks->OnError(); 141 callbacks->OnError();
142 return; 142 return;
143 } 143 }
144 144
145 // TODO(peter): GenerateNotificationId is more of a request id. Consider 145 // TODO(peter): GenerateNotificationId is more of a request id. Consider
146 // renaming the method in the NotificationDispatcher if this makes sense. 146 // renaming the method in the NotificationDispatcher if this makes sense.
147 int request_id = 147 int request_id =
148 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); 148 notification_dispatcher_->GenerateNotificationId(NotificationCurrentWorker Id());
149 149
150 pending_show_notification_requests_.AddWithID(std::move(callbacks), 150 pending_show_notification_requests_.AddWithID(std::move(callbacks),
151 request_id); 151 request_id);
152 152
153 // TODO(mkwst): This is potentially doing the wrong thing with unique 153 // TODO(mkwst): This is potentially doing the wrong thing with unique
154 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See 154 // origins. Perhaps also 'file:', 'blob:' and 'filesystem:'. See
155 // https://crbug.com/490074 for detail. 155 // https://crbug.com/490074 for detail.
156 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ShowPersistent( 156 thread_safe_sender_->Send(new PlatformNotificationHostMsg_ShowPersistent(
157 request_id, service_worker_registration_id, url::Origin(origin).GetURL(), 157 request_id, service_worker_registration_id, url::Origin(origin).GetURL(),
158 ToPlatformNotificationData(notification_data), 158 ToPlatformNotificationData(notification_data),
(...skipping 11 matching lines...) Expand all
170 static_cast<WebServiceWorkerRegistrationImpl*>( 170 static_cast<WebServiceWorkerRegistrationImpl*>(
171 service_worker_registration); 171 service_worker_registration);
172 172
173 GURL origin = GURL(service_worker_registration_impl->Scope()).GetOrigin(); 173 GURL origin = GURL(service_worker_registration_impl->Scope()).GetOrigin();
174 int64_t service_worker_registration_id = 174 int64_t service_worker_registration_id =
175 service_worker_registration_impl->RegistrationId(); 175 service_worker_registration_impl->RegistrationId();
176 176
177 // TODO(peter): GenerateNotificationId is more of a request id. Consider 177 // TODO(peter): GenerateNotificationId is more of a request id. Consider
178 // renaming the method in the NotificationDispatcher if this makes sense. 178 // renaming the method in the NotificationDispatcher if this makes sense.
179 int request_id = 179 int request_id =
180 notification_dispatcher_->GenerateNotificationId(CurrentWorkerId()); 180 notification_dispatcher_->GenerateNotificationId(NotificationCurrentWorker Id());
181 181
182 pending_get_notification_requests_.AddWithID(std::move(callbacks), 182 pending_get_notification_requests_.AddWithID(std::move(callbacks),
183 request_id); 183 request_id);
184 184
185 thread_safe_sender_->Send(new PlatformNotificationHostMsg_GetNotifications( 185 thread_safe_sender_->Send(new PlatformNotificationHostMsg_GetNotifications(
186 request_id, service_worker_registration_id, origin, 186 request_id, service_worker_registration_id, origin,
187 filter_tag.Utf8( 187 filter_tag.Utf8(
188 WebString::UTF8ConversionMode::kStrictReplacingErrorsWithFFFD))); 188 WebString::UTF8ConversionMode::kStrictReplacingErrorsWithFFFD)));
189 } 189 }
190 190
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 notifications[i] = web_notification_info; 309 notifications[i] = web_notification_info;
310 } 310 }
311 311
312 callbacks->OnSuccess(notifications); 312 callbacks->OnSuccess(notifications);
313 313
314 pending_get_notification_requests_.Remove(request_id); 314 pending_get_notification_requests_.Remove(request_id);
315 } 315 }
316 316
317 } // namespace content 317 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.cc ('k') | content/child/service_worker/service_worker_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698