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" |
| 11 #include "core/dom/ExecutionContext.h" |
| 12 #include "core/dom/TaskRunnerHelper.h" |
11 #include "modules/payments/PaymentUpdater.h" | 13 #include "modules/payments/PaymentUpdater.h" |
12 #include "public/platform/WebTraceLocation.h" | 14 #include "public/platform/WebTraceLocation.h" |
13 #include "wtf/text/WTFString.h" | 15 #include "wtf/text/WTFString.h" |
14 | 16 |
15 namespace blink { | 17 namespace blink { |
16 namespace { | 18 namespace { |
17 | 19 |
18 // Reject the payment request if the page does not resolve the promise from | 20 // Reject the payment request if the page does not resolve the promise from |
19 // updateWith within 60 seconds. | 21 // updateWith within 60 seconds. |
20 static const int abortTimeout = 60; | 22 static const int abortTimeout = 60; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 80 } |
79 | 81 |
80 Member<PaymentUpdater> m_updater; | 82 Member<PaymentUpdater> m_updater; |
81 }; | 83 }; |
82 | 84 |
83 } // namespace | 85 } // namespace |
84 | 86 |
85 PaymentRequestUpdateEvent::~PaymentRequestUpdateEvent() {} | 87 PaymentRequestUpdateEvent::~PaymentRequestUpdateEvent() {} |
86 | 88 |
87 PaymentRequestUpdateEvent* PaymentRequestUpdateEvent::create( | 89 PaymentRequestUpdateEvent* PaymentRequestUpdateEvent::create( |
| 90 ExecutionContext* executionContext, |
88 const AtomicString& type, | 91 const AtomicString& type, |
89 const PaymentRequestUpdateEventInit& init) { | 92 const PaymentRequestUpdateEventInit& init) { |
90 return new PaymentRequestUpdateEvent(type, init); | 93 return new PaymentRequestUpdateEvent(executionContext, type, init); |
91 } | 94 } |
92 | 95 |
93 void PaymentRequestUpdateEvent::setPaymentDetailsUpdater( | 96 void PaymentRequestUpdateEvent::setPaymentDetailsUpdater( |
94 PaymentUpdater* updater) { | 97 PaymentUpdater* updater) { |
95 DCHECK(!m_abortTimer.isActive()); | 98 DCHECK(!m_abortTimer.isActive()); |
96 m_abortTimer.startOneShot(abortTimeout, BLINK_FROM_HERE); | 99 m_abortTimer.startOneShot(abortTimeout, BLINK_FROM_HERE); |
97 m_updater = updater; | 100 m_updater = updater; |
98 } | 101 } |
99 | 102 |
100 void PaymentRequestUpdateEvent::updateWith(ScriptState* scriptState, | 103 void PaymentRequestUpdateEvent::updateWith(ScriptState* scriptState, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 141 |
139 void PaymentRequestUpdateEvent::onUpdateEventTimeout(TimerBase*) { | 142 void PaymentRequestUpdateEvent::onUpdateEventTimeout(TimerBase*) { |
140 if (!m_updater) | 143 if (!m_updater) |
141 return; | 144 return; |
142 | 145 |
143 m_updater->onUpdatePaymentDetailsFailure( | 146 m_updater->onUpdatePaymentDetailsFailure( |
144 "Timed out as the page didn't resolve the promise from change event"); | 147 "Timed out as the page didn't resolve the promise from change event"); |
145 } | 148 } |
146 | 149 |
147 PaymentRequestUpdateEvent::PaymentRequestUpdateEvent( | 150 PaymentRequestUpdateEvent::PaymentRequestUpdateEvent( |
| 151 ExecutionContext* executionContext, |
148 const AtomicString& type, | 152 const AtomicString& type, |
149 const PaymentRequestUpdateEventInit& init) | 153 const PaymentRequestUpdateEventInit& init) |
150 : Event(type, init), | 154 : Event(type, init), |
151 m_waitForUpdate(false), | 155 m_waitForUpdate(false), |
152 m_abortTimer(this, &PaymentRequestUpdateEvent::onUpdateEventTimeout) {} | 156 m_abortTimer( |
| 157 TaskRunnerHelper::get(TaskType::MiscPlatformAPI, executionContext), |
| 158 this, |
| 159 &PaymentRequestUpdateEvent::onUpdateEventTimeout) {} |
153 | 160 |
154 } // namespace blink | 161 } // namespace blink |
OLD | NEW |