OLD | NEW |
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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 subscription_callbacks_.Remove(request_id); | 177 subscription_callbacks_.Remove(request_id); |
178 } | 178 } |
179 | 179 |
180 void PushProvider::OnUnsubscribeSuccess(int request_id, bool did_unsubscribe) { | 180 void PushProvider::OnUnsubscribeSuccess(int request_id, bool did_unsubscribe) { |
181 blink::WebPushUnsubscribeCallbacks* callbacks = | 181 blink::WebPushUnsubscribeCallbacks* callbacks = |
182 unsubscribe_callbacks_.Lookup(request_id); | 182 unsubscribe_callbacks_.Lookup(request_id); |
183 if (!callbacks) | 183 if (!callbacks) |
184 return; | 184 return; |
185 | 185 |
186 callbacks->onSuccess(&did_unsubscribe); | 186 callbacks->onSuccess(did_unsubscribe); |
187 | 187 |
188 unsubscribe_callbacks_.Remove(request_id); | 188 unsubscribe_callbacks_.Remove(request_id); |
189 } | 189 } |
190 | 190 |
191 void PushProvider::OnUnsubscribeError( | 191 void PushProvider::OnUnsubscribeError( |
192 int request_id, | 192 int request_id, |
193 blink::WebPushError::ErrorType error_type, | 193 blink::WebPushError::ErrorType error_type, |
194 const std::string& error_message) { | 194 const std::string& error_message) { |
195 blink::WebPushUnsubscribeCallbacks* callbacks = | 195 blink::WebPushUnsubscribeCallbacks* callbacks = |
196 unsubscribe_callbacks_.Lookup(request_id); | 196 unsubscribe_callbacks_.Lookup(request_id); |
197 if (!callbacks) | 197 if (!callbacks) |
198 return; | 198 return; |
199 | 199 |
200 scoped_ptr<blink::WebPushError> error(new blink::WebPushError( | 200 callbacks->onError(blink::WebPushError( |
201 error_type, blink::WebString::fromUTF8(error_message))); | 201 error_type, blink::WebString::fromUTF8(error_message))); |
202 callbacks->onError(error.release()); | |
203 | 202 |
204 unsubscribe_callbacks_.Remove(request_id); | 203 unsubscribe_callbacks_.Remove(request_id); |
205 } | 204 } |
206 | 205 |
207 void PushProvider::OnGetRegistrationSuccess( | 206 void PushProvider::OnGetRegistrationSuccess( |
208 int request_id, | 207 int request_id, |
209 const GURL& endpoint, | 208 const GURL& endpoint, |
210 const std::vector<uint8_t>& curve25519dh) { | 209 const std::vector<uint8_t>& curve25519dh) { |
211 blink::WebPushSubscriptionCallbacks* callbacks = | 210 blink::WebPushSubscriptionCallbacks* callbacks = |
212 subscription_callbacks_.Lookup(request_id); | 211 subscription_callbacks_.Lookup(request_id); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 263 |
265 scoped_ptr<blink::WebPushError> web_error(new blink::WebPushError( | 264 scoped_ptr<blink::WebPushError> web_error(new blink::WebPushError( |
266 error, blink::WebString::fromUTF8(error_message))); | 265 error, blink::WebString::fromUTF8(error_message))); |
267 | 266 |
268 callbacks->onError(web_error.release()); | 267 callbacks->onError(web_error.release()); |
269 | 268 |
270 permission_status_callbacks_.Remove(request_id); | 269 permission_status_callbacks_.Remove(request_id); |
271 } | 270 } |
272 | 271 |
273 } // namespace content | 272 } // namespace content |
OLD | NEW |