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

Side by Side Diff: Source/modules/notifications/ServiceWorkerRegistrationNotifications.cpp

Issue 1234603003: CallbackPromiseAdapter types should be more compatible with WebCallbacks (1/3). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: retry! Created 5 years, 4 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h" 6 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" 8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
11 #include "bindings/core/v8/SerializedScriptValue.h" 11 #include "bindings/core/v8/SerializedScriptValue.h"
12 #include "bindings/core/v8/SerializedScriptValueFactory.h" 12 #include "bindings/core/v8/SerializedScriptValueFactory.h"
13 #include "bindings/core/v8/V8ThrowException.h" 13 #include "bindings/core/v8/V8ThrowException.h"
14 #include "core/dom/DOMException.h" 14 #include "core/dom/DOMException.h"
15 #include "core/dom/ExceptionCode.h" 15 #include "core/dom/ExceptionCode.h"
16 #include "core/dom/ExecutionContext.h" 16 #include "core/dom/ExecutionContext.h"
17 #include "modules/notifications/GetNotificationOptions.h" 17 #include "modules/notifications/GetNotificationOptions.h"
18 #include "modules/notifications/Notification.h" 18 #include "modules/notifications/Notification.h"
19 #include "modules/notifications/NotificationOptions.h" 19 #include "modules/notifications/NotificationOptions.h"
20 #include "modules/vibration/NavigatorVibration.h" 20 #include "modules/vibration/NavigatorVibration.h"
21 #include "platform/weborigin/KURL.h" 21 #include "platform/weborigin/KURL.h"
22 #include "public/platform/Platform.h" 22 #include "public/platform/Platform.h"
23 #include "public/platform/WebSecurityOrigin.h" 23 #include "public/platform/WebSecurityOrigin.h"
24 #include "public/platform/modules/notifications/WebNotificationData.h" 24 #include "public/platform/modules/notifications/WebNotificationData.h"
25 #include "public/platform/modules/notifications/WebNotificationManager.h" 25 #include "public/platform/modules/notifications/WebNotificationManager.h"
26 #include "wtf/OwnPtr.h"
26 #include "wtf/PassOwnPtr.h" 27 #include "wtf/PassOwnPtr.h"
27 28
28 namespace blink { 29 namespace blink {
29 namespace { 30 namespace {
30 31
31 // Allows using a CallbackPromiseAdapter with a WebVector to resolve the 32 // Allows using a CallbackPromiseAdapter with a WebVector to resolve the
32 // getNotifications() promise with a HeapVector owning Notifications. 33 // getNotifications() promise with a HeapVector owning Notifications.
33 class NotificationArray { 34 class NotificationArray {
34 public: 35 public:
35 using WebType = WebVector<WebPersistentNotificationInfo>; 36 using WebType = OwnPtr<WebVector<WebPersistentNotificationInfo>>;
36 37
37 static HeapVector<Member<Notification>> take(ScriptPromiseResolver* resolver , PassOwnPtr<WebType> notificationInfos) 38 static HeapVector<Member<Notification>> take(ScriptPromiseResolver* resolver , PassOwnPtr<WebVector<WebPersistentNotificationInfo>> notificationInfos)
38 { 39 {
39 HeapVector<Member<Notification>> notifications; 40 HeapVector<Member<Notification>> notifications;
40 for (const WebPersistentNotificationInfo& notificationInfo : *notificati onInfos) 41 for (const WebPersistentNotificationInfo& notificationInfo : *notificati onInfos)
41 notifications.append(Notification::create(resolver->executionContext (), notificationInfo.persistentId, notificationInfo.data)); 42 notifications.append(Notification::create(resolver->executionContext (), notificationInfo.persistentId, notificationInfo.data));
42 return notifications; 43 return notifications;
43 } 44 }
44 45
45 private: 46 private:
46 NotificationArray() = delete; 47 NotificationArray() = delete;
47 }; 48 };
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver); 118 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver);
118 119
119 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager(); 120 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager();
120 ASSERT(notificationManager); 121 ASSERT(notificationManager);
121 122
122 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks); 123 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks);
123 return promise; 124 return promise;
124 } 125 }
125 126
126 } // namespace blink 127 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/geofencing/GeofencingError.cpp ('k') | Source/modules/presentation/PresentationAvailability.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698