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

Side by Side Diff: Source/modules/app_banner/BeforeInstallPromptEvent.cpp

Issue 1233173002: Have ScriptPromiseResolver on the Oilpan heap always. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase upto conflicting r199893 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/app_banner/BeforeInstallPromptEvent.h" 6 #include "modules/app_banner/BeforeInstallPromptEvent.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" 8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 Vector<String> BeforeInstallPromptEvent::platforms() const 46 Vector<String> BeforeInstallPromptEvent::platforms() const
47 { 47 {
48 return m_platforms; 48 return m_platforms;
49 } 49 }
50 50
51 ScriptPromise BeforeInstallPromptEvent::userChoice(ScriptState* scriptState) 51 ScriptPromise BeforeInstallPromptEvent::userChoice(ScriptState* scriptState)
52 { 52 {
53 if (m_userChoice.isEmpty() && m_client) { 53 if (m_userChoice.isEmpty() && m_client) {
54 ASSERT(m_requestId != -1); 54 ASSERT(m_requestId != -1);
55 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolv er::create(scriptState); 55 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptSt ate);
56 m_userChoice = resolver->promise(); 56 m_userChoice = resolver->promise();
57 m_client->registerBannerCallbacks(m_requestId, new CallbackPromiseAdapte r<AppBannerPromptResult, void>(resolver)); 57 m_client->registerBannerCallbacks(m_requestId, new CallbackPromiseAdapte r<AppBannerPromptResult, void>(resolver));
58 } 58 }
59 59
60 return m_userChoice; 60 return m_userChoice;
61 } 61 }
62 62
63 const AtomicString& BeforeInstallPromptEvent::interfaceName() const 63 const AtomicString& BeforeInstallPromptEvent::interfaceName() const
64 { 64 {
65 return EventNames::BeforeInstallPromptEvent; 65 return EventNames::BeforeInstallPromptEvent;
66 } 66 }
67 67
68 ScriptPromise BeforeInstallPromptEvent::prompt(ScriptState* scriptState) 68 ScriptPromise BeforeInstallPromptEvent::prompt(ScriptState* scriptState)
69 { 69 {
70 if (m_client && defaultPrevented() && !m_redispatched) { 70 if (m_client && defaultPrevented() && !m_redispatched) {
71 ASSERT(m_requestId != -1); 71 ASSERT(m_requestId != -1);
72 m_redispatched = true; 72 m_redispatched = true;
73 m_client->showAppBanner(m_requestId); 73 m_client->showAppBanner(m_requestId);
74 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola te())); 74 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola te()));
75 } 75 }
76 76
77 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea te(InvalidStateError, "The prompt() method may only be called once, following pr eventDefault().")); 77 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea te(InvalidStateError, "The prompt() method may only be called once, following pr eventDefault()."));
78 } 78 }
79 79
80 } // namespace blink 80 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698