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