OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/payments/PaymentRequestEvent.h" | 5 #include "modules/payments/PaymentRequestEvent.h" |
6 | 6 |
7 #include "modules/serviceworkers/RespondWithObserver.h" | |
7 #include "wtf/text/AtomicString.h" | 8 #include "wtf/text/AtomicString.h" |
8 | 9 |
9 namespace blink { | 10 namespace blink { |
10 | 11 |
11 PaymentRequestEvent* PaymentRequestEvent::create( | 12 PaymentRequestEvent* PaymentRequestEvent::create( |
12 const AtomicString& type, | 13 const AtomicString& type, |
13 const PaymentAppRequest& appRequest, | 14 const PaymentAppRequest& appRequest, |
14 WaitUntilObserver* observer) { | 15 RespondWithObserver* respondWithObserver, |
15 return new PaymentRequestEvent(type, appRequest, observer); | 16 WaitUntilObserver* waitUntilObserver) { |
17 return new PaymentRequestEvent(type, appRequest, respondWithObserver, | |
18 waitUntilObserver); | |
16 } | 19 } |
17 | 20 |
18 PaymentRequestEvent::~PaymentRequestEvent() {} | 21 PaymentRequestEvent::~PaymentRequestEvent() {} |
19 | 22 |
20 const AtomicString& PaymentRequestEvent::interfaceName() const { | 23 const AtomicString& PaymentRequestEvent::interfaceName() const { |
21 return EventNames::PaymentRequestEvent; | 24 return EventNames::PaymentRequestEvent; |
22 } | 25 } |
23 | 26 |
24 void PaymentRequestEvent::appRequest(PaymentAppRequest& appRequest) const { | 27 void PaymentRequestEvent::appRequest(PaymentAppRequest& appRequest) const { |
25 appRequest = m_appRequest; | 28 appRequest = m_appRequest; |
26 } | 29 } |
27 | 30 |
28 void PaymentRequestEvent::respondWith(ScriptPromise) { | 31 void PaymentRequestEvent::respondWith(ScriptState* scriptState, |
29 NOTIMPLEMENTED(); | 32 ScriptPromise scriptPromise, |
33 ExceptionState& exceptionState) { | |
34 stopImmediatePropagation(); | |
35 if (m_observer) { | |
nhiroki
2017/03/16 13:24:47
Is it possible that |m_observer| is null here?
zino
2017/03/16 14:32:02
In the extream case, nullptr might be coming when
nhiroki
2017/03/17 07:45:12
Thank you for the clarification. I'm ok with keepi
| |
36 m_observer->respondWith(scriptState, scriptPromise, exceptionState); | |
37 } | |
30 } | 38 } |
31 | 39 |
32 DEFINE_TRACE(PaymentRequestEvent) { | 40 DEFINE_TRACE(PaymentRequestEvent) { |
33 visitor->trace(m_appRequest); | 41 visitor->trace(m_appRequest); |
42 visitor->trace(m_observer); | |
34 ExtendableEvent::trace(visitor); | 43 ExtendableEvent::trace(visitor); |
35 } | 44 } |
36 | 45 |
37 PaymentRequestEvent::PaymentRequestEvent(const AtomicString& type, | 46 PaymentRequestEvent::PaymentRequestEvent( |
38 const PaymentAppRequest& appRequest, | 47 const AtomicString& type, |
39 WaitUntilObserver* observer) | 48 const PaymentAppRequest& appRequest, |
40 : ExtendableEvent(type, ExtendableEventInit(), observer), | 49 RespondWithObserver* respondWithObserver, |
41 m_appRequest(appRequest) {} | 50 WaitUntilObserver* waitUntilObserver) |
51 : ExtendableEvent(type, ExtendableEventInit(), waitUntilObserver), | |
52 m_appRequest(appRequest), | |
53 m_observer(respondWithObserver) {} | |
42 | 54 |
43 } // namespace blink | 55 } // namespace blink |
OLD | NEW |