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/PaymentRequestUpdateEvent.h" | 5 #include "modules/payments/PaymentRequestUpdateEvent.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ScriptFunction.h" | 8 #include "bindings/core/v8/ScriptFunction.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 return new PaymentRequestUpdateEvent(); | 86 return new PaymentRequestUpdateEvent(); |
87 } | 87 } |
88 | 88 |
89 PaymentRequestUpdateEvent* PaymentRequestUpdateEvent::create(const AtomicString& type, const PaymentRequestUpdateEventInit& init) | 89 PaymentRequestUpdateEvent* PaymentRequestUpdateEvent::create(const AtomicString& type, const PaymentRequestUpdateEventInit& init) |
90 { | 90 { |
91 return new PaymentRequestUpdateEvent(type, init); | 91 return new PaymentRequestUpdateEvent(type, init); |
92 } | 92 } |
93 | 93 |
94 void PaymentRequestUpdateEvent::setPaymentDetailsUpdater(PaymentUpdater* updater ) | 94 void PaymentRequestUpdateEvent::setPaymentDetailsUpdater(PaymentUpdater* updater ) |
95 { | 95 { |
96 m_abortTimer.startOneShot(s_abortTimeout, BLINK_FROM_HERE); | |
please use gerrit instead
2016/07/21 16:35:24
#include "public/platform/WebTraceLocation.h"
Thi
haraken
2016/07/21 16:37:27
What happens if you hit setPaymentDetailsUpdater b
please use gerrit instead
2016/07/21 16:46:42
Should not happen. setPaymentDetailsUpdater is inv
pals
2016/07/22 04:06:19
Done.
| |
96 m_updater = updater; | 97 m_updater = updater; |
97 } | 98 } |
98 | 99 |
99 void PaymentRequestUpdateEvent::updateWith(ScriptState* scriptState, ScriptPromi se promise, ExceptionState& exceptionState) | 100 void PaymentRequestUpdateEvent::updateWith(ScriptState* scriptState, ScriptPromi se promise, ExceptionState& exceptionState) |
100 { | 101 { |
101 if (!m_updater) | 102 if (!m_updater) |
102 return; | 103 return; |
103 | 104 |
104 if (!isBeingDispatched()) { | 105 if (!isBeingDispatched()) { |
105 exceptionState.throwDOMException(InvalidStateError, "Cannot update detai ls when the event is not being dispatched"); | 106 exceptionState.throwDOMException(InvalidStateError, "Cannot update detai ls when the event is not being dispatched"); |
106 return; | 107 return; |
107 } | 108 } |
108 | 109 |
109 if (m_waitForUpdate) { | 110 if (m_waitForUpdate) { |
110 exceptionState.throwDOMException(InvalidStateError, "Cannot update detai ls twice"); | 111 exceptionState.throwDOMException(InvalidStateError, "Cannot update detai ls twice"); |
111 return; | 112 return; |
112 } | 113 } |
113 | 114 |
114 stopImmediatePropagation(); | 115 stopImmediatePropagation(); |
115 m_waitForUpdate = true; | 116 m_waitForUpdate = true; |
117 m_abortTimer.stop(); | |
116 | 118 |
117 promise.then(UpdatePaymentDetailsFunction::createFunction(scriptState, m_upd ater), | 119 promise.then(UpdatePaymentDetailsFunction::createFunction(scriptState, m_upd ater), |
118 UpdatePaymentDetailsErrorFunction::createFunction(scriptState, m_updater )); | 120 UpdatePaymentDetailsErrorFunction::createFunction(scriptState, m_updater )); |
119 } | 121 } |
120 | 122 |
123 void PaymentRequestUpdateEvent::onTimerFired(Timer<PaymentRequestUpdateEvent>*) | |
124 { | |
125 if (!m_updater) | |
126 return; | |
127 | |
128 m_updater->onUpdatePaymentDetailsFailure(ScriptValue()); | |
129 } | |
130 | |
121 DEFINE_TRACE(PaymentRequestUpdateEvent) | 131 DEFINE_TRACE(PaymentRequestUpdateEvent) |
122 { | 132 { |
123 visitor->trace(m_updater); | 133 visitor->trace(m_updater); |
124 Event::trace(visitor); | 134 Event::trace(visitor); |
125 } | 135 } |
126 | 136 |
127 PaymentRequestUpdateEvent::PaymentRequestUpdateEvent() | 137 PaymentRequestUpdateEvent::PaymentRequestUpdateEvent() |
128 : m_waitForUpdate(false) | 138 : m_waitForUpdate(false) |
139 , m_abortTimer(this, &PaymentRequestUpdateEvent::onTimerFired) | |
129 { | 140 { |
130 } | 141 } |
131 | 142 |
132 PaymentRequestUpdateEvent::PaymentRequestUpdateEvent(const AtomicString& type, c onst PaymentRequestUpdateEventInit& init) | 143 PaymentRequestUpdateEvent::PaymentRequestUpdateEvent(const AtomicString& type, c onst PaymentRequestUpdateEventInit& init) |
133 : Event(type, init) | 144 : Event(type, init) |
134 , m_waitForUpdate(false) | 145 , m_waitForUpdate(false) |
146 , m_abortTimer(this, &PaymentRequestUpdateEvent::onTimerFired) | |
135 { | 147 { |
136 } | 148 } |
137 | 149 |
138 } // namespace blink | 150 } // namespace blink |
OLD | NEW |