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: fix webusb ScriptPromiseResolver usage 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
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 data->toWireBytes(dataAsWireBytes); 73 data->toWireBytes(dataAsWireBytes);
74 } 74 }
75 75
76 for (const NotificationAction& action : options.actions()) { 76 for (const NotificationAction& action : options.actions()) {
77 if (action.action().isEmpty()) 77 if (action.action().isEmpty())
78 return ScriptPromise::reject(scriptState, V8ThrowException::createTy peError(scriptState->isolate(), "NotificationAction action must not be empty.")) ; 78 return ScriptPromise::reject(scriptState, V8ThrowException::createTy peError(scriptState->isolate(), "NotificationAction action must not be empty.")) ;
79 if (action.title().isEmpty()) 79 if (action.title().isEmpty())
80 return ScriptPromise::reject(scriptState, V8ThrowException::createTy peError(scriptState->isolate(), "NotificationAction title must not be empty.")); 80 return ScriptPromise::reject(scriptState, V8ThrowException::createTy peError(scriptState->isolate(), "NotificationAction title must not be empty."));
81 } 81 }
82 82
83 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 83 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
84 ScriptPromise promise = resolver->promise(); 84 ScriptPromise promise = resolver->promise();
85 85
86 // FIXME: Do the appropriate CORS checks on the icon URL. 86 // FIXME: Do the appropriate CORS checks on the icon URL.
87 87
88 KURL iconUrl; 88 KURL iconUrl;
89 if (options.hasIcon() && !options.icon().isEmpty()) { 89 if (options.hasIcon() && !options.icon().isEmpty()) {
90 iconUrl = executionContext->completeURL(options.icon()); 90 iconUrl = executionContext->completeURL(options.icon());
91 if (!iconUrl.isValid()) 91 if (!iconUrl.isValid())
92 iconUrl = KURL(); 92 iconUrl = KURL();
93 } 93 }
(...skipping 10 matching lines...) Expand all
104 104
105 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager(); 105 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager();
106 ASSERT(notificationManager); 106 ASSERT(notificationManager);
107 107
108 notificationManager->showPersistent(WebSecurityOrigin(origin), notification, serviceWorkerRegistration.webRegistration(), callbacks); 108 notificationManager->showPersistent(WebSecurityOrigin(origin), notification, serviceWorkerRegistration.webRegistration(), callbacks);
109 return promise; 109 return promise;
110 } 110 }
111 111
112 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Get NotificationOptions& options) 112 ScriptPromise ServiceWorkerRegistrationNotifications::getNotifications(ScriptSta te* scriptState, ServiceWorkerRegistration& serviceWorkerRegistration, const Get NotificationOptions& options)
113 { 113 {
114 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 114 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
115 ScriptPromise promise = resolver->promise(); 115 ScriptPromise promise = resolver->promise();
116 116
117 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver); 117 WebNotificationGetCallbacks* callbacks = new CallbackPromiseAdapter<Notifica tionArray, void>(resolver);
118 118
119 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager(); 119 WebNotificationManager* notificationManager = Platform::current()->notificat ionManager();
120 ASSERT(notificationManager); 120 ASSERT(notificationManager);
121 121
122 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks); 122 notificationManager->getNotifications(options.tag(), serviceWorkerRegistrati on.webRegistration(), callbacks);
123 return promise; 123 return promise;
124 } 124 }
125 125
126 } // namespace blink 126 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/navigatorconnect/ServicePortCollection.cpp ('k') | Source/modules/permissions/PermissionCallback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698