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

Side by Side Diff: content/child/push_messaging/push_provider.cc

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Created 4 years, 1 month 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/push_messaging/push_provider.h" 5 #include "content/child/push_messaging/push_provider.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 delete this; 97 delete this;
98 } 98 }
99 99
100 void PushProvider::subscribe( 100 void PushProvider::subscribe(
101 blink::WebServiceWorkerRegistration* service_worker_registration, 101 blink::WebServiceWorkerRegistration* service_worker_registration,
102 const blink::WebPushSubscriptionOptions& options, 102 const blink::WebPushSubscriptionOptions& options,
103 blink::WebPushSubscriptionCallbacks* callbacks) { 103 blink::WebPushSubscriptionCallbacks* callbacks) {
104 DCHECK(service_worker_registration); 104 DCHECK(service_worker_registration);
105 DCHECK(callbacks); 105 DCHECK(callbacks);
106 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId()); 106 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId());
107 subscription_callbacks_.AddWithID(callbacks, request_id); 107 subscription_callbacks_.AddWithID(
108 std::unique_ptr<blink::WebPushSubscriptionCallbacks>(callbacks),
109 request_id);
108 int64_t service_worker_registration_id = 110 int64_t service_worker_registration_id =
109 GetServiceWorkerRegistrationId(service_worker_registration); 111 GetServiceWorkerRegistrationId(service_worker_registration);
110 PushSubscriptionOptions content_options; 112 PushSubscriptionOptions content_options;
111 content_options.user_visible_only = options.userVisibleOnly; 113 content_options.user_visible_only = options.userVisibleOnly;
112 114
113 // Just treat the server key as a string of bytes and pass it to the push 115 // Just treat the server key as a string of bytes and pass it to the push
114 // service. 116 // service.
115 content_options.sender_info = options.applicationServerKey.latin1(); 117 content_options.sender_info = options.applicationServerKey.latin1();
116 thread_safe_sender_->Send(new PushMessagingHostMsg_Subscribe( 118 thread_safe_sender_->Send(new PushMessagingHostMsg_Subscribe(
117 ChildProcessHost::kInvalidUniqueID, request_id, 119 ChildProcessHost::kInvalidUniqueID, request_id,
118 service_worker_registration_id, content_options)); 120 service_worker_registration_id, content_options));
119 } 121 }
120 122
121 void PushProvider::unsubscribe( 123 void PushProvider::unsubscribe(
122 blink::WebServiceWorkerRegistration* service_worker_registration, 124 blink::WebServiceWorkerRegistration* service_worker_registration,
123 blink::WebPushUnsubscribeCallbacks* callbacks) { 125 blink::WebPushUnsubscribeCallbacks* callbacks) {
124 DCHECK(service_worker_registration); 126 DCHECK(service_worker_registration);
125 DCHECK(callbacks); 127 DCHECK(callbacks);
126 128
127 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId()); 129 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId());
128 unsubscribe_callbacks_.AddWithID(callbacks, request_id); 130 unsubscribe_callbacks_.AddWithID(
131 std::unique_ptr<blink::WebPushUnsubscribeCallbacks>(callbacks),
132 request_id);
129 133
130 int64_t service_worker_registration_id = 134 int64_t service_worker_registration_id =
131 GetServiceWorkerRegistrationId(service_worker_registration); 135 GetServiceWorkerRegistrationId(service_worker_registration);
132 thread_safe_sender_->Send(new PushMessagingHostMsg_Unsubscribe( 136 thread_safe_sender_->Send(new PushMessagingHostMsg_Unsubscribe(
133 request_id, service_worker_registration_id)); 137 request_id, service_worker_registration_id));
134 } 138 }
135 139
136 void PushProvider::getSubscription( 140 void PushProvider::getSubscription(
137 blink::WebServiceWorkerRegistration* service_worker_registration, 141 blink::WebServiceWorkerRegistration* service_worker_registration,
138 blink::WebPushSubscriptionCallbacks* callbacks) { 142 blink::WebPushSubscriptionCallbacks* callbacks) {
139 DCHECK(service_worker_registration); 143 DCHECK(service_worker_registration);
140 DCHECK(callbacks); 144 DCHECK(callbacks);
141 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId()); 145 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId());
142 subscription_callbacks_.AddWithID(callbacks, request_id); 146 subscription_callbacks_.AddWithID(
147 std::unique_ptr<blink::WebPushSubscriptionCallbacks>(callbacks),
148 request_id);
143 int64_t service_worker_registration_id = 149 int64_t service_worker_registration_id =
144 GetServiceWorkerRegistrationId(service_worker_registration); 150 GetServiceWorkerRegistrationId(service_worker_registration);
145 thread_safe_sender_->Send(new PushMessagingHostMsg_GetSubscription( 151 thread_safe_sender_->Send(new PushMessagingHostMsg_GetSubscription(
146 request_id, service_worker_registration_id)); 152 request_id, service_worker_registration_id));
147 } 153 }
148 154
149 void PushProvider::getPermissionStatus( 155 void PushProvider::getPermissionStatus(
150 blink::WebServiceWorkerRegistration* service_worker_registration, 156 blink::WebServiceWorkerRegistration* service_worker_registration,
151 const blink::WebPushSubscriptionOptions& options, 157 const blink::WebPushSubscriptionOptions& options,
152 blink::WebPushPermissionStatusCallbacks* callbacks) { 158 blink::WebPushPermissionStatusCallbacks* callbacks) {
153 DCHECK(service_worker_registration); 159 DCHECK(service_worker_registration);
154 DCHECK(callbacks); 160 DCHECK(callbacks);
155 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId()); 161 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId());
156 permission_status_callbacks_.AddWithID(callbacks, request_id); 162 permission_status_callbacks_.AddWithID(
163 std::unique_ptr<blink::WebPushPermissionStatusCallbacks>(callbacks),
164 request_id);
157 int64_t service_worker_registration_id = 165 int64_t service_worker_registration_id =
158 GetServiceWorkerRegistrationId(service_worker_registration); 166 GetServiceWorkerRegistrationId(service_worker_registration);
159 thread_safe_sender_->Send(new PushMessagingHostMsg_GetPermissionStatus( 167 thread_safe_sender_->Send(new PushMessagingHostMsg_GetPermissionStatus(
160 request_id, service_worker_registration_id, options.userVisibleOnly)); 168 request_id, service_worker_registration_id, options.userVisibleOnly));
161 } 169 }
162 170
163 bool PushProvider::OnMessageReceived(const IPC::Message& message) { 171 bool PushProvider::OnMessageReceived(const IPC::Message& message) {
164 bool handled = true; 172 bool handled = true;
165 IPC_BEGIN_MESSAGE_MAP(PushProvider, message) 173 IPC_BEGIN_MESSAGE_MAP(PushProvider, message)
166 IPC_MESSAGE_HANDLER(PushMessagingMsg_SubscribeFromWorkerSuccess, 174 IPC_MESSAGE_HANDLER(PushMessagingMsg_SubscribeFromWorkerSuccess,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 "supported."; 306 "supported.";
299 } 307 }
300 308
301 callbacks->onError( 309 callbacks->onError(
302 blink::WebPushError(error, blink::WebString::fromUTF8(error_message))); 310 blink::WebPushError(error, blink::WebString::fromUTF8(error_message)));
303 311
304 permission_status_callbacks_.Remove(request_id); 312 permission_status_callbacks_.Remove(request_id);
305 } 313 }
306 314
307 } // namespace content 315 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698