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

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

Issue 1233173002: Have ScriptPromiseResolver on the Oilpan heap always. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tidy unit tests Created 5 years, 5 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 "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"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // FIXME: Unify the code path here with the Notification.create() function. 66 // FIXME: Unify the code path here with the Notification.create() function.
67 Vector<char> dataAsWireBytes; 67 Vector<char> dataAsWireBytes;
68 if (options.hasData()) { 68 if (options.hasData()) {
69 RefPtr<SerializedScriptValue> data = SerializedScriptValueFactory::insta nce().create(options.data().isolate(), options.data(), nullptr, exceptionState); 69 RefPtr<SerializedScriptValue> data = SerializedScriptValueFactory::insta nce().create(options.data().isolate(), options.data(), nullptr, exceptionState);
70 if (exceptionState.hadException()) 70 if (exceptionState.hadException())
71 return exceptionState.reject(scriptState); 71 return exceptionState.reject(scriptState);
72 72
73 data->toWireBytes(dataAsWireBytes); 73 data->toWireBytes(dataAsWireBytes);
74 } 74 }
75 75
76 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 76 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
77 ScriptPromise promise = resolver->promise(); 77 ScriptPromise promise = resolver->promise();
78 78
79 // FIXME: Do the appropriate CORS checks on the icon URL. 79 // FIXME: Do the appropriate CORS checks on the icon URL.
80 80
81 KURL iconUrl; 81 KURL iconUrl;
82 if (options.hasIcon() && !options.icon().isEmpty()) { 82 if (options.hasIcon() && !options.icon().isEmpty()) {
83 iconUrl = executionContext->completeURL(options.icon()); 83 iconUrl = executionContext->completeURL(options.icon());
84 if (!iconUrl.isValid()) 84 if (!iconUrl.isValid())
85 iconUrl = KURL(); 85 iconUrl = KURL();
86 } 86 }
87 87
88 WebNotificationData::Direction dir = options.dir() == "rtl" ? WebNotificatio nData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight; 88 WebNotificationData::Direction dir = options.dir() == "rtl" ? WebNotificatio nData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight;
89 NavigatorVibration::VibrationPattern vibrate = NavigatorVibration::sanitizeV ibrationPattern(options.vibrate()); 89 NavigatorVibration::VibrationPattern vibrate = NavigatorVibration::sanitizeV ibrationPattern(options.vibrate());
90 WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, vibrate, options.silent(), dataAsWireBytes); 90 WebNotificationData notification(title, dir, options.lang(), options.body(), options.tag(), iconUrl, vibrate, options.silent(), dataAsWireBytes);
91 WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, v oid>(resolver); 91 WebNotificationShowCallbacks* callbacks = new CallbackPromiseAdapter<void, v oid>(resolver);
92 92
93 SecurityOrigin* origin = executionContext->securityOrigin(); 93 SecurityOrigin* origin = executionContext->securityOrigin();
94 ASSERT(origin); 94 ASSERT(origin);
95 95
96 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager(); 96 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager();
97 ASSERT(notificationManager); 97 ASSERT(notificationManager);
98 98
99 notificationManager->showPersistent(WebSerializedOrigin(*origin), notificati on, serviceWorkerRegistration.webRegistration(), callbacks); 99 notificationManager->showPersistent(WebSerializedOrigin(*origin), notificati on, serviceWorkerRegistration.webRegistration(), callbacks);
100 return promise; 100 return promise;
101 } 101 }
102 102
103 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Get NotificationOptions& options) 103 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Get NotificationOptions& options)
104 { 104 {
105 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 105 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
106 ScriptPromise promise = resolver->promise(); 106 ScriptPromise promise = resolver->promise();
107 107
108 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver); 108 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver);
109 109
110 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager(); 110 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager();
111 ASSERT(notificationManager); 111 ASSERT(notificationManager);
112 112
113 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks); 113 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks);
114 return promise; 114 return promise;
115 } 115 }
116 116
117 } // namespace blink 117 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698