| 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 "modules/notifications/ServiceWorkerRegistrationNotifications.h" | 5 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return exceptionState.reject(scriptState); | 68 return exceptionState.reject(scriptState); |
| 69 | 69 |
| 70 // Log number of actions developer provided in linear histogram: 0 -> underf
low bucket, 1-16 -> distinct buckets, 17+ -> overflow bucket. | 70 // Log number of actions developer provided in linear histogram: 0 -> underf
low bucket, 1-16 -> distinct buckets, 17+ -> overflow bucket. |
| 71 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, notificationCountHisto
gram, new EnumerationHistogram("Notifications.PersistentNotificationActionCount"
, 17)); | 71 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, notificationCountHisto
gram, new EnumerationHistogram("Notifications.PersistentNotificationActionCount"
, 17)); |
| 72 notificationCountHistogram.count(options.actions().size()); | 72 notificationCountHistogram.count(options.actions().size()); |
| 73 | 73 |
| 74 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 74 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 75 ScriptPromise promise = resolver->promise(); | 75 ScriptPromise promise = resolver->promise(); |
| 76 | 76 |
| 77 OwnPtr<WebNotificationShowCallbacks> callbacks = adoptPtr(new CallbackPromis
eAdapter<void, void>(resolver)); | 77 OwnPtr<WebNotificationShowCallbacks> callbacks = adoptPtr(new CallbackPromis
eAdapter<void, void>(resolver)); |
| 78 ServiceWorkerRegistrationNotifications::from(executionContext, registration)
.prepareShow(data, callbacks.release()); | 78 ServiceWorkerRegistrationNotifications::from(executionContext, registration)
.prepareShow(data, std::move(callbacks)); |
| 79 | 79 |
| 80 return promise; | 80 return promise; |
| 81 } | 81 } |
| 82 | 82 |
| 83 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta
te* scriptState, ServiceWorkerRegistration& registration, const GetNotificationO
ptions& options) | 83 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta
te* scriptState, ServiceWorkerRegistration& registration, const GetNotificationO
ptions& options) |
| 84 { | 84 { |
| 85 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 85 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 86 ScriptPromise promise = resolver->promise(); | 86 ScriptPromise promise = resolver->promise(); |
| 87 | 87 |
| 88 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica
tionArray, void>(resolver); | 88 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica
tionArray, void>(resolver); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 DCHECK(m_loaders.contains(loader)); | 136 DCHECK(m_loaders.contains(loader)); |
| 137 | 137 |
| 138 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); | 138 WebNotificationManager* notificationManager = Platform::current()->notificat
ionManager(); |
| 139 DCHECK(notificationManager); | 139 DCHECK(notificationManager); |
| 140 | 140 |
| 141 notificationManager->showPersistent(WebSecurityOrigin(origin.get()), data, l
oader->getResources(), m_registration->webRegistration(), callbacks.leakPtr()); | 141 notificationManager->showPersistent(WebSecurityOrigin(origin.get()), data, l
oader->getResources(), m_registration->webRegistration(), callbacks.leakPtr()); |
| 142 m_loaders.remove(loader); | 142 m_loaders.remove(loader); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace blink | 145 } // namespace blink |
| OLD | NEW |